|
@@ -269,7 +269,34 @@ 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)
|
|
|
{
|
|
|
+ /*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);
|
|
|
log_info("[solid_ball] start calc location");
|
|
|
+
|
|
|
+ auto itm = m_msg_list.find(loc.m_card_ct);
|
|
|
+
|
|
|
+ if(itm == m_msg_list.end()){
|
|
|
+ std::vector<message_ins_locinfo> vtm;
|
|
|
+ vtm.push_back(loc);
|
|
|
+ m_msg_list.insert(std::make_pair(loc.m_card_ct, vtm));
|
|
|
+ itm = m_msg_list.find(loc.m_card_ct);
|
|
|
+ }else{
|
|
|
+ itm->second.push_back(loc);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(itm->second.size() < 2){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ct切换了
|
|
|
m_ct = loc.m_card_ct;
|
|
|
m_time = loc.m_time_stamp;
|
|
|
auto site_ptr = sit_list::instance()->get(loc.m_site_id);
|
|
@@ -279,7 +306,97 @@ void card_location_base::on_message(zloop<task*>* loop, message_ins_locinfo& loc
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- m_message_handle->on_message(loop, loc, is_history);
|
|
|
+ // 卡号
|
|
|
+ std::string sid = tool_byte::to_cardid(m_type, m_id);
|
|
|
+ std::string site_info = "";
|
|
|
+ std::string now = tool_time::to_str_ex(tool_time::now_to_ms());
|
|
|
+
|
|
|
+ // 存入数据库
|
|
|
+ for(auto itl : itm->second){
|
|
|
+ site_info += std::to_string(itl.m_site_id);
|
|
|
+ double d = itl.m_tof * 15.65 * 2.996 * 1E-4;
|
|
|
+ site_info += "," + std::to_string(d);
|
|
|
+ site_info += ",0.0";
|
|
|
+ double v = 0.0;
|
|
|
+ auto its = last_site_info.find(itl.m_site_id);
|
|
|
+ if(its == last_site_info.end()){
|
|
|
+ sinfo si;
|
|
|
+ si.sct = m_ct;
|
|
|
+ si.sdist = d;
|
|
|
+ last_site_info.insert(std::make_pair(itl.m_site_id, si));
|
|
|
+ v = 0.0;
|
|
|
+ }else{
|
|
|
+ double dt = 0.0;
|
|
|
+ if(m_ct > its->second.sct ){
|
|
|
+ dt = (m_ct - its->second.sct) / 1000.0;
|
|
|
+ }else{
|
|
|
+ dt = (m_ct + 65535 - its->second.sct) / 1000.0;
|
|
|
+ }
|
|
|
+ v = (d - its->second.sdist) / dt;
|
|
|
+
|
|
|
+ its->second.sct = m_ct;
|
|
|
+ its->second.sdist = d;
|
|
|
+ }
|
|
|
+ site_info += "," + std::to_string(v);
|
|
|
+ site_info += ";";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 数据入库
|
|
|
+ char sql[1024] = { 0 };
|
|
|
+ snprintf(sql,
|
|
|
+ 1024,
|
|
|
+ "insert into his_raw_data_sb(card_id, x, y, z, speed, site_info, acc, acc_x, acc_y, acc_z, ang, ang_x, ang_y, ang_z, cur_time) values('%s', %.2f, %.2f, %.2f, %.2f, '%s', %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, '%s')",
|
|
|
+ sid.c_str(),
|
|
|
+ 0.0,
|
|
|
+ 0.0,
|
|
|
+ 0.0,
|
|
|
+ 0.0,
|
|
|
+ site_info.c_str(),
|
|
|
+ loc.m_ins_data.get_acc(),
|
|
|
+ loc.m_ins_data.get_acc(0),
|
|
|
+ loc.m_ins_data.get_acc(1),
|
|
|
+ loc.m_ins_data.get_acc(2),
|
|
|
+ loc.m_ins_data.get_gyro(),
|
|
|
+ loc.m_ins_data.get_gyro(0),
|
|
|
+ loc.m_ins_data.get_gyro(1),
|
|
|
+ loc.m_ins_data.get_gyro(2),
|
|
|
+ now.c_str()
|
|
|
+ );
|
|
|
+ db_tool::PushAsync(sql);
|
|
|
+ log_info("[sql] %s", sql);
|
|
|
+
|
|
|
+ // 更新数据到发送线程
|
|
|
+ sys::sb_data sd;
|
|
|
+ sd.cid = sid;
|
|
|
+ sd.speed = 0.0;
|
|
|
+ sd.site_info = site_info;
|
|
|
+ sd.acc = loc.m_ins_data.get_acc();
|
|
|
+ sd.ang = loc.m_ins_data.get_gyro();
|
|
|
+ std::copy(loc.m_ins_data.m_acc_data.begin(), loc.m_ins_data.m_acc_data.end(), sd.m_acc_data.begin());
|
|
|
+ std::copy(loc.m_ins_data.m_ang_data.begin(), loc.m_ins_data.m_ang_data.end(), sd.m_ang_data.begin());
|
|
|
+ sd.cur_time = now;
|
|
|
+
|
|
|
+ swsTimerThrd.upt_sb_data(std::move(sd));
|
|
|
+
|
|
|
+ logn_info(3,
|
|
|
+ "[solid_ball] cid='%s', stamp=%d, sinfo='%s', acc = %.2f, acc_x = %.2f, acc_y = %.2f, acc_z = %.2f, ang = %.2f, ang_x = %.2f, ang_y = %.2f, ang_z = %.2f, t = '%s')",
|
|
|
+ sid.c_str(),
|
|
|
+ m_ct,
|
|
|
+ site_info.c_str(),
|
|
|
+ loc.m_ins_data.get_acc(),
|
|
|
+ loc.m_ins_data.get_acc(0),
|
|
|
+ loc.m_ins_data.get_acc(1),
|
|
|
+ loc.m_ins_data.get_acc(2),
|
|
|
+ loc.m_ins_data.get_gyro(),
|
|
|
+ loc.m_ins_data.get_gyro(0),
|
|
|
+ loc.m_ins_data.get_gyro(1),
|
|
|
+ loc.m_ins_data.get_gyro(2),
|
|
|
+ now.c_str()
|
|
|
+ );
|
|
|
+
|
|
|
+ //清除数据
|
|
|
+ m_msg_list.erase(itm);
|
|
|
+ //m_message_handle->on_message(loop, loc, is_history);*/
|
|
|
}
|
|
|
|
|
|
/*
|