Browse Source

下发分站时间

zzj 5 years ago
parent
commit
0976ee21d2
3 changed files with 46 additions and 5 deletions
  1. 32 1
      card_path.cpp
  2. 2 0
      net-service.cpp
  3. 12 4
      znet.cpp

+ 32 - 1
card_path.cpp

@@ -14,7 +14,6 @@
 #include "card_path.h"
 #include "visit.h"
 
-extern config_file config;
 namespace{
 
 static const double PI=3.1416;
@@ -259,6 +258,35 @@ struct handle_path :visitor<std::shared_ptr<site>>
 };
 static std::vector<base_path> init_path(std::vector<base_path> & ret,vertex_list&v)
 {
+	do
+	{
+		config_file cfg;
+		if(cfg.open("../etc/path-not-cross.ini"))
+			break;
+
+		auto kset=cfg.keys();
+		if(kset.empty())
+			break;
+
+		for(auto k:kset)
+		{
+			if(strncmp(k,"add_path",8)!=0)
+				continue;
+
+			const char* vv=cfg.get(k,"");
+
+			point p0;
+			point p1;
+			if(sscanf(vv,"%lf,%lf,%lf,%lf",&p0.x,&p0.y,&p1.x,&p1.y)==4)
+			{
+				int p00=v.add(p0,0,999);
+				int p10=v.add(p1,0,999);
+
+				ret.push_back(base_path(p00,p10));
+			}
+		}
+		break;
+	}while(1);
 
 #ifdef __DEBUG__
 	log_path(ret,v);
@@ -355,6 +383,9 @@ static std::vector<base_path> init_path(std::vector<base_path> & ret,vertex_list
 
 		for(auto k:kset)
 		{
+			if(strncmp(k,"pt",2)!=0)
+				continue;
+
 			const char* v=cfg.get(k,"");
 
 			point tmp;

+ 2 - 0
net-service.cpp

@@ -77,11 +77,13 @@ void net_service::on_message(const std::shared_ptr<client> &clt,const char*data,
 						logn_error(1,"分站[%d]天线异常", site_id);
                         break;
                     }
+#if 1
 					if(!site_ptr->check_timestamp(data+10))
 					{
 						logn_error(1,"分站数据时间戳错误:%s",clt->name().c_str());
 						break;
 					}
+#endif
 
 					{
 						char timebuf[64]{0};

+ 12 - 4
znet.cpp

@@ -23,9 +23,6 @@
 #include "crc.h"
 
 extern config_file config;
-static int recv_timeout_first=config.get("service.recv_timeout_first",10);
-static int site_sync_freq=config.get("site_sync.freq",60);//分站时间同步间隔
-static int site_sync=config.get("site_sync",0);//分站时间同步,考虑到双IP双机情况,缺省关闭
 struct client_ex:client
 {
 	virtual void on_notify()=0;
@@ -219,11 +216,20 @@ struct sock_client:fd_io,client_ex
 
 //		m_recv_timer.set(ic);
 		m_recv_timer.set<sock_client,&sock_client::on_recv_timeout>(this);
+		int recv_timeout_first=config.get("service.recv_timeout_first",10);
+
+
 		m_recv_timer.start(recv_timeout_first,0);
 
+		int site_sync=config.get("site_sync",0);//分站时间同步,考虑到双IP双机情况,缺省关闭
+		int site_sync_freq=config.get("site_sync.freq",10*60);//分站时间同步间隔
+
 		m_sync_timer.set<sock_client,&sock_client::on_sync_timeout>(this);
+
+		log_info("检测同步定时器:%s,%d",name,site_sync_freq);
 		if(site_sync)
 		{
+			log_info("启动分站同步定时器:%s,%d",name,site_sync_freq);
 			m_sync_timer.start(0,site_sync_freq);
 		}
 
@@ -289,6 +295,8 @@ struct sock_client:fd_io,client_ex
 	void on_sync_timeout()
 	{
 //	从第一个字节开始,分别表示毫秒(2字节)、秒、分、时、天、月、年
+
+		log_info("分站同步:%s",m_name.c_str());
 		char buf[14]={0,12,0x78,0x3b};
 
 		struct timeval tv;
@@ -307,7 +315,7 @@ struct sock_client:fd_io,client_ex
 		buf[p++]=t->tm_hour;
 		buf[p++]=t->tm_mday;
 		buf[p++]=t->tm_mon;
-		buf[p++]=t->tm_year;
+		buf[p++]=t->tm_year-100;
 
 		uint16_t ccrc=do_crc((unsigned char*)buf+2,10);