1
0
forked from fsfw/fsfw

event update

This commit is contained in:
2020-12-08 14:34:56 +01:00
parent 89e80beb62
commit d9cccdedf3
21 changed files with 104 additions and 125 deletions

View File

@ -3,7 +3,7 @@
#include <stdint.h>
#include "fwSubsystemIdRanges.h"
//could be move to more suitable location
// could be moved to more suitable location
#include <events/subsystemIdRanges.h>
typedef uint16_t EventId_t;
@ -13,33 +13,28 @@ typedef uint8_t EventSeverity_t;
typedef uint32_t Event;
namespace EVENT {
EventId_t getEventId(Event event);
namespace event {
EventSeverity_t getSeverity(Event event);
Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId,
EventSeverity_t eventSeverity);
constexpr EventId_t getEventId(Event event) {
return (event & 0xFFFF);
}
namespace SEVERITY {
static const EventSeverity_t INFO = 1;
static const EventSeverity_t LOW = 2;
static const EventSeverity_t MEDIUM = 3;
static const EventSeverity_t HIGH = 4;
constexpr EventSeverity_t getSeverity(Event event) {
return ((event >> 16) & 0xFF);
}
//Unfortunately, this does not work nicely because of the inability to define static classes in headers.
//struct Event {
// Event(uint8_t domain, uint8_t counter, EventSeverity_t severity) :
// id(domain*100+counter), severity(severity) {
// }
// EventId_t id;
// EventSeverity_t severity;
// static const EventSeverity_t INFO = 1;
// static const EventSeverity_t LOW = 2;
// static const EventSeverity_t MEDIUM = 3;
// static const EventSeverity_t HIGH = 4;
//};
constexpr Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId,
EventSeverity_t eventSeverity) {
return (eventSeverity << 16) + (subsystemId * 100) + uniqueEventId;
}
}
namespace severity {
static constexpr EventSeverity_t INFO = 1;
static constexpr EventSeverity_t LOW = 2;
static constexpr EventSeverity_t MEDIUM = 3;
static constexpr EventSeverity_t HIGH = 4;
}
#endif /* EVENTOBJECT_EVENT_H_ */