Free Electron
BeaconTimeSync.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __BeaconTimeSync_h__
8 #define __BeaconTimeSync_h__
9 
10 namespace beacon
11 {
12 
13 class FE_DL_EXPORT BeaconTimeSync : virtual public BeaconTimeSyncI
14 {
15 public:
16  BeaconTimeSync();
17  virtual ~BeaconTimeSync();
18 
19  // Only do time sync with the Beacon without registering it
20  virtual bool timeSyncWithBeacon(const char *ipAddress,
21  const uint16_t requestPort) override;
22  virtual int64_t getTimeOffset() override;
23  virtual int64_t getBeaconTime()override;
24  virtual int64_t getLatency() override;
25 private:
26  char m_ipAddress[16]; // Beacon IP address (xxx.xxx.xxx.xxx\0)
27  uint16_t m_requestPort; // Beacon request port
28  uint16_t m_responsePort; // Response port messages from Beacon
29 
30  bool m_timeSynced;
31  int64_t m_latency;
32  int64_t m_deltaTime;
33 
34  fe::sp<fe::SingleMaster> m_spSingleMaster;
35  fe::sp<fe::ext::MessageI> m_sendMsgSystem;
36  fe::sp<fe::ext::MessageI> m_recMsgSystem;
37 
38  bool init();
39  bool syncWithBeaconTime();
40  int64_t getCurrentTime();
41 
42  void sendSyncRequest();
43  bool sendRequest(const fe::ext::Messagegram &m);
44  void shutdown();
45 };
46 
47 } // namespace beacon
48 
49 #endif // __BeaconTimeSync_h__
Definition: BeaconClient.cc:16