|
@@ -0,0 +1,81 @@
|
|
|
+#include "sys_setting.h"
|
|
|
+#include "db/db_api/CDBSingletonDefine.h"
|
|
|
+#include "log.h"
|
|
|
+#include <config_file.h>
|
|
|
+
|
|
|
+extern config_file config;
|
|
|
+SSys_setting CYaSetting::m_sys_setting;
|
|
|
+service_position_ptr ios_service::m_ios_service;
|
|
|
+
|
|
|
+/*
|
|
|
+* 从数据库的dat_setting表初始化系统阈值,
|
|
|
+* 包括:井下人员阈值,井下车辆阈值,人员超时阈值,车辆超时阈值,车辆超速阈值
|
|
|
+*/
|
|
|
+bool CYaSetting::Init_sys_setting()
|
|
|
+{
|
|
|
+ {
|
|
|
+ m_sys_setting.rav_disable=config.get("service.rav_disable","");
|
|
|
+ log_info("rav_disable:%s",m_sys_setting.rav_disable.c_str());
|
|
|
+ }
|
|
|
+ std::string Error;
|
|
|
+ YADB::CDBResultSet DBRes;
|
|
|
+ std::string sql = "select setting_id, name, type, value from dat_setting;";
|
|
|
+ sDBConnPool.Query(sql.c_str(),DBRes,Error);
|
|
|
+ int nCount = DBRes.GetRecordCount( Error );
|
|
|
+ if (nCount > 0)
|
|
|
+ {
|
|
|
+ while ( DBRes.GetNextRecod(Error) )
|
|
|
+ {
|
|
|
+ std::string strVal = "";
|
|
|
+ std::string val="";
|
|
|
+ DBRes.GetField("name",strVal, Error );
|
|
|
+#define D_GetValue(K,N,X,PS) \
|
|
|
+ if(strVal==N)\
|
|
|
+ {DBRes.GetField("value",val, Error);\
|
|
|
+ log_info("init_setting:%s,%s",N,val.c_str());\
|
|
|
+ K = atoi(val.c_str())*X;}\
|
|
|
+
|
|
|
+ D_GetValue(m_sys_setting.over_count_person,"over_count_person",1,"人员井下超员")
|
|
|
+ D_GetValue(m_sys_setting.over_count_vehicle,"over_count_vehicle",1,"车辆井下超员")
|
|
|
+ D_GetValue(m_sys_setting.over_time_person,"over_time_person",60,"人员井下超时")
|
|
|
+ D_GetValue(m_sys_setting.over_time_vehicle,"over_time_vehicle",60,"车辆井下超时")
|
|
|
+ D_GetValue(m_sys_setting.over_speed,"over_speed",1,"车辆超速限值")
|
|
|
+ D_GetValue(m_sys_setting.att_starttime_offset_staff,"att_starttime_offset_staff",60,"考勤开始时间向前偏移分钟数")
|
|
|
+ D_GetValue(m_sys_setting.att_endtime_offset_staff,"att_endtime_offset_staff",60,"车辆考勤开始时间向前偏移分钟数")
|
|
|
+ D_GetValue(m_sys_setting.att_starttime_offset_vehicle,"att_starttime_offset_vehicle",60,"车辆考勤结束时间向后偏移分钟数")
|
|
|
+ D_GetValue(m_sys_setting.att_endtime_offset_vehicle,"att_endtime_offset_vehicle",60,"车辆考勤结束时间向后偏移分钟数")
|
|
|
+ D_GetValue(m_sys_setting.att_person_thre_hour,"att_person_thre_hour",60*60,"")
|
|
|
+ D_GetValue(m_sys_setting.rear_end_d,"rear_end_distance",1,"")
|
|
|
+ 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, "")
|
|
|
+#undef D_GetValue
|
|
|
+
|
|
|
+ if(strVal == "anti_collision"){
|
|
|
+ val = "";
|
|
|
+ DBRes.GetField("value", val, Error);
|
|
|
+ log_info("init_setting: anti_collision:%s", val.c_str());
|
|
|
+ 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",
|
|
|
+ m_sys_setting.rear_end_d,
|
|
|
+ m_sys_setting.rear_end_t,
|
|
|
+ m_sys_setting.over_count_person,
|
|
|
+ m_sys_setting.over_count_vehicle,
|
|
|
+ m_sys_setting.over_time_person,
|
|
|
+ m_sys_setting.over_time_vehicle,
|
|
|
+ m_sys_setting.over_speed,
|
|
|
+ m_sys_setting.light_group_count
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+void ios_service::start_service_position(const int& port)
|
|
|
+{
|
|
|
+ m_ios_service = service_position_ptr(new service_position_ptr::element_type());
|
|
|
+ m_ios_service->set_port(port);
|
|
|
+ m_ios_service->start();
|
|
|
+}
|