Selaa lähdekoodia

add poa error event and site locate error event

zhuyf 3 vuotta sitten
vanhempi
commit
7548337c6f

+ 50 - 1
ant.cpp

@@ -8,6 +8,8 @@
 #include "area.h"
 #include "card_path.h"
 #include "websocket/wsTimerThread.h"
+#include "sys_setting.h"
+#include <numeric>
 
 int site::index()const
 {
@@ -108,6 +110,26 @@ void ant::set_path(const std::vector<line_v>&v_line_)
 	}
 }
 
+/*
+ * @brief			天线相位是否异常
+ * @param			无
+ * @return			相位异常返回true,否则返回false
+ * @note
+ * @warning
+ * @bug
+ * */
+bool ant::phase_error()
+{
+	if(m_cache_poa.size()<5){
+		return false;
+	}
+
+	double sum = std::accumulate(m_cache_poa.begin(), m_cache_poa.end(), 0.0);
+
+	return (sum < 1E-4?true:false);
+
+}
+
 void site::set_path(const std::vector<line_v>&v_line)
 {
 	if(v_line.empty())
@@ -229,6 +251,32 @@ bool visit_site_status::visit(std::shared_ptr<site> s)
 	int diff = now - s->m_time;
 	event_tool::instance()->handle_event(OT_DEVICE_READER, ET_READER_ERROR, s->m_id, READER_TIMEOUT, diff, diff>READER_TIMEOUT);
 
+	// 定位基站长时间无定位告警
+	if(s->m_loc_time > 0 && s->m_device_type_id == DEVICE_TYPE::LOCATE_SITE)
+	{
+		int diff = now - s->m_loc_time;
+		log_info("site_no_position: site_id=%d, diff=%d, loc_time=%ld", s->m_id, diff, s->m_loc_time);
+		event_tool::instance()->handle_event(OT_DEVICE_READER, ET_READER_LONG_TIME_NO_POSITION, s->m_id, CYaSetting::m_sys_setting.site_no_position_time, diff, diff>CYaSetting::m_sys_setting.site_no_position_time);
+	}
+
+	// 定位基站天线poa异常告警
+	if(s->m_device_type_id == DEVICE_TYPE::LOCATE_SITE){
+		if(s->m_ant[0].phase_error()&&s->m_ant[1].phase_error()){
+			event_tool::instance()->handle_event(OT_DEVICE_READER, ET_READER_ANTENNA_PHASE_ABNORMAL, s->m_id, 0, 3, true);
+		}else if(s->m_ant[0].phase_error()|| s->m_ant[1].phase_error()){
+			if(s->m_ant[0].phase_error()){
+				// 如果1天线相位值错误
+				event_tool::instance()->handle_event(OT_DEVICE_READER, ET_READER_ANTENNA_PHASE_ABNORMAL, s->m_id, 0, 1, true);
+			}else if(s->m_ant[1].phase_error()){
+				// 如果2天线相位值错误
+				event_tool::instance()->handle_event(OT_DEVICE_READER, ET_READER_ANTENNA_PHASE_ABNORMAL, s->m_id, 0, 2, true);
+			}
+		}else{
+			// 如果都没错误,告警消失
+			event_tool::instance()->handle_event(OT_DEVICE_READER, ET_READER_ANTENNA_PHASE_ABNORMAL, s->m_id, 0, 0, false);
+		}
+	}
+
 	// 更新设备状态
 	int state = (diff > READER_TIMEOUT ? 1 : 0);
 	//log_info("[device_state] rid=%d, diff=%d, timeout=%d, state=%d, now=%lld, rtime=%lld", s->m_id, diff, READER_TIMEOUT, state, now, s->m_time);
@@ -507,7 +555,7 @@ void sit_list::init_site(const std::string &ids /*=""*/)
             site_ptr->m_special = special;
          }
 
