|
@@ -8,47 +8,23 @@
|
|
|
#include "ant.h"
|
|
|
#include "ya_event.h"
|
|
|
|
|
|
+site_message_handle::site_message_handle()
|
|
|
+{
|
|
|
+ m_time_last_rec = 0;
|
|
|
+}
|
|
|
/** 解析 分站发送过来的数据中(分站的信息数据)*/
|
|
|
-void site_message_handle::parse_data_locate_reader(char * DataBuffer, int nLen, int dwConnID,int& nCurPos
|
|
|
- , int& reader_id )
|
|
|
+void site_message_handle::parse_data_locate_reader(int msgId,const message_siteinfo &loc ,bool bHistroy)
|
|
|
{
|
|
|
LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_15);
|
|
|
-#pragma pack(1)
|
|
|
- // 7字节 从第一个字节开始,分别表示秒、分、时、天、周、月、年
|
|
|
- struct _LocateInfo
|
|
|
- {
|
|
|
- unsigned int site_id; //分站ID
|
|
|
- unsigned short time_stamp; //时间戳(0-65535)
|
|
|
- unsigned char sec;
|
|
|
- unsigned char min;
|
|
|
- unsigned char hour;
|
|
|
- unsigned char day;
|
|
|
- unsigned char week;
|
|
|
- unsigned char mon;
|
|
|
- unsigned char year;
|
|
|
- unsigned char site_relation; //分站类型
|
|
|
- unsigned char site_state; //分站状态char
|
|
|
- unsigned char site_power; //分站电源类型
|
|
|
- };
|
|
|
-#pragma pack()
|
|
|
- _LocateInfo *_pLocateInfo = (_LocateInfo *)(DataBuffer + nCurPos);
|
|
|
- if (tool_other::IsBigEnd()) //大端
|
|
|
- {
|
|
|
- _pLocateInfo->site_id = ntohl(_pLocateInfo->site_id);
|
|
|
- _pLocateInfo->time_stamp = ntohs(_pLocateInfo->time_stamp);
|
|
|
- }
|
|
|
- nCurPos += sizeof(_LocateInfo);
|
|
|
-
|
|
|
- reader_id = _pLocateInfo->site_id;
|
|
|
- std::shared_ptr<site> pSite = sit_list::instance()->get(_pLocateInfo->site_id);
|
|
|
- bool isErrorReader = false;
|
|
|
|
|
|
+ std::shared_ptr<site> pSite = sit_list::instance()->get(loc.m_site_id);
|
|
|
+ //bool isErrorReader = false;
|
|
|
if(pSite){
|
|
|
//add_socket_to_list(dwConnID, reader_id, DEVICE_TYPE::DT_CARD_READER);
|
|
|
LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_16);
|
|
|
}else{
|
|
|
pSite = std::make_shared<site>();
|
|
|
- pSite->m_id = reader_id;
|
|
|
+ pSite->m_id = loc.m_site_id;
|
|
|
LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_17);
|
|
|
}
|
|
|
|
|
@@ -56,45 +32,39 @@ void site_message_handle::parse_data_locate_reader(char * DataBuffer, int nLen,
|
|
|
pSite->m_rec_time = time(NULL);
|
|
|
m_time_last_rec = pSite->m_rec_time; // 更新最后信号时间
|
|
|
// 分站时间戳
|
|
|
- pSite->m_tick_count = _pLocateInfo->time_stamp;
|
|
|
+ pSite->m_tick_count = loc.m_time_stamp;
|
|
|
// 分站时间
|
|
|
// 7字节 从第一个字节开始,分别表示秒、分、时、天、周、月、年
|
|
|
struct tm reader_time;
|
|
|
- reader_time.tm_sec = _pLocateInfo->sec;
|
|
|
- reader_time.tm_min = _pLocateInfo->min;
|
|
|
- reader_time.tm_hour = _pLocateInfo->hour;
|
|
|
- reader_time.tm_mday = _pLocateInfo->day;
|
|
|
- reader_time.tm_wday = _pLocateInfo->week;
|
|
|
- reader_time.tm_mon = _pLocateInfo->mon - 1;
|
|
|
- reader_time.tm_year = _pLocateInfo->year + 100; // + 2000 - 1900
|
|
|
+ reader_time.tm_sec = loc.m_sec;
|
|
|
+ reader_time.tm_min = loc.m_min;
|
|
|
+ reader_time.tm_hour = loc.m_hour;
|
|
|
+ reader_time.tm_mday = loc.m_day;
|
|
|
+ reader_time.tm_wday = loc.m_week;
|
|
|
+ reader_time.tm_mon = loc.m_mon - 1;
|
|
|
+ reader_time.tm_year = loc.m_year + 100; // + 2000 - 1900
|
|
|
pSite->m_time = mktime(&reader_time);
|
|
|
|
|
|
//改为大小分站信息,最高位第7位表示大小分站,1表示大分站,0表示小分站
|
|
|
//高6位表示分站(大或小)在大分站的左侧或右侧,1代表在大分站的左侧,0表示在大分站的右侧
|
|
|
//高5位预留位,用于区分是读卡分站还是大小分站
|
|
|
- uint8_t reader_type = _pLocateInfo->site_relation >>7; //大小分站的区别
|
|
|
- uint8_t reader_dir = (_pLocateInfo->site_relation >>6)&0x01;
|
|
|
- uint8_t reader_type_locate = (_pLocateInfo->site_relation >>5)&0x01; //大小分站与读卡分站的区别
|
|
|
- uint8_t relay_counts = _pLocateInfo->site_relation&0x0F;
|
|
|
+ uint8_t reader_type = loc.m_site_relation >>7; //大小分站的区别
|
|
|
+ uint8_t reader_dir = (loc.m_site_relation >>6)&0x01;
|
|
|
+ uint8_t reader_type_locate = (loc.m_site_relation >>5)&0x01; //大小分站与读卡分站的区别
|
|
|
+ uint8_t relay_counts = loc.m_site_relation&0x0F;
|
|
|
pSite->m_reader_dir = reader_dir;
|
|
|
pSite->m_relay_counts = relay_counts;
|
|
|
|
|
|
- reader_power_battery_alarm(_pLocateInfo->site_id,_pLocateInfo->site_power);
|
|
|
+ reader_power_battery_alarm(loc.m_site_id,loc.m_site_power);
|
|
|
|
|
|
log_info("id:%d, n:%d, %.2d-%.2d-%.2d %.2d:%.2d:%.2d, sta: %d,reader_power: %d"
|
|
|
",reader_type: %d,is_big_reader: %d,is_left: %d, counts: %d",
|
|
|
- _pLocateInfo->site_id, _pLocateInfo->time_stamp, _pLocateInfo->year, _pLocateInfo->mon, _pLocateInfo->day\
|
|
|
- , _pLocateInfo->hour, _pLocateInfo->min,_pLocateInfo->sec\
|
|
|
- , _pLocateInfo->site_state,_pLocateInfo->site_power,reader_type_locate,reader_type,reader_dir,relay_counts);/*tep:%d,*/
|
|
|
+ loc.m_site_id, loc.m_time_stamp, loc.m_year, loc.m_mon, loc.m_day\
|
|
|
+ , loc.m_hour, loc.m_min,loc.m_sec\
|
|
|
+ , loc.m_site_state,loc.m_site_power,reader_type_locate,reader_type,reader_dir,relay_counts);/*tep:%d,*/
|
|
|
|
|
|
|
|
|
}
|
|
|
-/** 解析单个卡数据 */
|
|
|
-int site_message_handle::parse_data_locate_card(char * DataBuffer, int reader_id
|
|
|
- , unsigned short wChr,int& nCurPos, unsigned long long ct_time/* = 0*/,int pos/* = 0*/)
|
|
|
-{
|
|
|
- return 0;
|
|
|
-}
|
|
|
|
|
|
void site_message_handle::reader_power_battery_alarm(unsigned int site_id, int powerType)
|
|
|
{
|
|
@@ -103,7 +73,7 @@ void site_message_handle::reader_power_battery_alarm(unsigned int site_id, int p
|
|
|
{
|
|
|
return ;
|
|
|
}
|
|
|
- std::shared_ptr<ya_event> ev_ptr = event_list::get_event_reader(site_id,ET_READER_POWER_BY_BATTERY);
|
|
|
+ std::shared_ptr<ya_event> ev_ptr = event_list::instance()->get_event_reader(site_id,ET_READER_POWER_BY_BATTERY);
|
|
|
int oldEvState = -1;
|
|
|
int usePowerType = powerType;
|
|
|
if (!pSite->m_needpower_alarm)
|
|
@@ -148,7 +118,7 @@ void site_message_handle::reader_power_battery_alarm(unsigned int site_id, int p
|
|
|
event_list::copy_event(pSite,ev_ptr);
|
|
|
event_list::instance()->add(ev_ptr->get_list_id(),ev_ptr);
|
|
|
}
|
|
|
- ev_ptr->status = ES_START;
|
|
|
+ ev_ptr->m_status = ES_START;
|
|
|
ev_ptr->m_limit_value = 0;
|
|
|
ev_ptr->m_cur_value = usePowerType;
|
|
|
event_list::save_event(ev_ptr);
|