HiveMind
InterlocMessageHandler.h
Go to the documentation of this file.
1 #ifndef __INTERLOCMESSAGEHANDLER_H__
2 #define __INTERLOCMESSAGEHANDLER_H__
3 
5 #include <INotificationQueue.h>
6 #include <bsp/IBSP.h>
7 #include <bsp/IInterlocManager.h>
8 #include <cpp-common/ICircularQueue.h>
9 #include <logger/ILogger.h>
10 #include <pheromones/MessageDTO.h>
11 #include <pheromones/interloc/InterlocAPIDTO.h>
12 
14  public:
16  IInterlocManager& interlocManager,
17  IBSP& bsp,
18  ICircularQueue<MessageDTO>& inputQueue,
19  ICircularQueue<MessageDTO>& hostQueue,
20  ICircularQueue<MessageDTO>& remoteQueue,
21  INotificationQueue<InterlocUpdate>& interlocPositionUpdateQueue);
22 
23  virtual ~InterlocMessageHandler() = default;
24 
25  bool processMessage() override;
26 
27  bool getDumpEnabled() const override;
28 
29  bool sendInterlocDump(InterlocUpdate* updatesHistory, uint8_t updatesLength) override;
30 
31  private:
35  ICircularQueue<MessageDTO>& m_inputQueue;
36  ICircularQueue<MessageDTO>& m_hostQueue;
37  ICircularQueue<MessageDTO>& m_remoteQueue;
38  INotificationQueue<InterlocUpdate>& m_interlocPositionUpdateQueue;
39 
40  std::array<GetNeighborResponseDTO, InterlocDumpDTO::MAX_UPDATES_SIZE> m_updateDtoArray;
41 
44 
45  bool handleMessage(const MessageDTO& dto);
46  bool handleStateChangeMessage(const SetInterlocStateDTO dto) const;
47  bool handleConfigurationMessage(const InterlocConfigurationDTO& dto);
48 
49  // bool handleCalibrationMessage(const CalibrationMessageDTO& dto, uint16_t sourceId) const;
50  ICircularQueue<MessageDTO>& getQueueForDestination(uint16_t destinationId) const;
51 
52  void stateChangeCallback(InterlocStateDTO previousState, InterlocStateDTO newState);
53  static void stateChangeCallbackStatic(void* context,
54  InterlocStateDTO previousState,
55  InterlocStateDTO newState);
56 
58  static void rawAngleDataCallbackStatic(void* context, BspInterlocRawAngleData& data);
59 
60  void ensureSendMessage(MessageDTO& msg);
61  static InterlocRawAngleDataDTO constructRawDataMessage(BspInterlocRawAngleData& data,
62  uint32_t fromId,
63  uint8_t numFrames);
64 };
65 
66 #endif //__INTERLOCMESSAGEHANDLER_H__
IInterlocManager
Definition: IInterlocManager.h:16
InterlocMessageHandler::~InterlocMessageHandler
virtual ~InterlocMessageHandler()=default
IBSP.h
IInterlocMessageHandler
Definition: IInterlocMessageHandler.h:6
InterlocMessageHandler::handleMessage
bool handleMessage(const MessageDTO &dto)
Definition: InterlocMessageHandler.cpp:47
InterlocMessageHandler::constructRawDataMessage
static InterlocRawAngleDataDTO constructRawDataMessage(BspInterlocRawAngleData &data, uint32_t fromId, uint8_t numFrames)
Definition: InterlocMessageHandler.cpp:164
InterlocMessageHandler::getDumpEnabled
bool getDumpEnabled() const override
Retrieves a flag to know if data dumps to the host should be done or not.
Definition: InterlocMessageHandler.cpp:202
BspInterlocRawAngleData
Definition: BspInterlocAngleRawData.h:24
InterlocMessageHandler::m_updateDtoArray
std::array< GetNeighborResponseDTO, InterlocDumpDTO::MAX_UPDATES_SIZE > m_updateDtoArray
Definition: InterlocMessageHandler.h:40
InterlocMessageHandler::m_logger
ILogger & m_logger
Definition: InterlocMessageHandler.h:32
InterlocMessageHandler::sendInterlocDump
bool sendInterlocDump(InterlocUpdate *updatesHistory, uint8_t updatesLength) override
Sends a history of interloc updates back to the host.
Definition: InterlocMessageHandler.cpp:204
InterlocMessageHandler::m_inputQueue
ICircularQueue< MessageDTO > & m_inputQueue
Definition: InterlocMessageHandler.h:35
InterlocMessageHandler
Definition: InterlocMessageHandler.h:13
InterlocMessageHandler::rawAngleDataCallbackStatic
static void rawAngleDataCallbackStatic(void *context, BspInterlocRawAngleData &data)
Definition: InterlocMessageHandler.cpp:192
InterlocMessageHandler::stateChangeCallback
void stateChangeCallback(InterlocStateDTO previousState, InterlocStateDTO newState)
Definition: InterlocMessageHandler.cpp:111
InterlocMessageHandler::m_dumpsEnabled
bool m_dumpsEnabled
Definition: InterlocMessageHandler.h:43
InterlocMessageHandler::m_remoteQueue
ICircularQueue< MessageDTO > & m_remoteQueue
Definition: InterlocMessageHandler.h:37
IBSP
Definition: IBSP.h:6
InterlocMessageHandler::ensureSendMessage
void ensureSendMessage(MessageDTO &msg)
Definition: InterlocMessageHandler.cpp:156
InterlocUpdate
Definition: InterlocUpdate.h:7
InterlocMessageHandler::stateChangeCallbackStatic
static void stateChangeCallbackStatic(void *context, InterlocStateDTO previousState, InterlocStateDTO newState)
Definition: InterlocMessageHandler.cpp:197
InterlocMessageHandler::handleStateChangeMessage
bool handleStateChangeMessage(const SetInterlocStateDTO dto) const
Definition: InterlocMessageHandler.cpp:75
ILogger
A logger class with basic logging capabilities.
Definition: ILogger.h:35
InterlocMessageHandler::getQueueForDestination
ICircularQueue< MessageDTO > & getQueueForDestination(uint16_t destinationId) const
Definition: InterlocMessageHandler.cpp:67
IInterlocMessageHandler.h
InterlocMessageHandler::processMessage
bool processMessage() override
Processes the next message in the queue.
Definition: InterlocMessageHandler.cpp:29
InterlocMessageHandler::m_hostQueue
ICircularQueue< MessageDTO > & m_hostQueue
Definition: InterlocMessageHandler.h:36
InterlocMessageHandler::rawAngleDataCallback
void rawAngleDataCallback(BspInterlocRawAngleData &data)
Definition: InterlocMessageHandler.cpp:127
IInterlocManager.h
InterlocMessageHandler::m_messageSourceId
uint16_t m_messageSourceId
Definition: InterlocMessageHandler.h:42
InterlocMessageHandler::m_interlocPositionUpdateQueue
INotificationQueue< InterlocUpdate > & m_interlocPositionUpdateQueue
Definition: InterlocMessageHandler.h:38
InterlocMessageHandler::m_bsp
IBSP & m_bsp
Definition: InterlocMessageHandler.h:34
InterlocMessageHandler::handleConfigurationMessage
bool handleConfigurationMessage(const InterlocConfigurationDTO &dto)
Definition: InterlocMessageHandler.cpp:85
InterlocMessageHandler::InterlocMessageHandler
InterlocMessageHandler(ILogger &logger, IInterlocManager &interlocManager, IBSP &bsp, ICircularQueue< MessageDTO > &inputQueue, ICircularQueue< MessageDTO > &hostQueue, ICircularQueue< MessageDTO > &remoteQueue, INotificationQueue< InterlocUpdate > &interlocPositionUpdateQueue)
Definition: InterlocMessageHandler.cpp:8
ILogger.h
InterlocMessageHandler::m_interlocManager
IInterlocManager & m_interlocManager
Definition: InterlocMessageHandler.h:33