added new local data pool files
This commit is contained in:
11
housekeeping/AcceptsHkPacketsIF.h
Normal file
11
housekeeping/AcceptsHkPacketsIF.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_
|
||||
#define FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_
|
||||
#include "../ipc/MessageQueueMessageIF.h"
|
||||
|
||||
class AcceptsHkPacketsIF {
|
||||
public:
|
||||
virtual~ AcceptsHkPacketsIF() {};
|
||||
virtual MessageQueueId_t getHkQueue() const = 0;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_ */
|
162
housekeeping/HousekeepingMessage.cpp
Normal file
162
housekeeping/HousekeepingMessage.cpp
Normal file
@ -0,0 +1,162 @@
|
||||
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
||||
#include "HousekeepingMessage.h"
|
||||
#include <cstring>
|
||||
|
||||
HousekeepingMessage::~HousekeepingMessage() {}
|
||||
|
||||
void HousekeepingMessage::setHkReportReply(CommandMessage* message, sid_t sid,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(HK_REPORT);
|
||||
message->setMessageSize(HK_MESSAGE_SIZE);
|
||||
setSid(message, sid);
|
||||
message->setParameter3(storeId.raw);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setHkDiagnosticsReply(CommandMessage* message,
|
||||
sid_t sid, store_address_t storeId) {
|
||||
message->setCommand(DIAGNOSTICS_REPORT);
|
||||
message->setMessageSize(HK_MESSAGE_SIZE);
|
||||
setSid(message, sid);
|
||||
message->setParameter3(storeId.raw);
|
||||
}
|
||||
|
||||
sid_t HousekeepingMessage::getHkDataReply(const CommandMessage *message,
|
||||
store_address_t *storeIdToSet) {
|
||||
if(storeIdToSet != nullptr) {
|
||||
*storeIdToSet = message->getParameter3();
|
||||
}
|
||||
return getSid(message);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setToggleReportingCommand(CommandMessage *message,
|
||||
sid_t sid, bool enableReporting, bool isDiagnostics) {
|
||||
if(isDiagnostics) {
|
||||
if(enableReporting) {
|
||||
message->setCommand(ENABLE_PERIODIC_DIAGNOSTICS_GENERATION);
|
||||
}
|
||||
else {
|
||||
message->setCommand(DISABLE_PERIODIC_DIAGNOSTICS_GENERATION);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(enableReporting) {
|
||||
message->setCommand(ENABLE_PERIODIC_HK_REPORT_GENERATION);
|
||||
}
|
||||
else {
|
||||
message->setCommand(DISABLE_PERIODIC_HK_REPORT_GENERATION);
|
||||
}
|
||||
}
|
||||
|
||||
setSid(message, sid);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setStructureReportingCommand(CommandMessage *command,
|
||||
sid_t sid, bool isDiagnostics) {
|
||||
if(isDiagnostics) {
|
||||
command->setCommand(REPORT_DIAGNOSTICS_REPORT_STRUCTURES);
|
||||
}
|
||||
else {
|
||||
command->setCommand(REPORT_HK_REPORT_STRUCTURES);
|
||||
}
|
||||
|
||||
setSid(command, sid);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setOneShotReportCommand(CommandMessage *command,
|
||||
sid_t sid, bool isDiagnostics) {
|
||||
if(isDiagnostics) {
|
||||
command->setCommand(GENERATE_ONE_DIAGNOSTICS_REPORT);
|
||||
}
|
||||
else {
|
||||
command->setCommand(GENERATE_ONE_PARAMETER_REPORT);
|
||||
}
|
||||
|
||||
setSid(command, sid);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setCollectionIntervalModificationCommand(
|
||||
CommandMessage *command, sid_t sid, float collectionInterval,
|
||||
bool isDiagnostics) {
|
||||
if(isDiagnostics) {
|
||||
command->setCommand(MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL);
|
||||
}
|
||||
else {
|
||||
command->setCommand(MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL);
|
||||
}
|
||||
command->setParameter3(collectionInterval);
|
||||
|
||||
setSid(command, sid);
|
||||
}
|
||||
|
||||
sid_t HousekeepingMessage::getCollectionIntervalModificationCommand(
|
||||
const CommandMessage* command, float* newCollectionInterval) {
|
||||
if(newCollectionInterval != nullptr) {
|
||||
*newCollectionInterval = command->getParameter3();
|
||||
}
|
||||
|
||||
return getSid(command);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setHkRequestSuccessReply(CommandMessage *reply,
|
||||
sid_t sid) {
|
||||
setSid(reply, sid);
|
||||
reply->setCommand(HK_REQUEST_SUCCESS);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setHkRequestFailureReply(CommandMessage *reply,
|
||||
sid_t sid, ReturnValue_t error) {
|
||||
setSid(reply, sid);
|
||||
reply->setCommand(HK_REQUEST_FAILURE);
|
||||
reply->setParameter3(error);
|
||||
}
|
||||
|
||||
sid_t HousekeepingMessage::getHkRequestFailureReply(const CommandMessage *reply,
|
||||
ReturnValue_t *error) {
|
||||
if(error != nullptr) {
|
||||
*error = reply->getParameter3();
|
||||
}
|
||||
return getSid(reply);
|
||||
}
|
||||
|
||||
sid_t HousekeepingMessage::getSid(const CommandMessage* message) {
|
||||
sid_t sid;
|
||||
std::memcpy(&sid.raw, message->getData(), sizeof(sid.raw));
|
||||
return sid;
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setSid(CommandMessage *message, sid_t sid) {
|
||||
std::memcpy(message->getData(), &sid.raw, sizeof(sid.raw));
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setHkStuctureReportReply(CommandMessage *reply,
|
||||
sid_t sid, store_address_t storeId) {
|
||||
reply->setCommand(HK_DEFINITIONS_REPORT);
|
||||
setSid(reply, sid);
|
||||
reply->setParameter3(storeId.raw);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setDiagnosticsStuctureReportReply(
|
||||
CommandMessage *reply, sid_t sid, store_address_t storeId) {
|
||||
reply->setCommand(DIAGNOSTICS_DEFINITION_REPORT);
|
||||
setSid(reply, sid);
|
||||
reply->setParameter3(storeId.raw);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::clear(CommandMessage* message) {
|
||||
switch(message->getCommand()) {
|
||||
case(HK_REPORT):
|
||||
case(DIAGNOSTICS_REPORT):
|
||||
case(HK_DEFINITIONS_REPORT):
|
||||
case(DIAGNOSTICS_DEFINITION_REPORT):
|
||||
case(UPDATE_SNAPSHOT): {
|
||||
store_address_t storeId;
|
||||
getHkDataReply(message, &storeId);
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != nullptr) {
|
||||
ipcStore->deleteData(storeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
}
|
157
housekeeping/HousekeepingMessage.h
Normal file
157
housekeeping/HousekeepingMessage.h
Normal file
@ -0,0 +1,157 @@
|
||||
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGMESSAGE_H_
|
||||
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGMESSAGE_H_
|
||||
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../ipc/FwMessageTypes.h"
|
||||
#include "../objectmanager/frameworkObjects.h"
|
||||
#include "../objectmanager/SystemObjectIF.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
|
||||
union sid_t {
|
||||
static constexpr uint64_t INVALID_SID = -1;
|
||||
static constexpr uint32_t INVALID_SET_ID = -1;
|
||||
static constexpr uint32_t INVALID_OBJECT_ID = objects::NO_OBJECT;
|
||||
sid_t(): raw(INVALID_SID) {}
|
||||
|
||||
sid_t(object_id_t objectId, uint32_t setId):
|
||||
objectId(objectId),
|
||||
ownerSetId(setId) {}
|
||||
|
||||
struct {
|
||||
object_id_t objectId ;
|
||||
/**
|
||||
* A generic 32 bit ID to identify unique HK packets for a single
|
||||
* object. For example, the DeviceCommandId_t is used for
|
||||
* DeviceHandlers
|
||||
*/
|
||||
uint32_t ownerSetId;
|
||||
};
|
||||
/**
|
||||
* Alternative access to the raw value. This is also the size of the type.
|
||||
*/
|
||||
uint64_t raw;
|
||||
|
||||
bool notSet() const {
|
||||
return raw == INVALID_SID;
|
||||
}
|
||||
|
||||
bool operator==(const sid_t& other) const {
|
||||
return raw == other.raw;
|
||||
}
|
||||
|
||||
bool operator!=(const sid_t& other) const {
|
||||
return not (raw == other.raw);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Special command message type for housekeeping messages
|
||||
* @details
|
||||
* This message is slightly larger than regular command messages to accomodate
|
||||
* the uint64_t structure ID (SID).
|
||||
*/
|
||||
class HousekeepingMessage {
|
||||
public:
|
||||
|
||||
static constexpr size_t HK_MESSAGE_SIZE = CommandMessageIF::HEADER_SIZE +
|
||||
sizeof(sid_t) + sizeof(uint32_t);
|
||||
|
||||
/**
|
||||
* Concrete instance is not used, instead this class operates on
|
||||
* command message instances.
|
||||
*/
|
||||
HousekeepingMessage() = delete;
|
||||
virtual ~HousekeepingMessage();
|
||||
|
||||
static constexpr uint8_t MESSAGE_ID = messagetypes::HOUSEKEEPING;
|
||||
|
||||
static constexpr Command_t ENABLE_PERIODIC_HK_REPORT_GENERATION =
|
||||
MAKE_COMMAND_ID(5);
|
||||
static constexpr Command_t DISABLE_PERIODIC_HK_REPORT_GENERATION =
|
||||
MAKE_COMMAND_ID(6);
|
||||
|
||||
static constexpr Command_t ENABLE_PERIODIC_DIAGNOSTICS_GENERATION =
|
||||
MAKE_COMMAND_ID(7);
|
||||
static constexpr Command_t DISABLE_PERIODIC_DIAGNOSTICS_GENERATION =
|
||||
MAKE_COMMAND_ID(8);
|
||||
|
||||
static constexpr Command_t REPORT_HK_REPORT_STRUCTURES = MAKE_COMMAND_ID(9);
|
||||
static constexpr Command_t REPORT_DIAGNOSTICS_REPORT_STRUCTURES =
|
||||
MAKE_COMMAND_ID(11);
|
||||
|
||||
static constexpr Command_t HK_DEFINITIONS_REPORT = MAKE_COMMAND_ID(10);
|
||||
static constexpr Command_t DIAGNOSTICS_DEFINITION_REPORT = MAKE_COMMAND_ID(12);
|
||||
|
||||
static constexpr Command_t HK_REPORT = MAKE_COMMAND_ID(25);
|
||||
static constexpr Command_t DIAGNOSTICS_REPORT = MAKE_COMMAND_ID(26);
|
||||
|
||||
static constexpr Command_t GENERATE_ONE_PARAMETER_REPORT =
|
||||
MAKE_COMMAND_ID(27);
|
||||
static constexpr Command_t GENERATE_ONE_DIAGNOSTICS_REPORT =
|
||||
MAKE_COMMAND_ID(28);
|
||||
|
||||
static constexpr Command_t MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL =
|
||||
MAKE_COMMAND_ID(31);
|
||||
static constexpr Command_t MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL =
|
||||
MAKE_COMMAND_ID(32);
|
||||
|
||||
static constexpr Command_t HK_REQUEST_SUCCESS =
|
||||
MAKE_COMMAND_ID(128);
|
||||
static constexpr Command_t HK_REQUEST_FAILURE =
|
||||
MAKE_COMMAND_ID(129);
|
||||
|
||||
static constexpr Command_t UPDATE_NOTIFICATION = MAKE_COMMAND_ID(130);
|
||||
static constexpr Command_t UPDATE_SNAPSHOT = MAKE_COMMAND_ID(131);
|
||||
|
||||
static constexpr Command_t UPDATE_HK_REPORT = MAKE_COMMAND_ID(132);
|
||||
|
||||
static sid_t getSid(const CommandMessage* message);
|
||||
|
||||
/** Setter functions */
|
||||
static void setToggleReportingCommand(CommandMessage* command, sid_t sid,
|
||||
bool enableReporting, bool isDiagnostics);
|
||||
static void setStructureReportingCommand(CommandMessage* command, sid_t sid,
|
||||
bool isDiagnostics);
|
||||
static void setOneShotReportCommand(CommandMessage* command, sid_t sid,
|
||||
bool isDiagnostics);
|
||||
static void setCollectionIntervalModificationCommand(
|
||||
CommandMessage* command, sid_t sid, float collectionInterval,
|
||||
bool isDiagnostics);
|
||||
|
||||
static void setHkReportReply(CommandMessage* reply, sid_t sid,
|
||||
store_address_t storeId);
|
||||
static void setHkDiagnosticsReply(CommandMessage* reply, sid_t sid,
|
||||
store_address_t storeId);
|
||||
|
||||
static void setHkRequestSuccessReply(CommandMessage* reply, sid_t sid);
|
||||
static void setHkRequestFailureReply(CommandMessage* reply, sid_t sid,
|
||||
ReturnValue_t error);
|
||||
|
||||
static void setHkStuctureReportReply(CommandMessage* reply,
|
||||
sid_t sid, store_address_t storeId);
|
||||
static void setDiagnosticsStuctureReportReply(CommandMessage* reply,
|
||||
sid_t sid, store_address_t storeId);
|
||||
|
||||
static sid_t getHkRequestFailureReply(const CommandMessage* reply,
|
||||
ReturnValue_t* error);
|
||||
|
||||
/**
|
||||
* @brief Generic getter function for housekeeping data replies
|
||||
* @details
|
||||
* Command ID can be used beforehand to distinguish between diagnostics and
|
||||
* regular HK packets. This getter function should be used for the
|
||||
* command IDs 10, 12, 25 and 26.
|
||||
*/
|
||||
static sid_t getHkDataReply(const CommandMessage* message,
|
||||
store_address_t * storeIdToSet);
|
||||
static sid_t getCollectionIntervalModificationCommand(
|
||||
const CommandMessage* command, float* newCollectionInterval);
|
||||
|
||||
static void clear(CommandMessage* message);
|
||||
private:
|
||||
static void setSid(CommandMessage* message, sid_t sid);
|
||||
};
|
||||
|
||||
|
||||
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGMESSAGE_H_ */
|
34
housekeeping/HousekeepingPacketDownlink.h
Normal file
34
housekeeping/HousekeepingPacketDownlink.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_
|
||||
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_
|
||||
|
||||
#include "../datapoollocal/LocalPoolDataSetBase.h"
|
||||
#include "../serialize/SerialLinkedListAdapter.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
|
||||
/**
|
||||
* @brief This class will be used to serialize general housekeeping packets
|
||||
* which are destined to be downlinked into the store.
|
||||
* @details
|
||||
* The housekeeping packets are stored into the IPC store and forwarded
|
||||
* to the designated housekeeping handler.
|
||||
*/
|
||||
class HousekeepingPacketDownlink: public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
HousekeepingPacketDownlink(sid_t sid, LocalPoolDataSetBase* dataSetPtr):
|
||||
sourceId(sid.objectId), setId(sid.ownerSetId), hkData(dataSetPtr) {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
private:
|
||||
void setLinks() {
|
||||
setStart(&sourceId);
|
||||
sourceId.setNext(&setId);
|
||||
setId.setNext(&hkData);
|
||||
}
|
||||
|
||||
SerializeElement<object_id_t> sourceId;
|
||||
SerializeElement<uint32_t> setId;
|
||||
LinkedElement<SerializeIF> hkData;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ */
|
73
housekeeping/HousekeepingPacketUpdate.h
Normal file
73
housekeeping/HousekeepingPacketUpdate.h
Normal file
@ -0,0 +1,73 @@
|
||||
#ifndef FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
|
||||
#define FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
|
||||
|
||||
#include "../serialize/SerialBufferAdapter.h"
|
||||
#include "../serialize/SerialLinkedListAdapter.h"
|
||||
#include "../datapoollocal/LocalPoolDataSetBase.h"
|
||||
|
||||
/**
|
||||
* @brief This helper class will be used to serialize and deserialize
|
||||
* update housekeeping packets into the store.
|
||||
*/
|
||||
class HousekeepingPacketUpdate: public SerializeIF {
|
||||
public:
|
||||
/**
|
||||
* @param timeStamp
|
||||
* @param timeStampSize
|
||||
* @param hkData
|
||||
* @param hkDataSize
|
||||
*/
|
||||
HousekeepingPacketUpdate(uint8_t* timeStamp, size_t timeStampSize,
|
||||
LocalPoolDataSetBase* dataSetPtr):
|
||||
timeStamp(timeStamp), timeStampSize(timeStampSize),
|
||||
dataSetPtr(dataSetPtr) {};
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
if(timeStamp != nullptr) {
|
||||
/* Endianness will always be MACHINE, so we can simply use memcpy
|
||||
here. */
|
||||
std::memcpy(*buffer, timeStamp, timeStampSize);
|
||||
*size += timeStampSize;
|
||||
*buffer += timeStampSize;
|
||||
}
|
||||
if(dataSetPtr == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
return dataSetPtr->serialize(buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
|
||||
virtual size_t getSerializedSize() const {
|
||||
if(dataSetPtr == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return timeStampSize + dataSetPtr->getSerializedSize();
|
||||
}
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
SerializeIF::Endianness streamEndianness) override {
|
||||
if(timeStamp != nullptr) {
|
||||
/* Endianness will always be MACHINE, so we can simply use memcpy
|
||||
here. */
|
||||
std::memcpy(timeStamp, *buffer, timeStampSize);
|
||||
*size += timeStampSize;
|
||||
*buffer += timeStampSize;
|
||||
}
|
||||
|
||||
if(dataSetPtr == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return dataSetPtr->deSerialize(buffer, size, streamEndianness);
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t* timeStamp;
|
||||
size_t timeStampSize;
|
||||
|
||||
LocalPoolDataSetBase* dataSetPtr = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_ */
|
59
housekeeping/HousekeepingSetPacket.h
Normal file
59
housekeeping/HousekeepingSetPacket.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_
|
||||
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_
|
||||
|
||||
#include "../housekeeping/HousekeepingMessage.h"
|
||||
#include "../serialize/SerialLinkedListAdapter.h"
|
||||
#include "../datapoollocal/LocalPoolDataSetBase.h"
|
||||
|
||||
class HousekeepingSetPacket: public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
HousekeepingSetPacket(sid_t sid, bool reportingEnabled, bool valid,
|
||||
float collectionInterval, LocalPoolDataSetBase* dataSetPtr):
|
||||
objectId(sid.objectId), setId(sid.ownerSetId),
|
||||
reportingEnabled(reportingEnabled), valid(valid),
|
||||
collectionIntervalSeconds(collectionInterval), dataSet(dataSetPtr) {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const override {
|
||||
ReturnValue_t result = SerialLinkedListAdapter::serialize(buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return dataSet->serializeLocalPoolIds(buffer, size ,maxSize,
|
||||
streamEndianness);
|
||||
}
|
||||
|
||||
size_t getSerializedSize() const override {
|
||||
size_t linkedSize = SerialLinkedListAdapter::getSerializedSize();
|
||||
linkedSize += dataSet->getLocalPoolIdsSerializedSize();
|
||||
return linkedSize;
|
||||
}
|
||||
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) override {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void setLinks() {
|
||||
setStart(&objectId);
|
||||
objectId.setNext(&setId);
|
||||
setId.setNext(&reportingEnabled);
|
||||
reportingEnabled.setNext(&valid);
|
||||
valid.setNext(&collectionIntervalSeconds);
|
||||
collectionIntervalSeconds.setEnd();
|
||||
}
|
||||
|
||||
SerializeElement<object_id_t> objectId;
|
||||
SerializeElement<uint32_t> setId;
|
||||
SerializeElement<bool> reportingEnabled;
|
||||
SerializeElement<bool> valid;
|
||||
SerializeElement<float> collectionIntervalSeconds;
|
||||
LocalPoolDataSetBase* dataSet;
|
||||
};
|
||||
|
||||
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_ */
|
48
housekeeping/PeriodicHousekeepingHelper.cpp
Normal file
48
housekeeping/PeriodicHousekeepingHelper.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "../datapoollocal/LocalPoolDataSetBase.h"
|
||||
#include "PeriodicHousekeepingHelper.h"
|
||||
#include <cmath>
|
||||
|
||||
PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(
|
||||
LocalPoolDataSetBase* owner): owner(owner) {}
|
||||
|
||||
|
||||
void PeriodicHousekeepingHelper::initialize(float collectionInterval,
|
||||
dur_millis_t minimumPeriodicInterval, bool isDiagnostics,
|
||||
uint8_t nonDiagIntervalFactor) {
|
||||
this->minimumPeriodicInterval = minimumPeriodicInterval;
|
||||
if(not isDiagnostics) {
|
||||
this->minimumPeriodicInterval = this->minimumPeriodicInterval *
|
||||
nonDiagIntervalFactor;
|
||||
}
|
||||
collectionIntervalTicks = intervalSecondsToInterval(collectionInterval);
|
||||
}
|
||||
|
||||
float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() {
|
||||
return intervalToIntervalSeconds(collectionIntervalTicks);
|
||||
}
|
||||
|
||||
bool PeriodicHousekeepingHelper::checkOpNecessary() {
|
||||
if(internalTickCounter >= collectionIntervalTicks) {
|
||||
internalTickCounter = 1;
|
||||
return true;
|
||||
}
|
||||
internalTickCounter++;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t PeriodicHousekeepingHelper::intervalSecondsToInterval(
|
||||
float collectionIntervalSeconds) {
|
||||
return std::ceil(collectionIntervalSeconds * 1000
|
||||
/ minimumPeriodicInterval);
|
||||
}
|
||||
|
||||
float PeriodicHousekeepingHelper::intervalToIntervalSeconds(
|
||||
uint32_t collectionInterval) {
|
||||
return static_cast<float>(collectionInterval *
|
||||
minimumPeriodicInterval);
|
||||
}
|
||||
|
||||
void PeriodicHousekeepingHelper::changeCollectionInterval(
|
||||
float newIntervalSeconds) {
|
||||
collectionIntervalTicks = intervalSecondsToInterval(newIntervalSeconds);
|
||||
}
|
32
housekeeping/PeriodicHousekeepingHelper.h
Normal file
32
housekeeping/PeriodicHousekeepingHelper.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_
|
||||
#define FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_
|
||||
|
||||
#include "../timemanager/Clock.h"
|
||||
#include <cstdint>
|
||||
|
||||
class LocalPoolDataSetBase;
|
||||
|
||||
class PeriodicHousekeepingHelper {
|
||||
public:
|
||||
PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner);
|
||||
|
||||
void initialize(float collectionInterval,
|
||||
dur_millis_t minimumPeriodicInterval, bool isDiagnostics,
|
||||
uint8_t nonDiagIntervalFactor);
|
||||
|
||||
void changeCollectionInterval(float newInterval);
|
||||
float getCollectionIntervalInSeconds();
|
||||
bool checkOpNecessary();
|
||||
private:
|
||||
LocalPoolDataSetBase* owner = nullptr;
|
||||
|
||||
uint32_t intervalSecondsToInterval(float collectionIntervalSeconds);
|
||||
float intervalToIntervalSeconds(uint32_t collectionInterval);
|
||||
|
||||
dur_millis_t minimumPeriodicInterval = 0;
|
||||
uint32_t internalTickCounter = 1;
|
||||
uint32_t collectionIntervalTicks = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ */
|
Reference in New Issue
Block a user