|
@@ -267,9 +267,12 @@ void card_location_base::on_message(zloop<task*>* loop, message_pdoa_locinfo& lo
|
|
|
snprintf(sql, 1024, "insert into his_distance_reader(card_type, ident, reader_id, dist, dir, cur_time) values(%d, %d, %d, %.2f, %d, '%s')", loc.m_card_type, loc.m_card_id, loc.m_site_id, loc.m_tof*15.65*2.996*1E-4, (tool_other::get_pdoa(loc.m_poa, site_ptr->m_pdoa_offset)>=0?1:-1), tool_time::to_str(time(NULL)).c_str());
|
|
|
db_tool::PushAsync(sql);
|
|
|
log_info("[sql] %s", sql);
|
|
|
-
|
|
|
+
|
|
|
+ do_site_locate_event(loc);
|
|
|
+ do_card_locate_event(loc);
|
|
|
+
|
|
|
m_message_handle->on_message(loop, loc, is_history);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//前端推送位置函数.
|
|
@@ -468,6 +471,14 @@ std::shared_ptr<card_location_base> card_location_base::make_car(const std::stri
|
|
|
return std::make_shared<car>(type, cardid, needdisplay, t, deptid, categoryid, type_id, level_id, cid);
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ * @brief 基站覆盖距离检测
|
|
|
+ * @param message_pdoa_locinfo& loc 卡数据
|
|
|
+ * @return 无
|
|
|
+ * @note
|
|
|
+ * @bug
|
|
|
+ * @warning
|
|
|
+ * */
|
|
|
void card_location_base::do_site_coverage(message_pdoa_locinfo& loc)
|
|
|
{
|
|
|
auto site_ptr = sit_list::instance()->get(loc.m_site_id);
|
|
@@ -504,3 +515,52 @@ void card_location_base::do_site_coverage(message_pdoa_locinfo& loc)
|
|
|
logn_info(2, "[sql] %s", sql);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief 卡定位异常检测
|
|
|
+ * @param message_pdoa_locinfo& loc 卡数据
|
|
|
+ * @return 无
|
|
|
+ * @note
|
|
|
+ * @bug
|
|
|
+ * @warning
|
|
|
+ * */
|
|
|
+void card_location_base::do_card_locate_event(const message_pdoa_locinfo& loc)
|
|
|
+{
|
|
|
+ bool status = false;
|
|
|
+
|
|
|
+ status = ((loc.m_tof == 0)?true:false);
|
|
|
+
|
|
|
+ uint64_t id = tool_other::type_id_to_u64(m_type, m_id);
|
|
|
+ event_tool::instance()->handle_event(OT_CARD, ET_CARD_LOCATE_ERROR, id, 0, 0, status);
|
|
|
+ //log_info("[card-locate-event] card_id=%d, ct=%d, tof=%lld", m_id, m_ct, loc.m_tof);
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief 基站定位异常检测
|
|
|
+ * @param message_pdoa_locinfo& loc 卡数据
|
|
|
+ * @return 无
|
|
|
+ * @note
|
|
|
+ * @bug
|
|
|
+ * @warning
|
|
|
+ * */
|
|
|
+void card_location_base::do_site_locate_event(const message_pdoa_locinfo& loc)
|
|
|
+{
|
|
|
+ //log_info("[site-locate-event] cur_ct=%d, ct=%d, m_last_ct=%d, m_last_site_id=%d, loc.m_site_id=%d", loc.m_card_ct, ct, m_last_ct, m_last_site_id, loc.m_site_id);
|
|
|
+ if(m_last_ct <= 0 || m_last_site_id == 0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(loc.m_site_id != m_last_site_id){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int dt = 0;
|
|
|
+ if(loc.m_card_ct > m_last_ct){
|
|
|
+ dt = loc.m_card_ct - m_last_ct;
|
|
|
+ }else{
|
|
|
+ dt = 65535 + loc.m_card_ct - m_last_ct;
|
|
|
+ }
|
|
|
+
|
|
|
+ event_tool::instance()->handle_event(OT_DEVICE_READER, ET_READER_LONG_TIME_NO_POSITION, loc.m_site_id, 3, dt, (dt>=3));
|
|
|
+ log_info("[site-locate-event] site_id=%d, card_id=%d, ct=%d, dt=%d", loc.m_site_id, m_id, loc.m_card_ct, dt);
|
|
|
+}
|