42 #ifndef TIME_ADJUST_SYNCHRONIZER_HPP_ 43 #define TIME_ADJUST_SYNCHRONIZER_HPP_ 51 #include "../sensors/sensor.hpp" 62 class TimeAjustSynchronizer :
public TimeSynchronizer {
68 class SensorSyncContainer {
70 unsigned int m_sensor_handle;
71 std::chrono::nanoseconds m_timestamp_reference = std::chrono::nanoseconds(std::numeric_limits<long>::max());
72 std::chrono::nanoseconds m_latest_timestamp = std::chrono::nanoseconds(std::numeric_limits<long>::max());
73 std::chrono::nanoseconds m_real_latest_timestamp = std::chrono::nanoseconds(std::numeric_limits<long>::max());
79 SensorSyncContainer(
unsigned int sensor_handle) {
80 m_sensor_handle = sensor_handle;
86 unsigned int getSensorHandle() {
87 return m_sensor_handle;
93 std::chrono::nanoseconds getTimestampReference() {
94 return m_timestamp_reference;
101 void setTimestampReference(std::chrono::nanoseconds timestamp_reference) {
102 m_timestamp_reference = timestamp_reference;
108 std::chrono::nanoseconds getLatestTimestamp() {
109 return m_latest_timestamp;
116 void setLatestTimestamp(std::chrono::nanoseconds latest_timestamp) {
117 m_latest_timestamp = latest_timestamp;
123 std::chrono::nanoseconds getRealLatestTimestamp() {
124 return m_real_latest_timestamp;
130 void setRealTimestamp() {
131 m_real_latest_timestamp = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch());
136 static const std::chrono::nanoseconds SENSOR_TIMEOUT_MILLIS;
139 static const std::chrono::nanoseconds SENSOR_MAX_RAW_TIMESTAMP;
142 std::list<SensorSyncContainer> m_sensor_containers;
155 void cleanSensorContainers();
163 std::chrono::nanoseconds calculateSensorReference(std::chrono::nanoseconds raw_sensor_timestamp);
172 std::chrono::nanoseconds syncSensorTimestamp(SensorSyncContainer& sensor_container, std::chrono::nanoseconds raw_sensor_timestamp);
178 error::KallistoDetailedResult sync();
191 error::KallistoDetailedResult
syncSensorEvent(Sensor& sensor, SensorEvent& event);
error::KallistoDetailedResult syncSensorEvent(Sensor &sensor, SensorEvent &event)
Definition: bluetooth_adapter.hpp:52
TimeAjustSynchronizer(bluetooth::BluetoothDispatcher &dispatcher)