1
0

module_mgr.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. log_info("[help-battery] card_id=%d, status=%d", card_id, st);
  83. // 人员呼救
  84. if((STATUS_HELP & st) != 0)
  85. {
  86. // STATUS_HELP 0x80
  87. module_call_help::instance()->rev_from_card_help(card_ptr);
  88. }
  89. // 人员呼叫
  90. if((STATUS_CALL & st) != 0)
  91. {
  92. module_call::instance()->rev_from_card_resp(card_ptr);
  93. }
  94. log_info("[help-battery] event, card_id=%d, status=%d", card_id, st);
  95. // 电量极低
  96. // 0000 0010
  97. if((STATUS_POWER_LOWER_SERIOUS & st) != 0)
  98. {
  99. if(!card_ptr->get_event_flag(ET_CARD_LOW_POWER_SERIOUS))
  100. {
  101. card_ptr->set_event_flag(ET_CARD_LOW_POWER_SERIOUS);
  102. module_other_alarm::power_lower_serious(card_ptr);
  103. }
  104. }
  105. // 电量正常
  106. // 0000 0001
  107. if((STATUS_POWER_NORMAL & st) != 0)
  108. {
  109. if(card_ptr->get_event_flag(ET_CARD_LOW_POWER_SERIOUS))
  110. {
  111. card_ptr->set_event_flag(ET_CARD_LOW_POWER_SERIOUS, 0);
  112. module_other_alarm::power_normal(card_ptr);
  113. }
  114. }
  115. }