#ifndef _CARD_HPP_
#define _CARD_HPP_
#include <message.h>
#include <ev++.h>
#include "point.h"
#include "ant.h"

#include "write-copy.h"

struct task;
template<typename T> struct zloop;
struct select_tool;
struct smooth_tool;
enum STA_TYPE
{
    STATUS_HELP=0,
    STATUS_LOW_POWER, 
};
struct card_message_handle;
struct card:point
{
	card(uint32_t id,uint16_t dis,int16_t type)
		:m_id(id)
		,m_type(type)
		,m_display(dis)
		,m_speed(0)
		,m_is_attendance(0)
		,m_stat(0)
	{}
	uint32_t m_id;				//卡号
	int16_t  m_type;			//类型
	uint16_t m_display;			//1显示0不显示，往前端推送
	double   m_speed;			//速度
	int      m_is_attendance;	//井上井下状态  0初始状态 1 井上 2 井下
	int		 m_stat;			//运动静止状态
};
struct card_location_base:card
{
    std::shared_ptr<select_tool> m_sel_tool=nullptr;
    std::shared_ptr<smooth_tool> m_smo_tool=nullptr;
	card_message_handle *m_message_handle=nullptr;
    ev::dynamic_loop * m_loop = nullptr;
	ev::timer m_timer;

    card_location_base()=default;
    card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t);
	void set(ev::dynamic_loop * loop);
	void on_timer();

	void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
	void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm );
    void do_status(STA_TYPE st)
    {
    }
	virtual ~card_location_base();
};

struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
{
	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();
	~card_list(){}
};

#endif


