lixioayao 6 rokov pred
rodič
commit
8dd720e30c
8 zmenil súbory, kde vykonal 100 pridanie a 50 odobranie
  1. 1 1
      Makefile
  2. 1 1
      Makefile.am
  3. 1 1
      Makefile.in
  4. 19 19
      autom4te.cache/requests
  5. 54 19
      card.cpp
  6. 3 1
      card.h
  7. 17 7
      main.cpp
  8. 4 1
      message.cpp

+ 1 - 1
Makefile

@@ -254,7 +254,7 @@ message_file.h message.h net-service.cpp net-service.h point.cpp point.h tdoa_sy
 worker.cpp worker.h zio.h zloop.h znet.cpp znet.h zstream.h site_area.cpp  site_area.h area.h area.cpp
 
 AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
-AM_LDFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
+AM_LDFLAGS = -fno-stack-protector -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
 yals_SOURCES = ${AM_SOURCES} main.cpp 
 yals_CPPFLAGS = ${AM_CPPFLAGS} 
 yals_LDFLAGS = ${AM_LDFLAGS}  -lzlog -lrt -lboost_chrono -lboost_system -lboost_thread -lmysqlclient -lthree_rates

+ 1 - 1
Makefile.am

@@ -12,7 +12,7 @@ message_file.h message.h net-service.cpp net-service.h point.cpp point.h tdoa_sy
 worker.cpp worker.h zio.h zloop.h znet.cpp znet.h zstream.h site_area.cpp  site_area.h area.h area.cpp
 
 AM_CPPFLAGS=-Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
-AM_LDFLAGS= -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
+AM_LDFLAGS= -fno-stack-protector -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
 
 yals_SOURCES=${AM_SOURCES} main.cpp 
 yals_CPPFLAGS=${AM_CPPFLAGS} 

+ 1 - 1
Makefile.in

@@ -254,7 +254,7 @@ message_file.h message.h net-service.cpp net-service.h point.cpp point.h tdoa_sy
 worker.cpp worker.h zio.h zloop.h znet.cpp znet.h zstream.h site_area.cpp  site_area.h area.h area.cpp
 
 AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
-AM_LDFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
+AM_LDFLAGS = -fno-stack-protector -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
 yals_SOURCES = ${AM_SOURCES} main.cpp 
 yals_CPPFLAGS = ${AM_CPPFLAGS} 
 yals_LDFLAGS = ${AM_LDFLAGS}  -lzlog -lrt -lboost_chrono -lboost_system -lboost_thread -lmysqlclient -lthree_rates

+ 19 - 19
autom4te.cache/requests

