| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- #pragma once
- #include <string>
- #include <map>
- #include <list>
- #include <vector>
- #include <yyjson.h>
- class CDevice;
- struct ST_MOMP_INFO
- {
- uint8_t check = 0xaa;
- uint8_t binstall_1 = 0;
- uint8_t binstall_2 = 0;
- uint8_t binstall_3 = 0;
- string name1;
- string name1utf;
- string name2;
- string name2utf;
- string name3;
- string name3utf;
- string out_name;
- string in_name;
- string imei;
- uint8_t idx = -1;
- CDevice *pDeivce = nullptr;
- uint32_t zzjno = 0;
- string mo;
- string mp;
- string name; //名称
- public:
- //牵引点中间内存缓存数据
- //定位常态保持力值
- // int fix_const_retension_force = INT_MIN;
- //反位常态保持力值
- //int int invert_const_retension_force = INT_MIN;
-
- ~ST_MOMP_INFO(){
- check = 0x00;
- }
- };
- enum class DAOCHA_POSITION {
- MP_UNKNOWN = 0,
- MP_FIX,
- MP_INVERT,
- };
- class CMonitorObject
- {
- public:
- CMonitorObject();
- virtual ~CMonitorObject();
- public:
- std::string id;
- std::string name;
- std::string type;
- std::string up;
- std::list<CMonitorObject*> m_lstMo;
- //type = mo.mp 时 生效 设备(转辙机编号)
- uint16_t eqpno = 0; //牵引点以上节点没有no。牵引点有自身no, 牵引点再往下一层为采集类型码AcqTypeCode
- CMonitorObject* parent = nullptr;
- uint8_t check = 0xaa;
- };
- class CMonitorObjectMng
- {
- CMonitorObjectMng();
- virtual ~CMonitorObjectMng();
- public:
- static CMonitorObjectMng* Instance() { return &obj; };
- friend class CResistAlarmMng;
- BOOL LoadMonitorTree();
- BOOL LoadHistoryData();
- //转换IMEI和idx 转换成 mo mp
- bool IMEI2MOMP(const std::string imei, const int idx, std::string& mo, std::string& mp);
- bool IMEI2MOMP(const std::string& imei_idx, std::string& mo_mp);
- bool MOMP2IMEI(const std::string& mo, const std::string& mp, std::string& imei, int& idx);
- bool MOMP2IMEI(const std::string& momp, std::string& imeiidx);
- bool MOMP2IMEI(const std::string& momp, std::string& imei, int& idx);
- //获取战场站点名
- bool GetStationNameByMomP(const std::string& momp, std::string& station, std::string& momp_name);
- bool GetStationNameByMomP(const std::string& mo, const std::string& mp, std::string& station, std::string& momp_name);
- //获取测力曲线名称
- bool GetNameByMoMp(const std::string& momp, std::string& name1, std::string& name2, std::string& name3);
- bool GetNameByMoMp(const std::string& momp, std::string& name1, std::string& name2, std::string& name3, std::string& out_name, std::string& in_name);
- //设置测力曲线名称
- void SetNameByMoMp(const std::string& momp, std::string& name1, std::string& name2, std::string& name3);
- //获取转换阻力方向名称
- bool GetDirectByMoMp(const std::string& momp, std::string& out_name, std::string& in_name);
- //设置转换阻力方向名称
- void SetDirectByMoMp(const std::string& momp, std::string& out_name, std::string& in_name);
- static bool spiltByPoint(const std::string&src, std::string& dst1, std::string& dst2);
- std::string concatStringByPoint(const std::string& src1, const std::string& src2);
- //通过ID来获取树节点
- CMonitorObject* GetTreeByID(const string& id);
- CMonitorObject* GetTreeByEpqID(uint16_t id);
- //根据momp来获取道岔对象
- //获取所有Type对象
- bool GetAllObjByType(std::vector<CMonitorObject*>& vctObj, const string& type);
- //序列化
- uint32_t GeneralMoPack(uint8_t** pack, int* len);
- void GeneralMoPack(CMonitorObject* pObject, yyjson_mut_doc* doc, yyjson_mut_val* val);
- uint32_t GeneralMpPack(uint8_t** pack, int* len);
- const std::map<std::string, std::vector<string>>* GetMoMpName()const { return &m_mapMoMpName; }
- const std::map<std::string, std::string>* GetImeiIdxMoMp()const { return &m_mapImeiIdxMoMp; }
- inline auto GetZZJNO(const string& momp) {
- return m_mapMoMpZZJNO[momp];
- }
- inline auto GetZZJEPOS(const string& momp){
- return m_mapMoMpZZJEPOS[momp];
- }
- void UpdateZZJEPOS(const string& momp, DAOCHA_POSITION epos);
- inline auto GetMoMpInfo(const string& momp)
- {
- return m_mapMoMpInfo[momp];
- }
- private:
- static CMonitorObject* GetTreeByID(CMonitorObject* p, const string& id);
- static CMonitorObject* GetTreeByEpqID(CMonitorObject* p, uint16_t id);
- static void GetAllObjByType(CMonitorObject* p, std::vector<CMonitorObject*>& vctObj, const string& type);
- BOOL LoadMoMap();
- void GetChild(std::list<CMonitorObject*>& lst, CMonitorObject* parent);
- bool GetStationNameByMomP(CMonitorObject* pInfo, const std::string& momp, std::string& station, std::string& momp_name);
- void Clear();
- CMonitorObject* m_treeroot = nullptr;//整棵树
- std::map<std::string, std::string> m_mapImeiIdxMoMp;//设备号对应momp
- std::map<std::string, std::string> m_mapMoMpImeiIdx;
- std::map<std::string, std::vector<string>> m_mapMoMpName; //mo, mp 对应三个测力曲线的名称
- std::map<std::string, ST_MOMP_INFO*> m_mapMoMpInfo;//mo, mp 对应信息
- std::map<std::string, std::vector<string>> m_mapMoMpDirect; //mo, mp 对应的两个阻力转换方向名称
- std::map<std::string, int> m_mapMoMpZZJNO; //mo, mp 对应的转辙机编号
- std::map<std::string, DAOCHA_POSITION> m_mapMoMpZZJEPOS; //mo, mp 对应的转辙机位置
- private:
- static CMonitorObjectMng obj;
- };
|