fsfw/src/fsfw/action/Action.h

64 lines
1.4 KiB
C
Raw Normal View History

2022-06-29 23:36:45 +02:00
#pragma once
2023-07-14 14:11:22 +02:00
#include <fsfw/introspection/HasTmTcParametersIF.h>
#include <fsfw/serialize/SerializeIF.h>
2022-06-29 23:36:45 +02:00
#include <stdint.h>
#include <vector>
#include "ActionMessage.h"
#ifdef FSFW_INTROSPECTION
#include "../introspection/Enum.h"
#endif
2023-07-14 14:11:22 +02:00
// TODO ActionId_t
2023-07-10 17:07:39 +02:00
2023-07-14 14:11:22 +02:00
class Action : public SerializeIF, public HasTmTcParametersIF {
2022-06-29 23:36:45 +02:00
public:
#ifdef FSFW_INTROSPECTION
Action();
2023-07-14 14:11:22 +02:00
void setEnum(EnumIF *id);
2022-06-29 23:36:45 +02:00
const char *getName();
#else
Action(ActionId_t id);
#endif
2023-07-14 14:11:22 +02:00
store_address_t getTc();
size_t getTcOffset();
// if an action is triggered by a TC, this should be set to be able to handle replies
// TODO make deleting it safe
// TODO integrate with internal commands
store_address_t tc;
size_t tcOffset;
2023-07-28 17:48:47 +02:00
MessageQueueId_t commandedBy;
2023-07-14 14:11:22 +02:00
2022-06-29 23:36:45 +02:00
ActionId_t getId();
2023-07-28 17:48:47 +02:00
void clear();
2022-07-20 16:59:42 +02:00
2022-07-28 14:43:22 +02:00
[[nodiscard]] virtual ReturnValue_t handle() = 0;
2022-06-29 23:36:45 +02:00
void registerParameter(ParameterIF *parameter) override;
2022-06-29 23:36:45 +02:00
2023-07-14 14:11:22 +02:00
std::vector<ParameterIF *> const *getParameters() const override;
2022-06-29 23:36:45 +02:00
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
2023-07-14 14:11:22 +02:00
Endianness streamEndianness) const override;
2022-06-29 23:36:45 +02:00
size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
2023-07-14 14:11:22 +02:00
Endianness streamEndianness) override;
2022-06-29 23:36:45 +02:00
private:
ActionId_t id;
2023-07-14 14:11:22 +02:00
2022-06-29 23:36:45 +02:00
#ifdef FSFW_INTROSPECTION
const char *name;
#endif
std::vector<ParameterIF *> parameterList;
};