@@ -81,58 +81,58 @@
                         'configure.ac'
                       ],
                       {
-                        'AM_PROG_F77_C_O' => 1,
                         '_LT_AC_TAGCONFIG' => 1,
-                        'm4_pattern_forbid' => 1,
+                        'AM_PROG_F77_C_O' => 1,
                         'AC_INIT' => 1,
-                        '_AM_COND_IF' => 1,
+                        'm4_pattern_forbid' => 1,
                         'AC_CANONICAL_TARGET' => 1,
-                        'AC_SUBST' => 1,
+                        '_AM_COND_IF' => 1,
                         'AC_CONFIG_LIBOBJ_DIR' => 1,
-                        'AC_FC_SRCEXT' => 1,
+                        'AC_SUBST' => 1,
                         'AC_CANONICAL_HOST' => 1,
+                        'AC_FC_SRCEXT' => 1,
                         'AC_PROG_LIBTOOL' => 1,
                         'AM_PROG_MKDIR_P' => 1,
                         'AM_INIT_AUTOMAKE' => 1,
-                        'AM_PATH_GUILE' => 1,
                         'AC_CONFIG_SUBDIRS' => 1,
+                        'AM_PATH_GUILE' => 1,
                         'AM_AUTOMAKE_VERSION' => 1,
                         'LT_CONFIG_LTDL_DIR' => 1,
-                        'AC_CONFIG_LINKS' => 1,
                         'AC_REQUIRE_AUX_FILE' => 1,
-                        'm4_sinclude' => 1,
+                        'AC_CONFIG_LINKS' => 1,
                         'LT_SUPPORTED_TAG' => 1,
+                        'm4_sinclude' => 1,
                         'AM_MAINTAINER_MODE' => 1,
                         'AM_NLS' => 1,
                         'AC_FC_PP_DEFINE' => 1,
                         'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
-                        'AM_MAKEFILE_INCLUDE' => 1,
                         '_m4_warn' => 1,
+                        'AM_MAKEFILE_INCLUDE' => 1,
                         'AM_PROG_CXX_C_O' => 1,
-                        '_AM_MAKEFILE_INCLUDE' => 1,
                         '_AM_COND_ENDIF' => 1,
+                        '_AM_MAKEFILE_INCLUDE' => 1,
                         'AM_ENABLE_MULTILIB' => 1,
                         'AM_PROG_MOC' => 1,
                         'AM_SILENT_RULES' => 1,
                         'AC_CONFIG_FILES' => 1,
-                        'LT_INIT' => 1,
                         'include' => 1,
-                        'AM_GNU_GETTEXT' => 1,
+                        'LT_INIT' => 1,
                         'AM_PROG_AR' => 1,
+                        'AM_GNU_GETTEXT' => 1,
                         'AC_LIBSOURCE' => 1,
-                        'AM_PROG_FC_C_O' => 1,
                         'AC_CANONICAL_BUILD' => 1,
+                        'AM_PROG_FC_C_O' => 1,
                         'AC_FC_FREEFORM' => 1,
-                        'AH_OUTPUT' => 1,
                         'AC_FC_PP_SRCEXT' => 1,
-                        'AC_CONFIG_AUX_DIR' => 1,
+                        'AH_OUTPUT' => 1,
                         '_AM_SUBST_NOTMAKE' => 1,
-                        'm4_pattern_allow' => 1,
-                        'sinclude' => 1,
+                        'AC_CONFIG_AUX_DIR' => 1,
                         'AM_PROG_CC_C_O' => 1,
-                        'AM_XGETTEXT_OPTION' => 1,
-                        'AC_CANONICAL_SYSTEM' => 1,
+                        'sinclude' => 1,
+                        'm4_pattern_allow' => 1,
                         'AM_CONDITIONAL' => 1,
+                        'AC_CANONICAL_SYSTEM' => 1,
+                        'AM_XGETTEXT_OPTION' => 1,
                         'AC_CONFIG_HEADERS' => 1,
                         'AC_DEFINE_TRACE_LITERAL' => 1,
                         'AM_POT_TOOLS' => 1,

+ 54 - 19
card.cpp

@@ -203,8 +203,10 @@ struct card_area
 struct person:card_location_base, card_area
 {
 	std::weak_ptr<monkey_person> m_monkeyPerson;
-	person(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,int32_t level_id,uint32_t cid)
+	int m_workLine=0;
+	person(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,int32_t level_id,uint32_t cid,int wl)
         :card_location_base(type,cardid,needdisplay,t,deptid,level_id,cid)
+		 ,m_workLine(wl)
 	{
         m_message_handle.reset(new card_message_handle(this));
 		m_his_location_card.reset(new location_staff(m_id,m_type));
@@ -248,12 +250,11 @@ struct person:card_location_base, card_area
         return m_site_area;
     }
 
-	virtual void do_business(const point &pt)
+	virtual void do_business(const point &pt,double acc)
 	{
 		m_area_tool->on_point(m_id,pt,m_speed,m_type);
         m_site_area->on_point(m_id,0,this, m_type);
-		card_pos cp;
-		three_rates::get_instance()->put(cp);
+		handle_three_rates(pt);
 	}
 	void reset(std::shared_ptr<monkey_person> mp)
 	{
@@ -261,6 +262,17 @@ struct person:card_location_base, card_area
 	}
 	~person(){}
 private:
+	void handle_three_rates(const point & pt)
+	{
+		card_pos cp;
+		cp.work_line=m_workLine;
+		cp.biz_stat = get_stat();
+		cp.x=pt.x;cp.y=pt.y;cp.z=pt.z;	
+		const auto lm = m_area_tool->getLandmark();
+		cp.enter_time = std::get<0>(lm)*1000;
+		cp.area_id = std::get<3>(lm);
+		put_three_rates(cp);
+	}
 	void on_timer()
 	{    
 		if(!m_mine_tool->is_attendance())
@@ -314,6 +326,7 @@ struct car:card_location_base,card_area
 {
 	int m_vehicle_category_id=0;
     int m_vehicle_type_id=0;
+	double m_acc =0;
     car(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,
         int32_t categoryid, int type_id,int32_t level_id,uint32_t cid)
         :card_location_base(type,cardid,needdisplay,t,deptid,level_id,cid)
@@ -348,12 +361,13 @@ struct car:card_location_base,card_area
         return m_site_area;
     }
 
-	virtual void do_business(const point &pt)
+	virtual void do_business(const point &pt,double acc)
 	{
+		m_acc=acc;
 		m_area_tool->on_point(m_id,pt,m_speed,m_type);
         m_site_area->on_point(m_id,0,this, m_type);
-
         m_mine_tool->on_point(m_id, m_type, m_vehicle_category_id);
+		handle_three_rates(pt);
 	}
 
     int get_vehicle_type_id()
@@ -363,6 +377,18 @@ struct car:card_location_base,card_area
 
 	~car(){}
 private:
+	void handle_three_rates(const point &pt)
+	{
+		card_pos cp;
+		cp.biz_stat = get_stat();
+		cp.x=pt.x;cp.y=pt.y;cp.z=pt.z;	
+		const auto lm = m_area_tool->getLandmark();
+		cp.enter_time = std::get<0>(lm)*1000;
+		cp.area_id = std::get<3>(lm);
+		cp.map_id = std::get<2>(lm);
+		cp.vibration=m_acc;
+		put_three_rates(cp);
+	}
 	void on_timer()
 	{
 		make_package();
@@ -434,7 +460,7 @@ void card_list::init_staffer(int32_t id)
 {
     std::string strategy = config.get("person.strategy","person1");
     std::string sql = "SELECT staff_id, s.card_id, c.card_type_id, s.dept_id, s.group_id, s.occupation_id, \
-            ol.occupation_level_id,s.worktype_id,s.need_display \
+            ol.occupation_level_id,s.worktype_id,s.need_display,s.work_line\
             FROM dat_staff_extend s \
             LEFT JOIN dat_card c ON s.card_id = c.card_id \
             LEFT JOIN dat_occupation o ON s.occupation_id = o.occupation_id \
@@ -495,17 +521,19 @@ void card_list::init_staffer(int32_t id)
 
         int need_display = 0;
         DBRes.GetField( "need_display",need_display, Error );
-
+		
+        int work_line = 0;
+        DBRes.GetField( "work_line",work_line, Error );
         //for now;
         //staff_id = vsid;
 
         if(-1 == id)
         {
             std::shared_ptr<card_location_base> clb =
-                    std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id);
-            uint64_t cardid = getId(staff_id,type);
-            log_info("cardId:%llu,staff_id:%d dept_id:%d,need_display:%d--c-ard:%s",
-                     cardid,vsid,dept_id,need_display,card_id.c_str());
+                    std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id,work_line);
+            uint64_t cardid = getId(vsid,type);
+            log_info("cardId:%llu,id:%d dept_id:%d,need_display:%d,card:%s:work_line:%d,staff_id:%d,type:%d",
+                     cardid,vsid,dept_id,need_display,card_id.c_str(),work_line,staff_id,card_type_id);
             map.insert({cardid,clb});
         }
         else
@@ -524,7 +552,7 @@ void card_list::init_staffer(int32_t id)
             }
             else
             {
-                auto clb = std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id);
+                auto clb = std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id,work_line);
                 card_list::instance()->add(card_id64, clb);
             }
 
