12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #ifndef _CARD_HPP_
- #define _CARD_HPP_
- #include <thread>
- #include <ev++.h>
- #include "card_base.h"
- #include "write-copy.h"
- #define CARD_LOST_TIME_OUT (30*1000)
- struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
- {
- ///id64=-1为初始化所有卡, id格式为:10000001016
- void init_staffer(int64_t id64);
- ///id64=-1为初始化所有卡, id格式为:10000001016
- void init_vehicle(int64_t id64);
- //void init_staffer();
- //void init_vehicle();
- uint64_t getId(uint32_t cardid,uint64_t);
- void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
- void init_card_from_db();
- void load_his_card_postion_vehicle();
- void load_his_card_postion_staff();
- void load_his_card_postion_from_db();
- std::unique_ptr<std::thread> m_pThread;
- bool m_bflag=false;
- void run()
- {
- m_pThread.reset(new std::thread(std::bind(&card_list::onTimer,this)));
- }
- // TODO : 停止进程
- void onStopRun();
-
- void onTimer();
- /// (类型<<32)|卡号
- //公用函数最好不要使用成员函数,改成公共函数。
- static uint64_t to_id64(int32_t type, uint32_t id)
- {
- return (static_cast<uint64_t>(type)<<32)|id;
- }
- static std::string to_id64_str(int32_t type, uint32_t id)
- {
- char sql[15] = {'\0'};
- sprintf(sql, "%03d%010d", type, id);
- return std::string(sql);
- }
- ~card_list(){m_bflag=true;}
- };
- #endif
|