| | |
| | | #include <string> |
| | | #include <vector> |
| | | #include <mutex> |
| | | #include <unordered_map> |
| | | #include "Database.h" |
| | | |
| | | struct AlarmInfo { |
| | | std::string strUnitID; |
| | | std::string strUnitNo; |
| | | int nAlarmLevel; |
| | | int nAlarmCode; |
| | | int nAlarmID; |
| | | std::string strAlarmText; |
| | | std::string strDescription; |
| | | }; |
| | | |
| | | using AlarmMap = std::unordered_map<int, AlarmInfo>; |
| | | |
| | | class AlarmManager { |
| | | public: |
| | |
| | | * @return 成功返回true,失败返回false |
| | | */ |
| | | bool destroyAlarmTable(); |
| | | |
| | | /** |
| | | * 插入模拟数据 |
| | | */ |
| | | void insertMockData(); |
| | | |
| | | /** |
| | | * 添加报警 |
| | |
| | | */ |
| | | void cleanOldAlarms(int daysToKeep = 30, const std::string& deviceName = ""); |
| | | |
| | | /** |
| | | * 读取报警文件 |
| | | * @param filename 文件名 |
| | | * @return 成功返回true,失败返回false |
| | | */ |
| | | bool readAlarmFile(const std::string& filename); |
| | | |
| | | /** |
| | | * 保存报警文件 |
| | | * @param filename 文件名 |
| | | * @return 成功返回true,失败返回false |
| | | */ |
| | | bool saveAlarmFile(const std::string& filename); |
| | | |
| | | /** |
| | | * 通过报警ID查询报警信息 |
| | | * @param nAlarmID 报警ID |
| | | * @return 报警信息的指针 |
| | | */ |
| | | const AlarmInfo* getAlarmInfoByID(int nAlarmID) const; |
| | | |
| | | /** |
| | | * 通过多个报警ID查询对应的报警信息 |
| | | * @param alarmIDs 多个报警ID |
| | | * @return 返回多个报警信息 |
| | | */ |
| | | std::vector<AlarmInfo> getAlarmsInfoByIDs(const std::vector<int>& alarmIDs) const; |
| | | |
| | | private: |
| | | AlarmManager(); |
| | | ~AlarmManager(); |
| | |
| | | AlarmManager& operator=(const AlarmManager&) = delete; |
| | | |
| | | BL::Database* m_pDB; |
| | | AlarmMap m_mapAlarm; |
| | | static std::mutex m_mutex; |
| | | }; |
| | | |