@@ -632,9 +660,9 @@ void card_list::init_vehicle(int32_t id)
         {
             auto clb = std::make_shared<car>(strategy,vsid,need_display,card_type_id,
                                              dept_id,vehicle_category_id, vehicle_type_id,vehicle_level_id,vehicle_id);
-            uint64_t cardid = getId(vehicle_id,type);
-            log_info("cardId:%llu,vehicle_id:%d dept_id:%d,need_display:%d---cardid:%s,categoryid:%d",
-                     cardid,vsid,dept_id,need_display,card_id.c_str(),vehicle_category_id);
+            uint64_t cardid = getId(vsid,type);
+            log_info("cardId:%llu,id:%d dept_id:%d,need_display:%d-cardid:%s,categoryid:%d,vchile_id:%d,type:%d",
+                     cardid,vsid,dept_id,need_display,card_id.c_str(),vehicle_category_id,vehicle_id,card_type_id);
             map.insert({cardid,clb});
         }
         else
@@ -1146,9 +1174,9 @@ void card_location_base::on_location(const std::vector<point>&vp,const std::vect
 		Msg m;
 		m.type=m_type;m.x=(int)x;m.y=(int)y;m.cmd=CMD_HANDLE;m.cardid=m_type<<32|m_id;
 		cardMgr::instance()->tryPut(m);
-
-		log_info("useful:card_id:%d,ct:%d,timestamp:%llu, loc_point,x:%.2f,y:%.2f ",m_id,m_ct,m_time,pt.x,pt.y);
-		do_business(pt);
+		double acc = lm[0].m_acc;
+		log_info("useful:card_id:%d,ct:%d,timestamp:%llu, loc_point,x:%.2f,y:%.2f acc:%.2f",m_id,m_ct,m_time,pt.x,pt.y,acc);
+		do_business(pt,acc);
 	}
 }
 
