2021-03-10 22:19:55 +01:00
|
|
|
#include "LocalPoolOwnerBase.h"
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
LocalPoolOwnerBase::LocalPoolOwnerBase(object_id_t objectId)
|
|
|
|
: SystemObject(objectId), poolManager(this, messageQueue), dataset(this, lpool::testSetId) {
|
|
|
|
messageQueue = new MessageQueueMockBase();
|
2021-03-10 22:19:55 +01:00
|
|
|
}
|
|
|
|
|
2021-03-11 12:04:54 +01:00
|
|
|
LocalPoolOwnerBase::~LocalPoolOwnerBase() {
|
2022-02-02 10:29:30 +01:00
|
|
|
QueueFactory::instance()->deleteMessageQueue(messageQueue);
|
2021-03-11 12:04:54 +01:00
|
|
|
}
|
|
|
|
|
2021-03-10 22:19:55 +01:00
|
|
|
ReturnValue_t LocalPoolOwnerBase::initializeHkManager() {
|
2022-02-02 10:29:30 +01:00
|
|
|
if (not initialized) {
|
|
|
|
initialized = true;
|
|
|
|
return poolManager.initialize(messageQueue);
|
|
|
|
}
|
2022-08-15 20:28:16 +02:00
|
|
|
return returnvalue::OK;
|
2021-03-10 22:19:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
2022-02-02 10:29:30 +01:00
|
|
|
LocalDataPoolManager &poolManager) {
|
|
|
|
// Default initialization empty for now.
|
|
|
|
localDataPoolMap.emplace(lpool::uint8VarId, new PoolEntry<uint8_t>({0}));
|
|
|
|
localDataPoolMap.emplace(lpool::floatVarId, new PoolEntry<float>({0}));
|
|
|
|
localDataPoolMap.emplace(lpool::uint32VarId, new PoolEntry<uint32_t>({0}));
|
|
|
|
|
|
|
|
localDataPoolMap.emplace(lpool::uint16Vec3Id, new PoolEntry<uint16_t>({0, 0, 0}));
|
|
|
|
localDataPoolMap.emplace(lpool::int64Vec2Id, new PoolEntry<int64_t>({0, 0}));
|
2022-08-15 20:28:16 +02:00
|
|
|
return returnvalue::OK;
|
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() {
|
2022-02-02 10:29:30 +01:00
|
|
|
resetSubscriptionList();
|
2022-08-15 20:28:16 +02:00
|
|
|
ReturnValue_t status = returnvalue::OK;
|
2022-02-02 10:29:30 +01:00
|
|
|
{
|
|
|
|
PoolReadGuard readHelper(&dataset);
|
2022-08-15 20:28:16 +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;
|
|
|
|
dataset.setValidity(false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
PoolReadGuard readHelper(&testUint32);
|
2022-08-15 20:28:16 +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;
|
|
|
|
testUint32.setValid(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
PoolReadGuard readHelper(&testInt64Vec);
|
2022-08-15 20:28:16 +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;
|
|
|
|
testInt64Vec.setValid(false);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
this->storeIdForChangedSet = storeId::INVALID_STORE_ADDRESS;
|
|
|
|
return condition;
|
2021-03-10 23:16:47 +01:00
|
|
|
}
|
|
|
|
|
2021-03-11 12:33:26 +01:00
|
|
|
void LocalPoolOwnerBase::handleChangedDataset(sid_t sid, store_address_t storeId,
|
2022-02-02 10:29:30 +01:00
|
|
|
bool *clearMessage) {
|
|
|
|
this->changedDatasetSid = sid;
|
|
|
|
this->storeIdForChangedSet = storeId;
|
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;
|
|
|
|
this->storeIdForChangedVariable = storeId::INVALID_STORE_ADDRESS;
|
|
|
|
return condition;
|
2021-03-10 23:16:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t LocalPoolOwnerBase::initializeHkManagerAfterTaskCreation() {
|
2022-02-02 10:29:30 +01:00
|
|
|
if (not initializedAfterTaskCreation) {
|
|
|
|
initializedAfterTaskCreation = true;
|
|
|
|
return poolManager.initializeAfterTaskCreation();
|
|
|
|
}
|
2022-08-15 20:28:16 +02:00
|
|
|
return returnvalue::OK;
|
2021-03-10 23:16:47 +01:00
|
|
|
}
|
|
|
|
|
2021-03-11 12:33:26 +01:00
|
|
|
void LocalPoolOwnerBase::handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId,
|
2022-02-02 10:29:30 +01:00
|
|
|
bool *clearMessage) {
|
|
|
|
this->changedPoolVariableGpid = globPoolId;
|
|
|
|
this->storeIdForChangedVariable = storeId;
|
2021-03-10 23:16:47 +01:00
|
|
|
}
|