1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #include "site_message_handle.h"
- #include "system_basic_info/SystemAnalysis.h"
- #include "common_tool.h"
- #include "ant.h"
- #include "event.h"
- site_message_handle::site_message_handle()
- {
- m_time_last_rec = 0;
- }
- void site_message_handle::parse_data_locate_reader(int msgId,const message_siteinfo &loc ,bool bHistroy)
- {
- LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_15);
- 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 = loc.m_site_id;
- LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_17);
- }
-
- pSite->m_rec_time = time(NULL);
- m_time_last_rec = pSite->m_rec_time;
-
- pSite->m_tick_count = loc.m_time_stamp;
-
-
- struct tm reader_time;
- 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 = 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(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",
- 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);
- }
- void site_message_handle::reader_power_battery_alarm(unsigned int site_id, int powerType)
- {
- std::shared_ptr<site> pSite = sit_list::instance()->get(site_id);
- if (pSite == nullptr || !pSite->m_needpower_alarm)
- {
- return ;
- }
- double limitVal = time(NULL);
- if (powerType != pSite->m_powerType && pSite->m_powerType == 1)
- {
-
- event_tool::instance()->handle_event(OT_DEVICE_READER,ET_READER_POWER_BY_BATTERY,0,limitVal,powerType,true);
- }
- else if (powerType != pSite->m_powerType && pSite->m_powerType != 1)
- {
-
- event_tool::instance()->handle_event(OT_DEVICE_READER,ET_READER_POWER_BY_BATTERY,0,limitVal,powerType,false);
- }
- log_info("[event warning: reader power supply by battery] reader_id: Power %d->%d.",site_id,pSite->m_powerType,powerType);
- pSite->m_powerType = powerType;
- }
|