-		 log_info ("site_position: site=%d, x=%.2lf, y=%.2lf, area_id=%d, m_scale=%.2f, pdoa_offset=%.2f, pdoa_direction=%d, special=%d", reader_id, x, y, area_id, scale, offset, direction, special);
+		 log_info ("site_position: site=%d, x=%.2lf, y=%.2lf, area_id=%d, m_scale=%.2f, pdoa_offset=%.2f, pdoa_direction=%d, special=%d, device_type_id=%d", reader_id, x, y, area_id, scale, offset, direction, special, device_type_id);
      }
 }
 
@@ -598,6 +646,7 @@ void site::create_area()
 {
     m_area=std::make_shared<area>(-m_id,0,0,m_scale,m_map_id,1<<7);
 }
+
 void site::clear_event()
 {
     event_tool::instance()->handle_event(OT_DEVICE_READER, ET_READER_ERROR, id(), READER_TIMEOUT, 0, false);

+ 15 - 0
ant.h

@@ -68,6 +68,12 @@ struct ant :point
     std::array<path,2> m_path;
     int m_id;
     double m_angle = 0;
+	boost::circular_buffer<double> m_cache_poa;		// 缓存5个天线的相位差值
+
+	ant()
+	{
+		m_cache_poa.set_capacity(5);
+	}
 
     path & operator[](int i)
     {
@@ -87,6 +93,8 @@ struct ant :point
 	void set_path(const std::vector<line_v>&v_line);
 	void set_path(const std::vector<line_v>&v_line,std::vector<line_v>::const_iterator it);
     std::vector<point> getsol(const double &dist) const;
+
+	bool phase_error();
 };
 
 struct site:point,std::enable_shared_from_this<site>
@@ -117,6 +125,7 @@ struct site:point,std::enable_shared_from_this<site>
     std::shared_ptr<area> m_area = nullptr;
 
 	time_t m_time;
+	time_t m_loc_time = time(0);	// 基站定位时间
 //  time_t m_rec_time;              // 接收数据的时间
 //  time_t m_lost_time;		        // 丢失时间
 //  time_t m_last_send_time;	    // 最后向前端发送时间
@@ -327,6 +336,12 @@ struct site:point,std::enable_shared_from_this<site>
     }
 
     double get_site_dist(const int& sid);
+
+	void push_poa(const double& poa1, const double& poa2)
+	{
+		m_ant[0].m_cache_poa.push_back(poa1);
+		m_ant[1].m_cache_poa.push_back(poa2);
+	}
 };
 
 struct visit_site_status:visitor<std::shared_ptr<site>>

+ 6 - 3
card.cpp

@@ -21,6 +21,7 @@ extern config_file config;
 int three_rates_flag    = 0;
 int traffic_light_flag  = 0;
 int anti_coll_flag      = 0;
