#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 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 m_errorConfigs; std::vector m_activeErrors; std::vector m_activeWarnings; mutable std::mutex m_mutex; std::unique_ptr m_MSGUnit; std::shared_ptr m_EventCenter; void AddError(std::string code, int level, const std::string& message); void AddWarning(std::string code, int level, const std::string& message); };