reapply clang format
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
#include "../ipc/MessageQueueMessageIF.h"
|
||||
|
||||
class AcceptsHkPacketsIF {
|
||||
public:
|
||||
virtual~ AcceptsHkPacketsIF() {};
|
||||
virtual MessageQueueId_t getHkQueue() const = 0;
|
||||
public:
|
||||
virtual ~AcceptsHkPacketsIF(){};
|
||||
virtual MessageQueueId_t getHkQueue() const = 0;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_ */
|
||||
|
||||
@@ -1,233 +1,224 @@
|
||||
#include "fsfw/housekeeping/HousekeepingMessage.h"
|
||||
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
|
||||
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::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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
/* Raw storage of the float in the message. Do not use setParameter3, does
|
||||
implicit conversion to integer type! */
|
||||
std::memcpy(command->getData() + 2 * sizeof(uint32_t), &collectionInterval,
|
||||
sizeof(collectionInterval));
|
||||
/* Raw storage of the float in the message. Do not use setParameter3, does
|
||||
implicit conversion to integer type! */
|
||||
std::memcpy(command->getData() + 2 * sizeof(uint32_t), &collectionInterval,
|
||||
sizeof(collectionInterval));
|
||||
|
||||
setSid(command, sid);
|
||||
setSid(command, sid);
|
||||
}
|
||||
|
||||
sid_t HousekeepingMessage::getCollectionIntervalModificationCommand(
|
||||
const CommandMessage* command, float* newCollectionInterval) {
|
||||
sid_t HousekeepingMessage::getCollectionIntervalModificationCommand(const CommandMessage *command,
|
||||
float *newCollectionInterval) {
|
||||
if (newCollectionInterval != nullptr) {
|
||||
std::memcpy(newCollectionInterval, command->getData() + 2 * sizeof(uint32_t),
|
||||
sizeof(*newCollectionInterval));
|
||||
}
|
||||
|
||||
if(newCollectionInterval != nullptr) {
|
||||
std::memcpy(newCollectionInterval, command->getData() + 2 * sizeof(uint32_t),
|
||||
sizeof(*newCollectionInterval));
|
||||
}
|
||||
|
||||
return getSid(command);
|
||||
return getSid(command);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setHkRequestSuccessReply(CommandMessage *reply,
|
||||
sid_t sid) {
|
||||
setSid(reply, sid);
|
||||
reply->setCommand(HK_REQUEST_SUCCESS);
|
||||
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);
|
||||
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);
|
||||
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;
|
||||
sid_t HousekeepingMessage::getSid(const CommandMessage *message) {
|
||||
sid_t sid;
|
||||
std::memcpy(&sid.raw, message->getData(), sizeof(sid.raw));
|
||||
return sid;
|
||||
}
|
||||
|
||||
gp_id_t HousekeepingMessage::getGpid(const CommandMessage* message) {
|
||||
gp_id_t globalPoolId;
|
||||
std::memcpy(&globalPoolId.raw, message->getData(), sizeof(globalPoolId.raw));
|
||||
return globalPoolId;
|
||||
gp_id_t HousekeepingMessage::getGpid(const CommandMessage *message) {
|
||||
gp_id_t globalPoolId;
|
||||
std::memcpy(&globalPoolId.raw, message->getData(), sizeof(globalPoolId.raw));
|
||||
return globalPoolId;
|
||||
}
|
||||
|
||||
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::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::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_SET):
|
||||
case(UPDATE_SNAPSHOT_VARIABLE): {
|
||||
store_address_t storeId;
|
||||
getHkDataReply(message, &storeId);
|
||||
StorageManagerIF *ipcStore = ObjectManager::instance()->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != nullptr) {
|
||||
ipcStore->deleteData(storeId);
|
||||
}
|
||||
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_SET):
|
||||
case (UPDATE_SNAPSHOT_VARIABLE): {
|
||||
store_address_t storeId;
|
||||
getHkDataReply(message, &storeId);
|
||||
StorageManagerIF *ipcStore =
|
||||
ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore != nullptr) {
|
||||
ipcStore->deleteData(storeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
}
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setUpdateNotificationSetCommand(
|
||||
CommandMessage *command, sid_t sid) {
|
||||
command->setCommand(UPDATE_NOTIFICATION_SET);
|
||||
setSid(command, sid);
|
||||
void HousekeepingMessage::setUpdateNotificationSetCommand(CommandMessage *command, sid_t sid) {
|
||||
command->setCommand(UPDATE_NOTIFICATION_SET);
|
||||
setSid(command, sid);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setUpdateNotificationVariableCommand(
|
||||
CommandMessage *command, gp_id_t globalPoolId) {
|
||||
command->setCommand(UPDATE_NOTIFICATION_VARIABLE);
|
||||
setGpid(command, globalPoolId);
|
||||
void HousekeepingMessage::setUpdateNotificationVariableCommand(CommandMessage *command,
|
||||
gp_id_t globalPoolId) {
|
||||
command->setCommand(UPDATE_NOTIFICATION_VARIABLE);
|
||||
setGpid(command, globalPoolId);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setUpdateSnapshotSetCommand(CommandMessage *command,
|
||||
sid_t sid, store_address_t storeId) {
|
||||
command->setCommand(UPDATE_SNAPSHOT_SET);
|
||||
setSid(command, sid);
|
||||
command->setParameter3(storeId.raw);
|
||||
void HousekeepingMessage::setUpdateSnapshotSetCommand(CommandMessage *command, sid_t sid,
|
||||
store_address_t storeId) {
|
||||
command->setCommand(UPDATE_SNAPSHOT_SET);
|
||||
setSid(command, sid);
|
||||
command->setParameter3(storeId.raw);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setUpdateSnapshotVariableCommand(
|
||||
CommandMessage *command, gp_id_t globalPoolId, store_address_t storeId) {
|
||||
command->setCommand(UPDATE_SNAPSHOT_VARIABLE);
|
||||
setGpid(command, globalPoolId);
|
||||
command->setParameter3(storeId.raw);
|
||||
void HousekeepingMessage::setUpdateSnapshotVariableCommand(CommandMessage *command,
|
||||
gp_id_t globalPoolId,
|
||||
store_address_t storeId) {
|
||||
command->setCommand(UPDATE_SNAPSHOT_VARIABLE);
|
||||
setGpid(command, globalPoolId);
|
||||
command->setParameter3(storeId.raw);
|
||||
}
|
||||
|
||||
sid_t HousekeepingMessage::getUpdateNotificationSetCommand(
|
||||
const CommandMessage *command) {
|
||||
return getSid(command);
|
||||
sid_t HousekeepingMessage::getUpdateNotificationSetCommand(const CommandMessage *command) {
|
||||
return getSid(command);
|
||||
}
|
||||
|
||||
gp_id_t HousekeepingMessage::getUpdateNotificationVariableCommand(
|
||||
const CommandMessage *command) {
|
||||
return getGpid(command);
|
||||
gp_id_t HousekeepingMessage::getUpdateNotificationVariableCommand(const CommandMessage *command) {
|
||||
return getGpid(command);
|
||||
}
|
||||
|
||||
sid_t HousekeepingMessage::getUpdateSnapshotSetCommand(
|
||||
const CommandMessage *command, store_address_t *storeId) {
|
||||
if(storeId != nullptr) {
|
||||
*storeId = command->getParameter3();
|
||||
}
|
||||
return getSid(command);
|
||||
sid_t HousekeepingMessage::getUpdateSnapshotSetCommand(const CommandMessage *command,
|
||||
store_address_t *storeId) {
|
||||
if (storeId != nullptr) {
|
||||
*storeId = command->getParameter3();
|
||||
}
|
||||
return getSid(command);
|
||||
}
|
||||
|
||||
gp_id_t HousekeepingMessage::getUpdateSnapshotVariableCommand(
|
||||
const CommandMessage *command, store_address_t *storeId) {
|
||||
if(storeId != nullptr) {
|
||||
*storeId = command->getParameter3();
|
||||
}
|
||||
return getGpid(command);
|
||||
gp_id_t HousekeepingMessage::getUpdateSnapshotVariableCommand(const CommandMessage *command,
|
||||
store_address_t *storeId) {
|
||||
if (storeId != nullptr) {
|
||||
*storeId = command->getParameter3();
|
||||
}
|
||||
return getGpid(command);
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setSid(CommandMessage *message, sid_t sid) {
|
||||
std::memcpy(message->getData(), &sid.raw, sizeof(sid.raw));
|
||||
std::memcpy(message->getData(), &sid.raw, sizeof(sid.raw));
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setGpid(CommandMessage *message, gp_id_t globalPoolId) {
|
||||
std::memcpy(message->getData(), &globalPoolId.raw, sizeof(globalPoolId.raw));
|
||||
std::memcpy(message->getData(), &globalPoolId.raw, sizeof(globalPoolId.raw));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "fsfw/objectmanager/frameworkObjects.h"
|
||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Special command message type for housekeeping messages
|
||||
* @details
|
||||
@@ -15,137 +14,110 @@
|
||||
* the uint64_t structure ID (SID).
|
||||
*/
|
||||
class HousekeepingMessage {
|
||||
public:
|
||||
public:
|
||||
static constexpr size_t HK_MESSAGE_SIZE =
|
||||
CommandMessageIF::HEADER_SIZE + sizeof(sid_t) + sizeof(uint32_t);
|
||||
|
||||
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();
|
||||
|
||||
/**
|
||||
* 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 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_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 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 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_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 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 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 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 HK_REQUEST_SUCCESS =
|
||||
MAKE_COMMAND_ID(128);
|
||||
static constexpr Command_t HK_REQUEST_FAILURE =
|
||||
MAKE_COMMAND_ID(129);
|
||||
static constexpr Command_t UPDATE_NOTIFICATION_SET = MAKE_COMMAND_ID(130);
|
||||
static constexpr Command_t UPDATE_NOTIFICATION_VARIABLE = MAKE_COMMAND_ID(131);
|
||||
|
||||
static constexpr Command_t UPDATE_NOTIFICATION_SET =
|
||||
MAKE_COMMAND_ID(130);
|
||||
static constexpr Command_t UPDATE_NOTIFICATION_VARIABLE =
|
||||
MAKE_COMMAND_ID(131);
|
||||
static constexpr Command_t UPDATE_SNAPSHOT_SET = MAKE_COMMAND_ID(132);
|
||||
static constexpr Command_t UPDATE_SNAPSHOT_VARIABLE = MAKE_COMMAND_ID(133);
|
||||
|
||||
static constexpr Command_t UPDATE_SNAPSHOT_SET = MAKE_COMMAND_ID(132);
|
||||
static constexpr Command_t UPDATE_SNAPSHOT_VARIABLE = MAKE_COMMAND_ID(133);
|
||||
// static constexpr Command_t UPDATE_HK_REPORT = MAKE_COMMAND_ID(134);
|
||||
|
||||
//static constexpr Command_t UPDATE_HK_REPORT = MAKE_COMMAND_ID(134);
|
||||
static sid_t getSid(const CommandMessage* message);
|
||||
static gp_id_t getGpid(const CommandMessage* message);
|
||||
|
||||
static sid_t getSid(const CommandMessage* message);
|
||||
static gp_id_t getGpid(const CommandMessage* message);
|
||||
/* Housekeeping Interface Messages */
|
||||
|
||||
/* Housekeeping Interface Messages */
|
||||
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 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 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 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 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);
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
/* Update Notification Messages */
|
||||
|
||||
static void setUpdateNotificationSetCommand(CommandMessage* command, sid_t sid);
|
||||
static void setUpdateNotificationVariableCommand(CommandMessage* command, gp_id_t globalPoolId);
|
||||
|
||||
/* Update Notification Messages */
|
||||
static void setUpdateSnapshotSetCommand(CommandMessage* command, sid_t sid,
|
||||
store_address_t storeId);
|
||||
static void setUpdateSnapshotVariableCommand(CommandMessage* command, gp_id_t globalPoolId,
|
||||
store_address_t storeId);
|
||||
|
||||
static void setUpdateNotificationSetCommand(CommandMessage* command,
|
||||
sid_t sid);
|
||||
static void setUpdateNotificationVariableCommand(CommandMessage* command,
|
||||
gp_id_t globalPoolId);
|
||||
static sid_t getUpdateNotificationSetCommand(const CommandMessage* command);
|
||||
static gp_id_t getUpdateNotificationVariableCommand(const CommandMessage* command);
|
||||
|
||||
static void setUpdateSnapshotSetCommand(CommandMessage* command, sid_t sid,
|
||||
store_address_t storeId);
|
||||
static void setUpdateSnapshotVariableCommand(CommandMessage* command,
|
||||
gp_id_t globalPoolId, store_address_t storeId);
|
||||
static sid_t getUpdateSnapshotSetCommand(const CommandMessage* command, store_address_t* storeId);
|
||||
static gp_id_t getUpdateSnapshotVariableCommand(const CommandMessage* command,
|
||||
store_address_t* storeId);
|
||||
|
||||
static sid_t getUpdateNotificationSetCommand(const CommandMessage* command);
|
||||
static gp_id_t getUpdateNotificationVariableCommand(
|
||||
const CommandMessage* command);
|
||||
/** Utility */
|
||||
static void clear(CommandMessage* message);
|
||||
|
||||
static sid_t getUpdateSnapshotSetCommand(const CommandMessage* command,
|
||||
store_address_t* storeId);
|
||||
static gp_id_t getUpdateSnapshotVariableCommand(const CommandMessage* command,
|
||||
store_address_t* storeId);
|
||||
|
||||
/** Utility */
|
||||
static void clear(CommandMessage* message);
|
||||
private:
|
||||
static void setSid(CommandMessage* message, sid_t sid);
|
||||
static void setGpid(CommandMessage* message, gp_id_t globalPoolId);
|
||||
private:
|
||||
static void setSid(CommandMessage* message, sid_t sid);
|
||||
static void setGpid(CommandMessage* message, gp_id_t globalPoolId);
|
||||
};
|
||||
|
||||
|
||||
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGMESSAGE_H_ */
|
||||
|
||||
@@ -16,23 +16,23 @@
|
||||
* - Housekeeping Data: The rest of the packet will be the serialized housekeeping data. A validity
|
||||
* buffer might be appended at the end, depending on the set configuration.
|
||||
*/
|
||||
class HousekeepingPacketDownlink: public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
HousekeepingPacketDownlink(sid_t sid, LocalPoolDataSetBase* dataSetPtr):
|
||||
sourceId(sid.objectId), setId(sid.ownerSetId), hkData(dataSetPtr) {
|
||||
setLinks();
|
||||
}
|
||||
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);
|
||||
}
|
||||
private:
|
||||
void setLinks() {
|
||||
setStart(&sourceId);
|
||||
sourceId.setNext(&setId);
|
||||
setId.setNext(&hkData);
|
||||
}
|
||||
|
||||
SerializeElement<object_id_t> sourceId;
|
||||
SerializeElement<uint32_t> setId;
|
||||
LinkedElement<SerializeIF> hkData;
|
||||
SerializeElement<object_id_t> sourceId;
|
||||
SerializeElement<uint32_t> setId;
|
||||
LinkedElement<SerializeIF> hkData;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ */
|
||||
|
||||
@@ -1,59 +1,60 @@
|
||||
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_
|
||||
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_
|
||||
|
||||
#include "../datapoollocal/LocalPoolDataSetBase.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();
|
||||
}
|
||||
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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) override {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void setLinks() {
|
||||
setStart(&objectId);
|
||||
objectId.setNext(&setId);
|
||||
setId.setNext(&reportingEnabled);
|
||||
reportingEnabled.setNext(&valid);
|
||||
valid.setNext(&collectionIntervalSeconds);
|
||||
collectionIntervalSeconds.setEnd();
|
||||
}
|
||||
|
||||
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;
|
||||
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_ */
|
||||
|
||||
@@ -1,117 +1,111 @@
|
||||
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGSNAPSHOT_H_
|
||||
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGSNAPSHOT_H_
|
||||
|
||||
#include "../serialize/SerialBufferAdapter.h"
|
||||
#include "../serialize/SerialLinkedListAdapter.h"
|
||||
#include "../datapoollocal/LocalPoolDataSetBase.h"
|
||||
#include "../datapoollocal/LocalPoolObjectBase.h"
|
||||
#include "../serialize/SerialBufferAdapter.h"
|
||||
#include "../serialize/SerialLinkedListAdapter.h"
|
||||
#include "../timemanager/CCSDSTime.h"
|
||||
|
||||
/**
|
||||
* @brief This helper class will be used to serialize and deserialize update housekeeping packets
|
||||
* into the store.
|
||||
*/
|
||||
class HousekeepingSnapshot:
|
||||
public SerializeIF {
|
||||
public:
|
||||
class HousekeepingSnapshot : public SerializeIF {
|
||||
public:
|
||||
/**
|
||||
* Update packet constructor for datasets.
|
||||
* @param cdsShort If a CSD short timestamp is used, a reference should be
|
||||
* supplied here
|
||||
* @param dataSetPtr Pointer to the dataset instance to serialize or deserialize the
|
||||
* data into
|
||||
*/
|
||||
HousekeepingSnapshot(CCSDSTime::CDS_short* cdsShort, LocalPoolDataSetBase* dataSetPtr)
|
||||
: timeStamp(reinterpret_cast<uint8_t*>(cdsShort)),
|
||||
timeStampSize(sizeof(CCSDSTime::CDS_short)),
|
||||
updateData(dataSetPtr){};
|
||||
|
||||
/**
|
||||
* Update packet constructor for datasets.
|
||||
* @param cdsShort If a CSD short timestamp is used, a reference should be
|
||||
* supplied here
|
||||
* @param dataSetPtr Pointer to the dataset instance to serialize or deserialize the
|
||||
* data into
|
||||
*/
|
||||
HousekeepingSnapshot(CCSDSTime::CDS_short* cdsShort, LocalPoolDataSetBase* dataSetPtr):
|
||||
timeStamp(reinterpret_cast<uint8_t*>(cdsShort)),
|
||||
timeStampSize(sizeof(CCSDSTime::CDS_short)), updateData(dataSetPtr) {};
|
||||
/**
|
||||
* Update packet constructor for datasets.
|
||||
* @param timeStamp Pointer to the buffer where the timestamp will be stored.
|
||||
* @param timeStampSize Size of the timestamp
|
||||
* @param dataSetPtr Pointer to the dataset instance to deserialize the data into
|
||||
*/
|
||||
HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize, LocalPoolDataSetBase* dataSetPtr)
|
||||
: timeStamp(timeStamp), timeStampSize(timeStampSize), updateData(dataSetPtr){};
|
||||
|
||||
/**
|
||||
* Update packet constructor for datasets.
|
||||
* @param timeStamp Pointer to the buffer where the timestamp will be stored.
|
||||
* @param timeStampSize Size of the timestamp
|
||||
* @param dataSetPtr Pointer to the dataset instance to deserialize the data into
|
||||
*/
|
||||
HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize,
|
||||
LocalPoolDataSetBase* dataSetPtr):
|
||||
timeStamp(timeStamp), timeStampSize(timeStampSize),
|
||||
updateData(dataSetPtr) {};
|
||||
/**
|
||||
* Update packet constructor for pool variables.
|
||||
* @param timeStamp
|
||||
* @param timeStampSize
|
||||
* @param dataSetPtr
|
||||
*/
|
||||
HousekeepingSnapshot(CCSDSTime::CDS_short* cdsShort, LocalPoolObjectBase* dataSetPtr)
|
||||
: timeStamp(reinterpret_cast<uint8_t*>(cdsShort)),
|
||||
timeStampSize(sizeof(CCSDSTime::CDS_short)),
|
||||
updateData(dataSetPtr){};
|
||||
|
||||
/**
|
||||
* Update packet constructor for pool variables.
|
||||
* @param timeStamp
|
||||
* @param timeStampSize
|
||||
* @param dataSetPtr
|
||||
*/
|
||||
HousekeepingSnapshot(CCSDSTime::CDS_short* cdsShort, LocalPoolObjectBase* dataSetPtr):
|
||||
timeStamp(reinterpret_cast<uint8_t*>(cdsShort)),
|
||||
timeStampSize(sizeof(CCSDSTime::CDS_short)), updateData(dataSetPtr) {};
|
||||
/**
|
||||
* Update packet constructor for pool variables.
|
||||
* @param timeStamp
|
||||
* @param timeStampSize
|
||||
* @param dataSetPtr
|
||||
*/
|
||||
HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize, LocalPoolObjectBase* dataSetPtr)
|
||||
: timeStamp(timeStamp), timeStampSize(timeStampSize), updateData(dataSetPtr){};
|
||||
|
||||
|
||||
/**
|
||||
* Update packet constructor for pool variables.
|
||||
* @param timeStamp
|
||||
* @param timeStampSize
|
||||
* @param dataSetPtr
|
||||
*/
|
||||
HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize,
|
||||
LocalPoolObjectBase* dataSetPtr):
|
||||
timeStamp(timeStamp), timeStampSize(timeStampSize),
|
||||
updateData(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(updateData == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
return updateData->serialize(buffer, size, maxSize, streamEndianness);
|
||||
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 (updateData == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
virtual size_t getSerializedSize() const {
|
||||
if(updateData == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return timeStampSize + updateData->getSerializedSize();
|
||||
return updateData->serialize(buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
|
||||
virtual size_t getSerializedSize() const {
|
||||
if (updateData == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return timeStampSize + updateData->getSerializedSize();
|
||||
}
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
SerializeIF::Endianness streamEndianness) override {
|
||||
if (*size < timeStampSize) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
SerializeIF::Endianness streamEndianness) override {
|
||||
if(*size < timeStampSize) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
|
||||
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(updateData == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if(*size < updateData->getSerializedSize()) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
|
||||
return updateData->deSerialize(buffer, size, streamEndianness);
|
||||
if (timeStamp != nullptr) {
|
||||
/* Endianness will always be MACHINE, so we can simply use memcpy
|
||||
here. */
|
||||
std::memcpy(timeStamp, *buffer, timeStampSize);
|
||||
*size -= timeStampSize;
|
||||
*buffer += timeStampSize;
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t* timeStamp = nullptr;
|
||||
size_t timeStampSize = 0;
|
||||
if (updateData == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (*size < updateData->getSerializedSize()) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
|
||||
SerializeIF* updateData = nullptr;
|
||||
return updateData->deSerialize(buffer, size, streamEndianness);
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t* timeStamp = nullptr;
|
||||
size_t timeStampSize = 0;
|
||||
|
||||
SerializeIF* updateData = nullptr;
|
||||
};
|
||||
|
||||
|
||||
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGSNAPSHOT_H_ */
|
||||
|
||||
@@ -1,90 +1,87 @@
|
||||
#include "fsfw/housekeeping/PeriodicHousekeepingHelper.h"
|
||||
|
||||
#include "fsfw/datapoollocal/LocalPoolDataSetBase.h"
|
||||
#include <cmath>
|
||||
|
||||
PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(
|
||||
LocalPoolDataSetBase* owner): owner(owner) {}
|
||||
#include "fsfw/datapoollocal/LocalPoolDataSetBase.h"
|
||||
|
||||
PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner)
|
||||
: owner(owner) {}
|
||||
|
||||
void PeriodicHousekeepingHelper::initialize(float collectionInterval,
|
||||
dur_millis_t minimumPeriodicInterval, uint8_t nonDiagIntervalFactor) {
|
||||
this->minimumPeriodicInterval = minimumPeriodicInterval;
|
||||
this->nonDiagIntervalFactor = nonDiagIntervalFactor;
|
||||
collectionIntervalTicks = intervalSecondsToIntervalTicks(collectionInterval);
|
||||
/* This will cause a checkOpNecessary call to be true immediately. I think it's okay
|
||||
if a HK packet is generated immediately instead of waiting one generation cycle. */
|
||||
internalTickCounter = collectionIntervalTicks;
|
||||
dur_millis_t minimumPeriodicInterval,
|
||||
uint8_t nonDiagIntervalFactor) {
|
||||
this->minimumPeriodicInterval = minimumPeriodicInterval;
|
||||
this->nonDiagIntervalFactor = nonDiagIntervalFactor;
|
||||
collectionIntervalTicks = intervalSecondsToIntervalTicks(collectionInterval);
|
||||
/* This will cause a checkOpNecessary call to be true immediately. I think it's okay
|
||||
if a HK packet is generated immediately instead of waiting one generation cycle. */
|
||||
internalTickCounter = collectionIntervalTicks;
|
||||
}
|
||||
|
||||
float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() const {
|
||||
return intervalTicksToSeconds(collectionIntervalTicks);
|
||||
return intervalTicksToSeconds(collectionIntervalTicks);
|
||||
}
|
||||
|
||||
bool PeriodicHousekeepingHelper::checkOpNecessary() {
|
||||
if(internalTickCounter >= collectionIntervalTicks) {
|
||||
internalTickCounter = 1;
|
||||
return true;
|
||||
}
|
||||
internalTickCounter++;
|
||||
return false;
|
||||
if (internalTickCounter >= collectionIntervalTicks) {
|
||||
internalTickCounter = 1;
|
||||
return true;
|
||||
}
|
||||
internalTickCounter++;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t PeriodicHousekeepingHelper::intervalSecondsToIntervalTicks(
|
||||
float collectionIntervalSeconds) {
|
||||
if(owner == nullptr) {
|
||||
return 0;
|
||||
float collectionIntervalSeconds) {
|
||||
if (owner == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
bool isDiagnostics = owner->isDiagnostics();
|
||||
|
||||
/* Avoid division by zero */
|
||||
if (minimumPeriodicInterval == 0) {
|
||||
if (isDiagnostics) {
|
||||
/* Perform operation each cycle */
|
||||
return 1;
|
||||
} else {
|
||||
return nonDiagIntervalFactor;
|
||||
}
|
||||
bool isDiagnostics = owner->isDiagnostics();
|
||||
|
||||
/* Avoid division by zero */
|
||||
if(minimumPeriodicInterval == 0) {
|
||||
if(isDiagnostics) {
|
||||
/* Perform operation each cycle */
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return nonDiagIntervalFactor;
|
||||
}
|
||||
} else {
|
||||
dur_millis_t intervalInMs = collectionIntervalSeconds * 1000;
|
||||
uint32_t divisor = minimumPeriodicInterval;
|
||||
if (not isDiagnostics) {
|
||||
/* We need to multiply the divisor because non-diagnostics only
|
||||
allow a multiple of the minimum periodic interval */
|
||||
divisor *= nonDiagIntervalFactor;
|
||||
}
|
||||
else {
|
||||
dur_millis_t intervalInMs = collectionIntervalSeconds * 1000;
|
||||
uint32_t divisor = minimumPeriodicInterval;
|
||||
if(not isDiagnostics) {
|
||||
/* We need to multiply the divisor because non-diagnostics only
|
||||
allow a multiple of the minimum periodic interval */
|
||||
divisor *= nonDiagIntervalFactor;
|
||||
}
|
||||
uint32_t ticks = std::ceil(static_cast<float>(intervalInMs) / divisor);
|
||||
if(not isDiagnostics) {
|
||||
/* Now we need to multiply the calculated ticks with the factor as as well
|
||||
because the minimum tick count to generate a non-diagnostic is the factor itself.
|
||||
uint32_t ticks = std::ceil(static_cast<float>(intervalInMs) / divisor);
|
||||
if (not isDiagnostics) {
|
||||
/* Now we need to multiply the calculated ticks with the factor as as well
|
||||
because the minimum tick count to generate a non-diagnostic is the factor itself.
|
||||
|
||||
Example calculation for non-diagnostic with
|
||||
0.4 second interval and 0.2 second task interval.
|
||||
Resultant tick count of 5 is equal to operation each second.
|
||||
Example calculation for non-diagnostic with
|
||||
0.4 second interval and 0.2 second task interval.
|
||||
Resultant tick count of 5 is equal to operation each second.
|
||||
|
||||
Examle calculation for non-diagnostic with 2.0 second interval and 0.2 second
|
||||
task interval.
|
||||
Resultant tick count of 10 is equal to operatin every 2 seconds.
|
||||
Examle calculation for non-diagnostic with 2.0 second interval and 0.2 second
|
||||
task interval.
|
||||
Resultant tick count of 10 is equal to operatin every 2 seconds.
|
||||
|
||||
Example calculation for diagnostic with 0.4 second interval and 0.3
|
||||
second task interval. Resulting tick count of 2 is equal to operation
|
||||
every 0.6 seconds. */
|
||||
ticks *= nonDiagIntervalFactor;
|
||||
}
|
||||
return ticks;
|
||||
Example calculation for diagnostic with 0.4 second interval and 0.3
|
||||
second task interval. Resulting tick count of 2 is equal to operation
|
||||
every 0.6 seconds. */
|
||||
ticks *= nonDiagIntervalFactor;
|
||||
}
|
||||
return ticks;
|
||||
}
|
||||
}
|
||||
|
||||
float PeriodicHousekeepingHelper::intervalTicksToSeconds(
|
||||
uint32_t collectionInterval) const {
|
||||
/* Number of ticks times the minimum interval is in milliseconds, so we divide by 1000 to get
|
||||
the value in seconds */
|
||||
return static_cast<float>(collectionInterval * minimumPeriodicInterval / 1000.0);
|
||||
float PeriodicHousekeepingHelper::intervalTicksToSeconds(uint32_t collectionInterval) const {
|
||||
/* Number of ticks times the minimum interval is in milliseconds, so we divide by 1000 to get
|
||||
the value in seconds */
|
||||
return static_cast<float>(collectionInterval * minimumPeriodicInterval / 1000.0);
|
||||
}
|
||||
|
||||
void PeriodicHousekeepingHelper::changeCollectionInterval(
|
||||
float newIntervalSeconds) {
|
||||
collectionIntervalTicks = intervalSecondsToIntervalTicks(newIntervalSeconds);
|
||||
void PeriodicHousekeepingHelper::changeCollectionInterval(float newIntervalSeconds) {
|
||||
collectionIntervalTicks = intervalSecondsToIntervalTicks(newIntervalSeconds);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
#ifndef FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_
|
||||
#define FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_
|
||||
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
#include <cstdint>
|
||||
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
|
||||
class LocalPoolDataSetBase;
|
||||
|
||||
class PeriodicHousekeepingHelper {
|
||||
public:
|
||||
PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner);
|
||||
public:
|
||||
PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner);
|
||||
|
||||
void initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
||||
uint8_t nonDiagIntervalFactor);
|
||||
void initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
||||
uint8_t nonDiagIntervalFactor);
|
||||
|
||||
void changeCollectionInterval(float newInterval);
|
||||
float getCollectionIntervalInSeconds() const;
|
||||
bool checkOpNecessary();
|
||||
void changeCollectionInterval(float newInterval);
|
||||
float getCollectionIntervalInSeconds() const;
|
||||
bool checkOpNecessary();
|
||||
|
||||
private:
|
||||
LocalPoolDataSetBase* owner = nullptr;
|
||||
uint8_t nonDiagIntervalFactor = 0;
|
||||
private:
|
||||
LocalPoolDataSetBase* owner = nullptr;
|
||||
uint8_t nonDiagIntervalFactor = 0;
|
||||
|
||||
uint32_t intervalSecondsToIntervalTicks(float collectionIntervalSeconds);
|
||||
float intervalTicksToSeconds(uint32_t collectionInterval) const;
|
||||
|
||||
dur_millis_t minimumPeriodicInterval = 0;
|
||||
uint32_t internalTickCounter = 1;
|
||||
uint32_t collectionIntervalTicks = 0;
|
||||
uint32_t intervalSecondsToIntervalTicks(float collectionIntervalSeconds);
|
||||
float intervalTicksToSeconds(uint32_t collectionInterval) const;
|
||||
|
||||
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