2021-03-10 22:19:55 +01:00
|
|
|
#include "LocalPoolOwnerBase.h"
|
|
|
|
|
2022-07-25 19:36:56 +02:00
|
|
|
LocalPoolOwnerBase::LocalPoolOwnerBase(MessageQueueIF &queue, object_id_t objectId)
|
|
|
|
: SystemObject(objectId),
|
|
|
|
queue(queue),
|
2024-11-05 17:02:45 +01:00
|
|
|
sharedPool(getObjectId()),
|
|
|
|
hkHelper(this, &queue),
|
|
|
|
dataset(sharedPool, lpool::testSetId) {}
|
2021-03-10 22:19:55 +01:00
|
|
|
|
2022-07-25 19:36:56 +02:00
|
|
|
LocalPoolOwnerBase::~LocalPoolOwnerBase() = default;
|
2021-03-11 12:04:54 +01:00
|
|
|
|
2024-11-05 17:02:45 +01:00
|
|
|
ReturnValue_t LocalPoolOwnerBase::initialize() {
|
|
|
|
sharedPool.addPoolEntry(lpool::uint8VarId, &u8PoolEntry);
|
|
|
|
sharedPool.addPoolEntry(lpool::floatVarId, &floatPoolEntry);
|
|
|
|
sharedPool.addPoolEntry(lpool::uint32VarId, &u32PoolEntry);
|
|
|
|
sharedPool.addPoolEntry(lpool::uint16Vec3Id, &u16VecPoolEntry);
|
|
|
|
sharedPool.addPoolEntry(lpool::int64Vec2Id, &i64VecPoolEntry);
|
|
|
|
ReturnValue_t result = hkHelper.initialize(&queue);
|
|
|
|
if (result != returnvalue::OK) {
|
|
|
|
return result;
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
2024-11-05 17:02:45 +01:00
|
|
|
return SystemObject::initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
localpool::SharedPool *LocalPoolOwnerBase::getOptionalSharedPool() { return &sharedPool; }
|
|
|
|
|
|
|
|
ReturnValue_t LocalPoolOwnerBase::serializeDataset(sid_t structureId, uint8_t *buf,
|
|
|
|
size_t maxSize) {
|
2022-08-16 01:08:26 +02:00
|
|
|
return returnvalue::OK;
|
2021-03-10 22:19:55 +01:00
|
|
|
}
|
|
|
|
|
2024-11-05 17:02:45 +01:00
|
|
|
ReturnValue_t LocalPoolOwnerBase::specifyDatasets(
|
|
|
|
std::vector<periodicHk::SetSpecification> &setList) {
|
|
|
|
return returnvalue::OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-03-10 22:19:55 +01:00
|
|
|
ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
2024-11-04 17:32:21 +01:00
|
|
|
PeriodicHkGenerationHelper &poolManager) {
|
2022-02-02 10:29:30 +01:00
|
|
|
// Default initialization empty for now.
|
2022-07-25 22:10:20 +02:00
|
|
|
localDataPoolMap.emplace(lpool::uint8VarId, &u8PoolEntry);
|
|
|
|
localDataPoolMap.emplace(lpool::floatVarId, &floatPoolEntry);
|
|
|
|
localDataPoolMap.emplace(lpool::uint32VarId, &u32PoolEntry);
|
2022-02-02 10:29:30 +01:00
|
|
|
|
2022-07-25 22:10:20 +02:00
|
|
|
localDataPoolMap.emplace(lpool::uint16Vec3Id, &u16VecPoolEntry);
|
|
|
|
localDataPoolMap.emplace(lpool::int64Vec2Id, &i64VecPoolEntry);
|
2022-08-16 01:08:26 +02:00
|
|
|
return returnvalue::OK;
|
2021-03-10 22:19:55 +01:00
|
|
|
}
|
2024-11-05 17:02:45 +01:00
|
|
|
*/
|
2021-03-10 22:19:55 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
LocalPoolObjectBase *LocalPoolOwnerBase::getPoolObjectHandle(lp_id_t localPoolId) {
|
|
|
|
if (localPoolId == lpool::uint8VarId) {
|
|
|
|
return &testUint8;
|
|
|
|
} else if (localPoolId == lpool::uint16Vec3Id) {
|
|
|
|
return &testUint16Vec;
|
|
|
|
} else if (localPoolId == lpool::floatVarId) {
|
|
|
|
return &testFloat;
|
|
|
|
} else if (localPoolId == lpool::int64Vec2Id) {
|
|
|
|
return &testInt64Vec;
|
|
|
|
} else if (localPoolId == lpool::uint32VarId) {
|
|
|
|
return &testUint32;
|
|
|
|
} else {
|
|
|
|
return &testUint8;
|
|
|
|
}
|
2021-03-10 22:19:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t LocalPoolOwnerBase::reset() {
|
2024-11-04 17:32:21 +01:00
|
|
|
// resetSubscriptionList();
|
2022-08-16 01:08:26 +02:00
|
|
|
ReturnValue_t status = returnvalue::OK;
|
2022-02-02 10:29:30 +01:00
|
|
|
{
|
|
|
|
PoolReadGuard readHelper(&dataset);
|
2022-08-16 01:08:26 +02:00
|
|
|
if (readHelper.getReadResult() != returnvalue::OK) {
|
2022-02-02 10:29:30 +01:00
|
|
|
status = readHelper.getReadResult();
|
2021-03-10 22:19:55 +01:00
|
|
|
}
|
2022-02-02 10:29:30 +01:00
|
|
|
dataset.localPoolVarUint8.value = 0;
|
|
|
|
dataset.localPoolVarFloat.value = 0.0;
|
|
|
|
dataset.localPoolUint16Vec.value[0] = 0;
|
|
|
|
dataset.localPoolUint16Vec.value[1] = 0;
|
|
|
|
dataset.localPoolUint16Vec.value[2] = 0;
|
2024-11-04 17:32:21 +01:00
|
|
|
// dataset.setValidity(false, true);
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
PoolReadGuard readHelper(&testUint32);
|
2022-08-16 01:08:26 +02:00
|
|
|
if (readHelper.getReadResult() != returnvalue::OK) {
|
2022-02-02 10:29:30 +01:00
|
|
|
status = readHelper.getReadResult();
|
2021-03-10 22:19:55 +01:00
|
|
|
}
|
2022-02-02 10:29:30 +01:00
|
|
|
testUint32.value = 0;
|
2024-11-04 17:32:21 +01:00
|
|
|
// testUint32.setValid(false);
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
PoolReadGuard readHelper(&testInt64Vec);
|
2022-08-16 01:08:26 +02:00
|
|
|
if (readHelper.getReadResult() != returnvalue::OK) {
|
2022-02-02 10:29:30 +01:00
|
|
|
status = readHelper.getReadResult();
|
2021-03-10 22:19:55 +01:00
|
|
|
}
|
2022-02-02 10:29:30 +01:00
|
|
|
testInt64Vec.value[0] = 0;
|
|
|
|
testInt64Vec.value[1] = 0;
|
2024-11-04 17:32:21 +01:00
|
|
|
// testInt64Vec.setValid(false);
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
|
|
|
return status;
|
2021-03-10 22:19:55 +01:00
|
|
|
}
|
2021-03-10 23:16:47 +01:00
|
|
|
|
|
|
|
bool LocalPoolOwnerBase::changedDataSetCallbackWasCalled(sid_t &sid, store_address_t &storeId) {
|
2022-02-02 10:29:30 +01:00
|
|
|
bool condition = false;
|
|
|
|
if (not this->changedDatasetSid.notSet()) {
|
|
|
|
condition = true;
|
|
|
|
}
|
|
|
|
sid = changedDatasetSid;
|
|
|
|
storeId = storeIdForChangedSet;
|
|
|
|
this->changedDatasetSid.raw = sid_t::INVALID_SID;
|
2022-07-25 11:15:45 +02:00
|
|
|
this->storeIdForChangedSet = store_address_t::invalid();
|
2022-02-02 10:29:30 +01:00
|
|
|
return condition;
|
2021-03-10 23:16:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool LocalPoolOwnerBase::changedVariableCallbackWasCalled(gp_id_t &gpid, store_address_t &storeId) {
|
2022-02-02 10:29:30 +01:00
|
|
|
bool condition = false;
|
|
|
|
if (not this->changedPoolVariableGpid.notSet()) {
|
|
|
|
condition = true;
|
|
|
|
}
|
|
|
|
gpid = changedPoolVariableGpid;
|
|
|
|
storeId = storeIdForChangedVariable;
|
|
|
|
this->changedPoolVariableGpid.raw = gp_id_t::INVALID_GPID;
|
2022-07-25 11:15:45 +02:00
|
|
|
this->storeIdForChangedVariable = store_address_t::invalid();
|
2022-02-02 10:29:30 +01:00
|
|
|
return condition;
|
2021-03-10 23:16:47 +01:00
|
|
|
}
|
|
|
|
|
2024-11-05 17:02:45 +01:00
|
|
|
void LocalPoolOwnerBase::setHkDestId(MessageQueueId_t id) { hkHelper.setHkDestinationId(id); }
|