Pārlūkot izejas kodu

Merge branch 'master' of http://local.beijingyongan.com:3000/linux-dev/ya-serv

daiyueteng 6 gadi atpakaļ
vecāks
revīzija
c5f31a134e
5 mainītis faili ar 62 papildinājumiem un 4 dzēšanām
  1. 35 0
      ant.cpp
  2. 17 0
      ant.h
  3. 2 0
      area_business.cpp
  4. 7 4
      net-service.cpp
  5. 1 0
      net-service.h

+ 35 - 0
ant.cpp

@@ -19,10 +19,12 @@ site::site(int id)
 {
 	m_time=time(0);
 }
+
 const algo_config&site::config()const
 {
 	return g_config[index()];
 }
+
 bool visit_site_status::visit(std::shared_ptr<site> s)
 {
 	time_t now = time(0);
@@ -57,6 +59,7 @@ bool visit_site_status::visit(std::shared_ptr<site> s)
 	}
 	return true;
 }
+
 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";
@@ -353,6 +356,38 @@ void sit_list::read_sit_list(int id)
         }
     }
 }
+
+
+/*
+
+   处理分站供电状态,交流供电时,ac_down=false,直流供电时,ac_down=true
+
+   目前只有大分站实现了这个功能,并且井下安装时是否接入了该电信号也不确定
+   ,所以需要有张表定义某个ID是否需要告警
+
+ */
+void site::on_power_status(bool ac_down)//电源状态
+{
+	if(!m_power_check_enable)
+		return;
+	
+	if(ac_down == m_power_ac_down)
+		return;
+	
+	if(m_power_ac_down=ac_down)
+	{
+		//掉电告警
+	
+	
+	}
+	else
+	{
+		//撤销警告
+	
+	
+	}
+}
+
 #if 0
 void sit_list::init_site()
 {

+ 17 - 0
ant.h

@@ -127,9 +127,13 @@ struct site:point,std::enable_shared_from_this<site>
     /// 指定分站定位类型:一维定位,二维定位,三维定位
     int m_dimension=0;
     std::shared_ptr<client> m_clt=nullptr;
+
+
 	time_t m_time;
 
     site(int id=-1);
+
+
     int index()const;
     const algo_config&config()const;
     int id()const
@@ -313,6 +317,19 @@ struct site:point,std::enable_shared_from_this<site>
         m_ant[0].m_path.clear();
         m_ant[1].m_path.clear();
     }
+
+	bool m_power_check_enable=false;//该分站是否启用交流掉电检测功能
+	bool m_power_ac_down=false;//交流电供电状态
+/*
+
+	处理分站供电状态,交流供电时,ac_down=false,直流供电时,ac_down=true
+
+	目前只有大分站实现了这个功能,并且井下安装时是否接入了该电信号也不确定
+	,所以需要有张表定义某个ID是否需要告警
+
+*/
+
+	void on_power_status(bool ac_down);//电源状态
 };
 struct visit_site_status:visitor<std::shared_ptr<site>>
 {

+ 2 - 0
area_business.cpp

@@ -52,6 +52,8 @@ struct area_business_factory
 			if((business_type&1)==0)
 				continue;
 
+			business_type >>= 1;
+
 			check_list.push_back(m_check_list[i].get());
 		}
 

+ 7 - 4
net-service.cpp

@@ -35,9 +35,10 @@ void net_service::on_timer()
 	sit_list::instance()->accept(vss);
 	mine_business::inst()->run_business();
 }
+
 void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t len)
 {
-	logn_bin(1,"",data,len);//输出二进制日志
+	logn_bin(1,clt->name().c_str(),data,len);//输出二进制日志
 
 	zistream is(data,len-2);
 	uint16_t cmd;
@@ -47,7 +48,8 @@ void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t
 		case 0x843b://tof
 			{
 				uint32_t site_id;
-				is>>site_id>>skip(12);
+				uint8_t  power;
+				is>>site_id>>skip(11)>>power;
                 auto site_ptr = sit_list::instance()->get(static_cast<int32_t>(site_id));
                 if(!site_ptr)
                 {
@@ -55,6 +57,7 @@ void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t
                     break;
                 }
                 site_ptr->set_client(clt);
+                site_ptr->on_power_status((power&1)==0);
 
 				struct timeval tv;
 				gettimeofday(&tv,NULL);
@@ -66,7 +69,7 @@ void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t
 					index++;
 					task*t=task::alloc<message_locinfo>();
 					message_locinfo&m=t->body<message_locinfo>();
-					m.load(is,cmd==0x863b);
+					m.load(is,false);
 					m.m_time_stamp=tstamp;
 					m.m_site_id=site_id;
 
@@ -86,7 +89,7 @@ void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t
 				{
 					task*t=task::alloc<message_locinfo>();
 					message_locinfo&m=t->body<message_locinfo>();
-					m.load(is,cmd==0x863b);
+					m.load(is,true);
 					m.m_site_id=site_id;
 					t->m_cmd_code=cmd;
 					t->m_hash_id=m.m_card_id;

+ 1 - 0
net-service.h

@@ -20,3 +20,4 @@ struct net_service:service_callback
 
 #endif
 
+