Skip to content
Snippets Groups Projects
Commit 0abdcf54 authored by Joaquim Casals Buñuel's avatar Joaquim Casals Buñuel
Browse files

Merge branch '340-add-time-stamp-tolerance-to-problem-check' into devel

parents bcc19f0c 70017378
No related branches found
No related tags found
1 merge request!376WIP: Resolve "Add time stamp tolerance to problem::check()"
Pipeline #5843 passed
...@@ -359,6 +359,8 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce ...@@ -359,6 +359,8 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce
int getDim() const; int getDim() const;
double getTimeTolerance() const;
void link(SensorBasePtr); void link(SensorBasePtr);
template<typename classType, typename... T> template<typename classType, typename... T>
static std::shared_ptr<classType> emplace(SensorBasePtr _sen_ptr, T&&... all); static std::shared_ptr<classType> emplace(SensorBasePtr _sen_ptr, T&&... all);
...@@ -426,6 +428,10 @@ inline int ProcessorBase::getDim() const ...@@ -426,6 +428,10 @@ inline int ProcessorBase::getDim() const
{ {
return dim_; return dim_;
} }
inline double ProcessorBase::getTimeTolerance() const
{
return params_->time_tolerance;
}
template<typename classType, typename... T> template<typename classType, typename... T>
std::shared_ptr<classType> ProcessorBase::emplace(SensorBasePtr _sen_ptr, T&&... all) std::shared_ptr<classType> ProcessorBase::emplace(SensorBasePtr _sen_ptr, T&&... all)
......
...@@ -364,7 +364,7 @@ CheckLog CaptureBase::localCheck(bool _verbose, CaptureBasePtr _cap_ptr, std::os ...@@ -364,7 +364,7 @@ CheckLog CaptureBase::localCheck(bool _verbose, CaptureBasePtr _cap_ptr, std::os
auto frm_cap = _cap_ptr->getFrame(); auto frm_cap = _cap_ptr->getFrame();
inconsistency_explanation << "Cap" << id() << " @ " << _cap_ptr inconsistency_explanation << "Cap" << id() << " @ " << _cap_ptr
<< " ---> Frm" << frm_cap->id() << " @ " << frm_cap << " ---> Frm" << frm_cap->id() << " @ " << frm_cap
<< " -X-> Frm" << id(); << " -X-> Frm" << id() << "\n";
auto frm_cap_list = frm_cap->getCaptureList(); 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;}); 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); log.assertTrue(frame_has_cap != frm_cap_list.end(), inconsistency_explanation);
...@@ -376,6 +376,28 @@ CheckLog CaptureBase::localCheck(bool _verbose, CaptureBasePtr _cap_ptr, std::os ...@@ -376,6 +376,28 @@ CheckLog CaptureBase::localCheck(bool _verbose, CaptureBasePtr _cap_ptr, std::os
<< " -X-> Cap" << id(); << " -X-> Cap" << id();
log.assertTrue((f->getCapture() == _cap_ptr), inconsistency_explanation); 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; return log;
} }
bool CaptureBase::check(CheckLog& _log, std::shared_ptr<NodeBase> _node_ptr, bool _verbose, std::ostream& _stream, std::string _tabs) const bool CaptureBase::check(CheckLog& _log, std::shared_ptr<NodeBase> _node_ptr, bool _verbose, std::ostream& _stream, std::string _tabs) const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment