
#include "site_area.h"
#include "card.h"
#include "ant.h"

//每张卡包含这样一个对象，保存最后一个分站区域
//1、记录卡进出分站的时间，地点
//2、用于考勤
std::shared_ptr<site> site_area_hover::get_site()
{
	return sit_list::instance()->get(m_site_id);
}
void site_area_hover::on_point(uint32_t card_id,int site_id,const point*pt,int32_t type)
{
	if(pt!=nullptr)
	{
		if(m_enter_point.empty())
			m_enter_point=*pt;

		m_last_point=*pt;
	}
	else
	{
		if(m_site_id==site_id) 
		{
			m_last_time=time(0);
			return;
		}
        int last_id = m_site_id;
        m_site_id = site_id;

        //离开现有分站处理，记录现有分站的进出时间和地点
        leave_site(card_id,last_id,type);

        //进入分站覆盖区域处理，考勤
        enter_site(card_id,site_id,type);

        //m_site_id=site_id;
        m_enter_time=m_last_time=time(nullptr);

        m_enter_point.set(0,0);
        m_last_point.set(0,0);
	}
}

void site_area_hover::enter_site(uint32_t card_id,int enter_site,int32_t type)
{

}

void site_area_hover::leave_site(uint32_t card_id,int enter_site,int32_t type)
{

}
int site_area_hover::get_att_type() const 
{
	int id = -1;
		const auto &s = sit_list::instance()->get(m_site_id);
		if(s)
			if(s->m_reader_type_id == READER_TYPE_ID_DOWN)
				id=0;
		return id;
}
