module_mgr.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. /**
  14. * @brief 注册web回调函数,读配置文件,启动向web发送线程
  15. */
  16. void module_mgr::init(config_file& config, std::map<std::string, YA::MSG_HANDLE_FUNC_TYPE>& MsgFuncList)
  17. {
  18. module_web::instance()->init(config, MsgFuncList);
  19. module_call::instance()->init(config);
  20. area_business_motionless_persion::init(config);
  21. area_business_geofault::init(config);
  22. }
  23. /**
  24. * @brief 启动线程start:向web发送事件
  25. */
  26. void module_mgr::start()
  27. {
  28. area_business_geofault::init_geofault_from_db();
  29. area_business_speed_checker::init_vehicle_category_from_db();
  30. //area_business_car_attendance::init_attendance_area_from_db();
  31. module_web::instance()->start();
  32. module_call::instance()->start();
  33. //module_motionless_persion::instance()->start();
  34. }
  35. /**
  36. * @brief 结束线程stop
  37. */
  38. void module_mgr::stop()
  39. {
  40. module_web::instance()->stop();
  41. module_call::instance()->stop();
  42. //module_motionless_persion::instance()->stop();
  43. }
  44. void module_mgr::do_status(STATUS_CARD st, uint32_t card_id, int32_t type)
  45. {
  46. auto card_ptr=card_list::instance()->get(tool_other::type_id_to_u64(type, card_id));
  47. if(!card_ptr)
  48. {
  49. log_error("卡不存在card_id=%d", card_id);
  50. return;
  51. }
  52. if(STATUS_HELP == st)
  53. {
  54. module_call_help::instance()->rev_from_card_help(card_ptr);
  55. }
  56. if(STATUS_CALL == st)
  57. {
  58. module_call::instance()->rev_from_card_resp(card_ptr);
  59. }
  60. if(STATUS_POWER_LOWER_SERIOUS == st)
  61. {
  62. module_other_alarm::power_lower_serious(card_ptr);
  63. }
  64. if(STATUS_POWER_NOMARL == st)
  65. {
  66. module_other_alarm::power_nomarl(card_ptr);
  67. }
  68. }