12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #pragma once
- #include "DIOS.Dev.IODevice.Detail.hpp"
- #include "DIOS.Dev.MSGMould.hpp"
- namespace nDetail = DIOS::Dev::Detail;
- struct ErrorConfig {
- std::string code;
- int level;
- std::string message;
- std::string type;
- };
- class DeviceErrorHandler {
- public:
- DeviceErrorHandler(std::shared_ptr <DIOS::Dev::IOEventCenter> EventCenter, std::string DevInstance, std::string strInfoPath);
- ~DeviceErrorHandler();
- bool LoadConfig(const std::string& configPath);
- std::string ParseAndReport(const std::string& rawCode);
- void ClearAllErrors();
- void ClearAllWarnings();
- bool HasActiveErrors() const;
- bool HasActiveWarnings() const;
- private:
- struct ActiveError {
- std::string code;
- int level;
- std::string message;
- };
- std::unordered_map<std::string, ErrorConfig> m_errorConfigs;
- std::vector<ActiveError> m_activeErrors;
- std::vector<ActiveError> m_activeWarnings;
- mutable std::mutex m_mutex;
- std::unique_ptr <nDetail::MSGUnit> m_MSGUnit;
- std::shared_ptr <DIOS::Dev::IOEventCenter> m_EventCenter;
- void AddError(std::string code, int level, const std::string& message);
- void AddWarning(std::string code, int level, const std::string& message);
- };
|