generate HK packet function continued
This commit is contained in:
parent
3b4413a6ee
commit
4a90f41122
@ -1,6 +1,7 @@
|
||||
#include <framework/datapoollocal/LocalDataPoolManager.h>
|
||||
#include <framework/datapoollocal/LocalDataSet.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/objectmanager/frameworkObjects.h>
|
||||
#include <framework/ipc/MutexFactory.h>
|
||||
#include <framework/ipc/MutexHelper.h>
|
||||
|
||||
@ -13,7 +14,15 @@ LocalDataPoolManager::LocalDataPoolManager(OwnsLocalDataPoolIF* owner) {
|
||||
}
|
||||
this->owner = owner;
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
//owner->setMinimalHkSamplingFrequency();
|
||||
if(mutex == nullptr) {
|
||||
sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
|
||||
"Could not create mutex." << std::endl;
|
||||
}
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if(ipcStore == nullptr) {
|
||||
sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
|
||||
"Could not set IPC store." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
LocalDataPoolManager::~LocalDataPoolManager() {}
|
||||
@ -52,32 +61,37 @@ MutexIF* LocalDataPoolManager::getMutexHandle() {
|
||||
return mutex;
|
||||
}
|
||||
|
||||
//void HousekeepingManager::setMinimalSamplingFrequency(float frequencySeconds) {
|
||||
// this->samplingFrequency = frequencySeconds;
|
||||
//
|
||||
//}
|
||||
|
||||
void LocalDataPoolManager::generateHousekeepingPacket(sid_t sid) {
|
||||
ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid) {
|
||||
LocalDataSet* dataSetToSerialize = dynamic_cast<LocalDataSet*>(
|
||||
owner->getDataSetHandle(sid));
|
||||
if(dataSetToSerialize == nullptr) {
|
||||
sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
|
||||
" Set ID not found" << std::endl;
|
||||
return;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
store_address_t storeId;
|
||||
size_t hkSize = dataSetToSerialize->getSerializedSize();
|
||||
uint8_t* storePtr = nullptr;
|
||||
ReturnValue_t result = ipcStore->getFreeElement(&storeId, hkSize,&storePtr);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "HousekeepingManager::generateHousekeepingPacket: "
|
||||
"Could not get free element from IPC store." << std::endl;
|
||||
return result;
|
||||
}
|
||||
std::array<uint8_t, 256> testBuffer = {};
|
||||
uint8_t* dataPtr = testBuffer.data();
|
||||
size_t size = 0;
|
||||
dataSetToSerialize->serialize(&dataPtr, &size, testBuffer.size(),
|
||||
false);
|
||||
// and now we send it to the TM funnel or somewhere else
|
||||
|
||||
dataSetToSerialize->serialize(&storePtr, &size, hkSize, false);
|
||||
// and now we have to set a HK message and send it the queue.
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void LocalDataPoolManager::setHkPacketQueue(MessageQueueIF *msgQueue) {
|
||||
this->hkPacketQueue = msgQueue;
|
||||
}
|
||||
|
||||
void LocalDataPoolManager::setHkReplyQueue(MessageQueueIF *replyQueue) {
|
||||
this->hkReplyQueue = replyQueue;
|
||||
}
|
||||
|
||||
const OwnsLocalDataPoolIF* LocalDataPoolManager::getOwner() const {
|
||||
return owner;
|
||||
}
|
||||
|
@ -37,14 +37,15 @@ class LocalDataPoolManager {
|
||||
friend class LocalPoolVector;
|
||||
friend class LocalDataSet;
|
||||
public:
|
||||
static constexpr float MINIMAL_SAMPLING_FREQUENCY = 0.2;
|
||||
|
||||
LocalDataPoolManager(OwnsLocalDataPoolIF* owner);
|
||||
virtual~ LocalDataPoolManager();
|
||||
|
||||
/* Copying forbidden */
|
||||
LocalDataPoolManager(const LocalDataPoolManager &) = delete;
|
||||
LocalDataPoolManager operator=(const LocalDataPoolManager&) = delete;
|
||||
|
||||
// propably will just call respective local data set functions.
|
||||
void generateHousekeepingPacket(sid_t sid);
|
||||
ReturnValue_t generateHousekeepingPacket(sid_t sid);
|
||||
ReturnValue_t handleHousekeepingMessage(CommandMessage* message);
|
||||
|
||||
/**
|
||||
@ -55,7 +56,12 @@ public:
|
||||
*/
|
||||
ReturnValue_t initializeHousekeepingPoolEntriesOnce();
|
||||
|
||||
//! Set the queue for HK packets, which are sent unrequested.
|
||||
void setHkPacketQueue(MessageQueueIF* msgQueue);
|
||||
//! Set the queue for replies. This can be set manually or by the owner
|
||||
//! class if the manager if message are relayed by it.
|
||||
void setHkReplyQueue(MessageQueueIF* replyQueue);
|
||||
|
||||
const OwnsLocalDataPoolIF* getOwner() const;
|
||||
|
||||
ReturnValue_t printPoolEntry(lp_id_t localPoolId);
|
||||
@ -81,6 +87,8 @@ private:
|
||||
//! Maybe this will just be the TM funnel.
|
||||
MessageQueueIF* hkPacketQueue = nullptr;
|
||||
|
||||
//! Global IPC store is used to store all packets.
|
||||
StorageManagerIF* ipcStore = nullptr;
|
||||
/**
|
||||
* Get the pointer to the mutex. Can be used to lock the data pool
|
||||
* eternally. Use with care and don't forget to unlock locked mutexes!
|
||||
|
@ -218,7 +218,7 @@ void CommandingServiceBase::handleRequestQueue() {
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
const uint8_t* data, size_t dataLen, const uint8_t* headerData,
|
||||
size_t headerSize) {
|
||||
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
|
||||
@ -228,36 +228,38 @@ void CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
this->tmPacketCounter++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
object_id_t objectId, const uint8_t *data, size_t dataLen) {
|
||||
uint8_t buffer[sizeof(object_id_t)];
|
||||
uint8_t* pBuffer = buffer;
|
||||
size_t size = 0;
|
||||
SerializeAdapter<object_id_t>::serialize(&objectId, &pBuffer, &size,
|
||||
sizeof(object_id_t), true);
|
||||
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, buffer, size);
|
||||
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
this->tmPacketCounter++;
|
||||
}
|
||||
|
||||
ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
object_id_t objectId, const uint8_t *data, size_t dataLen) {
|
||||
uint8_t buffer[sizeof(object_id_t)];
|
||||
uint8_t* pBuffer = buffer;
|
||||
size_t size = 0;
|
||||
SerializeAdapter<object_id_t>::serialize(&objectId, &pBuffer, &size,
|
||||
sizeof(object_id_t), true);
|
||||
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, buffer, size);
|
||||
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
this->tmPacketCounter++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
SerializeIF* content, SerializeIF* header) {
|
||||
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, content, header);
|
||||
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
this->tmPacketCounter++;
|
||||
}
|
||||
ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
SerializeIF* content, SerializeIF* header) {
|
||||
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, content, header);
|
||||
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
this->tmPacketCounter++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -212,36 +212,38 @@ protected:
|
||||
*/
|
||||
PeriodicTaskIF* executingTask;
|
||||
|
||||
// todo: why do these functions not have returnvalues? the caller should be
|
||||
// able to check whether the send operations actually work.
|
||||
/**
|
||||
* Send TM data from pointer to data. If a header is supplied it is added before data
|
||||
* @brief Send TM data from pointer to data.
|
||||
* If a header is supplied it is added before data
|
||||
* @param subservice Number of subservice
|
||||
* @param data Pointer to the data in the Packet
|
||||
* @param dataLen Lenght of data in the Packet
|
||||
* @param headerData HeaderData will be placed before data
|
||||
* @param headerSize Size of HeaderData
|
||||
*/
|
||||
void sendTmPacket(uint8_t subservice, const uint8_t *data, size_t dataLen,
|
||||
const uint8_t* headerData = nullptr,size_t headerSize = 0);
|
||||
ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t *data,
|
||||
size_t dataLen, const uint8_t* headerData = nullptr,
|
||||
size_t headerSize = 0);
|
||||
|
||||
/**
|
||||
* To send TM packets of objects that still need to be serialized and consist of an object ID with appended data
|
||||
* @brief To send TM packets of objects that still need to be serialized
|
||||
* and consist of an object ID with appended data.
|
||||
* @param subservice Number of subservice
|
||||
* @param objectId ObjectId is placed before data
|
||||
* @param data Data to append to the packet
|
||||
* @param dataLen Length of Data
|
||||
*/
|
||||
void sendTmPacket(uint8_t subservice, object_id_t objectId,
|
||||
ReturnValue_t sendTmPacket(uint8_t subservice, object_id_t objectId,
|
||||
const uint8_t *data, size_t dataLen);
|
||||
|
||||
/**
|
||||
* To send packets has data which is in form of a SerializeIF or Adapters implementing it
|
||||
* @brief To send packets which are contained inside a class implementing
|
||||
* SerializeIF.
|
||||
* @param subservice Number of subservice
|
||||
* @param content This is a pointer to the serialized packet
|
||||
* @param header Serialize IF header which will be placed before content
|
||||
*/
|
||||
void sendTmPacket(uint8_t subservice, SerializeIF* content,
|
||||
ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF* content,
|
||||
SerializeIF* header = nullptr);
|
||||
|
||||
virtual void handleUnrequestedReply(CommandMessage *reply);
|
||||
|
Loading…
Reference in New Issue
Block a user