1
0

module_mgr.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #include "module_mgr.h"
  2. #include "module_web.h"
  3. #include "module_call_help.h"
  4. #include "module_call.h"
  5. #include "area_business_speed_checker.h"
  6. #include "module_other_alarm.h"
  7. #include "area_business_car_attendance.h"
  8. #include "area_business_motionless_persion.h"
  9. #include "area_business_geofault.h"
  10. #include "log.h"
  11. #include "common_tool.h"
  12. #include "config_file.h"
  13. #include "module_screen.h"
  14. /**
  15. * @brief 注册web回调函数,读配置文件,启动向web发送线程
  16. * @param config_file& config
  17. * @param std::map<std::string, sys::MSG_HANDLE_FUNC_TYPE>& MsgFuncList
  18. * @return
  19. * @note
  20. * @warning
  21. * @bug
  22. */
  23. void module_mgr::init(config_file& config, std::map<std::string, sys::MSG_HANDLE_FUNC_TYPE>& MsgFuncList)
  24. {
  25. module_web::instance()->init(config, MsgFuncList);
  26. module_call::instance()->init(config);
  27. area_business_motionless_persion::init(config);
  28. area_business_geofault::init(config);
  29. module_screen::instance()->start();
  30. }
  31. /*
  32. * @brief 启动线程start:向web发送事件
  33. * @param
  34. * @return
  35. * @note
  36. * @warning
  37. * @bug
  38. * */
  39. void module_mgr::start()
  40. {
  41. area_business_geofault::init_geofault_from_db();
  42. area_business_car_attendance::init_attendance_area_from_db();
  43. module_web::instance()->start();
  44. module_call::instance()->start();
  45. //module_motionless_persion::instance()->start();
  46. }
  47. /*
  48. * @brief 结束线程stop
  49. * @param
  50. * @return
  51. * @note
  52. * @warning
  53. * @bug
  54. * */
  55. void module_mgr::stop()
  56. {
  57. module_web::instance()->stop();
  58. module_call::instance()->stop();
  59. //module_motionless_persion::instance()->stop();
  60. module_screen::instance()->stop();
  61. }
  62. /*
  63. * @brief 1.电量告警逻辑处理
  64. * 2.呼叫呼救状态检查
  65. *
  66. * @param STATUS_CARD st
  67. * @param uint32_t card_id
  68. * @param int32_t type
  69. * @return
  70. * @note
  71. * @warning
  72. * @bug
  73. * */
  74. void module_mgr::do_status(STATUS_CARD st, uint32_t card_id, int32_t type)
  75. {
  76. auto card_ptr=card_list::instance()->get(tool_other::type_id_to_u64(type, card_id));
  77. if(!card_ptr)
  78. {
  79. log_error("卡不存在card_id=%d", card_id);
  80. return;
  81. }
  82. if((STATUS_HELP & st) != 0)
  83. {
  84. module_call_help::instance()->rev_from_card_help(card_ptr);
  85. }
  86. if((STATUS_CALL & st) != 0)
  87. {
  88. module_call::instance()->rev_from_card_resp(card_ptr);
  89. }
  90. if((STATUS_POWER_LOWER_SERIOUS & st) != 0)
  91. {
  92. if(!card_ptr->get_event_flag(ET_CARD_LOW_POWER_SERIOUS))
  93. {
  94. card_ptr->set_event_flag(ET_CARD_LOW_POWER_SERIOUS);
  95. module_other_alarm::power_lower_serious(card_ptr);
  96. }
  97. }
  98. if((STATUS_POWER_NOMARL & st) != 0)
  99. {
  100. if(card_ptr->get_event_flag(ET_CARD_LOW_POWER_SERIOUS))
  101. {
  102. card_ptr->set_event_flag(ET_CARD_LOW_POWER_SERIOUS, 0);
  103. module_other_alarm::power_normal(card_ptr);
  104. }
  105. }
  106. }