MonitorObject.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #pragma once
  2. #include <string>
  3. #include <map>
  4. #include <list>
  5. #include <vector>
  6. #include <yyjson.h>
  7. class CDevice;
  8. struct ST_MOMP_INFO
  9. {
  10. uint8_t check = 0xaa;
  11. uint8_t binstall_1 = 0;
  12. uint8_t binstall_2 = 0;
  13. uint8_t binstall_3 = 0;
  14. string name1;
  15. string name1utf;
  16. string name2;
  17. string name2utf;
  18. string name3;
  19. string name3utf;
  20. string out_name;
  21. string in_name;
  22. string imei;
  23. uint8_t idx = -1;
  24. CDevice *pDeivce = nullptr;
  25. uint32_t zzjno = 0;
  26. string mo;
  27. string mp;
  28. string name; //名称
  29. public:
  30. //牵引点中间内存缓存数据
  31. //定位常态保持力值
  32. // int fix_const_retension_force = INT_MIN;
  33. //反位常态保持力值
  34. //int int invert_const_retension_force = INT_MIN;
  35. ~ST_MOMP_INFO(){
  36. check = 0x00;
  37. }
  38. };
  39. enum class DAOCHA_POSITION {
  40. MP_UNKNOWN = 0,
  41. MP_FIX,
  42. MP_INVERT,
  43. };
  44. class CMonitorObject
  45. {
  46. public:
  47. CMonitorObject();
  48. virtual ~CMonitorObject();
  49. public:
  50. std::string id;
  51. std::string name;
  52. std::string type;
  53. std::string up;
  54. std::list<CMonitorObject*> m_lstMo;
  55. //type = mo.mp 时 生效 设备(转辙机编号)
  56. uint16_t eqpno = 0; //牵引点以上节点没有no。牵引点有自身no, 牵引点再往下一层为采集类型码AcqTypeCode
  57. CMonitorObject* parent = nullptr;
  58. uint8_t check = 0xaa;
  59. };
  60. class CMonitorObjectMng
  61. {
  62. CMonitorObjectMng();
  63. virtual ~CMonitorObjectMng();
  64. public:
  65. static CMonitorObjectMng* Instance() { return &obj; };
  66. friend class CResistAlarmMng;
  67. BOOL LoadMonitorTree();
  68. BOOL LoadHistoryData();
  69. //转换IMEI和idx 转换成 mo mp
  70. bool IMEI2MOMP(const std::string imei, const int idx, std::string& mo, std::string& mp);
  71. bool IMEI2MOMP(const std::string& imei_idx, std::string& mo_mp);
  72. bool MOMP2IMEI(const std::string& mo, const std::string& mp, std::string& imei, int& idx);
  73. bool MOMP2IMEI(const std::string& momp, std::string& imeiidx);
  74. bool MOMP2IMEI(const std::string& momp, std::string& imei, int& idx);
  75. //获取战场站点名
  76. bool GetStationNameByMomP(const std::string& momp, std::string& station, std::string& momp_name);
  77. bool GetStationNameByMomP(const std::string& mo, const std::string& mp, std::string& station, std::string& momp_name);
  78. //获取测力曲线名称
  79. bool GetNameByMoMp(const std::string& momp, std::string& name1, std::string& name2, std::string& name3);
  80. bool GetNameByMoMp(const std::string& momp, std::string& name1, std::string& name2, std::string& name3, std::string& out_name, std::string& in_name);
  81. //设置测力曲线名称
  82. void SetNameByMoMp(const std::string& momp, std::string& name1, std::string& name2, std::string& name3);
  83. //获取转换阻力方向名称
  84. bool GetDirectByMoMp(const std::string& momp, std::string& out_name, std::string& in_name);
  85. //设置转换阻力方向名称
  86. void SetDirectByMoMp(const std::string& momp, std::string& out_name, std::string& in_name);
  87. static bool spiltByPoint(const std::string&src, std::string& dst1, std::string& dst2);
  88. std::string concatStringByPoint(const std::string& src1, const std::string& src2);
  89. //通过ID来获取树节点
  90. CMonitorObject* GetTreeByID(const string& id);
  91. CMonitorObject* GetTreeByEpqID(uint16_t id);
  92. //根据momp来获取道岔对象
  93. //获取所有Type对象
  94. bool GetAllObjByType(std::vector<CMonitorObject*>& vctObj, const string& type);
  95. //序列化
  96. uint32_t GeneralMoPack(uint8_t** pack, int* len);
  97. void GeneralMoPack(CMonitorObject* pObject, yyjson_mut_doc* doc, yyjson_mut_val* val);
  98. uint32_t GeneralMpPack(uint8_t** pack, int* len);
  99. const std::map<std::string, std::vector<string>>* GetMoMpName()const { return &m_mapMoMpName; }
  100. const std::map<std::string, std::string>* GetImeiIdxMoMp()const { return &m_mapImeiIdxMoMp; }
  101. inline auto GetZZJNO(const string& momp) {
  102. return m_mapMoMpZZJNO[momp];
  103. }
  104. inline auto GetZZJEPOS(const string& momp){
  105. return m_mapMoMpZZJEPOS[momp];
  106. }
  107. void UpdateZZJEPOS(const string& momp, DAOCHA_POSITION epos);
  108. inline auto GetMoMpInfo(const string& momp)
  109. {
  110. return m_mapMoMpInfo[momp];
  111. }
  112. private:
  113. static CMonitorObject* GetTreeByID(CMonitorObject* p, const string& id);
  114. static CMonitorObject* GetTreeByEpqID(CMonitorObject* p, uint16_t id);
  115. static void GetAllObjByType(CMonitorObject* p, std::vector<CMonitorObject*>& vctObj, const string& type);
  116. BOOL LoadMoMap();
  117. void GetChild(std::list<CMonitorObject*>& lst, CMonitorObject* parent);
  118. bool GetStationNameByMomP(CMonitorObject* pInfo, const std::string& momp, std::string& station, std::string& momp_name);
  119. void Clear();
  120. CMonitorObject* m_treeroot = nullptr;//整棵树
  121. std::map<std::string, std::string> m_mapImeiIdxMoMp;//设备号对应momp
  122. std::map<std::string, std::string> m_mapMoMpImeiIdx;
  123. std::map<std::string, std::vector<string>> m_mapMoMpName; //mo, mp 对应三个测力曲线的名称
  124. std::map<std::string, ST_MOMP_INFO*> m_mapMoMpInfo;//mo, mp 对应信息
  125. std::map<std::string, std::vector<string>> m_mapMoMpDirect; //mo, mp 对应的两个阻力转换方向名称
  126. std::map<std::string, int> m_mapMoMpZZJNO; //mo, mp 对应的转辙机编号
  127. std::map<std::string, DAOCHA_POSITION> m_mapMoMpZZJEPOS; //mo, mp 对应的转辙机位置
  128. private:
  129. static CMonitorObjectMng obj;
  130. };