merging renaming into main branch
This commit is contained in:
32
housekeeping/HasHkPoolParametersIF.h
Normal file
32
housekeeping/HasHkPoolParametersIF.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef FRAMEWORK_DATAPOOL_HASHKPOOLPARAMETERSIF_H_
|
||||
#define FRAMEWORK_DATAPOOL_HASHKPOOLPARAMETERSIF_H_
|
||||
#include <framework/datapool/PoolEntryIF.h>
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
#include <map>
|
||||
|
||||
class HousekeepingManager;
|
||||
/**
|
||||
* @brief Type definition for local pool entries.
|
||||
*/
|
||||
using lp_id_t = uint32_t;
|
||||
using LocalDataPoolMap = std::map<lp_id_t, PoolEntryIF*>;
|
||||
using LocalDataPoolMapIter = LocalDataPoolMap::iterator;
|
||||
|
||||
/**
|
||||
* @brief Interface for the local housekeeping managers used by the device
|
||||
* handler.
|
||||
*/
|
||||
class HasHkPoolParametersIF {
|
||||
public:
|
||||
virtual~ HasHkPoolParametersIF() {};
|
||||
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
virtual ReturnValue_t initializeHousekeepingPoolEntries(
|
||||
LocalDataPoolMap& localDataPoolMap) = 0;
|
||||
virtual float setMinimalHkSamplingFrequency() = 0;
|
||||
virtual HousekeepingManager* getHkManagerHandle() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_DATAPOOL_HASHKPOOLPARAMETERSIF_H_ */
|
50
housekeeping/HousekeepingManager.cpp
Normal file
50
housekeeping/HousekeepingManager.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include <framework/housekeeping/HousekeepingManager.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/ipc/MutexFactory.h>
|
||||
#include <framework/ipc/MutexHelper.h>
|
||||
|
||||
HousekeepingManager::HousekeepingManager(HasHkPoolParametersIF* owner) {
|
||||
//todo :: nullptr check owner.
|
||||
if(owner == nullptr) {
|
||||
sif::error << "HkManager: Invalid supplied owner!" << std::endl;
|
||||
std::exit(0);
|
||||
}
|
||||
this->owner = owner;
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
owner->setMinimalHkSamplingFrequency();
|
||||
}
|
||||
|
||||
HousekeepingManager::~HousekeepingManager() {}
|
||||
|
||||
ReturnValue_t HousekeepingManager::initializeHousekeepingPoolEntriesOnce() {
|
||||
if(not mapInitialized) {
|
||||
ReturnValue_t result = owner->initializeHousekeepingPoolEntries(localDpMap);
|
||||
if(result == HasReturnvaluesIF::RETURN_OK) {
|
||||
mapInitialized = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
sif::warning << "hk manager says no" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t HousekeepingManager::handleHousekeepingMessage(
|
||||
CommandMessage *message) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
MutexIF* HousekeepingManager::getMutexHandle() {
|
||||
return mutex;
|
||||
}
|
||||
|
||||
void HousekeepingManager::setMinimalSamplingFrequency(float frequencySeconds) {
|
||||
this->samplingFrequency = frequencySeconds;
|
||||
|
||||
}
|
||||
|
||||
void HousekeepingManager::generateHousekeepingPacket(DataSetIF *dataSet) {
|
||||
}
|
||||
|
||||
void HousekeepingManager::setHkPacketQueue(MessageQueueIF *msgQueue) {
|
||||
this->hkPacketQueue = msgQueue;
|
||||
}
|
95
housekeeping/HousekeepingManager.h
Normal file
95
housekeeping/HousekeepingManager.h
Normal file
@ -0,0 +1,95 @@
|
||||
#ifndef FRAMEWORK_HK_HOUSEKEEPINGHELPER_H_
|
||||
#define FRAMEWORK_HK_HOUSEKEEPINGHELPER_H_
|
||||
#include <framework/datapool/DataSetIF.h>
|
||||
#include <framework/objectmanager/SystemObjectIF.h>
|
||||
#include <framework/housekeeping/HasHkPoolParametersIF.h>
|
||||
#include <framework/ipc/MutexIF.h>
|
||||
|
||||
#include <framework/datapool/PoolEntry.h>
|
||||
#include <framework/ipc/CommandMessage.h>
|
||||
#include <framework/ipc/MessageQueueIF.h>
|
||||
#include <framework/ipc/MutexHelper.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
class HousekeepingManager {
|
||||
public:
|
||||
static constexpr float MINIMAL_SAMPLING_FREQUENCY = 0.2;
|
||||
|
||||
HousekeepingManager(HasHkPoolParametersIF* owner);
|
||||
virtual~ HousekeepingManager();
|
||||
|
||||
MutexIF* getMutexHandle();
|
||||
|
||||
// propably will just call respective local data set functions.
|
||||
void generateHousekeepingPacket(DataSetIF* dataSet);
|
||||
ReturnValue_t handleHousekeepingMessage(CommandMessage* message);
|
||||
|
||||
/**
|
||||
* Read a variable by supplying its local pool ID and assign the pool
|
||||
* entry to the supplied PoolEntry pointer. The type of the pool entry
|
||||
* is deduced automatically. This call is not thread-safe!
|
||||
* @tparam T Type of the pool entry
|
||||
* @param localPoolId Pool ID of the variable to read
|
||||
* @param poolVar [out] Corresponding pool entry will be assigned to the
|
||||
* supplied pointer.
|
||||
* @return
|
||||
*/
|
||||
template <class T>
|
||||
ReturnValue_t fetchPoolEntry(lp_id_t localPoolId, PoolEntry<T> *poolEntry);
|
||||
void setMinimalSamplingFrequency(float frequencySeconds);
|
||||
|
||||
/**
|
||||
* This function is used to fill the local data pool map with pool
|
||||
* entries. The default implementation is empty.
|
||||
* @param localDataPoolMap
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t initializeHousekeepingPoolEntriesOnce();
|
||||
|
||||
void setHkPacketQueue(MessageQueueIF* msgQueue);
|
||||
private:
|
||||
//! this depends on the PST frequency.. maybe it would be better to just
|
||||
//! set this manually with a global configuration value which is also
|
||||
//! passed to the PST. Or force setting this in device handler.
|
||||
float samplingFrequency = MINIMAL_SAMPLING_FREQUENCY;
|
||||
|
||||
//! This is the map holding the actual data. Should only be initialized
|
||||
//! once !
|
||||
bool mapInitialized = false;
|
||||
LocalDataPoolMap localDpMap;
|
||||
|
||||
//! Every housekeeping data manager has a mutex to protect access
|
||||
//! to it's data pool.
|
||||
MutexIF * mutex = nullptr;
|
||||
|
||||
//! The class which actually owns the manager (and its datapool).
|
||||
HasHkPoolParametersIF* owner = nullptr;
|
||||
|
||||
//! Used for replies.
|
||||
//! (maybe we dont need this, the sender can be retrieved from command
|
||||
//! message..)
|
||||
MessageQueueIF* hkReplyQueue = nullptr;
|
||||
//! Used for HK packets, which are generated without requests.
|
||||
MessageQueueIF* hkPacketQueue = nullptr;
|
||||
};
|
||||
|
||||
template<class T> inline
|
||||
ReturnValue_t HousekeepingManager::fetchPoolEntry(lp_id_t localPoolId,
|
||||
PoolEntry<T> *poolEntry) {
|
||||
auto poolIter = localDpMap.find(localPoolId);
|
||||
if (poolIter == localDpMap.end()) {
|
||||
// todo: special returnvalue.
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
poolEntry = dynamic_cast< PoolEntry<T>* >(poolIter->second);
|
||||
if(poolEntry == nullptr) {
|
||||
// todo: special returnvalue.
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
#endif /* FRAMEWORK_HK_HOUSEKEEPINGHELPER_H_ */
|
10
housekeeping/HousekeepingMessage.cpp
Normal file
10
housekeeping/HousekeepingMessage.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include <framework/housekeeping/HousekeepingMessage.h>
|
||||
|
||||
void HousekeepingMessage::setAddHkReportStructMessage(CommandMessage *message,
|
||||
set_t setId, store_address_t packet) {
|
||||
message->setCommand(ADD_HK_REPORT_STRUCT);
|
||||
message->setParameter(setId);
|
||||
message->setParameter2(packet.raw);
|
||||
}
|
||||
|
||||
//void Housekeeping
|
87
housekeeping/HousekeepingMessage.h
Normal file
87
housekeeping/HousekeepingMessage.h
Normal file
@ -0,0 +1,87 @@
|
||||
#ifndef FRAMEWORK_HK_HOUSEKEEPINGMESSAGE_H_
|
||||
#define FRAMEWORK_HK_HOUSEKEEPINGMESSAGE_H_
|
||||
#include <framework/ipc/CommandMessage.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include <limits>
|
||||
|
||||
/**
|
||||
* the sid consists of the target object ID and... something else I forgot.
|
||||
* Propably a special HK id to distinguish multiple hk pool packages
|
||||
* inside a handler or controller
|
||||
*/
|
||||
typedef uint32_t set_t;
|
||||
|
||||
union sid_t {
|
||||
static constexpr uint64_t INVALID_ADDRESS = std::numeric_limits<uint64_t>::max();
|
||||
sid_t(): raw(INVALID_ADDRESS) {}
|
||||
|
||||
struct {
|
||||
object_id_t objectId ;
|
||||
set_t hkId;
|
||||
};
|
||||
/**
|
||||
* Alternative access to the raw value.
|
||||
*/
|
||||
uint64_t raw;
|
||||
};
|
||||
class HousekeepingMessage {
|
||||
public:
|
||||
/**
|
||||
* No instances of a message shall be created, instead
|
||||
* a CommandMessage instance is manipulated.
|
||||
*/
|
||||
HousekeepingMessage() = delete;
|
||||
HousekeepingMessage(const HousekeepingMessage&) = delete;
|
||||
HousekeepingMessage operator=(const HousekeepingMessage &) = delete;
|
||||
|
||||
static constexpr uint8_t MESSAGE_ID = MESSAGE_TYPE::HOUSEKEEPING;
|
||||
static constexpr Command_t ADD_HK_REPORT_STRUCT =
|
||||
MAKE_COMMAND_ID(1);
|
||||
static constexpr Command_t ADD_DIAGNOSTICS_REPORT_STRUCT =
|
||||
MAKE_COMMAND_ID(2);
|
||||
|
||||
static constexpr Command_t DELETE_HK_REPORT_STRUCT = MAKE_COMMAND_ID(3);
|
||||
static constexpr Command_t DELETE_DIAGNOSTICS_REPORT_STRUCT =
|
||||
MAKE_COMMAND_ID(4);
|
||||
|
||||
static constexpr Command_t ENABLE_PERIODIC_HK_GENERATION =
|
||||
MAKE_COMMAND_ID(5);
|
||||
static constexpr Command_t DISABLE_PERIODIC_HK_REPORT_GENERATION =
|
||||
MAKE_COMMAND_ID(6);
|
||||
|
||||
static constexpr Command_t ENABLE_PERIODIC_DIAGNOSTICS_GENERATION =
|
||||
MAKE_COMMAND_ID(7);
|
||||
static constexpr Command_t DISABLE_PERIODIC_DIAGNOSTICS_GENERATION =
|
||||
MAKE_COMMAND_ID(8);
|
||||
|
||||
static constexpr Command_t REPORT_HK_REPORT_STRUCTURES = MAKE_COMMAND_ID(9);
|
||||
static constexpr Command_t REPORT_DIAGNOSTICS_REPORT_STRUCTURES =
|
||||
MAKE_COMMAND_ID(11);
|
||||
|
||||
static constexpr Command_t HK_DEFINITIONS_REPORT = MAKE_COMMAND_ID(10);
|
||||
static constexpr Command_t DIAGNOSTICS_DEFINITION_REPORT = MAKE_COMMAND_ID(12);
|
||||
|
||||
static constexpr Command_t HK_REPORT = MAKE_COMMAND_ID(25);
|
||||
static constexpr Command_t DIAGNOSTICS_REPORT = MAKE_COMMAND_ID(26);
|
||||
|
||||
static constexpr Command_t GENERATE_ONE_PARAMETER_REPORT =
|
||||
MAKE_COMMAND_ID(27);
|
||||
static constexpr Command_t GENERATE_ONE_DIAGNOSTICS_REPORT =
|
||||
MAKE_COMMAND_ID(28);
|
||||
|
||||
static constexpr Command_t APPEND_PARAMETERS_TO_PARAMETER_REPORT_STRUCTURE =
|
||||
MAKE_COMMAND_ID(29);
|
||||
static constexpr Command_t APPEND_PARAMETERS_TO_DIAGNOSTICS_REPORT_STRUCTURE =
|
||||
MAKE_COMMAND_ID(30);
|
||||
|
||||
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 void setAddHkReportStructMessage(CommandMessage* message,
|
||||
set_t setId, store_address_t packet);
|
||||
};
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_HK_HOUSEKEEPINGMESSAGE_H_ */
|
Reference in New Issue
Block a user