Kaynağa Gözat

修改 module_mgr

daiyueteng 6 yıl önce
ebeveyn
işleme
f8e8ad96ba
2 değiştirilmiş dosya ile 86 ekleme ve 95 silme
  1. 78 0
      module_service/module_mgr.cpp
  2. 8 95
      module_service/module_mgr.h

+ 78 - 0
module_service/module_mgr.cpp

@@ -0,0 +1,78 @@
+#include"module_mgr.h"
+
+
+#include"module_web.h"
+#include"module_call_help.h"
+#include"module_call.h"
+#include"module_over_speed_vehicle.h"
+#include"module_other_alarm.h"
+#include"module_attendance_vehicle.h"
+#include"module_motionless_persion.h"
+#include"module_geofault.h"
+#include"log.h"
+#include"common_tool.h"
+
+/**
+ * @brief 注册web回调函数,读配置文件,启动向web发送线程
+ */
+void module_mgr::init(config_file& config, std::map<std::string, YA::MSG_HANDLE_FUNC_TYPE>& MsgFuncList)
+{
+    module_web::instance()->init(config, MsgFuncList);
+    module_call::instance()->init(config);
+
+    module_motionless_persion::instance()->init(config);
+    module_geofault::instance()->init(config);
+}
+
+/**
+     * @brief 启动线程start:向web发送事件
+     */
+void module_mgr::start()
+{
+    module_geofault::instance()->init_geofault_from_db();
+    module_over_speed_vehicle::instance()->init_vehicle_category_from_db();
+    module_attendance_vehicle::instance()->init_attendance_area_from_db();
+
+    module_web::instance()->start();
+    module_call::instance()->start();
+    module_motionless_persion::instance()->start();
+}
+
+/**
+     * @brief 结束线程stop
+     */
+void module_mgr::stop()
+{
+    module_web::instance()->stop();
+    module_call::instance()->stop();
+    module_motionless_persion::instance()->stop();
+}
+
+void module_mgr::do_status(STATUS_CARD st, uint32_t card_id, int32_t type)
+{
+    auto card_ptr=card_list::instance()->get(tool_other::type_id_to_u64(type, card_id));
+    if(!card_ptr)
+    {
+        log_error("卡不存在card_id=%d", card_id);
+        return;
+    }
+
+    if(STATUS_HELP == st)
+    {
+        module_call_help::instance()->rev_from_card_help(card_ptr);
+    }
+    if(STATUS_CALL == st)
+    {
+        module_call::instance()->rev_from_card_resp(card_ptr);
+    }
+    if(STATUS_POWER_LOWER_SERIOUS == st)
+    {
+        module_other_alarm::power_lower_serious(card_ptr);
+    }
+    if(STATUS_POWER_NOMARL == st)
+    {
+        module_other_alarm::power_nomarl(card_ptr);
+    }
+}
+
+

+ 8 - 95
module_service/module_mgr.h

@@ -10,12 +10,10 @@
  * @date 2018-08-25
  */
 
-#include"module_web.h"
-#include"module_area.h"
-#include"module_call_help.h"
-#include"module_call.h"
-#include"module_over_speed_vehicle.h"
-#include"module_other_alarm.h"
+#include "module_singleton_base.h"
+#include "config_file.h"
+#include "websocket/wsClientMgr.h"
+#include "common.h"
 
 class module_mgr: public singleton_base<module_mgr>
 {
@@ -29,103 +27,18 @@ public:
     /**
      * @brief 注册web回调函数,读配置文件,启动向web发送线程
      */
-    static void init(config_file& config, std::map<std::string, YA::MSG_HANDLE_FUNC_TYPE>& MsgFuncList)
-    {
-        module_web::instance()->init(config, MsgFuncList);
-        module_call::instance()->init(config);
-    }
+    static void init(config_file& config, std::map<std::string, YA::MSG_HANDLE_FUNC_TYPE>& MsgFuncList);
 
     /**
      * @brief 启动线程start:向web发送事件
      */
-    static void start()
-    {
-        module_over_speed_vehicle::instance()->init_vehicle_category_from_db();
-        //init_attendance_from_db();
-        module_attendance_vehicle::instance()->init_attendance_area_from_db();
-
-        module_web::instance()->start();
-        module_call::instance()->start();
-    }
-
+    static void start();
     /**
      * @brief 结束线程stop
      */
-    static void stop()
-    {
-        module_web::instance()->stop();
-        module_call::instance()->stop();
-    }
-
-    static void do_status(STATUS_CARD st, uint32_t card_id, int32_t type)
-    {
-        auto card_ptr=card_list::instance()->get(tool_other::type_id_to_u64(type, card_id));
-        if(!card_ptr)
-        {
-            log_error("卡不存在card_id=%d", card_id);
-            return;
-        }
-
-        if(STATUS_HELP == st)
-        {
-            module_call_help::instance()->rev_from_card_help(card_ptr);
-        }
-        if(STATUS_CALL == st)
-        {
-            module_call::instance()->rev_from_card_resp(card_ptr);
-        }
-        if(STATUS_POWER_LOWER_SERIOUS == st)
-        {
-            module_other_alarm::power_lower_serious(card_ptr);
-        }
-        if(STATUS_POWER_NOMARL == st)
-        {
-            module_other_alarm::power_nomarl(card_ptr);
-        }
-    }
-
-//private:
-//    static void init_attendance_from_db()
-//    {
-//        const char *sql = "select card_id, start_time, end_time from rt_att_staff;";
-//        std::string Error;
-//        YADB::CDBResultSet DBRes;
-//        sDBConnPool.Query(sql,DBRes,Error);
-//        uint64_t nCount = DBRes.GetRecordCount( Error );
-//        if (nCount > 0)
-//        {
-//            log_info( "init_attendance. The record count=%d\n", nCount );
-
-//            while ( DBRes.GetNextRecod(Error) )
-//            {
-//                std::string card_id;
-//                DBRes.GetField( "card_id",card_id, Error );
-
-//                std::string end_time;
-//                DBRes.GetField( "end_time",end_time, Error );
-
-//                if(end_time.empty())
-//                {
-//                    uint32_t id = tool_other::id64_to_id(card_id);
-//                    int32_t type = tool_other::id64_to_type(card_id);
-
-//                    auto card_ptr = card_list::instance()->get(tool_other::type_id_to_u64(type, id));
-//                    if(card_ptr)
-//                    {
-//                        std::string start_time;
-//                        DBRes.GetField( "start_time",start_time, Error );
-
-//                        auto mine_tool_ptr = card_ptr->get_mine_tool();
+    static void stop();
 
-//                        mine_tool_ptr->m_attendance_start_time = tool_time::to_time_ex(start_time);
-//                        mine_tool_ptr->m_stat_attendance = AS_ATTENDANCE;
-//                        //std_debug("%s",
-//                        //   tool_time::to_str_ex(tool_time::to_ms(site_area_ptr->m_attendance_start_time)).c_str());
-//                    }
-//                }
-//            }
-//        }
-//    }
+    static void do_status(STATUS_CARD st, uint32_t card_id, int32_t type);
 };
 
 #endif // MODULE_MGR_H