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/objectmanager/ObjectManager.h>
|
||||
|
||||
#include "HasDatapoolIF.h"
|
||||
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
Dataset::Dataset(HasDatapoolIF* owner, bool allowUserCommit)
|
||||
: allocated(true), allowUserCommit(allowUserCommit) {
|
||||
@ -21,13 +23,13 @@ void Dataset::setEnum(EnumIF *theEnum) {
|
||||
description = theEnum->getDescription();
|
||||
}
|
||||
#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) {
|
||||
this->owner.pointer = owner;
|
||||
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
|
||||
|
||||
Dataset::~Dataset() { MutexFactory::instance()->deleteMutex(mutex); }
|
||||
|
@ -9,8 +9,10 @@
|
||||
#include <vector>
|
||||
|
||||
#include "DatasetEntryIF.h"
|
||||
#include "HasDatapoolIF.h"
|
||||
|
||||
// TODO ring inclusion
|
||||
// #include "HasDatapoolIF.h"
|
||||
class HasDatapoolIF;
|
||||
|
||||
using DataSetId_t = uint32_t;
|
||||
|
||||
@ -47,8 +49,8 @@ class Dataset {
|
||||
Dataset(uint32_t owner_id);
|
||||
void setEnum(EnumIF* theEnum);
|
||||
#else
|
||||
Dataset(HasDatapoolIF* owner, uint32_t id, bool allowUserCommit);
|
||||
Dataset(uint32_t owner_id, uint32_t id);
|
||||
Dataset(HasDatapoolIF* owner, DataSetId_t id, bool allowUserCommit);
|
||||
Dataset(uint32_t owner_id, DataSetId_t id);
|
||||
#endif
|
||||
public:
|
||||
~Dataset();
|
||||
@ -87,7 +89,7 @@ class Dataset {
|
||||
* 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
|
||||
@ -96,23 +98,23 @@ class Dataset {
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
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
|
||||
@ -168,7 +170,7 @@ class Dataset {
|
||||
uint32_t id;
|
||||
HasDatapoolIF* pointer;
|
||||
} owner;
|
||||
uint8_t id;
|
||||
DataSetId_t id;
|
||||
MutexIF* mutex;
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
const char* description;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "DataSet.h"
|
||||
#include "Dataset.h"
|
||||
|
||||
//TODO use object_id_t
|
||||
|
||||
@ -19,7 +19,7 @@ class TemplateSet : public Dataset {
|
||||
: Dataset(owner, static_cast<DataSetId_t>(id), allowUserCommit) {
|
||||
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
|
||||
virtual ~TemplateSet() = default;
|
||||
};
|
@ -1,2 +1,4 @@
|
||||
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);
|
||||
if (result != returnvalue::OK) {
|
||||
// nothing to send
|
||||
if (tc != store_address_t()) {
|
||||
if (IPCStore->hasDataAtId(tc)) {
|
||||
IPCStore->deleteData(tc);
|
||||
}
|
||||
return;
|
||||
@ -230,7 +230,7 @@ void UdpTmTcBridgeNew::handleTM() {
|
||||
sif::error << "UdpTmTcBridge::handleTM: sendto failed with " << errno << std::endl;
|
||||
}
|
||||
IPCStore->deleteData(tm);
|
||||
if (tc != store_address_t()) {
|
||||
if (IPCStore->hasDataAtId(tc)) {
|
||||
IPCStore->deleteData(tc);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user