some improvements
This commit is contained in:
parent
02bd667376
commit
d251d7ed02
@ -1,13 +1,13 @@
|
|||||||
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_
|
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_
|
||||||
#define MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_
|
#define MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#include "fsfw/datapoollocal/LocalPoolVariable.h"
|
#include "fsfw/datapoollocal/LocalPoolVariable.h"
|
||||||
#include "fsfw/datapoollocal/StaticLocalDataSet.h"
|
#include "fsfw/datapoollocal/StaticLocalDataSet.h"
|
||||||
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
|
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
|
||||||
#include "fsfw/serialize/SerialLinkedListAdapter.h"
|
#include "fsfw/serialize/SerialLinkedListAdapter.h"
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
namespace mgmRm3100 {
|
namespace mgmRm3100 {
|
||||||
|
|
||||||
/* Actually 10, we round up a little bit */
|
/* Actually 10, we round up a little bit */
|
||||||
|
@ -139,7 +139,7 @@ GeneratesPeriodicHkIF* PeriodicHelper::getOwner() const { return owner; }
|
|||||||
ReturnValue_t PeriodicHelper::generateHousekeepingPacket(const dp::sid_t sid,
|
ReturnValue_t PeriodicHelper::generateHousekeepingPacket(const dp::sid_t sid,
|
||||||
MessageQueueId_t destination) {
|
MessageQueueId_t destination) {
|
||||||
store_address_t storeId;
|
store_address_t storeId;
|
||||||
const auto optSetSpec = getSetSpecification(sid);
|
const auto optSetSpec = getMutSetSpecification(sid);
|
||||||
if (!optSetSpec.has_value()) {
|
if (!optSetSpec.has_value()) {
|
||||||
return DATASET_NOT_FOUND;
|
return DATASET_NOT_FOUND;
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ void PeriodicHelper::performPeriodicHkGeneration(SetSpecification& setSpec, time
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PeriodicHelper::togglePeriodicGeneration(const dp::sid_t sid, const bool enable) {
|
ReturnValue_t PeriodicHelper::togglePeriodicGeneration(const dp::sid_t sid, const bool enable) {
|
||||||
const auto optSetSpec = getSetSpecification(sid);
|
const auto optSetSpec = getMutSetSpecification(sid);
|
||||||
if (!optSetSpec.has_value()) {
|
if (!optSetSpec.has_value()) {
|
||||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "togglePeriodicGeneration",
|
printWarningOrError(sif::OutputTypes::OUT_WARNING, "togglePeriodicGeneration",
|
||||||
DATASET_NOT_FOUND);
|
DATASET_NOT_FOUND);
|
||||||
@ -222,7 +222,7 @@ ReturnValue_t PeriodicHelper::togglePeriodicGeneration(const dp::sid_t sid, cons
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::reference_wrapper<SetSpecification>> PeriodicHelper::getSetSpecification(
|
std::optional<std::reference_wrapper<SetSpecification>> PeriodicHelper::getMutSetSpecification(
|
||||||
dp::sid_t structureId) {
|
dp::sid_t structureId) {
|
||||||
for (auto& receiver : setList) {
|
for (auto& receiver : setList) {
|
||||||
if (receiver.dataId.sid == structureId) {
|
if (receiver.dataId.sid == structureId) {
|
||||||
@ -232,6 +232,16 @@ std::optional<std::reference_wrapper<SetSpecification>> PeriodicHelper::getSetSp
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<std::reference_wrapper<const SetSpecification>> PeriodicHelper::getSetSpecification(
|
||||||
|
dp::sid_t structureId) const {
|
||||||
|
for (const auto& receiver : setList) {
|
||||||
|
if (receiver.dataId.sid == structureId) {
|
||||||
|
return receiver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t PeriodicHelper::setCollectionInterval(dp::sid_t sid,
|
ReturnValue_t PeriodicHelper::setCollectionInterval(dp::sid_t sid,
|
||||||
dur_millis_t newCollectionIntervalMs) {
|
dur_millis_t newCollectionIntervalMs) {
|
||||||
bool wasUpdated = false;
|
bool wasUpdated = false;
|
||||||
@ -250,7 +260,7 @@ ReturnValue_t PeriodicHelper::setCollectionInterval(dp::sid_t sid,
|
|||||||
|
|
||||||
ReturnValue_t PeriodicHelper::generateSetStructurePacket(dp::structure_id_t sid) {
|
ReturnValue_t PeriodicHelper::generateSetStructurePacket(dp::structure_id_t sid) {
|
||||||
// Get and check dataset first.
|
// Get and check dataset first.
|
||||||
auto optSetSpec = getSetSpecification(sid);
|
auto optSetSpec = getMutSetSpecification(sid);
|
||||||
if (!optSetSpec.has_value()) {
|
if (!optSetSpec.has_value()) {
|
||||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "performPeriodicHkGeneration",
|
printWarningOrError(sif::OutputTypes::OUT_WARNING, "performPeriodicHkGeneration",
|
||||||
DATASET_NOT_FOUND);
|
DATASET_NOT_FOUND);
|
||||||
@ -301,10 +311,8 @@ ReturnValue_t PeriodicHelper::generateSetStructurePacket(dp::structure_id_t sid)
|
|||||||
ReturnValue_t PeriodicHelper::enablePeriodicPacket(const dp::structure_id_t structureId,
|
ReturnValue_t PeriodicHelper::enablePeriodicPacket(const dp::structure_id_t structureId,
|
||||||
const std::optional<dur_millis_t> frequencyMs) {
|
const std::optional<dur_millis_t> frequencyMs) {
|
||||||
// Get and check dataset first.
|
// Get and check dataset first.
|
||||||
const auto optSetSpec = getSetSpecification(structureId);
|
const auto optSetSpec = getMutSetSpecification(structureId);
|
||||||
if (!optSetSpec.has_value()) {
|
if (!optSetSpec.has_value()) {
|
||||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "performPeriodicHkGeneration",
|
|
||||||
DATASET_NOT_FOUND);
|
|
||||||
return DATASET_NOT_FOUND;
|
return DATASET_NOT_FOUND;
|
||||||
}
|
}
|
||||||
auto& setSpec = optSetSpec.value().get();
|
auto& setSpec = optSetSpec.value().get();
|
||||||
@ -317,10 +325,8 @@ ReturnValue_t PeriodicHelper::enablePeriodicPacket(const dp::structure_id_t stru
|
|||||||
|
|
||||||
ReturnValue_t PeriodicHelper::disablePeriodicPacket(const dp::structure_id_t structureId) {
|
ReturnValue_t PeriodicHelper::disablePeriodicPacket(const dp::structure_id_t structureId) {
|
||||||
// Get and check dataset first.
|
// Get and check dataset first.
|
||||||
const auto optSetSpec = getSetSpecification(structureId);
|
const auto optSetSpec = getMutSetSpecification(structureId);
|
||||||
if (!optSetSpec.has_value()) {
|
if (!optSetSpec.has_value()) {
|
||||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "performPeriodicHkGeneration",
|
|
||||||
DATASET_NOT_FOUND);
|
|
||||||
return DATASET_NOT_FOUND;
|
return DATASET_NOT_FOUND;
|
||||||
}
|
}
|
||||||
auto& setSpec = optSetSpec.value().get();
|
auto& setSpec = optSetSpec.value().get();
|
||||||
@ -328,6 +334,17 @@ ReturnValue_t PeriodicHelper::disablePeriodicPacket(const dp::structure_id_t str
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t PeriodicHelper::collectionEnabled(dp::sid_t structureId,
|
||||||
|
bool& collectionEnabled) const {
|
||||||
|
// Get and check dataset first.
|
||||||
|
const auto optSetSpec = getSetSpecification(structureId);
|
||||||
|
if (!optSetSpec.has_value()) {
|
||||||
|
return DATASET_NOT_FOUND;
|
||||||
|
}
|
||||||
|
auto& setSpec = optSetSpec.value().get();
|
||||||
|
collectionEnabled = setSpec.periodicCollectionEnabled;
|
||||||
|
return returnvalue::OK;
|
||||||
|
}
|
||||||
object_id_t PeriodicHelper::getCreatorObjectId() const { return owner->getObjectId(); }
|
object_id_t PeriodicHelper::getCreatorObjectId() const { return owner->getObjectId(); }
|
||||||
|
|
||||||
void PeriodicHelper::printWarningOrError(sif::OutputTypes outputType, const char* functionName,
|
void PeriodicHelper::printWarningOrError(sif::OutputTypes outputType, const char* functionName,
|
||||||
|
@ -145,13 +145,17 @@ class PeriodicHelper : public PeriodicHelperIF {
|
|||||||
ReturnValue_t enablePeriodicPacket(dp::sid_t structureId,
|
ReturnValue_t enablePeriodicPacket(dp::sid_t structureId,
|
||||||
std::optional<dur_millis_t> frequencyMs) override;
|
std::optional<dur_millis_t> frequencyMs) override;
|
||||||
ReturnValue_t disablePeriodicPacket(dp::sid_t structureId) override;
|
ReturnValue_t disablePeriodicPacket(dp::sid_t structureId) override;
|
||||||
|
ReturnValue_t collectionEnabled(dp::sid_t structureId, bool& collectionEnabled) const override;
|
||||||
|
|
||||||
ReturnValue_t setCollectionInterval(dp::sid_t structureId,
|
ReturnValue_t setCollectionInterval(dp::sid_t structureId,
|
||||||
dur_millis_t newCollectionIntervalMs) override;
|
dur_millis_t newCollectionIntervalMs) override;
|
||||||
|
|
||||||
std::optional<std::reference_wrapper<SetSpecification>> getSetSpecification(
|
std::optional<std::reference_wrapper<SetSpecification>> getMutSetSpecification(
|
||||||
dp::sid_t structureId);
|
dp::sid_t structureId);
|
||||||
|
|
||||||
|
std::optional<std::reference_wrapper<const SetSpecification>> getSetSpecification(
|
||||||
|
dp::sid_t structureId) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::optional<dur_millis_t> getCollectionFrequency(dp::sid_t structureId);
|
std::optional<dur_millis_t> getCollectionFrequency(dp::sid_t structureId);
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ class PeriodicHelperIF {
|
|||||||
virtual ReturnValue_t enablePeriodicPacket(dp::sid_t structureId,
|
virtual ReturnValue_t enablePeriodicPacket(dp::sid_t structureId,
|
||||||
std::optional<dur_millis_t> frequencyMs) = 0;
|
std::optional<dur_millis_t> frequencyMs) = 0;
|
||||||
virtual ReturnValue_t disablePeriodicPacket(dp::sid_t structureId) = 0;
|
virtual ReturnValue_t disablePeriodicPacket(dp::sid_t structureId) = 0;
|
||||||
|
virtual ReturnValue_t collectionEnabled(dp::sid_t structureId, bool& collectionEnabled) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace hk
|
} // namespace hk
|
@ -11,6 +11,8 @@ class List : public SerializeIF {
|
|||||||
serializables.push_back(serializable);
|
serializables.push_back(serializable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t getNumberOfSerializables() const { return serializables.size(); }
|
||||||
|
|
||||||
[[nodiscard]] ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
[[nodiscard]] ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||||
Endianness streamEndianness) const override {
|
Endianness streamEndianness) const override {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user