#ifndef _MSGHANDLER_HPP_ #define _MSGHANDLER_HPP_ #include #include #include #include class MsgHandler { public: int fd; std::string device; std::vector m_WeightData; MsgHandler(); ~MsgHandler() = default; void HandleDdsMsg(const std::map& msg); template bool HandleDeviceMsg(T& msg); bool SetDevice(const std::string& device); virtual bool OpenPort(const std::string& port, const std::string& baudrate); virtual int SendDeviceMsg(const std::vector& data); virtual int RecvDeviceMsg(std::vector& data, int timeoutMs); int SendMsg(const std::vector& data); int RecvMsg(std::vector& data, int timeoutMs); bool isOpen() const { return fd != -1; } void ClosePort(); private: bool get_frame(std::vector& frame, uint8_t frame_size, uint8_t start, uint8_t end); bool get_weight_1(std::string& weight, std::vector& frame); bool get_weight_1(float& weight, std::vector& frame); bool get_weight_2(std::string& weight, std::vector& frame); bool get_weight_2(float& weight, std::vector& frame); }; #endif