fsfw/events/Event.h

41 lines
956 B
C
Raw Normal View History

#ifndef EVENTOBJECT_EVENT_H_
#define EVENTOBJECT_EVENT_H_
#include <stdint.h>
2020-08-13 20:53:35 +02:00
#include "fwSubsystemIdRanges.h"
2020-12-08 14:43:44 +01:00
// could be moved to more suitable location
2020-11-17 19:25:57 +01:00
#include <events/subsystemIdRanges.h>
typedef uint16_t EventId_t;
typedef uint8_t EventSeverity_t;
#define MAKE_EVENT(id, severity) (((severity)<<16)+(SUBSYSTEM_ID*100)+(id))
typedef uint32_t Event;
2020-12-08 14:43:44 +01:00
namespace event {
2020-12-08 14:43:44 +01:00
constexpr EventId_t getEventId(Event event) {
return (event & 0xFFFF);
}
constexpr EventSeverity_t getSeverity(Event event) {
return ((event >> 16) & 0xFF);
}
2020-12-08 14:43:44 +01:00
constexpr Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId,
EventSeverity_t eventSeverity) {
return (eventSeverity << 16) + (subsystemId * 100) + uniqueEventId;
}
2020-12-01 17:44:36 +01:00
}
2020-12-08 14:43:44 +01:00
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_ */