@@ -1221,6 +1249,13 @@ void  card_location_base::clear()
     //m_ct;				//ct
     m_time=0;			//时间戳
 }
+void card_location_base::put_three_rates(card_pos & cp)
+{
+	cp.rec_time=m_time;cp.type=m_type;cp.id=m_id;
+	cp.identifier_id=m_cid;cp.running_stat=m_stat;cp.final_v=m_speed;
+	log_info("three_rates:type:%d,id:%d,cid:%d",cp.type,cp.id,cp.identifier_id);
+	three_rates::get_instance()->put(cp);
+}
 card_location_base::~card_location_base()
 {
 }

+ 3 - 1
card.h

@@ -21,6 +21,7 @@ struct monkey_person;
 struct card_message_handle;
 struct mine_tool;
 struct location_card;
+struct card_pos;
 struct card:point
 {
 	card(uint32_t id,uint16_t dis,uint64_t type,int32_t deptid,int32_t level_id,uint32_t cid)
@@ -62,7 +63,7 @@ struct card_location_base:card
     card_location_base()=default;
     card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t,int32_t,int32_t,uint32_t );
 
-	virtual void do_business(const point &pt)=0;
+	virtual void do_business(const point &pt,double acc)=0;
 //	virtual void set(ev::dynamic_loop * loop)=0;
 	virtual void on_timer()=0;
 	virtual void site_hover(int sid)=0;
@@ -81,6 +82,7 @@ struct card_location_base:card
 	void upt_card_pos(YA::_CARD_POS_ &,const point &pt);
 	void del_card_pos();
 	int get_stat();
+	void put_three_rates(card_pos &);
     bool is_person() const
     {
         return CT_PERSON == m_type;

+ 17 - 7
main.cpp

@@ -19,7 +19,7 @@
 #include <config_file.h>
 #include "three_rates.h"
 config_file config;
-static void handlereader()
+static void handlereader(uint32_t readerid,bool duration,uint32_t t)
 {
 
 }
@@ -42,7 +42,7 @@ struct Init_Setting
         DBSetting.DBName = config.get("db.dbname","yaxt");
         DBSetting.CharSet = config.get("db.charset","utf8");
         DBSetting.TimeOut = config.get("db.conn_timeout",5);
-        DBSetting.PoolSize = config.get("db.conn_timeout",30);
+        DBSetting.PoolSize = config.get("db.pool_size",30);
         _mysql_init(DBSetting);
 
         sit_list::instance()->load_from_db();
@@ -66,9 +66,18 @@ struct Init_Setting
 
         card_list::instance()->load_his_card_postion_from_db();
         event_list::instance()->load_his_data_from_db();
-		init_three_rates(DBSetting);
+		db_para dp;	
+
+        dp.Host=DBSetting.Host;
+        dp.User=DBSetting.User;
+        dp.PWD=DBSetting.PWD ;
+        dp.DBName=DBSetting.DBName;
+        dp.CharSet=DBSetting.CharSet ;
+        dp.TimeOut=DBSetting.TimeOut;
+        dp.PoolSize=DBSetting.PoolSize;
+		init_three_rates(dp);
     }
-	void init_three_rates(const YADB::_DB_POOL_SETTING_& dbs)
+	void init_three_rates(const db_para& dbs)
 	{
 		std_info("three_rates ...................");
 		init_para ip;
@@ -79,7 +88,7 @@ struct Init_Setting
     void _mysql_init(YADB::_DB_POOL_SETTING_ &dps)
     {
         std::string Error;
-
+		//std::this_thread::sleep_for(std::chrono::seconds(2));
         //创建连接池
         if ( !sDBConnPool.Create( dps, Error ) )
         {
@@ -161,8 +170,6 @@ int main(int argc ,char * argv[])
         return 0;
     }
 
-    module_mgr::start();
-    atexit(&cleanup);
 
     log_init("../etc/log.ini");
     if(config.open("../etc/config.ini"))
@@ -173,6 +180,9 @@ int main(int argc ,char * argv[])
 	card_path::init();
 	test_find_path(point(4717,209.2),point(4727,206.4));
 
+    module_mgr::start();
+    atexit(&cleanup);
+
 
     net_service mh;
     int port=config.get("service.port",4000);

+ 4 - 1
message.cpp

@@ -31,7 +31,10 @@ void message_locinfo::load(zistream&is,bool tdoa)
 
 	//加速度
 	is>>b;
-	m_acc=((b&0x80)?-1.:1.)*(b&0x7f)*98;
+	if(m_card_type==4 || m_card_type==5)
+		m_acc=b;
+	else
+		m_acc=((b&0x80)?-1.:1.)*(b&0x7f)*98;
 
 	//TOF
 	is>>b>>i;