2020-08-23 20:27:00 +02:00
|
|
|
#include "HousekeepingMessage.h"
|
2020-06-13 17:37:48 +02:00
|
|
|
#include <cstring>
|
2020-05-17 01:17:11 +02:00
|
|
|
|
2020-06-14 19:03:28 +02:00
|
|
|
HousekeepingMessage::~HousekeepingMessage() {}
|
|
|
|
|
2020-09-14 18:01:48 +02:00
|
|
|
void HousekeepingMessage::setHkReportReply(CommandMessage* message, sid_t sid,
|
2020-06-13 17:37:48 +02:00
|
|
|
store_address_t storeId) {
|
2020-06-24 02:00:26 +02:00
|
|
|
message->setCommand(HK_REPORT);
|
|
|
|
message->setMessageSize(HK_MESSAGE_SIZE);
|
|
|
|
setSid(message, sid);
|
2020-08-10 18:33:28 +02:00
|
|
|
message->setParameter3(storeId.raw);
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|
|
|
|
|
2020-09-14 18:01:48 +02:00
|
|
|
void HousekeepingMessage::setHkDiagnosticsReply(CommandMessage* message,
|
2020-06-24 02:00:26 +02:00
|
|
|
sid_t sid, store_address_t storeId) {
|
|
|
|
message->setCommand(DIAGNOSTICS_REPORT);
|
2020-06-24 02:02:57 +02:00
|
|
|
message->setMessageSize(HK_MESSAGE_SIZE);
|
2020-06-24 02:00:26 +02:00
|
|
|
setSid(message, sid);
|
2020-08-10 18:33:28 +02:00
|
|
|
message->setParameter3(storeId.raw);
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|
|
|
|
|
2020-09-14 18:01:48 +02:00
|
|
|
sid_t HousekeepingMessage::getHkDataReply(const CommandMessage *message,
|
2020-06-24 02:00:26 +02:00
|
|
|
store_address_t *storeIdToSet) {
|
2020-06-14 19:03:28 +02:00
|
|
|
if(storeIdToSet != nullptr) {
|
2020-08-10 18:33:28 +02:00
|
|
|
*storeIdToSet = message->getParameter3();
|
2020-06-14 19:03:28 +02:00
|
|
|
}
|
2020-06-24 02:00:26 +02:00
|
|
|
return getSid(message);
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|
|
|
|
|
2020-09-14 18:01:48 +02:00
|
|
|
void HousekeepingMessage::setToggleReportingCommand(CommandMessage *message,
|
2020-09-11 14:06:08 +02:00
|
|
|
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) {
|
2020-09-19 01:17:43 +02:00
|
|
|
message->setCommand(ENABLE_PERIODIC_HK_REPORT_GENERATION);
|
2020-09-11 14:06:08 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
message->setCommand(DISABLE_PERIODIC_HK_REPORT_GENERATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setSid(message, sid);
|
|
|
|
}
|
|
|
|
|
2020-09-14 18:01:48 +02:00
|
|
|
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);
|
|
|
|
}
|
2020-09-11 14:06:08 +02:00
|
|
|
|
2020-09-19 17:08:08 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-06-24 02:02:57 +02:00
|
|
|
sid_t HousekeepingMessage::getSid(const CommandMessage* message) {
|
|
|
|
sid_t sid;
|
|
|
|
std::memcpy(&sid.raw, message->getData(), sizeof(sid.raw));
|
|
|
|
return sid;
|
|
|
|
}
|
|
|
|
|
2020-06-24 02:00:26 +02:00
|
|
|
void HousekeepingMessage::setSid(CommandMessage *message, sid_t sid) {
|
|
|
|
std::memcpy(message->getData(), &sid.raw, sizeof(sid.raw));
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|