MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / callback

Method callback

src/loggers/bt_sqlite_logger.cpp:163–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163void SqliteLogger::callback(Duration timestamp, const TreeNode& node,
164 NodeStatus prev_status, NodeStatus status)
165{
166 using namespace std::chrono;
167 const int64_t tm_usec = int64_t(duration_cast<microseconds>(timestamp).count());
168 monotonic_timestamp_ = std::max(monotonic_timestamp_ + 1, tm_usec);
169
170 long elapsed_time = 0;
171
172 if(prev_status == NodeStatus::IDLE && status == NodeStatus::RUNNING)
173 {
174 starting_time_[&node] = monotonic_timestamp_;
175 }
176
177 if(prev_status == NodeStatus::RUNNING && status != NodeStatus::RUNNING)
178 {
179 elapsed_time = monotonic_timestamp_;
180 auto it = starting_time_.find(&node);
181 if(it != starting_time_.end())
182 {
183 elapsed_time -= it->second;
184 }
185 }
186
187 Transition trans;
188 trans.timestamp = monotonic_timestamp_;
189 trans.duration = elapsed_time;
190 trans.node_uid = node.UID();
191 trans.status = status;
192
193 if(extra_func_)
194 {
195 trans.extra_data = extra_func_(timestamp, node, prev_status, status);
196 }
197
198 {
199 const std::scoped_lock lk(queue_mutex_);
200 transitions_queue_.push_back(trans);
201 }
202 queue_cv_.notify_one();
203}
204
205void SqliteLogger::execSqlStatement(std::string statement)
206{

Callers

nothing calls this directly

Calls 3

UIDMethod · 0.80
push_backMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected