6 #ifndef MOTORCORTEX_CORE_SM_ERRORPUB_H
7 #define MOTORCORTEX_CORE_SM_ERRORPUB_H
9 #include "motorcortex.pb.h"
10 #include "ps_parameter.h"
11 #include "sg_signalid.h"
12 #include "sm_errorhandlebase.h"
15 #include <initializer_list>
18 namespace mcx::state_machine {
20 constexpr
auto MAX_NUM_OF_ERRORS =
sizeof(MotorcortexErrorList::errors) /
sizeof(MotorcortexErrorList::errors[0]);
37 bool clear(
bool warnings_only);
39 void update(
const std::vector<std::reference_wrapper<const ErrorPublisher>>& error_pub);
43 bool hasError(
const Error& error)
const;
45 bool hasErrorLevel(MotorcortexErrorLevel error_level)
const;
47 const std::map<Error, MotorcortexError>& getActiveErrors()
const;
51 unsigned long getUpdateCounter()
const;
53 bool compare(
unsigned long& counter)
const;
55 bool addError(
const Error& error, MotorcortexErrorLevel error_level);
59 void encode(
size_t counter);
61 inline void setName(
const std::string& name) { name_ = name; }
63 inline const std::string& getName()
const {
return name_; }
66 static void updateErrorHandle(ErrorHandles& error_handle);
68 bool processError(
const Error& error, motorcortex_ErrorLevel error_level, uint64_t timestamp,
bool print_error);
76 ErrorHandles error_handles_;
78 uint8_t error_list_msg_[motorcortex_ErrorList_size]{};
80 std::array<uint64_t, MAX_NUM_OF_ERRORS> es_errors_{};
81 std::array<uint64_t, MAX_NUM_OF_ERRORS> sd_errors_{};
82 std::array<uint64_t, MAX_NUM_OF_ERRORS> fd_errors_{};
83 std::array<uint64_t, MAX_NUM_OF_ERRORS> warnings_{};
86 std::map<Error, MotorcortexError> active_errors_;
89 size_t update_counter_{};
95 #endif // MOTORCORTEX_CORE_SM_ERRORPUB_H