123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- //
- // Created by zx on 2020/6/18.
- //
- #ifndef PARKSPACE_ALLOCATION_COMMUNICATOR_H
- #define PARKSPACE_ALLOCATION_COMMUNICATOR_H
- #include <mutex>
- #include "communication_socket_base.h"
- #include "singleton.h"
- #include "parkspace_allocation_message.pb.h"
- #include "error_code.h"
- class Parkspace_allocation_communicator: public Singleton<Parkspace_allocation_communicator>, public Communication_socket_base
- {
- friend Singleton<Parkspace_allocation_communicator>;
- public:
- virtual ~Parkspace_allocation_communicator();
- //外部调用,反馈结果消息
- Error_manager send_response(Communication_message* message);
- //更新所有车位状态,现有状态将被全部覆盖,车位数量可能变动
- Error_manager update_parkspace_status(message::Parkspace_allocation_status_msg message);
- //更新某个车位状态,不修改车位数量,车位按编号从0开始
- Error_manager update_parkspace_status(int parkspace_id, message::Parkspace_info parkspace_info);
- //获取所有车位状态
- message::Parkspace_allocation_status_msg get_status();
- protected:
- Parkspace_allocation_communicator();
- //封装反馈消息,加入队列父类自行发送
- virtual Error_manager encapsulate_msg(Communication_message* message);
- //解析车位分配请求消息具体内容,激活车位分配单例处理函数(不可阻塞),获得结果后由车位分配单例封装消息发送
- virtual Error_manager execute_msg(Communication_message* p_msg);
- //检查是否接收到本模块需要的消息,重载后父类自行调用判断
- virtual Error_manager check_msg(Communication_message* p_msg);
- //重载检查执行者函数,判断执行者状态
- virtual Error_manager check_executer(Communication_message* p_msg);
- //心跳与车位实时信息
- virtual Error_manager encapsulate_send_data();
- protected:
- message::Parkspace_allocation_status_msg m_parkspace_status_msg;
- std::mutex m_status_mutex;
- };
- #endif //PARKSPACE_ALLOCATION_COMMUNICATOR_H
|