|
@@ -10,6 +10,7 @@
|
|
#include "websocket/wsTimerThread.h"
|
|
#include "websocket/wsTimerThread.h"
|
|
#include "sys_setting.h"
|
|
#include "sys_setting.h"
|
|
#include <numeric>
|
|
#include <numeric>
|
|
|
|
+#include "tunnel.h"
|
|
|
|
|
|
int site::index()const
|
|
int site::index()const
|
|
{
|
|
{
|
|
@@ -35,9 +36,13 @@ const algo_config&site::config()const
|
|
|
|
|
|
void ant::set_path(const std::vector<line_v>& v_line, std::vector<line_v>::const_iterator itm)
|
|
void ant::set_path(const std::vector<line_v>& v_line, std::vector<line_v>::const_iterator itm)
|
|
{
|
|
{
|
|
|
|
+ //auto it = itm;
|
|
auto it = itm;
|
|
auto it = itm;
|
|
- for(int i = 0; i < 2 && it != v_line.end(); ++it,++i)
|
|
|
|
- m_path[0][i]=*it;
|
|
|
|
|
|
+ for (int i = 0; i < 2 && it != v_line.end(); ++it, ++i)
|
|
|
|
+ {
|
|
|
|
+ m_path[0][i] = *it;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
it=itm-1;
|
|
it=itm-1;
|
|
for(int i=0;i<2 && it>=v_line.begin();--it,++i)
|
|
for(int i=0;i<2 && it>=v_line.begin();--it,++i)
|
|
@@ -216,30 +221,38 @@ std::vector<point> ant::getsol(const double &dist) const
|
|
std::vector<point> v;
|
|
std::vector<point> v;
|
|
for(const auto & p : m_path)
|
|
for(const auto & p : m_path)
|
|
{
|
|
{
|
|
- if(!p.valid())
|
|
|
|
|
|
+ if (!p.valid())
|
|
continue;
|
|
continue;
|
|
|
|
|
|
point pt;
|
|
point pt;
|
|
double d = dist;
|
|
double d = dist;
|
|
|
|
|
|
- //logn_info(3, "[pdoa] dist=%.2f, line.length()=%.2f, %s", dist, p.m_line[0].length(), p.to_str().c_str());
|
|
|
|
- if(dist <= p.m_line[0].length())
|
|
|
|
|
|
+ if (true)
|
|
{
|
|
{
|
|
- d += d*p.m_line[0][0].z;
|
|
|
|
- pt = point(p.m_line[0][0].x + d*p.m_line[0].cos() , p.m_line[0][0].y + d*p.m_line[0].sin());
|
|
|
|
|
|
+ pt = point(p.m_line[0][0].x + d * p.m_line[0].cos(), p.m_line[0][0].y + d * p.m_line[0].sin());
|
|
}
|
|
}
|
|
- else if(p.m_line[1].length()>0)
|
|
|
|
- {
|
|
|
|
- d -= p.m_line[0].length()*(1-d*p.m_line[0][1].z);
|
|
|
|
- d += d*p.m_line[1][0].z;
|
|
|
|
|
|
|
|
- pt = point(p.m_line[1][0].x+d*p.m_line[1].cos(),p.m_line[1][0].y+d*p.m_line[1].sin());
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ if (false)
|
|
{
|
|
{
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
+ //logn_info(3, "[pdoa] dist=%.2f, line.length()=%.2f, %s", dist, p.m_line[0].length(), p.to_str().c_str());
|
|
|
|
+ if (dist <= p.m_line[0].length())
|
|
|
|
+ {
|
|
|
|
+ d += d * p.m_line[0][0].z;
|
|
|
|
+ pt = point(p.m_line[0][0].x + d * p.m_line[0].cos(), p.m_line[0][0].y + d * p.m_line[0].sin());
|
|
|
|
+ }
|
|
|
|
+ else if (p.m_line[1].length() > 0)
|
|
|
|
+ {
|
|
|
|
+ d -= p.m_line[0].length()*(1 - d * p.m_line[0][1].z);
|
|
|
|
+ d += d * p.m_line[1][0].z;
|
|
|
|
|
|
|
|
+ pt = point(p.m_line[1][0].x + d * p.m_line[1].cos(), p.m_line[1][0].y + d * p.m_line[1].sin());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
v.push_back(pt);
|
|
v.push_back(pt);
|
|
}
|
|
}
|
|
return std::move(v);
|
|
return std::move(v);
|
|
@@ -303,7 +316,7 @@ bool visit_site_status::visit(std::shared_ptr<site> s)
|
|
|
|
|
|
void sit_list::read_ant_path(int id)
|
|
void sit_list::read_ant_path(int id)
|
|
{
|
|
{
|
|
- std::string sql = "SELECT reader_id,tof_flag,b_x,b_y,b_z,e_x,e_y,e_z,spacing_ratio FROM dat_reader_path_tof_n";
|
|
|
|
|
|
+ std::string sql = "SELECT reader_id,tof_flag,b_x,b_y,b_z,e_x,e_y,e_z,spacing_ratio,angle FROM dat_reader_path_tof_n";
|
|
|
|
|
|
std::map<int,std::vector<line_v>> map_path;
|
|
std::map<int,std::vector<line_v>> map_path;
|
|
|
|
|
|
@@ -371,13 +384,19 @@ void sit_list::read_ant_path(int id)
|
|
double spacing_ratio = 0;
|
|
double spacing_ratio = 0;
|
|
DBRes.GetField( "spacing_ratio",spacing_ratio, Error );
|
|
DBRes.GetField( "spacing_ratio",spacing_ratio, Error );
|
|
|
|
|
|
|
|
+ double angle = 0;
|
|
|
|
+ DBRes.GetField("angle", angle, Error);
|
|
|
|
+
|
|
log_info("src-path:site=%d,x0=%.2f,y0=%.2f,x1=%.2f,y1=%.2f",reader_id,b_x,b_y,e_x,e_y);
|
|
log_info("src-path:site=%d,x0=%.2f,y0=%.2f,x1=%.2f,y1=%.2f",reader_id,b_x,b_y,e_x,e_y);
|
|
|
|
|
|
point p1(b_x, b_y, spacing_ratio);
|
|
point p1(b_x, b_y, spacing_ratio);
|
|
point p2(e_x, e_y, spacing_ratio);
|
|
point p2(e_x, e_y, spacing_ratio);
|
|
|
|
|
|
map_path.insert(std::make_pair(reader_id,std::vector<line_v>()));
|
|
map_path.insert(std::make_pair(reader_id,std::vector<line_v>()));
|
|
- map_path.find(reader_id)->second.push_back(line_v(p1,p2));
|
|
|
|
|
|
+ auto line = line_v(p1, p2);
|
|
|
|
+ line.angle.x = cos(angle*PI / 180);
|
|
|
|
+ line.angle.y = sin(angle*PI / 180);
|
|
|
|
+ map_path.find(reader_id)->second.push_back(line);
|
|
#if 0
|
|
#if 0
|
|
|
|
|
|
auto &sit_ = *site_ptr;
|
|
auto &sit_ = *site_ptr;
|
|
@@ -483,7 +502,7 @@ void sit_list::init_site(const std::string &ids /*=""*/)
|
|
FROM dat_reader AS r \
|
|
FROM dat_reader AS r \
|
|
LEFT JOIN dat_map AS m ON r.map_id=m.map_id \
|
|
LEFT JOIN dat_map AS m ON r.map_id=m.map_id \
|
|
LEFT JOIN his_reader_coverage AS rc ON r.reader_id = rc.reader_id \
|
|
LEFT JOIN his_reader_coverage AS rc ON r.reader_id = rc.reader_id \
|
|
- WHERE r.state=0;";
|
|
|
|
|
|
+ WHERE r.state=0 or r.state=1;";
|
|
|
|
|
|
if(ids.empty())
|
|
if(ids.empty())
|
|
{
|
|
{
|
|
@@ -509,6 +528,8 @@ void sit_list::init_site(const std::string &ids /*=""*/)
|
|
return ;
|
|
return ;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ s_tunnel.init_cells();
|
|
|
|
+
|
|
log_info( "init_site. The record count=%ld\n", nCount );
|
|
log_info( "init_site. The record count=%ld\n", nCount );
|
|
|
|
|
|
while ( DBRes.GetNextRecod(Error) )
|
|
while ( DBRes.GetNextRecod(Error) )
|
|
@@ -563,6 +584,8 @@ void sit_list::init_site(const std::string &ids /*=""*/)
|
|
site_ptr->x = x;
|
|
site_ptr->x = x;
|
|
site_ptr->y = y;
|
|
site_ptr->y = y;
|
|
|
|
|
|
|
|
+ site_ptr->m_cell_index = s_tunnel.get_cell_index_by_position(point(x, y, 0));
|
|
|
|
+
|
|
double offset = 0.0;
|
|
double offset = 0.0;
|
|
DBRes.GetField("pdoa_offset", offset, Error);
|
|
DBRes.GetField("pdoa_offset", offset, Error);
|
|
site_ptr->m_pdoa_offset = offset;
|
|
site_ptr->m_pdoa_offset = offset;
|
|
@@ -827,7 +850,7 @@ void sit_list_v::read_sit_list(int id /*= -1*/)
|
|
|
|
|
|
void sit_list_v::read_ant_path(int id /*= -1*/)
|
|
void sit_list_v::read_ant_path(int id /*= -1*/)
|
|
{
|
|
{
|
|
- std::string sql = "SELECT reader_id,tof_flag,b_x,b_y,b_z,e_x,e_y,e_z,spacing_ratio FROM dat_reader_path_tof_n_v";
|
|
|
|
|
|
+ std::string sql = "SELECT reader_id,tof_flag,b_x,b_y,b_z,e_x,e_y,e_z,spacing_ratio,angle FROM dat_reader_path_tof_n_v";
|
|
|
|
|
|
std::map<int, std::vector<line_v>> map_path;
|
|
std::map<int, std::vector<line_v>> map_path;
|
|
|
|
|
|
@@ -896,13 +919,19 @@ void sit_list_v::read_ant_path(int id /*= -1*/)
|
|
double spacing_ratio = 0;
|
|
double spacing_ratio = 0;
|
|
DBRes.GetField("spacing_ratio", spacing_ratio, Error);
|
|
DBRes.GetField("spacing_ratio", spacing_ratio, Error);
|
|
|
|
|
|
|
|
+ double angle = 0;
|
|
|
|
+ DBRes.GetField("angle", angle, Error);
|
|
|
|
+
|
|
log_info("src-path:site=%d,x0=%.2f,y0=%.2f,x1=%.2f,y1=%.2f", reader_id, b_x, b_y, e_x, e_y);
|
|
log_info("src-path:site=%d,x0=%.2f,y0=%.2f,x1=%.2f,y1=%.2f", reader_id, b_x, b_y, e_x, e_y);
|
|
|
|
|
|
point p1(b_x, b_y, spacing_ratio);
|
|
point p1(b_x, b_y, spacing_ratio);
|
|
point p2(e_x, e_y, spacing_ratio);
|
|
point p2(e_x, e_y, spacing_ratio);
|
|
|
|
|
|
|
|
+ auto line = line_v(p1, p2);
|
|
|
|
+ line.angle.x = cos(angle*PI / 180);
|
|
|
|
+ line.angle.y = sin(angle*PI / 180);
|
|
map_path.insert(std::make_pair(reader_id, std::vector<line_v>()));
|
|
map_path.insert(std::make_pair(reader_id, std::vector<line_v>()));
|
|
- map_path.find(reader_id)->second.push_back(line_v(p1, p2));
|
|
|
|
|
|
+ map_path.find(reader_id)->second.push_back(line);
|
|
#if 0
|
|
#if 0
|
|
|
|
|
|
auto &sit_ = *site_ptr;
|
|
auto &sit_ = *site_ptr;
|
|
@@ -1004,7 +1033,7 @@ void sit_list_v::init_site(const std::string &ids /*= ""*/)
|
|
FROM dat_reader_v, dat_map where \
|
|
FROM dat_reader_v, dat_map where \
|
|
dat_reader_v.map_id=dat_map.map_id and state=0";*/
|
|
dat_reader_v.map_id=dat_map.map_id and state=0";*/
|
|
std::string sql = "SELECT r.reader_id, r.device_type_id, \
|
|
std::string sql = "SELECT r.reader_id, r.device_type_id, \
|
|
- r.need_power_alarm, r.x, r.y, r.pdoa_offset, \
|
|
|
|
|
|
+ r.need_power_alarm, r.x, r.y, r.pdoa_offset, r.pdoa_direction, \
|
|
rc.plus_dist, rc.plus_card_id, rc.plus_occur_time, rc.minus_dist, rc.minus_card_id, rc.minus_occur_time \
|
|
rc.plus_dist, rc.plus_card_id, rc.plus_occur_time, rc.minus_dist, rc.minus_card_id, rc.minus_occur_time \
|
|
FROM dat_reader_v AS r \
|
|
FROM dat_reader_v AS r \
|
|
LEFT JOIN his_reader_coverage AS rc ON r.reader_id = rc.reader_id \
|
|
LEFT JOIN his_reader_coverage AS rc ON r.reader_id = rc.reader_id \
|
|
@@ -1033,6 +1062,7 @@ void sit_list_v::init_site(const std::string &ids /*= ""*/)
|
|
log_error("增加或修改失败,数据库中找不到: 分站id=%s", ids.c_str());
|
|
log_error("增加或修改失败,数据库中找不到: 分站id=%s", ids.c_str());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ s_tunnel.init_cells();
|
|
|
|
|
|
log_info("init_site. The record count=%ld\n", nCount);
|
|
log_info("init_site. The record count=%ld\n", nCount);
|
|
|
|
|
|
@@ -1089,6 +1119,8 @@ void sit_list_v::init_site(const std::string &ids /*= ""*/)
|
|
site_ptr->x = x;
|
|
site_ptr->x = x;
|
|
site_ptr->y = y;
|
|
site_ptr->y = y;
|
|
|
|
|
|
|
|
+ site_ptr->m_cell_index = s_tunnel.get_cell_index_by_position(point(x, y, 0));
|
|
|
|
+
|
|
double offset = 0.0;
|
|
double offset = 0.0;
|
|
DBRes.GetField("pdoa_offset", offset, Error);
|
|
DBRes.GetField("pdoa_offset", offset, Error);
|
|
site_ptr->m_pdoa_offset = offset;
|
|
site_ptr->m_pdoa_offset = offset;
|