diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h index dd4c37b277a514f40051ee96de70ab04cfe43c62..df300c7267b4e6ff0bbf3f425392487fd5b90841 100644 --- a/include/core/processor/processor_base.h +++ b/include/core/processor/processor_base.h @@ -359,6 +359,8 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce int getDim() const; + double getTimeTolerance() const; + void link(SensorBasePtr); template<typename classType, typename... T> static std::shared_ptr<classType> emplace(SensorBasePtr _sen_ptr, T&&... all); @@ -426,6 +428,10 @@ inline int ProcessorBase::getDim() const { return dim_; } +inline double ProcessorBase::getTimeTolerance() const +{ + return params_->time_tolerance; +} template<typename classType, typename... T> std::shared_ptr<classType> ProcessorBase::emplace(SensorBasePtr _sen_ptr, T&&... all) diff --git a/src/capture/capture_base.cpp b/src/capture/capture_base.cpp index 8b31edc53276216811daa1ca640bf042e1c4f82b..2f49c352d20dbdfc781c1469ef5645859ae27578 100644 --- a/src/capture/capture_base.cpp +++ b/src/capture/capture_base.cpp @@ -363,7 +363,7 @@ CheckLog CaptureBase::localCheck(bool _verbose, CaptureBasePtr _cap_ptr, std::os auto frm_cap = _cap_ptr->getFrame(); inconsistency_explanation << "Cap" << id() << " @ " << _cap_ptr << " ---> Frm" << frm_cap->id() << " @ " << frm_cap - << " -X-> Frm" << id(); + << " -X-> Frm" << id() << "\n"; auto frm_cap_list = frm_cap->getCaptureList(); auto frame_has_cap = std::find_if(frm_cap_list.begin(), frm_cap_list.end(), [&_cap_ptr](CaptureBasePtr cap){ return cap == _cap_ptr;}); log.assertTrue(frame_has_cap != frm_cap_list.end(), inconsistency_explanation); @@ -375,6 +375,28 @@ CheckLog CaptureBase::localCheck(bool _verbose, CaptureBasePtr _cap_ptr, std::os << " -X-> Cap" << id(); log.assertTrue((f->getCapture() == _cap_ptr), inconsistency_explanation); } + //Check that the capture is within time tolerance of some processor + auto frame = getFrame(); + double time_diff = fabs(getTimeStamp() - frame->getTimeStamp()); + + //It looks like some gtests add captures by hand, without using processors, so the processor list is empty. + //This inicialization is needed because if the list empty the execution does not go into the loop and the + //assertion fails + bool match_any_prc_timetolerance; + if(getSensor() != nullptr ) + { + match_any_prc_timetolerance = getSensor()->getProcessorList().empty(); + for(auto const& prc : getSensor()->getProcessorList()) + { + match_any_prc_timetolerance = match_any_prc_timetolerance or (time_diff <= prc->getTimeTolerance()); + } + inconsistency_explanation << "Cap " << id() << " @ " << _cap_ptr + << " ts =" << getTimeStamp() << ((frame->isKey()) ? "KFrm" : "Frm") << frame->id() + << " ts = " << frame->getTimeStamp() << " their time difference (" << time_diff << ") does not match any time tolerance of" + << " any processor in sensor " << getSensor()->id() << "\n"; + log.assertTrue((match_any_prc_timetolerance), inconsistency_explanation); + } + return log; } bool CaptureBase::check(CheckLog& _log, std::shared_ptr<NodeBase> _node_ptr, bool _verbose, std::ostream& _stream, std::string _tabs) const