|
@@ -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)
|
|
|
-
|
|
|
- struct _LocateInfo
|
|
|
- {
|
|
|
- unsigned int site_id;
|
|
|
- unsigned short time_stamp;
|
|
|
- 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;
|
|
|
- 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);
|
|
|
+
|
|
|
if(pSite){
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
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;
|
|
|
+ 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;
|
|
|
pSite->m_time = mktime(&reader_time);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- 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);
|
|
|
+ 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);
|
|
|
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-int site_message_handle::parse_data_locate_card(char * DataBuffer, int reader_id
|
|
|
- , unsigned short wChr,int& nCurPos, unsigned long long ct_time,int pos)
|
|
|
-{
|
|
|
- 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);
|