working on HK and Dataset TM
This commit is contained in:
parent
33a2fb48e5
commit
d766469f1e
@ -4,6 +4,8 @@
|
|||||||
#include <fsfw/ipc/MutexFactory.h>
|
#include <fsfw/ipc/MutexFactory.h>
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
|
|
||||||
|
#include "HasDatapoolIF.h"
|
||||||
|
|
||||||
#ifdef FSFW_INTROSPECTION
|
#ifdef FSFW_INTROSPECTION
|
||||||
Dataset::Dataset(HasDatapoolIF* owner, bool allowUserCommit)
|
Dataset::Dataset(HasDatapoolIF* owner, bool allowUserCommit)
|
||||||
: allocated(true), allowUserCommit(allowUserCommit) {
|
: allocated(true), allowUserCommit(allowUserCommit) {
|
||||||
@ -21,13 +23,13 @@ void Dataset::setEnum(EnumIF *theEnum) {
|
|||||||
description = theEnum->getDescription();
|
description = theEnum->getDescription();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Dataset::Dataset(HasDatapoolIF* owner, uint8_t id, bool allowUserCommit)
|
Dataset::Dataset(HasDatapoolIF* owner, DataSetId_t id, bool allowUserCommit)
|
||||||
: allocated(true), allowUserCommit(allowUserCommit), id(id) {
|
: allocated(true), allowUserCommit(allowUserCommit), id(id) {
|
||||||
this->owner.pointer = owner;
|
this->owner.pointer = owner;
|
||||||
mutex = MutexFactory::instance()->createMutex();
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dataset::Dataset(uint32_t owner_id, uint8_t id): id(id) { this->owner.id = owner_id; }
|
Dataset::Dataset(uint32_t owner_id, DataSetId_t id): id(id) { this->owner.id = owner_id; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Dataset::~Dataset() { MutexFactory::instance()->deleteMutex(mutex); }
|
Dataset::~Dataset() { MutexFactory::instance()->deleteMutex(mutex); }
|
||||||
|
@ -9,8 +9,10 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "DatasetEntryIF.h"
|
#include "DatasetEntryIF.h"
|
||||||
#include "HasDatapoolIF.h"
|
|
||||||
|
|
||||||
|
// TODO ring inclusion
|
||||||
|
// #include "HasDatapoolIF.h"
|
||||||
|
class HasDatapoolIF;
|
||||||
|
|
||||||
using DataSetId_t = uint32_t;
|
using DataSetId_t = uint32_t;
|
||||||
|
|
||||||
@ -47,8 +49,8 @@ class Dataset {
|
|||||||
Dataset(uint32_t owner_id);
|
Dataset(uint32_t owner_id);
|
||||||
void setEnum(EnumIF* theEnum);
|
void setEnum(EnumIF* theEnum);
|
||||||
#else
|
#else
|
||||||
Dataset(HasDatapoolIF* owner, uint32_t id, bool allowUserCommit);
|
Dataset(HasDatapoolIF* owner, DataSetId_t id, bool allowUserCommit);
|
||||||
Dataset(uint32_t owner_id, uint32_t id);
|
Dataset(uint32_t owner_id, DataSetId_t id);
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
~Dataset();
|
~Dataset();
|
||||||
@ -87,7 +89,7 @@ class Dataset {
|
|||||||
* Force sending of TM packet, in reference to tc
|
* Force sending of TM packet, in reference to tc
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void commitAndReport(store_address_t tc);
|
void commitAndReport(store_address_t tc, size_t tc_offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy content of local copies into actual variable
|
* Copy content of local copies into actual variable
|
||||||
@ -96,23 +98,23 @@ class Dataset {
|
|||||||
* calls setValid(valid) before committing
|
* calls setValid(valid) before committing
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void commitAndReport(bool valid, store_address_t tc);
|
void commitAndReport(bool valid, store_address_t tc, size_t tc_offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy content of local copies into actual variable
|
* Copy content of local copies into actual variable
|
||||||
* Force sending of TM packet, in reference to tc
|
* Force sending of TM packet, in reference to tc, if tc is valid
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void commitAndReportIfRequested(store_address_t tc);
|
void commitAndReportIfRequested(store_address_t tc, size_t tc_offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy content of local copies into actual variable
|
* Copy content of local copies into actual variable
|
||||||
* Force sending of TM packet, in reference to tc
|
* Force sending of TM packet, in reference to tc, if tc is valid
|
||||||
*
|
*
|
||||||
* calls setValid(valid) before committing
|
* calls setValid(valid) before committing
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void commitAndReportIfRequested(bool valid, store_address_t tc);
|
void commitAndReportIfRequested(bool valid, store_address_t tc, size_t tc_offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set all contained variables to #valid
|
* set all contained variables to #valid
|
||||||
@ -168,7 +170,7 @@ class Dataset {
|
|||||||
uint32_t id;
|
uint32_t id;
|
||||||
HasDatapoolIF* pointer;
|
HasDatapoolIF* pointer;
|
||||||
} owner;
|
} owner;
|
||||||
uint8_t id;
|
DataSetId_t id;
|
||||||
MutexIF* mutex;
|
MutexIF* mutex;
|
||||||
#ifdef FSFW_INTROSPECTION
|
#ifdef FSFW_INTROSPECTION
|
||||||
const char* description;
|
const char* description;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "DataSet.h"
|
#include "Dataset.h"
|
||||||
|
|
||||||
//TODO use object_id_t
|
//TODO use object_id_t
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ class TemplateSet : public Dataset {
|
|||||||
: Dataset(owner, static_cast<DataSetId_t>(id), allowUserCommit) {
|
: Dataset(owner, static_cast<DataSetId_t>(id), allowUserCommit) {
|
||||||
owner->getDatapoolHelper()->registerSet(this);
|
owner->getDatapoolHelper()->registerSet(this);
|
||||||
}
|
}
|
||||||
TemplateSet(uint32_t owner_id, HkIDs id) : Dataset(owner_id, static_cast<DataSetId_t>(id) {}
|
TemplateSet(uint32_t owner_id, HkIDs id) : Dataset(owner_id, static_cast<DataSetId_t>(id)) {}
|
||||||
#endif
|
#endif
|
||||||
virtual ~TemplateSet() = default;
|
virtual ~TemplateSet() = default;
|
||||||
};
|
};
|
@ -1,2 +1,4 @@
|
|||||||
target_sources(${LIB_FSFW_NAME} PRIVATE HousekeepingMessage.cpp
|
target_sources(${LIB_FSFW_NAME} PRIVATE HousekeepingMessage.cpp
|
||||||
PeriodicHousekeepingHelper.cpp)
|
PeriodicHousekeepingHelper.cpp
|
||||||
|
HousekeepingHelper.cpp
|
||||||
|
HousekeepingSet.cpp)
|
||||||
|
10
src/fsfw/housekeeping/GeneratesHousekeepingIF.h
Normal file
10
src/fsfw/housekeeping/GeneratesHousekeepingIF.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "HousekeepingHelper.h"
|
||||||
|
|
||||||
|
class GeneratesHousekeepingIF {
|
||||||
|
public:
|
||||||
|
virtual ~GeneratesHousekeepingIF() = default;
|
||||||
|
|
||||||
|
virtual HousekeepingHelper* getHelper();
|
||||||
|
};
|
5
src/fsfw/housekeeping/HousekeepingEntryIF.h
Normal file
5
src/fsfw/housekeeping/HousekeepingEntryIF.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class HousekeepingEntryIF {
|
||||||
|
|
||||||
|
};
|
16
src/fsfw/housekeeping/HousekeepingHelper.cpp
Normal file
16
src/fsfw/housekeeping/HousekeepingHelper.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include "HousekeepingHelper.h"
|
||||||
|
|
||||||
|
HousekeepingHelper::HousekeepingHelper() {}
|
||||||
|
|
||||||
|
const HousekeepingSet* HousekeepingHelper::getHousekeepingSet(HousekeepingSetId_t id) {
|
||||||
|
auto iter = housekeepingSets.find(id);
|
||||||
|
if (iter == housekeepingSets.end()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HousekeepingHelper::registerSet(HousekeepingSet* set) {
|
||||||
|
auto id = set->getId();
|
||||||
|
housekeepingSets.emplace(id, set);
|
||||||
|
}
|
30
src/fsfw/housekeeping/HousekeepingHelper.h
Normal file
30
src/fsfw/housekeeping/HousekeepingHelper.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <fsfw/returnvalues/returnvalue.h>
|
||||||
|
#include <fsfw/serialize/SerializeIF.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "HousekeepingSet.h"
|
||||||
|
|
||||||
|
class HousekeepingHelper {
|
||||||
|
friend class HousekeepingHelper;
|
||||||
|
|
||||||
|
public:
|
||||||
|
HousekeepingHelper();
|
||||||
|
~HousekeepingHelper() = default;
|
||||||
|
|
||||||
|
const HousekeepingSet* getHousekeepingSet(HousekeepingSetId_t id);
|
||||||
|
|
||||||
|
const std::map<HousekeepingSetId_t, HousekeepingSet*>* getHousekeepingSets() const {
|
||||||
|
return &housekeepingSets;
|
||||||
|
}
|
||||||
|
|
||||||
|
void registerSet(HousekeepingSet* set);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ReturnValue_t reportHousekeeping(SerializeIF* data, const Action* action = nullptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<HousekeepingSetId_t, HousekeepingSet*> housekeepingSets;
|
||||||
|
};
|
18
src/fsfw/housekeeping/HousekeepingSet.cpp
Normal file
18
src/fsfw/housekeeping/HousekeepingSet.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include "HousekeepingSet.h"
|
||||||
|
|
||||||
|
#include "GeneratesHousekeepingIF.h"
|
||||||
|
|
||||||
|
#ifdef FSFW_INTROSPECTION
|
||||||
|
HousekeepingSet::HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSetId_t id) {
|
||||||
|
owner->getHelper()->registerSet(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HousekeepingSet::setEnum(EnumIF* theEnum) {
|
||||||
|
id = theEnum->getValue();
|
||||||
|
description = theEnum->getDescription();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
HousekeepingSet::HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSetId_t id) : id(id) {
|
||||||
|
owner->getHelper()->registerSet(this);
|
||||||
|
}
|
||||||
|
#endif
|
35
src/fsfw/housekeeping/HousekeepingSet.h
Normal file
35
src/fsfw/housekeeping/HousekeepingSet.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <fsfw/action/Action.h>
|
||||||
|
#include <fsfw/introspection/Enum.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "HousekeepingEntryIF.h"
|
||||||
|
|
||||||
|
class HousekeepingHelper;
|
||||||
|
class GeneratesHousekeepingIF;
|
||||||
|
|
||||||
|
using HousekeepingSetId_t = uint32_t;
|
||||||
|
|
||||||
|
class HousekeepingSet {
|
||||||
|
public:
|
||||||
|
#ifdef FSFW_INTROSPECTION
|
||||||
|
HousekeepingSet(GeneratesHousekeepingIF* owner);
|
||||||
|
void setEnum(EnumIF* theEnum);
|
||||||
|
#else
|
||||||
|
HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSetId_t id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HousekeepingSetId_t getId() const { return id; }
|
||||||
|
|
||||||
|
void report(const Action* action = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
HousekeepingHelper* helper;
|
||||||
|
HousekeepingSetId_t id;
|
||||||
|
#ifdef FSFW_INTROSPECTION
|
||||||
|
const char* description;
|
||||||
|
#endif
|
||||||
|
std::vector<HousekeepingEntryIF*> variables;
|
||||||
|
};
|
@ -218,7 +218,7 @@ void UdpTmTcBridgeNew::handleTM() {
|
|||||||
result = IPCStore->getData(tm, &tmData, &tmDataSize);
|
result = IPCStore->getData(tm, &tmData, &tmDataSize);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
// nothing to send
|
// nothing to send
|
||||||
if (tc != store_address_t()) {
|
if (IPCStore->hasDataAtId(tc)) {
|
||||||
IPCStore->deleteData(tc);
|
IPCStore->deleteData(tc);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -230,7 +230,7 @@ void UdpTmTcBridgeNew::handleTM() {
|
|||||||
sif::error << "UdpTmTcBridge::handleTM: sendto failed with " << errno << std::endl;
|
sif::error << "UdpTmTcBridge::handleTM: sendto failed with " << errno << std::endl;
|
||||||
}
|
}
|
||||||
IPCStore->deleteData(tm);
|
IPCStore->deleteData(tm);
|
||||||
if (tc != store_address_t()) {
|
if (IPCStore->hasDataAtId(tc)) {
|
||||||
IPCStore->deleteData(tc);
|
IPCStore->deleteData(tc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user