huge progress on hk + testing
This commit is contained in:
parent
757d2275ea
commit
ba56f48e8e
@ -35,7 +35,7 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner,
|
|||||||
AcceptsHkPacketsIF* hkPacketReceiver =
|
AcceptsHkPacketsIF* hkPacketReceiver =
|
||||||
objectManager->get<AcceptsHkPacketsIF>(defaultHkDestination);
|
objectManager->get<AcceptsHkPacketsIF>(defaultHkDestination);
|
||||||
if(hkPacketReceiver != nullptr) {
|
if(hkPacketReceiver != nullptr) {
|
||||||
defaultHkDestinationId = hkPacketReceiver->getHkQueue();
|
hkDestinationId = hkPacketReceiver->getHkQueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,9 +78,6 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
|
|||||||
ReturnValue_t LocalDataPoolManager::performHkOperation() {
|
ReturnValue_t LocalDataPoolManager::performHkOperation() {
|
||||||
for(auto& hkReceiversIter: hkReceiversMap) {
|
for(auto& hkReceiversIter: hkReceiversMap) {
|
||||||
HkReceiver* receiver = &hkReceiversIter.second;
|
HkReceiver* receiver = &hkReceiversIter.second;
|
||||||
if(not receiver->reportingEnabled) {
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(receiver->reportingType) {
|
switch(receiver->reportingType) {
|
||||||
case(ReportingType::PERIODIC): {
|
case(ReportingType::PERIODIC): {
|
||||||
@ -118,7 +115,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid,
|
|||||||
hkReceiver.dataId.dataSetSid = sid;
|
hkReceiver.dataId.dataSetSid = sid;
|
||||||
hkReceiver.reportingType = ReportingType::PERIODIC;
|
hkReceiver.reportingType = ReportingType::PERIODIC;
|
||||||
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
|
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
|
||||||
hkReceiver.reportingEnabled = enableReporting;
|
|
||||||
if(not isDiagnostics) {
|
if(not isDiagnostics) {
|
||||||
hkReceiver.hkParameter.collectionIntervalTicks =
|
hkReceiver.hkParameter.collectionIntervalTicks =
|
||||||
intervalSecondsToInterval(isDiagnostics, collectionInterval *
|
intervalSecondsToInterval(isDiagnostics, collectionInterval *
|
||||||
@ -129,7 +126,13 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid,
|
|||||||
intervalSecondsToInterval(isDiagnostics, collectionInterval);
|
intervalSecondsToInterval(isDiagnostics, collectionInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
hkReceiver.isDiagnostics = isDiagnostics;
|
LocalPoolDataSetBase* dataSet = dynamic_cast<LocalPoolDataSetBase*>(
|
||||||
|
owner->getDataSetHandle(sid));
|
||||||
|
if(dataSet != nullptr) {
|
||||||
|
dataSet->setReportingEnabled(enableReporting);
|
||||||
|
dataSet->setIsDiagnostic(isDiagnostics);
|
||||||
|
}
|
||||||
|
|
||||||
hkReceiver.intervalCounter = 1;
|
hkReceiver.intervalCounter = 1;
|
||||||
|
|
||||||
hkReceiversMap.emplace(packetDestination, hkReceiver);
|
hkReceiversMap.emplace(packetDestination, hkReceiver);
|
||||||
@ -139,16 +142,51 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid,
|
|||||||
ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
||||||
CommandMessage* message) {
|
CommandMessage* message) {
|
||||||
Command_t command = message->getCommand();
|
Command_t command = message->getCommand();
|
||||||
|
sid_t sid = HousekeepingMessage::getSid(message);
|
||||||
switch(command) {
|
switch(command) {
|
||||||
|
case(HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION):
|
||||||
|
return togglePeriodicGeneration(sid, true, true);
|
||||||
|
case(HousekeepingMessage::DISABLE_PERIODIC_DIAGNOSTICS_GENERATION):
|
||||||
|
return togglePeriodicGeneration(sid, false, true);
|
||||||
|
case(HousekeepingMessage::ENABLE_PERIODIC_HK_REPORT_GENERATION):
|
||||||
|
return togglePeriodicGeneration(sid, true, false);
|
||||||
|
case(HousekeepingMessage::DISABLE_PERIODIC_HK_REPORT_GENERATION):
|
||||||
|
return togglePeriodicGeneration(sid, false, false);
|
||||||
|
|
||||||
case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES):
|
case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES):
|
||||||
case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES):
|
case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES):
|
||||||
//return generateSetStructurePacket(message->getSid());
|
return generateSetStructurePacket(sid);
|
||||||
|
|
||||||
|
case(HousekeepingMessage::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL):
|
||||||
|
case(HousekeepingMessage::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL): {
|
||||||
|
float newCollIntvl = 0;
|
||||||
|
HousekeepingMessage::getCollectionIntervalModificationCommand(message,
|
||||||
|
&newCollIntvl);
|
||||||
|
if(command == HousekeepingMessage::
|
||||||
|
MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL) {
|
||||||
|
return changeCollectionInterval(sid, newCollIntvl, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return changeCollectionInterval(sid, newCollIntvl, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT):
|
case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT):
|
||||||
|
case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): {
|
||||||
|
LocalPoolDataSetBase* dataSet = dynamic_cast<LocalPoolDataSetBase*>(
|
||||||
|
owner->getDataSetHandle(sid));
|
||||||
|
if(command == HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT
|
||||||
|
and dataSet->getIsDiagnostics()) {
|
||||||
|
return WRONG_HK_PACKET_TYPE;
|
||||||
|
}
|
||||||
|
else if(command == HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT
|
||||||
|
and not dataSet->getIsDiagnostics()) {
|
||||||
|
return WRONG_HK_PACKET_TYPE;
|
||||||
|
}
|
||||||
return generateHousekeepingPacket(HousekeepingMessage::getSid(message),
|
return generateHousekeepingPacket(HousekeepingMessage::getSid(message),
|
||||||
false, true);
|
dataSet, true);
|
||||||
case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT):
|
}
|
||||||
return generateHousekeepingPacket(HousekeepingMessage::getSid(message),
|
|
||||||
true, true);
|
|
||||||
default:
|
default:
|
||||||
return CommandMessageIF::UNKNOWN_COMMAND;
|
return CommandMessageIF::UNKNOWN_COMMAND;
|
||||||
}
|
}
|
||||||
@ -175,17 +213,17 @@ const HasLocalDataPoolIF* LocalDataPoolManager::getOwner() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||||
bool isDiagnostics, bool forDownlink, MessageQueueId_t destination) {
|
LocalPoolDataSetBase* dataSet, bool forDownlink,
|
||||||
LocalPoolDataSetBase* dataSetToSerialize =
|
MessageQueueId_t destination) {
|
||||||
dynamic_cast<LocalPoolDataSetBase*>(owner->getDataSetHandle(sid));
|
if(dataSet == nullptr) {
|
||||||
if(dataSetToSerialize == nullptr) {
|
// Configuration error.
|
||||||
sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
|
sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
|
||||||
" Set ID not found or dataset not assigned!" << std::endl;
|
" Set ID not found or dataset not assigned!" << std::endl;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
store_address_t storeId;
|
store_address_t storeId;
|
||||||
HousekeepingPacketDownlink hkPacket(sid, dataSetToSerialize);
|
HousekeepingPacketDownlink hkPacket(sid, dataSet);
|
||||||
size_t serializedSize = 0;
|
size_t serializedSize = 0;
|
||||||
ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, storeId,
|
ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, storeId,
|
||||||
forDownlink, &serializedSize);
|
forDownlink, &serializedSize);
|
||||||
@ -195,7 +233,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
|||||||
|
|
||||||
// and now we set a HK message and send it the HK packet destination.
|
// and now we set a HK message and send it the HK packet destination.
|
||||||
CommandMessage hkMessage;
|
CommandMessage hkMessage;
|
||||||
if(isDiagnostics) {
|
if(dataSet->getIsDiagnostics()) {
|
||||||
HousekeepingMessage::setHkDiagnosticsReply(&hkMessage, sid, storeId);
|
HousekeepingMessage::setHkDiagnosticsReply(&hkMessage, sid, storeId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -206,11 +244,11 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
|||||||
return QUEUE_OR_DESTINATION_NOT_SET;
|
return QUEUE_OR_DESTINATION_NOT_SET;
|
||||||
}
|
}
|
||||||
if(destination == MessageQueueIF::NO_QUEUE) {
|
if(destination == MessageQueueIF::NO_QUEUE) {
|
||||||
if(defaultHkDestinationId == MessageQueueIF::NO_QUEUE) {
|
if(hkDestinationId == MessageQueueIF::NO_QUEUE) {
|
||||||
// error, all destinations invalid
|
// error, all destinations invalid
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
destination = defaultHkDestinationId;
|
destination = hkDestinationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hkQueue->sendMessage(destination, &hkMessage);
|
return hkQueue->sendMessage(destination, &hkMessage);
|
||||||
@ -273,8 +311,15 @@ void LocalDataPoolManager::setNonDiagnosticIntervalFactor(
|
|||||||
void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver* receiver) {
|
void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver* receiver) {
|
||||||
if(receiver->intervalCounter >=
|
if(receiver->intervalCounter >=
|
||||||
receiver->hkParameter.collectionIntervalTicks) {
|
receiver->hkParameter.collectionIntervalTicks) {
|
||||||
|
sid_t sid = receiver->dataId.dataSetSid;
|
||||||
|
LocalPoolDataSetBase* dataSet = dynamic_cast<LocalPoolDataSetBase*>(
|
||||||
|
owner->getDataSetHandle(sid));
|
||||||
|
if(not dataSet->getReportingEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t result = generateHousekeepingPacket(
|
ReturnValue_t result = generateHousekeepingPacket(
|
||||||
receiver->dataId.dataSetSid, receiver->isDiagnostics, true);
|
sid, dataSet, true);
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
// configuration error
|
// configuration error
|
||||||
sif::debug << "LocalDataPoolManager::performHkOperation:"
|
sif::debug << "LocalDataPoolManager::performHkOperation:"
|
||||||
@ -312,3 +357,43 @@ float LocalDataPoolManager::intervalToIntervalSeconds(bool isDiagnostics,
|
|||||||
regularMinimumInterval);
|
regularMinimumInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid,
|
||||||
|
bool enable, bool isDiagnostics) {
|
||||||
|
LocalPoolDataSetBase* dataSet = dynamic_cast<LocalPoolDataSetBase*>(
|
||||||
|
owner->getDataSetHandle(sid));
|
||||||
|
if((dataSet->getIsDiagnostics() and not isDiagnostics) or
|
||||||
|
(not dataSet->getIsDiagnostics() and isDiagnostics)) {
|
||||||
|
return WRONG_HK_PACKET_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((dataSet->getReportingEnabled() and enable) or
|
||||||
|
(not dataSet->getReportingEnabled() and not enable)) {
|
||||||
|
return REPORTING_STATUS_UNCHANGED;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSet->setReportingEnabled(enable);
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid,
|
||||||
|
float newCollectionInterval, bool isDiagnostics) {
|
||||||
|
LocalPoolDataSetBase* dataSet = dynamic_cast<LocalPoolDataSetBase*>(
|
||||||
|
owner->getDataSetHandle(sid));
|
||||||
|
bool targetIsDiagnostics = dataSet->getIsDiagnostics();
|
||||||
|
if((targetIsDiagnostics and not isDiagnostics) or
|
||||||
|
(not targetIsDiagnostics and isDiagnostics)) {
|
||||||
|
return WRONG_HK_PACKET_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto& receiver: hkReceiversMap) {
|
||||||
|
if(receiver.second.reportingType != ReportingType::PERIODIC) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t newInterval = intervalSecondsToInterval(isDiagnostics,
|
||||||
|
newCollectionInterval);
|
||||||
|
receiver.second.hkParameter.collectionIntervalTicks = newInterval;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
@ -23,7 +23,7 @@ class LocalDataSetBase;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class is the managing instance for local data pool.
|
* @brief This class is the managing instance for the local data pool.
|
||||||
* @details
|
* @details
|
||||||
* The actual data pool structure is a member of this class. Any class which
|
* The actual data pool structure is a member of this class. Any class which
|
||||||
* has a local data pool shall have this class as a member and implement
|
* has a local data pool shall have this class as a member and implement
|
||||||
@ -49,11 +49,13 @@ class LocalDataPoolManager {
|
|||||||
public:
|
public:
|
||||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER;
|
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER;
|
||||||
|
|
||||||
static constexpr ReturnValue_t POOL_ENTRY_NOT_FOUND = MAKE_RETURN_CODE(0x0);
|
static constexpr ReturnValue_t POOL_ENTRY_NOT_FOUND = MAKE_RETURN_CODE(0x00);
|
||||||
static constexpr ReturnValue_t POOL_ENTRY_TYPE_CONFLICT = MAKE_RETURN_CODE(0x1);
|
static constexpr ReturnValue_t POOL_ENTRY_TYPE_CONFLICT = MAKE_RETURN_CODE(0x01);
|
||||||
|
|
||||||
static constexpr ReturnValue_t QUEUE_OR_DESTINATION_NOT_SET = MAKE_RETURN_CODE(0x2);
|
static constexpr ReturnValue_t QUEUE_OR_DESTINATION_NOT_SET = MAKE_RETURN_CODE(0x02);
|
||||||
|
|
||||||
|
static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(0x03);
|
||||||
|
static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(0x04);
|
||||||
/**
|
/**
|
||||||
* This constructor is used by a class which wants to implement
|
* This constructor is used by a class which wants to implement
|
||||||
* a personal local data pool. The queueToUse can be supplied if it
|
* a personal local data pool. The queueToUse can be supplied if it
|
||||||
@ -110,7 +112,7 @@ public:
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ReturnValue_t generateHousekeepingPacket(sid_t sid,
|
ReturnValue_t generateHousekeepingPacket(sid_t sid,
|
||||||
bool isDiagnostics, bool forDownlink,
|
LocalPoolDataSetBase* dataSet, bool forDownlink,
|
||||||
MessageQueueId_t destination = MessageQueueIF::NO_QUEUE);
|
MessageQueueId_t destination = MessageQueueIF::NO_QUEUE);
|
||||||
ReturnValue_t generateSetStructurePacket(sid_t sid);
|
ReturnValue_t generateSetStructurePacket(sid_t sid);
|
||||||
|
|
||||||
@ -169,7 +171,7 @@ private:
|
|||||||
|
|
||||||
/** Default receiver for periodic HK packets */
|
/** Default receiver for periodic HK packets */
|
||||||
static object_id_t defaultHkDestination;
|
static object_id_t defaultHkDestination;
|
||||||
MessageQueueId_t defaultHkDestinationId = MessageQueueIF::NO_QUEUE;
|
MessageQueueId_t hkDestinationId = MessageQueueIF::NO_QUEUE;
|
||||||
|
|
||||||
/** The data pool manager will keep an internal map of HK receivers. */
|
/** The data pool manager will keep an internal map of HK receivers. */
|
||||||
struct HkReceiver {
|
struct HkReceiver {
|
||||||
@ -185,8 +187,11 @@ private:
|
|||||||
DataId dataId;
|
DataId dataId;
|
||||||
|
|
||||||
ReportingType reportingType = ReportingType::PERIODIC;
|
ReportingType reportingType = ReportingType::PERIODIC;
|
||||||
|
// SHOULDDO: it would be nice to also have the object ID instead of
|
||||||
|
// a queue (or in addition).. but the FSFW is not ready for that yet.
|
||||||
|
// Also, an object can have multiple queues.
|
||||||
MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE;
|
MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE;
|
||||||
bool reportingEnabled = true;
|
|
||||||
/** Different members of this union will be used depending on reporting
|
/** Different members of this union will be used depending on reporting
|
||||||
type */
|
type */
|
||||||
union HkParameter {
|
union HkParameter {
|
||||||
@ -196,7 +201,6 @@ private:
|
|||||||
bool hkDataChanged;
|
bool hkDataChanged;
|
||||||
};
|
};
|
||||||
HkParameter hkParameter;
|
HkParameter hkParameter;
|
||||||
bool isDiagnostics;
|
|
||||||
/** General purpose counter which is used for periodic generation. */
|
/** General purpose counter which is used for periodic generation. */
|
||||||
uint32_t intervalCounter;
|
uint32_t intervalCounter;
|
||||||
};
|
};
|
||||||
@ -245,7 +249,6 @@ private:
|
|||||||
template <class T> ReturnValue_t fetchPoolEntry(lp_id_t localPoolId,
|
template <class T> ReturnValue_t fetchPoolEntry(lp_id_t localPoolId,
|
||||||
PoolEntry<T> **poolEntry);
|
PoolEntry<T> **poolEntry);
|
||||||
|
|
||||||
void setMinimalSamplingFrequency(float frequencySeconds);
|
|
||||||
ReturnValue_t serializeHkPacketIntoStore(
|
ReturnValue_t serializeHkPacketIntoStore(
|
||||||
HousekeepingPacketDownlink& hkPacket,
|
HousekeepingPacketDownlink& hkPacket,
|
||||||
store_address_t& storeId, bool forDownlink, size_t* serializedSize);
|
store_address_t& storeId, bool forDownlink, size_t* serializedSize);
|
||||||
@ -256,6 +259,10 @@ private:
|
|||||||
uint32_t collectionInterval);
|
uint32_t collectionInterval);
|
||||||
|
|
||||||
void performPeriodicHkGeneration(HkReceiver* hkReceiver);
|
void performPeriodicHkGeneration(HkReceiver* hkReceiver);
|
||||||
|
ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable,
|
||||||
|
bool isDiagnostics);
|
||||||
|
ReturnValue_t changeCollectionInterval(sid_t sid,
|
||||||
|
float newCollectionInterval, bool isDiagnostics);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +175,22 @@ void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const {
|
|||||||
*byte |= 1 << shiftNumber;
|
*byte |= 1 << shiftNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalPoolDataSetBase::setIsDiagnostic(bool isDiagnostics) {
|
||||||
|
this->isDiagnostics = isDiagnostics;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalPoolDataSetBase::getIsDiagnostics() const {
|
||||||
|
return isDiagnostics;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalPoolDataSetBase::setReportingEnabled(bool reportingEnabled) {
|
||||||
|
this->reportingEnabled = reportingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalPoolDataSetBase::getReportingEnabled() const {
|
||||||
|
return reportingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte,
|
bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte,
|
||||||
uint8_t position) const {
|
uint8_t position) const {
|
||||||
if(position > 7) {
|
if(position > 7) {
|
||||||
|
@ -32,6 +32,7 @@ class LocalDataPoolManager;
|
|||||||
* @ingroup data_pool
|
* @ingroup data_pool
|
||||||
*/
|
*/
|
||||||
class LocalPoolDataSetBase: public PoolDataSetBase {
|
class LocalPoolDataSetBase: public PoolDataSetBase {
|
||||||
|
friend class LocalDataPoolManager;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor for the creator of local pool data.
|
* @brief Constructor for the creator of local pool data.
|
||||||
@ -97,11 +98,23 @@ public:
|
|||||||
* If this is true, all contained datasets will also be set recursively.
|
* If this is true, all contained datasets will also be set recursively.
|
||||||
*/
|
*/
|
||||||
void setValidity(bool valid, bool setEntriesRecursively);
|
void setValidity(bool valid, bool setEntriesRecursively);
|
||||||
|
|
||||||
bool isValid() const override;
|
bool isValid() const override;
|
||||||
|
|
||||||
|
void setIsDiagnostic(bool diagnostics);
|
||||||
|
bool getIsDiagnostics() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
sid_t sid;
|
sid_t sid;
|
||||||
|
|
||||||
|
bool isDiagnostics = false;
|
||||||
|
|
||||||
|
void setReportingEnabled(bool enabled);
|
||||||
|
bool getReportingEnabled() const;
|
||||||
|
/**
|
||||||
|
* Used for periodic generation.
|
||||||
|
*/
|
||||||
|
bool reportingEnabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the valid state of a dataset is always relevant to the whole
|
* If the valid state of a dataset is always relevant to the whole
|
||||||
* data set we can use this flag.
|
* data set we can use this flag.
|
||||||
|
@ -38,13 +38,14 @@ public:
|
|||||||
* @param poolId ID of the local pool entry.
|
* @param poolId ID of the local pool entry.
|
||||||
* @param hkOwner Pointer of the owner. This will generally be the calling
|
* @param hkOwner Pointer of the owner. This will generally be the calling
|
||||||
* class itself which passes "this".
|
* class itself which passes "this".
|
||||||
* @param setReadWriteMode Specify the read-write mode of the pool variable.
|
|
||||||
* @param dataSet The data set in which the variable shall register itself.
|
* @param dataSet The data set in which the variable shall register itself.
|
||||||
* If nullptr, the variable is not registered.
|
* If nullptr, the variable is not registered.
|
||||||
|
* @param setReadWriteMode Specify the read-write mode of the pool variable.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
LocalPoolVar(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
|
LocalPoolVar(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
|
||||||
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE,
|
DataSetIF* dataSet = nullptr,
|
||||||
DataSetIF* dataSet = nullptr);
|
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor is used by data users like controllers to have
|
* This constructor is used by data users like controllers to have
|
||||||
@ -58,13 +59,14 @@ public:
|
|||||||
* the pool variable in that dataset directly.
|
* the pool variable in that dataset directly.
|
||||||
* @param poolId ID of the local pool entry.
|
* @param poolId ID of the local pool entry.
|
||||||
* @param hkOwner object ID of the pool owner.
|
* @param hkOwner object ID of the pool owner.
|
||||||
* @param setReadWriteMode Specify the read-write mode of the pool variable.
|
|
||||||
* @param dataSet The data set in which the variable shall register itself.
|
* @param dataSet The data set in which the variable shall register itself.
|
||||||
* If nullptr, the variable is not registered.
|
* If nullptr, the variable is not registered.
|
||||||
|
* @param setReadWriteMode Specify the read-write mode of the pool variable.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
LocalPoolVar(lp_id_t poolId, object_id_t poolOwner,
|
LocalPoolVar(lp_id_t poolId, object_id_t poolOwner,
|
||||||
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE,
|
DataSetIF* dataSet = nullptr,
|
||||||
DataSetIF* dataSet = nullptr);
|
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
|
||||||
|
|
||||||
virtual~ LocalPoolVar() {};
|
virtual~ LocalPoolVar() {};
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId,
|
inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId,
|
||||||
HasLocalDataPoolIF* hkOwner, pool_rwm_t setReadWriteMode,
|
HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet,
|
||||||
DataSetIF* dataSet):
|
pool_rwm_t setReadWriteMode):
|
||||||
localPoolId(poolId),readWriteMode(setReadWriteMode) {
|
localPoolId(poolId),readWriteMode(setReadWriteMode) {
|
||||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||||
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the "
|
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the "
|
||||||
@ -27,7 +27,7 @@ inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId,
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner,
|
inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner,
|
||||||
pool_rwm_t setReadWriteMode, DataSetIF *dataSet):
|
DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||||
readWriteMode(setReadWriteMode) {
|
readWriteMode(setReadWriteMode) {
|
||||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||||
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the "
|
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the "
|
||||||
|
@ -47,8 +47,9 @@ public:
|
|||||||
* If nullptr, the variable is not registered.
|
* If nullptr, the variable is not registered.
|
||||||
*/
|
*/
|
||||||
LocalPoolVector(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
|
LocalPoolVector(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
|
||||||
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE,
|
DataSetIF* dataSet = nullptr,
|
||||||
DataSetIF* dataSet = nullptr);
|
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor is used by data users like controllers to have
|
* This constructor is used by data users like controllers to have
|
||||||
@ -65,8 +66,9 @@ public:
|
|||||||
* If nullptr, the variable is not registered.
|
* If nullptr, the variable is not registered.
|
||||||
*/
|
*/
|
||||||
LocalPoolVector(lp_id_t poolId, object_id_t poolOwner,
|
LocalPoolVector(lp_id_t poolId, object_id_t poolOwner,
|
||||||
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE,
|
DataSetIF* dataSet = nullptr,
|
||||||
DataSetIF* dataSet = nullptr);
|
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is the local copy of the data pool entry.
|
* @brief This is the local copy of the data pool entry.
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(lp_id_t poolId,
|
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(lp_id_t poolId,
|
||||||
HasLocalDataPoolIF* hkOwner, pool_rwm_t setReadWriteMode,
|
HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet,
|
||||||
DataSetIF* dataSet) :
|
pool_rwm_t setReadWriteMode):
|
||||||
localPoolId(poolId), valid(false), readWriteMode(setReadWriteMode) {
|
localPoolId(poolId), valid(false), readWriteMode(setReadWriteMode) {
|
||||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||||
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the "
|
sif::warning << "LocalPoolVector: PoolVariableIF::NO_PARAMETER passed "
|
||||||
"NO_PARAMETER value!" << std::endl;
|
<< "as pool ID, which is the NO_PARAMETER value!" << std::endl;
|
||||||
}
|
}
|
||||||
memset(this->value, 0, vectorSize * sizeof(T));
|
std::memset(this->value, 0, vectorSize * sizeof(T));
|
||||||
hkManager = hkOwner->getHkManagerHandle();
|
hkManager = hkOwner->getHkManagerHandle();
|
||||||
if (dataSet != nullptr) {
|
if (dataSet != nullptr) {
|
||||||
dataSet->registerVariable(this);
|
dataSet->registerVariable(this);
|
||||||
@ -23,17 +23,18 @@ inline LocalPoolVector<T, vectorSize>::LocalPoolVector(lp_id_t poolId,
|
|||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(lp_id_t poolId,
|
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(lp_id_t poolId,
|
||||||
object_id_t poolOwner, pool_rwm_t setReadWriteMode, DataSetIF *dataSet):
|
object_id_t poolOwner, DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||||
readWriteMode(readWriteMode) {
|
readWriteMode(setReadWriteMode) {
|
||||||
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
if(poolId == PoolVariableIF::NO_PARAMETER) {
|
||||||
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the "
|
sif::warning << "LocalPoolVector: PoolVariableIF::NO_PARAMETER passed "
|
||||||
"NO_PARAMETER value!" << std::endl;
|
<< "as pool ID, which is the NO_PARAMETER value!" << std::endl;
|
||||||
}
|
}
|
||||||
HasLocalDataPoolIF* hkOwner =
|
HasLocalDataPoolIF* hkOwner =
|
||||||
objectManager->get<HasLocalDataPoolIF>(poolOwner);
|
objectManager->get<HasLocalDataPoolIF>(poolOwner);
|
||||||
if(hkOwner == nullptr) {
|
if(hkOwner == nullptr) {
|
||||||
sif::error << "LocalPoolVariable: The supplied pool owner did not implement"
|
sif::error << "LocalPoolVariable: The supplied pool owner did not "
|
||||||
"the correct interface HasHkPoolParametersIF!" << std::endl;
|
<< "implement the correct interface HasHkPoolParametersIF!"
|
||||||
|
<< std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hkManager = hkOwner->getHkManagerHandle();
|
hkManager = hkOwner->getHkManagerHandle();
|
||||||
@ -67,7 +68,7 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
|||||||
std::dec << " failed." << std::endl;
|
std::dec << " failed." << std::endl;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
memcpy(this->value, poolEntry->address, poolEntry->getByteSize());
|
std::memcpy(this->value, poolEntry->address, poolEntry->getByteSize());
|
||||||
this->valid = poolEntry->valid;
|
this->valid = poolEntry->valid;
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
@ -96,7 +97,7 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
|
|||||||
std::dec << " failed.\n" << std::flush;
|
std::dec << " failed.\n" << std::flush;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
memcpy(poolEntry->address, this->value, poolEntry->getByteSize());
|
std::memcpy(poolEntry->address, this->value, poolEntry->getByteSize());
|
||||||
poolEntry->valid = this->valid;
|
poolEntry->valid = this->valid;
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,26 @@ PeriodicOperationDivider::PeriodicOperationDivider(uint32_t divider,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PeriodicOperationDivider::checkAndIncrement() {
|
bool PeriodicOperationDivider::checkAndIncrement() {
|
||||||
if(counter >= divider) {
|
bool opNecessary = check();
|
||||||
|
if(opNecessary) {
|
||||||
if(resetAutomatically) {
|
if(resetAutomatically) {
|
||||||
counter = 0;
|
counter = 0;
|
||||||
}
|
}
|
||||||
return true;
|
return opNecessary;
|
||||||
}
|
}
|
||||||
counter ++;
|
counter ++;
|
||||||
|
return opNecessary;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PeriodicOperationDivider::check() {
|
||||||
|
if(counter >= divider) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PeriodicOperationDivider::resetCounter() {
|
void PeriodicOperationDivider::resetCounter() {
|
||||||
counter = 0;
|
counter = 0;
|
||||||
}
|
}
|
||||||
|
@ -21,17 +21,27 @@ public:
|
|||||||
*/
|
*/
|
||||||
PeriodicOperationDivider(uint32_t divider, bool resetAutomatically = true);
|
PeriodicOperationDivider(uint32_t divider, bool resetAutomatically = true);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether operation is necessary.
|
* Check whether operation is necessary.
|
||||||
* If an operation is necessary and the class has been
|
* If an operation is necessary and the class has been
|
||||||
* configured to be reset automatically, the counter will be reset.
|
* configured to be reset automatically, the counter will be reset.
|
||||||
* If not, the counter will be incremented.
|
*
|
||||||
* @return
|
* @return
|
||||||
* -@c true if the counter is larger or equal to the divider
|
* -@c true if the counter is larger or equal to the divider
|
||||||
* -@c false otherwise
|
* -@c false otherwise
|
||||||
*/
|
*/
|
||||||
bool checkAndIncrement();
|
bool checkAndIncrement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether an operation is necessary.
|
||||||
|
* This function will not increment the counter!
|
||||||
|
* @return
|
||||||
|
* -@c true if the counter is larger or equal to the divider
|
||||||
|
* -@c false otherwise
|
||||||
|
*/
|
||||||
|
bool check();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be used to reset the counter to 0 manually.
|
* Can be used to reset the counter to 0 manually.
|
||||||
*/
|
*/
|
||||||
|
@ -39,7 +39,7 @@ void HousekeepingMessage::setToggleReportingCommand(CommandMessage *message,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(enableReporting) {
|
if(enableReporting) {
|
||||||
message->setCommand(ENABLE_PERIODIC_HK_GENERATION);
|
message->setCommand(ENABLE_PERIODIC_HK_REPORT_GENERATION);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
message->setCommand(DISABLE_PERIODIC_HK_REPORT_GENERATION);
|
message->setCommand(DISABLE_PERIODIC_HK_REPORT_GENERATION);
|
||||||
|
@ -33,6 +33,14 @@ union sid_t {
|
|||||||
bool notSet() const {
|
bool notSet() const {
|
||||||
return raw == INVALID_ADDRESS;
|
return raw == INVALID_ADDRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const sid_t& other) const {
|
||||||
|
return raw == other.raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const sid_t& other) const {
|
||||||
|
return not (raw == other.raw);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +65,7 @@ public:
|
|||||||
|
|
||||||
static constexpr uint8_t MESSAGE_ID = messagetypes::HOUSEKEEPING;
|
static constexpr uint8_t MESSAGE_ID = messagetypes::HOUSEKEEPING;
|
||||||
|
|
||||||
static constexpr Command_t ENABLE_PERIODIC_HK_GENERATION =
|
static constexpr Command_t ENABLE_PERIODIC_HK_REPORT_GENERATION =
|
||||||
MAKE_COMMAND_ID(5);
|
MAKE_COMMAND_ID(5);
|
||||||
static constexpr Command_t DISABLE_PERIODIC_HK_REPORT_GENERATION =
|
static constexpr Command_t DISABLE_PERIODIC_HK_REPORT_GENERATION =
|
||||||
MAKE_COMMAND_ID(6);
|
MAKE_COMMAND_ID(6);
|
||||||
|
@ -14,13 +14,8 @@
|
|||||||
*/
|
*/
|
||||||
class HousekeepingPacketDownlink: public SerialLinkedListAdapter<SerializeIF> {
|
class HousekeepingPacketDownlink: public SerialLinkedListAdapter<SerializeIF> {
|
||||||
public:
|
public:
|
||||||
HousekeepingPacketDownlink(sid_t sid, /*bool reportingStatus,
|
HousekeepingPacketDownlink(sid_t sid, LocalPoolDataSetBase* dataSetPtr):
|
||||||
float collectionInterval, uint8_t numberOfParameters, */
|
sourceId(sid.objectId), setId(sid.ownerSetId), hkData(dataSetPtr) {
|
||||||
LocalPoolDataSetBase* dataSetPtr):
|
|
||||||
sourceId(sid.objectId), setId(sid.ownerSetId),
|
|
||||||
/*reportingStatus(reportingStatus),
|
|
||||||
collectionInterval(collectionInterval),
|
|
||||||
numberOfParameters(numberOfParameters), */hkData(dataSetPtr) {
|
|
||||||
setLinks();
|
setLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,17 +24,10 @@ private:
|
|||||||
setStart(&sourceId);
|
setStart(&sourceId);
|
||||||
sourceId.setNext(&setId);
|
sourceId.setNext(&setId);
|
||||||
setId.setNext(&hkData);
|
setId.setNext(&hkData);
|
||||||
//setId.setNext(&reportingStatus);
|
|
||||||
//reportingStatus.setNext(&collectionInterval);
|
|
||||||
//collectionInterval.setNext(&numberOfParameters);
|
|
||||||
//numberOfParameters.setNext(&hkData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializeElement<object_id_t> sourceId;
|
SerializeElement<object_id_t> sourceId;
|
||||||
SerializeElement<uint32_t> setId;
|
SerializeElement<uint32_t> setId;
|
||||||
//SerializeElement<uint8_t> reportingStatus;
|
|
||||||
//SerializeElement<float> collectionInterval;
|
|
||||||
//SerializeElement<uint8_t> numberOfParameters;
|
|
||||||
LinkedElement<SerializeIF> hkData;
|
LinkedElement<SerializeIF> hkData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
|
#ifndef FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
|
||||||
#define FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
|
#define FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_
|
||||||
|
|
||||||
#include <framework/serialize/SerialBufferAdapter.h>
|
#include "../serialize/SerialBufferAdapter.h"
|
||||||
#include <framework/serialize/SerialLinkedListAdapter.h>
|
#include "../serialize/SerialLinkedListAdapter.h"
|
||||||
#include <framework/datapoollocal/LocalPoolDataSetBase.h>
|
#include "../datapoollocal/LocalPoolDataSetBase.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This helper class will be used to serialize and deserialize
|
* @brief This helper class will be used to serialize and deserialize
|
||||||
|
13
housekeeping/HousekeepingSetPacket.h
Normal file
13
housekeeping/HousekeepingSetPacket.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_
|
||||||
|
#define FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_
|
||||||
|
|
||||||
|
#include "../serialize/SerialLinkedListAdapter.h"
|
||||||
|
|
||||||
|
class HousekeepingSetPacket: public SerialLinkedListAdapter<SerializeIF> {
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_ */
|
@ -116,7 +116,7 @@ ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand(
|
|||||||
CommandMessage *command, object_id_t objectId,
|
CommandMessage *command, object_id_t objectId,
|
||||||
bool enableReporting, bool isDiagnostics,
|
bool enableReporting, bool isDiagnostics,
|
||||||
const uint8_t* tcData, size_t tcDataLen) {
|
const uint8_t* tcData, size_t tcDataLen) {
|
||||||
if(tcDataLen < sizeof(object_id_t)) {
|
if(tcDataLen < sizeof(sid_t)) {
|
||||||
// TC data should consist of object ID and set ID.
|
// TC data should consist of object ID and set ID.
|
||||||
return CommandingServiceBase::INVALID_TC;
|
return CommandingServiceBase::INVALID_TC;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user