switching to non template set, added valid flag handling
This commit is contained in:
parent
753d587b69
commit
4c0d9ae039
@ -8,14 +8,14 @@
|
|||||||
#include "HasDatapoolIF.h"
|
#include "HasDatapoolIF.h"
|
||||||
|
|
||||||
#ifdef FSFW_INTROSPECTION
|
#ifdef FSFW_INTROSPECTION
|
||||||
Dataset::Dataset(HasDatapoolIF* owner, bool allowUserCommit)
|
Dataset::Dataset(HasDatapoolIF* owner, const EnumIF &id, bool allowUserCommit)
|
||||||
: HousekeepingSet(owner), allocated(true), allowUserCommit(allowUserCommit) {
|
: HousekeepingSet(owner, id), allocated(true), allowUserCommit(allowUserCommit) {
|
||||||
this->owner.pointer = owner;
|
this->owner.pointer = owner;
|
||||||
mutex = MutexFactory::instance()->createMutex();
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dataset::Dataset(uint32_t owner_id)
|
Dataset::Dataset(uint32_t owner_id, const EnumIF &id)
|
||||||
: HousekeepingSet(nullptr), allocated(false), allowUserCommit(false) {
|
: HousekeepingSet(nullptr, id), allocated(false), allowUserCommit(false) {
|
||||||
this->owner.id = owner_id;
|
this->owner.id = owner_id;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -46,8 +46,8 @@ class HasDatapoolIF;
|
|||||||
class Dataset : public HousekeepingSet {
|
class Dataset : public HousekeepingSet {
|
||||||
protected:
|
protected:
|
||||||
#ifdef FSFW_INTROSPECTION
|
#ifdef FSFW_INTROSPECTION
|
||||||
Dataset(HasDatapoolIF* owner, bool allowUserCommit);
|
Dataset(HasDatapoolIF* owner, const EnumIF &id, bool allowUserCommit);
|
||||||
Dataset(uint32_t owner_id);
|
Dataset(uint32_t owner_id, const EnumIF &id);
|
||||||
#else
|
#else
|
||||||
Dataset(HasDatapoolIF* owner, HousekeepingSetId_t id, bool allowUserCommit);
|
Dataset(HasDatapoolIF* owner, HousekeepingSetId_t id, bool allowUserCommit);
|
||||||
Dataset(uint32_t owner_id, HousekeepingSetId_t id);
|
Dataset(uint32_t owner_id, HousekeepingSetId_t id);
|
||||||
|
@ -1,128 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Dataset.h"
|
|
||||||
#include "DatasetEntryIF.h"
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class DatasetEntry : public DatasetEntryIF {
|
|
||||||
protected:
|
|
||||||
#ifdef FSFW_INTROSPECTION
|
|
||||||
DatasetEntry(Dataset* set, const char* name) : name(name) {
|
|
||||||
#else
|
|
||||||
DatasetEntry(Dataset* set) {
|
|
||||||
#endif
|
|
||||||
allocated = set->registerEntry(this);
|
|
||||||
if (!allocated) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
storedValue = new T();
|
|
||||||
storedValid = new bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
#ifdef FSFW_INTROSPECTION
|
|
||||||
Types::ParameterType getType() override {
|
|
||||||
return enumHelper<std::is_base_of<EnumIF, T>::value>::template getType<T>();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef FSFW_INTROSPECTION
|
|
||||||
static DatasetEntry createEntry(Dataset* set, const char *name) {
|
|
||||||
return DatasetEntry(set, name);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static DatasetEntry createEntry(Dataset* set) { return DatasetEntry(set); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
~DatasetEntry() {
|
|
||||||
if (allocated) {
|
|
||||||
delete storedValue;
|
|
||||||
delete storedValid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
operator T() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
DatasetEntry &operator=(T newValue){
|
|
||||||
value = newValue;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setValid(bool isValid) override { valid = isValid; }
|
|
||||||
|
|
||||||
bool getValid() override { return valid; }
|
|
||||||
|
|
||||||
// TODO this is generic with the action parameter
|
|
||||||
#ifdef FSFW_INTROSPECTION
|
|
||||||
double getFloating() override { return (double)value; }
|
|
||||||
int64_t getSigned() override { return (int64_t)value; }
|
|
||||||
|
|
||||||
bool setFloating(double value) override {
|
|
||||||
if (getType() != Types::FLOATING) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this->value = value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool setSigned(int64_t value) override {
|
|
||||||
if ((getType() != Types::SIGNED) && (getType() != Types::ENUM)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this->value = value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<int64_t> getEnumValues() override {
|
|
||||||
return enumHelper<std::is_base_of<EnumIF, T>::value>::getEnumValues(&value);
|
|
||||||
}
|
|
||||||
const char* const* getEnumDescriptions() override {
|
|
||||||
return enumHelper<std::is_base_of<EnumIF, T>::value>::getEnumDescriptions(&value);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* getName() override { return name; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char* name;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void commit() override {
|
|
||||||
*storedValue = value;
|
|
||||||
*storedValid = valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void read() override {
|
|
||||||
value = *storedValue;
|
|
||||||
valid = *storedValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void connect(DatasetEntryIF* entry) override {
|
|
||||||
DatasetEntry<T>* theOther = dynamic_cast<DatasetEntry<T>*>(entry);
|
|
||||||
if (theOther == nullptr) {
|
|
||||||
// Configuration error
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this->storedValue = theOther->storedValue;
|
|
||||||
this->storedValid = theOther->storedValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool changed() override { return ((value != *storedValue) || (valid != *storedValid)); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
T value;
|
|
||||||
T* storedValue;
|
|
||||||
bool* storedValid;
|
|
||||||
bool valid;
|
|
||||||
bool allocated;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef FSFW_INTROSPECTION
|
|
||||||
#define createEntry(p1, p2) createEntry(p1, p2)
|
|
||||||
#else
|
|
||||||
#define createEntry(p1, p2) createEntry(p1)
|
|
||||||
#endif
|
|
@ -1,25 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Dataset.h"
|
|
||||||
|
|
||||||
//TODO use object_id_t
|
|
||||||
|
|
||||||
template <typename HkIDs>
|
|
||||||
class TemplateSet : public Dataset {
|
|
||||||
public:
|
|
||||||
#ifdef FSFW_INTROSPECTION
|
|
||||||
TemplateSet(HasDatapoolIF* owner, HkIDs id, bool allowUserCommit)
|
|
||||||
: Dataset(owner, allowUserCommit) {
|
|
||||||
setEnum(&id);
|
|
||||||
owner->getDatapoolHelper()->registerSet(this);
|
|
||||||
}
|
|
||||||
TemplateSet(uint32_t owner_id, HkIDs id) : Dataset(owner_id) { setEnum(&id); }
|
|
||||||
#else
|
|
||||||
TemplateSet(HasDatapoolIF* owner, HkIDs id, bool allowUserCommit)
|
|
||||||
: Dataset(owner, static_cast<HousekeepingSetId_t>(id), allowUserCommit) {
|
|
||||||
owner->getDatapoolHelper()->registerSet(this);
|
|
||||||
}
|
|
||||||
TemplateSet(uint32_t owner_id, HkIDs id) : Dataset(owner_id, static_cast<HousekeepingSetId_t>(id)) {}
|
|
||||||
#endif
|
|
||||||
virtual ~TemplateSet() = default;
|
|
||||||
};
|
|
@ -5,16 +5,13 @@
|
|||||||
#include "GeneratesHousekeepingIF.h"
|
#include "GeneratesHousekeepingIF.h"
|
||||||
|
|
||||||
#ifdef FSFW_INTROSPECTION
|
#ifdef FSFW_INTROSPECTION
|
||||||
HousekeepingSet::HousekeepingSet(GeneratesHousekeepingIF* owner) {
|
HousekeepingSet::HousekeepingSet(GeneratesHousekeepingIF* owner, const EnumIF &id) {
|
||||||
if (owner != nullptr) {
|
if (owner != nullptr) {
|
||||||
helper = owner->getHousekeepingHelper();
|
helper = owner->getHousekeepingHelper();
|
||||||
helper->registerSet(this);
|
helper->registerSet(this);
|
||||||
}
|
}
|
||||||
}
|
this->id = id.getValue();
|
||||||
|
description = id.getDescription();
|
||||||
void HousekeepingSet::setEnum(EnumIF* theEnum) {
|
|
||||||
id = theEnum->getValue();
|
|
||||||
description = theEnum->getDescription();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* HousekeepingSet::getDescription() const { return description; }
|
const char* HousekeepingSet::getDescription() const { return description; }
|
||||||
|
@ -17,8 +17,7 @@ class HousekeepingSet : public HasTmTcParametersIF, public SerializeIF {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
#ifdef FSFW_INTROSPECTION
|
#ifdef FSFW_INTROSPECTION
|
||||||
HousekeepingSet(GeneratesHousekeepingIF* owner);
|
HousekeepingSet(GeneratesHousekeepingIF* owner, const EnumIF &id);
|
||||||
void setEnum(EnumIF* theEnum);
|
|
||||||
#else
|
#else
|
||||||
HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSetId_t id);
|
HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSetId_t id);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user