2020-05-17 01:17:11 +02:00
|
|
|
#include <framework/housekeeping/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-06-24 02:00:26 +02:00
|
|
|
void HousekeepingMessage::setHkReportMessage(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);
|
|
|
|
message->setParameter(storeId.raw);
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|
|
|
|
|
2020-06-24 02:00:26 +02:00
|
|
|
void HousekeepingMessage::setHkDiagnosticsMessage(CommandMessage* message,
|
|
|
|
sid_t sid, store_address_t storeId) {
|
|
|
|
message->setCommand(DIAGNOSTICS_REPORT);
|
|
|
|
setSid(message, sid);
|
|
|
|
setParameter(message, storeId.raw);
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|
2020-06-24 02:00:26 +02:00
|
|
|
sid_t HousekeepingMessage::getSid(const CommandMessage* message) {
|
2020-06-13 17:37:48 +02:00
|
|
|
sid_t sid;
|
2020-06-24 02:00:26 +02:00
|
|
|
std::memcpy(&sid.raw, message->getData(), sizeof(sid.raw));
|
2020-06-13 17:37:48 +02:00
|
|
|
return sid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-24 02:00:26 +02:00
|
|
|
sid_t HousekeepingMessage::getHkReportMessage(const CommandMessage *message,
|
|
|
|
store_address_t *storeIdToSet) {
|
2020-06-14 19:03:28 +02:00
|
|
|
if(storeIdToSet != nullptr) {
|
2020-06-24 02:00:26 +02:00
|
|
|
*storeIdToSet = getParameter(message);
|
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-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
|
|
|
}
|
2020-06-14 19:03:28 +02:00
|
|
|
|
|
|
|
|
2020-06-24 02:00:26 +02:00
|
|
|
void HousekeepingMessage::setParameter(CommandMessage *message,
|
|
|
|
uint32_t parameter) {
|
|
|
|
message->setParameter3(parameter);
|
2020-06-14 19:03:28 +02:00
|
|
|
}
|
|
|
|
|
2020-06-24 02:00:26 +02:00
|
|
|
uint32_t HousekeepingMessage::getParameter(const CommandMessage *message) {
|
|
|
|
return message->getParameter3();
|
2020-06-14 19:03:28 +02:00
|
|
|
}
|