|
@@ -8,7 +8,6 @@
|
|
|
#include "module_service/module_mgr.h"
|
|
|
#include "websocket/wsClientMgr.h"
|
|
|
#include "websocket/wsTimerThread.h"
|
|
|
-//#include "three_rates.h"
|
|
|
#include "his_location.h"
|
|
|
#include "event.h"
|
|
|
#include "module_service/module_call.h"
|
|
@@ -52,7 +51,7 @@ void card_location_base::do_status(int st)
|
|
|
time_t now = time(0);
|
|
|
//bool help_flag = false;
|
|
|
|
|
|
- log_info("[help-battery] card_id=%d, help_bit=%d, status=%d", m_id, m_help_bit, st);
|
|
|
+ //log_info("[help-battery] card_id=%d, help_bit=%d, status=%d", m_id, m_help_bit, st);
|
|
|
// 呼救
|
|
|
if((m_help_bit & 1) && (st & STATUS_HELP))
|
|
|
{
|
|
@@ -96,9 +95,9 @@ void card_location_base::do_status(int st)
|
|
|
}
|
|
|
|
|
|
/*if(!help_flag)
|
|
|
- {
|
|
|
- st = st & (0xFFFFFFFF ^ STATUS_HELP);
|
|
|
- }*/
|
|
|
+ {
|
|
|
+ st = st & (0xFFFFFFFF ^ STATUS_HELP);
|
|
|
+ }*/
|
|
|
|
|
|
if((STATUS_POWER_LOWER_SERIOUS & st) != 0)
|
|
|
{
|
|
@@ -109,102 +108,122 @@ void card_location_base::do_status(int st)
|
|
|
m_pwr_stat = 0;
|
|
|
}
|
|
|
|
|
|
- module_mgr::do_status((STATUS_CARD)st, m_id, m_type);
|
|
|
+ module_mgr::do_status((STATUS_CARD)st, m_id, m_type);
|
|
|
}
|
|
|
|
|
|
//写入历史轨迹
|
|
|
void card_location_base::make_his_location(uint64_t t,const point & pt,bool bclose /*= false*/)
|
|
|
{
|
|
|
int area_id = 0, map_id = 0, site_id = 0;
|
|
|
- double scale = 0.0;
|
|
|
+ double scale = 0.0;
|
|
|
if(auto site_ptr = get_area_tool()->m_site)
|
|
|
{
|
|
|
area_id = site_ptr->m_area_id;
|
|
|
map_id = site_ptr->m_map_id;
|
|
|
site_id = site_ptr->m_id;
|
|
|
- scale = site_ptr->m_scale;
|
|
|
+ scale = site_ptr->m_scale;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
auto mine_ptr = get_mine_tool();
|
|
|
if(m_time < mine_ptr->get_down_time())
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
m_his_location_card->push(t, pt, area_id, map_id, site_id, bclose);
|
|
|
- m_his_location_card->insert(t, pt, area_id, map_id, site_id, scale);
|
|
|
+ m_his_location_card->insert(t, pt, area_id, map_id, site_id, scale);
|
|
|
}
|
|
|
|
|
|
//坐标点输入业务入口
|
|
|
-void card_location_base::on_location(const std::vector<point>&vp, const std::vector<loc_message> &lm, bool is_v_map)
|
|
|
+void card_location_base::on_location(const std::vector<point>&vp, const std::vector<loc_message> &lm)
|
|
|
{
|
|
|
- m_isVehicleMap = false;
|
|
|
- if (is_vehicle())
|
|
|
- {
|
|
|
- if (!is_v_map)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if (is_person())
|
|
|
- {
|
|
|
- if (is_v_map)
|
|
|
- {
|
|
|
- m_isVehicleMap = true;
|
|
|
- }
|
|
|
+ /*std::for_each(vp.begin(), vp.end(), [](point it){
|
|
|
+ logn_info(3, "possible solution: x = %.2f, y = %.2f", it.x, it.y);
|
|
|
+ });*/
|
|
|
+ if(lm.size() < 2){
|
|
|
+ return;
|
|
|
}
|
|
|
-
|
|
|
- loc_point pt = m_sel_tool->select_solution(vp, lm);
|
|
|
- //pt.y = pt.y;
|
|
|
-
|
|
|
+ loc_point pt = m_sel_tool->select_solution(vp, lm);
|
|
|
+ //logn_info(3, "select solution: x = %.2f, y = %.2f", pt.x, pt.y);
|
|
|
auto site_ptr = get_area_tool()->m_site;
|
|
|
int sid = 0;
|
|
|
- if(site_ptr)
|
|
|
+ // 天线间间距默认为3米,实际取基站上的天线间距离配置参数
|
|
|
+ double ant_dist = 3.0;
|
|
|
+ if(site_ptr){
|
|
|
sid = site_ptr->m_id;
|
|
|
+ ant_dist = site_ptr->m_pdoa_offset;
|
|
|
+ }
|
|
|
+
|
|
|
+ // first way
|
|
|
+ sys::tof_data tdt;
|
|
|
+ tdt.cid = tool_byte::to_cardid(m_type, m_id);
|
|
|
+ tdt.sid = 0;
|
|
|
+ tdt.cur_time = tool_time::to_str_ex(tool_time::now_to_ms());
|
|
|
+ int aid = lm[0].m_ant_id;
|
|
|
+ tdt.ant_dist[aid] = lm[0].m_num_ticks*15.65*2.996*1E-4;
|
|
|
+ aid = lm[1].m_ant_id;
|
|
|
+ tdt.ant_dist[aid] = lm[1].m_num_ticks*15.65*2.996*1E-4;
|
|
|
+
|
|
|
+ if(tdt.ant_dist[0] > 1000 || tdt.ant_dist[1] > 1000){
|
|
|
+ int a = 11;
|
|
|
+ pt.x = a;
|
|
|
+ }
|
|
|
+
|
|
|
+ logn_info(3, "[tof_data] cid=%d, ct=%d, 1ant_dist=%.2f, 2ant_dist=%.2f", m_id, m_ct, tdt.ant_dist[0], tdt.ant_dist[1]);
|
|
|
+
|
|
|
+ loc_point tp;
|
|
|
+ if(tdt.ant_dist[0] > tdt.ant_dist[1] && tdt.ant_dist[0] > ant_dist){
|
|
|
+ // 在0天线侧外部
|
|
|
+ tp.y = -1.5 + tdt.ant_dist[0];
|
|
|
+ }else if(tdt.ant_dist[1] > tdt.ant_dist[0] && tdt.ant_dist[1] > ant_dist){
|
|
|
+ // 在1天线测外部
|
|
|
+ tp.y = 1.5 - tdt.ant_dist[1];
|
|
|
+ }else if(tdt.ant_dist[0] < 3.0 && tdt.ant_dist[1] < ant_dist) {
|
|
|
+ // 在两天线之间
|
|
|
+ tp.y = (-1.5 + tdt.ant_dist[0]) + (1.5 - tdt.ant_dist[1])/2.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ logn_info(3, "another solution:cid =%d, ct=%d, x = %.2f, y = %.2f", m_id, m_ct, tp.x, tp.y);
|
|
|
+ tdt.y = tp.y;
|
|
|
+ pt = tp;
|
|
|
+ pt.m_useless = true;
|
|
|
+
|
|
|
if(pt.m_useless)
|
|
|
{
|
|
|
- if (is_person())
|
|
|
- {
|
|
|
- if (!is_v_map)
|
|
|
- {
|
|
|
- x = tool_other::round(pt.x, 3);
|
|
|
- y = tool_other::round(pt.y, 3);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_v_point.x = tool_other::round(pt.x, 3);
|
|
|
- m_v_point.y = tool_other::round(pt.y, 3);
|
|
|
- log_info("useful loc m_v_point: type=%d, card=%d, site=%d, ct=%d, timestamp=%llu, x=%f, y=%f, speed=%.2f, acc=%.2f", m_type, m_id, sid, m_ct, m_time, m_v_point.x, m_v_point.y, m_speed, lm[0].m_acc);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (is_vehicle())
|
|
|
- {
|
|
|
- if (is_v_map)
|
|
|
- {
|
|
|
- x = tool_other::round(pt.x, 3);
|
|
|
- y = tool_other::round(pt.y, 3);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- double acc = lm[0].m_acc;
|
|
|
- m_acc = lm[0].m_acc;
|
|
|
- log_info("useful loc point: type=%d, card=%d, site=%d, ct=%d, timestamp=%llu, x=%f, y=%f, speed=%.2f, acc=%.2f",m_type,m_id,sid,m_ct,m_time,x,y, m_speed, acc);
|
|
|
- do_business(lm.front().m_sit, pt, acc);
|
|
|
+ x = tool_other::round(pt.x, 3);
|
|
|
+ y = tool_other::round(pt.y, 3);
|
|
|
|
|
|
+ do_business(lm.front().m_sit, pt);
|
|
|
+
|
|
|
+ sys::tof_data td;
|
|
|
+ td.cid = tool_byte::to_cardid(m_type, m_id);
|
|
|
+ td.y = y;
|
|
|
+ td.sid = sid;
|
|
|
+ td.cur_time = tool_time::to_str_ex(tool_time::now_to_ms());
|
|
|
+ int aid = lm[0].m_ant_id;
|
|
|
+ td.ant_dist[aid] = lm[0].m_num_ticks*15.65*2.996*1E-4;
|
|
|
+ aid = lm[1].m_ant_id;
|
|
|
+ td.ant_dist[aid] = lm[1].m_num_ticks*15.65*2.996*1E-4;
|
|
|
+ td.ant_diff = site_ptr->m_pdoa_offset;
|
|
|
+
|
|
|
+ // 将数据存入数据库中
|
|
|
+ char sql[1024] = {0};
|
|
|
+ snprintf(sql, 1024, "insert into his_tof_locate_data(card_id, ant_one_dist, ant_two_dist, ant_dist,site_id, y, cur_time) values('%s', %.2f, %.2f, %.2f, %d, %.2f, '%s')", tool_byte::to_cardid(m_type, m_id).c_str(), td.ant_dist[0], td.ant_dist[1], site_ptr->m_pdoa_offset, sid, y, tool_time::to_str_ex(tool_time::now_to_ms()).c_str());
|
|
|
+ db_tool::PushAsync(sql);
|
|
|
+ log_info("[sql] %s", sql);
|
|
|
+
|
|
|
+ //add json to send to web
|
|
|
+ swsTimerThrd.upt_tof_data(std::move(td));
|
|
|
+
|
|
|
// 呼救128,正常0
|
|
|
- int val = (lm[0].m_rav?STATUS_HELP:STATUS_NORMAL);
|
|
|
+ /*int val = (lm[0].m_rav?STATUS_HELP:STATUS_NORMAL);
|
|
|
if(m_battery_value > 3){
|
|
|
val += STATUS_POWER_NORMAL;
|
|
|
}else{
|
|
|
val += STATUS_POWER_LOWER_SERIOUS;
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
- log_info("[help-battery] card_id=%d, battery=%d, val=%d", m_id, m_battery_value, val);
|
|
|
- do_status(val);
|
|
|
+ //log_info("[help-battery] card_id=%d, battery=%d, val=%d", m_id, m_battery_value, val);
|
|
|
+ //do_status(STATUS_NORMAL);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -245,6 +264,24 @@ void card_location_base::on_message(zloop<task*>* loop, message_locinfo& loc,boo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ * 实心球原始数据调用算法模块进行定位处理
|
|
|
+ * */
|
|
|
+void card_location_base::on_message(zloop<task*>* loop, message_ins_locinfo& loc,bool is_history)
|
|
|
+{
|
|
|
+ log_info("[solid_ball] start calc location");
|
|
|
+ m_ct = loc.m_card_ct;
|
|
|
+ m_time = loc.m_time_stamp;
|
|
|
+ auto site_ptr = sit_list::instance()->get(loc.m_site_id);
|
|
|
+ if(!site_ptr)
|
|
|
+ {
|
|
|
+ log_warn("接收到分站的数据,site=%d,card=%d,ct=%d,但是分站未定义",loc.m_site_id,m_id,loc.m_card_ct);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_message_handle->on_message(loop, loc, is_history);
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
* tdoa 调用算法库定位
|
|
|
* */
|
|
@@ -414,31 +451,6 @@ void card_location_base::clear()
|
|
|
m_cb_point.clear();
|
|
|
}
|
|
|
|
|
|
-/*void card_location_base::put_three_rates(card_pos & cp)
|
|
|
-{
|
|
|
- if(!three_rates_flag)
|
|
|
- return;
|
|
|
-
|
|
|
- cp.rec_time = m_time;
|
|
|
- cp.type = m_type;
|
|
|
- cp.id = m_id;
|
|
|
- cp.identifier_id= m_cid;
|
|
|
- cp.running_stat = m_stat;
|
|
|
- cp.final_v = m_speed;
|
|
|
- cp.dpt_id = m_deptid;
|
|
|
- std::shared_ptr<area_tool> _areatool = get_area_tool();
|
|
|
- if(nullptr != _areatool && nullptr != _areatool->m_site)
|
|
|
- {
|
|
|
- cp.reader_x = _areatool->m_site->x;
|
|
|
- cp.reader_y = _areatool->m_site->y;
|
|
|
- cp.reader_id = _areatool->m_site->m_id;
|
|
|
- }
|
|
|
-
|
|
|
- log_info("three_rates:type:%d,id:%d,cid:%d",cp.type,cp.id,cp.identifier_id);
|
|
|
- three_rates::get_instance()->put(cp);
|
|
|
-
|
|
|
-}*/
|
|
|
-
|
|
|
void card_location_base::put_traffic_light(card_pos& cp)
|
|
|
{
|
|
|
if(!traffic_light_flag){
|
|
@@ -606,4 +618,5 @@ void card_location_base::do_site_locate_event(const message_pdoa_locinfo& loc)
|
|
|
|
|
|
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);
|
|
|
-}
|
|
|
+}
|
|
|
+
|