+int use_original_algo   = 0;
 
 static void request(uint64_t id,uint32_t hash_id,uint16_t dis)
 {
@@ -401,7 +402,7 @@ void card_list::on_message(zloop<task*>* loop, message_tdoa_locinfo& loc, bool i
 	const auto &c=card_list::instance()->get(cardid);
 	if(!c)
 	{
-		log_warn("[tdoa] 数据库中未定义该卡的信息,card_id=%d, card_type=%d, cardid:%lld",loc.m_card_msg.m_id,loc.m_card_msg.m_type, cardid);
+		log_warn("[tdoa] 数据库中未定义该卡的信息,card_id=%d, card_type=%d, cardid:%lld", loc.m_card_msg.m_id, loc.m_card_msg.m_type, cardid);
 		return;
 	}
     
@@ -414,10 +415,12 @@ void card_list::on_message(zloop<task*>* loop, message_pdoa_locinfo& loc, bool i
 	const auto &c = card_list::instance()->get(cardid);
 	if(!c)
 	{
-		log_warn("[pdoa] 数据库中未定义该卡的信息,card_id=%d, card_type=%d, cardid:%lld",loc.m_card_id,loc.m_card_type,cardid);
+		log_warn("[pdoa] 数据库中未定义该卡的信息,card_id=%d, card_type=%d, cardid:%lld", loc.m_card_id, loc.m_card_type, cardid);
 		return;
 	}
-    
+
+	// 是否使用原始定位算法,0为否,1为是
+	loc.m_sync_ct = use_original_algo;
     c->on_message(loop, loc, is_history);
 }
 

+ 1 - 0
card.h

@@ -8,6 +8,7 @@
 extern int three_rates_flag;
 extern int traffic_light_flag;
 extern int anti_coll_flag;
+extern int use_original_algo;
 
 struct card_list_visit:visitor<std::shared_ptr<card_location_base>>
 {

+ 27 - 13
card_base.cpp

@@ -50,6 +50,8 @@ 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);
+	// 呼救
 	if((m_help_bit & 1) && (st & STATUS_HELP))
 	{
 		//      1111111111
@@ -66,39 +68,43 @@ void card_location_base::do_status(int st)
 	{
 		//      00000000011111
 		//               ^
-
+		// 呼救开始
 		if((m_help_bit&0x3)==2)
 		{
-			log_warn("handle_m_help,card_id:%d\n",m_id);
+			//log_warn("[help-battery] handle_m_help, card_id=%d",m_id);
 			help_flag=true;
 		}
 
-		m_help_last_time=now;
+		m_help_last_time = now;
 		m_help_bit<<=1;
 		m_help_bit|=1;
+
+		log_info("[help-battery] begin help, card_id=%d, help_bit=%d, status=%d", m_id, m_help_bit, st);
 	}
 	else 
 	{
 		//      11111111100000
 		//                   ^
-		if(now-m_help_last_time>60)
+		// 呼救结束后持续1分钟                   
+		if(now - m_help_last_time > 60)
 		{
-			m_help_bit=0;
+			m_help_bit = 0;
+			log_info("[help-battery] end help, card_id=%d, help_bit=%d, status=%d", m_id, m_help_bit, st);
 		}
 	}
 
-	if(!help_flag)
+	/*if(!help_flag)
 	{
 		st = st & (0xFFFFFFFF ^ STATUS_HELP);
-	}
+	}*/
 
 	if((STATUS_POWER_LOWER_SERIOUS & st) != 0)
 	{
-		m_pwr_stat=STATUS_POWER_LOWER_SERIOUS;
+		m_pwr_stat = STATUS_POWER_LOWER_SERIOUS;
 	}
 	else
 	{
-		m_pwr_stat=0;
+		m_pwr_stat = 0;
 	}
 
     module_mgr::do_status((STATUS_CARD)st, m_id, m_type);
@@ -145,7 +151,16 @@ void card_location_base::on_location(const std::vector<point>&vp,const std::vect
         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);
+		
+		// 呼救128,正常0
 		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);
     }
 	else
@@ -225,15 +240,14 @@ void card_location_base::on_message(zloop<task*>* loop, message_pdoa_locinfo& lo
     if(!site_ptr){
         log_warn("[pdoa] 接收到分站的数据:site=%d, card=%d, ct=%d, 但是分站未定义", loc.m_site_id, m_id, loc.m_card_ct);
         return;
-    }
+    }	
+
+	site_ptr->m_loc_time = time(0);
 
     auto area_tool=get_area_tool();
 	area_tool->set_site(site_ptr);
 
-    // 此条件用于解决井下有的基站不能送出电量值时,会将卡的电量值按0输出,这种情况,默认卡的电量为初始值或之前值
-    //if(loc.m_batty_status > 0){
     m_battery_value = loc.m_batty_status;       // 电量值
-    //}
 
     handle_message(loc.m_card_ct, loc.m_batty_status);
     if(site_ptr->is_up_site()){

+ 0 - 2
card_person.cpp

@@ -235,11 +235,9 @@ void person::on_timer()
         cp.area_id = site_ptr->m_area_id;
     }
     cp.dept_id = m_deptid;
-    //cp.stat = m_battery_value;
 
     upt_card_pos(cp,pt);
 	log_info("on_timer here ...%d,%lld,%.2f,%.2f,%d,%d--%d,speed=%.2f",m_id,_time,pt.x,pt.y,cp.map_id,cp.area_info.size(),person::m_limit_detained_time,m_speed);
-    //int sid=0; if(auto st=m_area_tool->m_site)sid=st->m_area_id; m_his_location_card->push(_time,pt,sid,cp.map_id);
 
 	uint64_t _now = tool_time::now_to_ms();
 	uint64_t t    = _now>m_timeval?_now-m_timeval:m_timeval-_now;

+ 12 - 3
common.h

@@ -15,9 +15,16 @@
 enum READER_TYPE_ID
 {
     ///井上分站
-    READER_TYPE_ID_UP=1,
+    READER_TYPE_ID_UP	= 1,
     ///井下分站
-    READER_TYPE_ID_DOWN=2
+    READER_TYPE_ID_DOWN	= 2
+};
+
+enum DEVICE_TYPE{
+	UNKNOWN			= 0,	// 未知
+	LOCATE_SITE		= 1,	// 定位基站
+	LAMP			= 3,	// 红绿灯
+	WIRELESS_SITE	= 6,	// 无线通信基站
 };
 
 enum STA_TYPE
@@ -29,7 +36,7 @@ enum STA_TYPE
 enum STATUS_CARD
 {
 	STATUS_NORMAL=0,
-    STATUS_POWER_NOMARL = 1,
+    STATUS_POWER_NORMAL = 1,
     STATUS_POWER_LOWER_SERIOUS = 2, //电量极低
 	STATUS_OVER_SPEED=8,
 	STATUS_AREA_OVER_TIME=16,
@@ -147,6 +154,8 @@ enum EVENT_TYPE{
     ET_VEHICLE_NEAR_GEOFAULT=38,            // 靠近断层告警
 	ET_READER_LOCATION_REVERSAL=39,         // 掘进面天线反向告警
     ET_PERSON_VEHICLE_ANTI_COLLISION=41,    // 人车防碰撞
+	ET_READER_ANTENNA_PHASE_ABNORMAL=42,	// 天线相位差异常
+	ET_READER_LONG_TIME_NO_POSITION=43,		// 基站长时间无定位异常
     CARD_EVENT_COUNT_MAX
 };
 

+ 8 - 8
db/db_api/CDBCommon.h

@@ -56,14 +56,14 @@ namespace YADB
 	*/
 	struct _DB_CONN_SETTING_
 	{
-		unsigned int Port;//端口
-		int TimeOut;//连接数据库超时(单位:秒)
-		std::string Host;//数据库主机地址
-		std::string User;//用户名
-		std::string PWD;//密码
-		std::string DBName;//数据库名
-		std::string CharSet;//字符集
-		std::string stmtSQL;//预处理SQL
+		unsigned int Port;		//端口
+		int TimeOut;			//连接数据库超时(单位:秒)
+		std::string Host;		//数据库主机地址
+		std::string User;		//用户名
+		std::string PWD;		//密码
+		std::string DBName;		//数据库名
+		std::string CharSet;	//字符集
+		std::string stmtSQL;	//预处理SQL
 		_DB_CONN_SETTING_()
 		{
 			Port    = 3306;

+ 0 - 2
db/db_api/CDBConnPool.cpp

@@ -23,8 +23,6 @@ namespace YADB
 
 	CDBConnect * CDBConnPool::__CreateIdleConn( std::string& ConnErr, bool IsTemp )
 	{
-		//std::string ConnErr;
-
 		_DB_CONN_SETTING_ ConnSetting = static_cast< _DB_CONN_SETTING_ >(__Setting);
 		CDBConnect* pConn = new CDBConnect( IsTemp );
 		if ( !pConn->Connect( ConnSetting, ConnErr ) )

+ 0 - 1
db/db_api/CDBConnPool.h

@@ -10,7 +10,6 @@
 V 1.0.0
 
 * @author
-王益俊
 
 * @date
 创建时间:  2018-04-17\n

+ 1 - 1
db/db_api/CDBConnect.cpp

@@ -40,7 +40,7 @@ namespace YADB
 		}
 
 		//连接数据库
-		if ( !mysql_real_connect( __pConn, DBSetting.Host.c_str(), DBSetting.User.c_str(), DBSetting.PWD.c_str(), DBSetting.DBName.c_str(), DBSetting.Port, NULL, 0 ) )
+		if (!mysql_real_connect( __pConn, DBSetting.Host.c_str(), DBSetting.User.c_str(), DBSetting.PWD.c_str(), DBSetting.DBName.c_str(), DBSetting.Port, NULL, 0 ) )
 		{
 			Error = "Failed to connect database,";
 			Error += " LastError=";

+ 0 - 1
db/db_api/CDBConnect.h

@@ -6,7 +6,6 @@
 V 1.0.0
 
 * @author
-王益俊
 
 * @date
 创建时间:  2018-04-17\n

+ 0 - 1
db/db_api/CDBHelper.h

@@ -6,7 +6,6 @@
 V 1.0.0
 
 * @author
-王益俊
 
 * @date
 创建时间:  2018-04-19\n

+ 0 - 1
db/db_api/CDBResultSet.h

@@ -6,7 +6,6 @@
 V 1.0.0
 
 * @author
-王益俊
 
 * @date
 创建时间:  2018-04-18\n

+ 22 - 4
db/db_area.h

@@ -1,8 +1,26 @@
+/* db_area.h.  Generated from db_area.h.in by configure.  */
+/* db_area.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Name of package */
+#define PACKAGE "libyadb-a"
 
-namespace db_area
-{
-	
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "BUG-REPORT-ADDRESS"
 
-}
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libyadb.a"
 
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libyadb.a 1.0"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libyadb-a"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.0"
+
+/* Version number of package */
+#define VERSION "1.0"

+ 2 - 4
his_location.cpp

@@ -180,10 +180,9 @@ void location_card::push(uint64_t timestamp,const point & p,int32_t areaid,int32
         m_d.emplace(p,timestamp);
         return ;
     }
-    //log_info("his_location: 3333333333333333333333333");
-    if(!is_valid())
+    
+	if(!is_valid())
     {
-        //if(p==m_p)
         if(point::eq(p.x,m_p.x,0.2) && point::eq(p.y,m_p.y,0.2))
         {
             set(p,timestamp);
@@ -204,7 +203,6 @@ void location_card::push(uint64_t timestamp,const point & p,int32_t areaid,int32
         insert();
         return;
     }
-    //log_info("his_location: 44444444444444444444444444444444444");
     bool flag=false;
     int  iflag=0;
     //判断是否路径发生了变化

+ 1 - 0
main.cpp

@@ -46,6 +46,7 @@ struct Init_Setting
         three_rates_flag    = config.get("service.three_rates_flag", 0);
         traffic_light_flag  = config.get("service.traffic_light_flag", 0);
         anti_coll_flag      = config.get("service.anti_collision_flag", 0);
+		use_original_algo	= config.get("algo.use_original_algo", 0);
 
         YADB::_DB_POOL_SETTING_ DBSetting;
         DBSetting.Host = config.get("db.host","127.0.0.1");

+ 3 - 1
message.cpp

@@ -392,5 +392,7 @@ void message_pdoa_locinfo::load(zistream& is)
         m_poa[i] = (float)((((short)_poa)*1.0)/1000.0);
     }
 
-    logn_info(3,"[pdoa] card_type=%d, card_id=%d, ct=%d, status=%d, call_type=%d, rav=%d, acc=%d, tof=%llu, ant_id=%d, rssi=%d, poa1=%.2f, poa2=%.2f, poa3=%.2f", m_card_type, m_card_id, m_card_ct, m_batty_status, m_callinfo, m_rav, m_acc, m_tof, m_ant_id, m_rssi, m_poa[0], m_poa[1], m_poa[2]);
+	if(tof > 0){
+		logn_info(3,"[pdoa] card_type=%d, card_id=%d, ct=%d, status=%d, call_type=%d, rav=%d, acc=%d, tof=%llu, ant_id=%d, rssi=%d, poa1=%.2f, poa2=%.2f, poa3=%.2f", m_card_type, m_card_id, m_card_ct, m_batty_status, m_callinfo, m_rav, m_acc, m_tof, m_ant_id, m_rssi, m_poa[0], m_poa[1], m_poa[2]);
+	}
 }

+ 1 - 1
message.h

@@ -117,7 +117,7 @@ struct message_locinfo:task
 	int8_t  m_rav;				// 角速度
 	uint8_t  m_acc;				// 加速度
 	uint8_t  m_ant_id;			// 天线号
-	uint16_t m_sync_ct;			// 同步序列号 
+	uint16_t m_sync_ct;			// 同步序列号,对于pdoa应用,用来保存是否使用原始定位算法参数 
 	int16_t  m_rssi;			// 信号功率强度
 
     //优化协议

+ 6 - 1
module_service/module_mgr.cpp

@@ -87,6 +87,8 @@ void module_mgr::do_status(STATUS_CARD st, uint32_t card_id, int32_t type)
         return;
     }
 
+	log_info("[help-battery] card_id=%d, status=%d", card_id, st);
+
 	// 人员呼救
     if((STATUS_HELP & st) != 0)
     {
@@ -100,7 +102,9 @@ void module_mgr::do_status(STATUS_CARD st, uint32_t card_id, int32_t type)
         module_call::instance()->rev_from_card_resp(card_ptr);
     }
 	
+	log_info("[help-battery] event, card_id=%d, status=%d", card_id, st);
 	// 电量极低
+	// 0000 0010
     if((STATUS_POWER_LOWER_SERIOUS & st) != 0)
     {
         if(!card_ptr->get_event_flag(ET_CARD_LOW_POWER_SERIOUS))
@@ -111,7 +115,8 @@ void module_mgr::do_status(STATUS_CARD st, uint32_t card_id, int32_t type)
     }
 
 	// 电量正常
-    if((STATUS_POWER_NOMARL & st) != 0)
+	// 0000 0001
+    if((STATUS_POWER_NORMAL & st) != 0)
     {
         if(card_ptr->get_event_flag(ET_CARD_LOW_POWER_SERIOUS))
         {

+ 1 - 0
module_service/module_other_alarm.cpp

@@ -30,3 +30,4 @@ void module_other_alarm::power_normal(std::shared_ptr<card_location_base> card_p
     uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
     event_tool::instance()->handle_event(OT_CARD, ET_CARD_LOW_POWER_SERIOUS, id, 0, 0, false);
 }
+

+ 4 - 1
module_service/module_other_alarm.h

@@ -2,6 +2,7 @@
 #define MODULE_OTHER_ALARM_H
 #include "module_singleton_base.h"
 #include "card.h"
+#include "ant.h"
 
 class module_other_alarm:public singleton_base<module_other_alarm>
 {
@@ -12,7 +13,9 @@ private:
     }
 
 public:
-    static void power_lower_serious(std::shared_ptr<card_location_base> card_ptr);
+    // 电量低告警
+	static void power_lower_serious(std::shared_ptr<card_location_base> card_ptr);
+	// 电量正常
     static void power_normal(std::shared_ptr<card_location_base> card_ptr);
 };
 

+ 7 - 0
module_service/module_traffic_light_manager.h

@@ -15,6 +15,13 @@
 
 // 红绿灯管理
 struct traffic_light_manager{
+	private:
+		~traffic_light_manager()
+		{
+			stop();
+		}
+
+	public:
     static traffic_light_manager* instance();
 
     // 从数据库加载数据

+ 3 - 0
net-service.cpp

@@ -245,6 +245,9 @@ void net_service::on_message(const std::shared_ptr<client> &clt,const char*data,
                         if(m.m_poa[1] == 10.0 || dist < 0.0001 ){
                             continue;
                         }
+
+						site_ptr->push_poa(fabs(m.m_poa[0]), fabs(m.m_poa[1]));
+
                         m_loc_worker->request(t);
                     }
                 }

+ 4 - 2
sys_setting.cpp

@@ -49,6 +49,7 @@ bool CYaSetting::Init_sys_setting()
 			D_GetValue(m_sys_setting.rear_end_t,"rear_end_time",1,"")
 			D_GetValue(m_sys_setting.geofault_warn_dis,"geofault_warn",1,"")
             D_GetValue(m_sys_setting.light_group_count, "light_group_count", 1, "")
+			D_GetValue(m_sys_setting.site_no_position_time, "site_no_position_time", 60, "基站长时间无定位阈值(分钟数)");
 #undef D_GetValue
 
             if(strVal == "anti_collision"){
@@ -58,7 +59,7 @@ bool CYaSetting::Init_sys_setting()
                 m_sys_setting.init_anti_coll_value(val);
             }
         }
-        log_info("init_setting:rear_end_d:%f, rear_end_t:%ld, over_count_person:%u, over_count_vehicle:%u, over_time_person:%u, over_time_vehicle:%u, over_speed:%f, light_group_count:%d",
+        log_info("init_setting:rear_end_d:%f, rear_end_t:%ld, over_count_person:%u, over_count_vehicle:%u, over_time_person:%u, over_time_vehicle:%u, over_speed:%f, light_group_count:%d, site_no_position_time: %d",
                     m_sys_setting.rear_end_d,
                     m_sys_setting.rear_end_t,
 					m_sys_setting.over_count_person,
@@ -66,7 +67,8 @@ bool CYaSetting::Init_sys_setting()
                     m_sys_setting.over_time_person,
                     m_sys_setting.over_time_vehicle,
                     m_sys_setting.over_speed,
-                    m_sys_setting.light_group_count
+                    m_sys_setting.light_group_count,
+					m_sys_setting.site_no_position_time
                     );
 	}
 

+ 8 - 6
sys_setting.h

@@ -11,11 +11,11 @@
 // 系统设置,,读取DB.dat_setting
 struct  SSys_setting // system_limit_setting
 {
-	unsigned int over_count_person; // 井下人员超员
-	unsigned int over_count_vehicle; // 井下车辆超员
-	unsigned int over_time_person; // 井下人员超时
-	unsigned int over_time_vehicle; // 井下车辆超时
-	double over_speed; // 井下车辆超速
+	unsigned int over_count_person;		// 井下人员超员
+	unsigned int over_count_vehicle;	// 井下车辆超员
+	unsigned int over_time_person;		// 井下人员超时
+	unsigned int over_time_vehicle;		// 井下车辆超时
+	double over_speed;					// 井下车辆超速
 
 	// 考勤偏移时间
 	int att_starttime_offset_staff;
@@ -30,8 +30,9 @@ struct  SSys_setting // system_limit_setting
     std::string rav_disable;
     int light_group_count;
     // 人车防碰撞参数,三个档位
-    bool m_enable_anti_coll;    // 功能使能
+    bool m_enable_anti_coll;			// 功能使能
     std::map<int, float> mp_anti_collision;
+	int site_no_position_time;			// 基站长时间无定位阈值
 
     SSys_setting()
     {
@@ -64,6 +65,7 @@ struct  SSys_setting // system_limit_setting
         light_group_count = 1;
         m_enable_anti_coll = false;
         mp_anti_collision.erase(mp_anti_collision.begin(), mp_anti_collision.end());
+		site_no_position_time = 60;	// 默认60分钟
     }
 
     void init_anti_coll_value(const std::string& ctx)

+ 5 - 2
websocket/wsTimerThread.cpp

@@ -133,7 +133,8 @@ namespace sys
         //log_info("[light_info] light_state's size=%d, copy=%d", light_state_list.size(), lights.size());
         std::string json_light = __jsBuilder.build_traffic_light(lights);
         swsClientMgr.send(JSON_CMD_VALUE_PUSH, json_light);
-        light_state_list.erase(light_state_list.begin(), light_state_list.end());
+        light_state_list.clear();
+		light_state_list.resize(0);
     }
 
 	void wsTimerThread::send_device_state()
@@ -145,7 +146,9 @@ namespace sys
 		std::vector<device_state> ds = device_state_list;
 		std::string json_device = __jsBuilder.build_device_state(ds);
 		swsClientMgr.send(JSON_CMD_VALUE_PUSH, json_device);
-		device_state_list.erase(device_state_list.begin(), device_state_list.end());
+		//device_state_list.erase(device_state_list.begin(), device_state_list.end());
+		device_state_list.clear();
+		device_state_list.resize(0);
 	}
 
     /*