| 198 | } |
| 199 | |
| 200 | void Groot2Publisher::callback(Duration ts, const TreeNode& node, NodeStatus prev_status, |
| 201 | NodeStatus new_status) |
| 202 | { |
| 203 | const std::unique_lock<std::mutex> lk(_p->status_mutex); |
| 204 | auto status = static_cast<char>(new_status); |
| 205 | |
| 206 | if(new_status == NodeStatus::IDLE) |
| 207 | { |
| 208 | status = static_cast<char>(10 + static_cast<int>(prev_status)); |
| 209 | } |
| 210 | *(_p->status_buffermap.at(node.UID())) = status; |
| 211 | |
| 212 | if(_p->recording) |
| 213 | { |
| 214 | Transition trans{}; |
| 215 | trans.node_uid = node.UID(); |
| 216 | trans.status = static_cast<uint8_t>(new_status); |
| 217 | auto timestamp = ts - _p->recording_fist_time; |
| 218 | trans.timestamp_usec = |
| 219 | std::chrono::duration_cast<std::chrono::microseconds>(timestamp).count(); |
| 220 | _p->transitions_buffer.push_back(trans); |
| 221 | while(_p->transitions_buffer.size() > 1000) |
| 222 | { |
| 223 | _p->transitions_buffer.pop_front(); |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | void Groot2Publisher::flush() |
| 229 | { |