17 auto start = std::chrono::high_resolution_clock::now();
18 bool instances_accepted =
false;
19 std::int64_t current = 0;
27 this->setNonCorruptedTimestampType(e);
36 if (this->lastTimesPerEntity.end() == this->lastTimesPerEntity.find(memID))
43 auto lastT = this->getNonCorruptedTimestamp(firstInsance, simulatedVersion);
45 auto end = std::chrono::high_resolution_clock::now();
47 stats.additional_time += (end - start);
50 this->lastTimesPerEntity[memID] = lastT;
55 auto lastTime = this->lastTimesPerEntity.at(memID);
60 [
this, &instances_accepted, ¤t, &lastTime, &simulatedVersion](
63 auto t = this->getNonCorruptedTimestamp(i, simulatedVersion);
64 int difference = std::abs(t - lastTime);
65 if (difference > this->maxDifference)
67 instances_accepted =
true;
68 current = this->getNonCorruptedTimestamp(i, simulatedVersion);
72 if (instances_accepted)
75 this->lastTimesPerEntity[memID] = current;
80 auto end = std::chrono::high_resolution_clock::now();
82 stats.additional_time += (end - start);
84 if (instances_accepted)
86 this->
stats.accepted += 1;
90 this->
stats.rejected += 1;
93 return instances_accepted;
101 auto sentTime = firstInsance.metadata().sentTime;
102 auto arrivedTime = firstInsance.metadata().arrivedTime;
103 auto referencedTime = firstInsance.metadata().referencedTime;
110 if (referencedTime.toMilliSecondsSinceEpoch() < 946688400000)
113 if (sentTime.toMilliSecondsSinceEpoch() < 946688400000)
116 if (arrivedTime.toMilliSecondsSinceEpoch() < 946688400000)
119 if (!corruptedWarningGiven)
121 ARMARX_WARNING <<
"LTM recording does not work correctly, as frequency "
122 "filter is used, but "
123 <<
"time sent, arrived and referenced are all corrupted. \n"
124 <<
"Accepting all snapshots.";
126 corruptedWarningGiven =
true;
131 if (!corruptedWarningGiven)
133 ARMARX_INFO <<
"Time referenced and sent for snapshot corrupted, using "
134 "time arrived for filtering";
135 corruptedWarningGiven =
true;
142 if (!corruptedWarningGiven)
145 <<
"Time referenced snapshot corrupted, using time sent for filtering";
146 corruptedWarningGiven =
true;
188 SnapshotFrequencyFilter::getNonCorruptedTimestamp(
const armem::wm::EntityInstance& i,
189 bool simulatedVersion)
191 switch (this->nonCorruptedType)
194 if (!simulatedVersion)
219 stats.additional_info =
"Max Difference in ms: " + std::to_string(this->maxDifference);
221 stats.start_time = std::chrono::high_resolution_clock::now();
222 stats.number_of_compared_objects = 1;
223 stats.similarity_type =
231 stats.end_time = std::chrono::high_resolution_clock::now();
MemoryID getEntityID() const
bool forEachInstance(InstanceFunctionT &&func)
EntityInstanceT & getInstance(int index)
Get the given instance.
std::vector< int > getInstanceIndices() const
struct armarx::armem::server::ltm::processor::SnapshotFilter::FilterStatistics stats
std::mutex filterMutex_
Mutex for thread-safe access to filter state (stats and derived class state) Derived classes should l...
void configure(const nlohmann::json &json) override
virtual bool accept(const armem::wm::EntitySnapshot &e, bool simulatedVersion) override
static const constexpr char * PARAM_WAITING_TIME
std::string getName() override
FilterStatistics getFilterStatistics() override
static const constexpr char * NAME
Client-side working entity instance.
Client-side working memory entity snapshot.
std::int64_t toMilliSecondsSinceEpoch() const
#define ARMARX_INFO
The normal logging level.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.