/* * @file * module_screen.h * * @brief * 大屏业务 * @version * V1.0 * @author * zhuyf * @date * 2021/05/18 * @note * * @warning * @bug * @copyright * */ #ifndef module_screen_hpp #define module_screen_hpp #include #include #include #include #include "module_singleton_base.h" #include "websocket/ws_common.h" struct mine_person{ uint32_t m_id; // card id int m_battery; // value uint64_t m_recv_time; // mine_person() : m_id(0) , m_battery(0) , m_recv_time(0) {} mine_person(uint32_t id, int battery) : m_id(id) , m_battery(battery) , m_recv_time(time(NULL)) {} }; class module_screen: public singleton_base { private: friend class singleton_base; module_screen(){} public: void do_write(const std::map card_pos_list); void do_wellhead(); void put(const mine_person& p) { std::lock_guard lg(m_mtx); auto it = m_card_list.find(p.m_id); if(it == m_card_list.end()){ m_card_list.insert(std::make_pair(p.m_id, p)); }else{ m_card_list[p.m_id].m_recv_time = time(NULL); m_card_list[p.m_id].m_battery = p.m_battery; } } void start(); void run(); void stop() { m_exited = true; } private: std::unique_ptr m_thread; std::mutex m_mtx; std::map m_card_list; bool m_exited = false; }; #endif