123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /*
- * @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 <map>
- #include <mutex>
- #include <thread>
- #include <memory>
- #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<module_screen>
- {
- private:
- friend class singleton_base<module_screen>;
- module_screen(){}
- public:
- void do_write(const std::map<uint64_t, sys::_CARD_POS_> card_pos_list);
- void do_wellhead();
- void put(const mine_person& p)
- {
- std::lock_guard<std::mutex> 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<std::thread> m_thread;
- std::mutex m_mtx;
- std::map<uint64_t, mine_person> m_card_list;
- bool m_exited = false;
- };
- #endif
|