Merge remote-tracking branch 'origin/master' into mueller/fmt-log
This commit is contained in:
@ -1,9 +1,5 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
FsfwReaderTask.cpp
|
||||
FsfwExampleTask.cpp
|
||||
MutexExample.cpp
|
||||
FsfwTestTask.cpp
|
||||
)
|
||||
target_sources(${TARGET_NAME} PRIVATE FsfwReaderTask.cpp FsfwExampleTask.cpp
|
||||
MutexExample.cpp FsfwTestTask.cpp)
|
||||
|
||||
if(OBSW_ADD_FMT_TESTS)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
|
@ -7,15 +7,15 @@
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "commonSystemObjects.h"
|
||||
#include "commonObjects.h"
|
||||
#include "objects/systemObjectList.h"
|
||||
|
||||
FsfwExampleTask::FsfwExampleTask(object_id_t objectId)
|
||||
: SystemObject(objectId),
|
||||
poolManager(this, nullptr),
|
||||
demoSet(this),
|
||||
monitor(objectId, MONITOR_ID, gp_id_t(objectId, FsfwDemoSet::VARIABLE_LIMIT), 30, 10) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(10, CommandMessage::MAX_MESSAGE_SIZE);
|
||||
: SystemObject(objectId), poolManager(this, nullptr), demoSet(this),
|
||||
monitor(objectId, MONITOR_ID,
|
||||
gp_id_t(objectId, FsfwDemoSet::VARIABLE_LIMIT), 30, 10) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||
10, CommandMessage::MAX_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
FsfwExampleTask::~FsfwExampleTask() {}
|
||||
@ -47,33 +47,33 @@ ReturnValue_t FsfwExampleTask::performOperation(uint8_t operationCode) {
|
||||
|
||||
object_id_t FsfwExampleTask::getNextRecipient() {
|
||||
switch (this->getObjectId()) {
|
||||
case (objects::TEST_DUMMY_1): {
|
||||
return objects::TEST_DUMMY_2;
|
||||
}
|
||||
case (objects::TEST_DUMMY_2): {
|
||||
return objects::TEST_DUMMY_3;
|
||||
}
|
||||
case (objects::TEST_DUMMY_3): {
|
||||
return objects::TEST_DUMMY_1;
|
||||
}
|
||||
default:
|
||||
return objects::TEST_DUMMY_1;
|
||||
case (objects::TEST_DUMMY_1): {
|
||||
return objects::TEST_DUMMY_2;
|
||||
}
|
||||
case (objects::TEST_DUMMY_2): {
|
||||
return objects::TEST_DUMMY_3;
|
||||
}
|
||||
case (objects::TEST_DUMMY_3): {
|
||||
return objects::TEST_DUMMY_1;
|
||||
}
|
||||
default:
|
||||
return objects::TEST_DUMMY_1;
|
||||
}
|
||||
}
|
||||
|
||||
object_id_t FsfwExampleTask::getSender() {
|
||||
switch (this->getObjectId()) {
|
||||
case (objects::TEST_DUMMY_1): {
|
||||
return objects::TEST_DUMMY_3;
|
||||
}
|
||||
case (objects::TEST_DUMMY_2): {
|
||||
return objects::TEST_DUMMY_1;
|
||||
}
|
||||
case (objects::TEST_DUMMY_3): {
|
||||
return objects::TEST_DUMMY_2;
|
||||
}
|
||||
default:
|
||||
return objects::TEST_DUMMY_1;
|
||||
case (objects::TEST_DUMMY_1): {
|
||||
return objects::TEST_DUMMY_3;
|
||||
}
|
||||
case (objects::TEST_DUMMY_2): {
|
||||
return objects::TEST_DUMMY_1;
|
||||
}
|
||||
case (objects::TEST_DUMMY_3): {
|
||||
return objects::TEST_DUMMY_2;
|
||||
}
|
||||
default:
|
||||
return objects::TEST_DUMMY_1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,8 @@ ReturnValue_t FsfwExampleTask::initialize() {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
// we need a private copy of the previous dataset.. or we use the shared dataset.
|
||||
// we need a private copy of the previous dataset.. or we use the shared
|
||||
// dataset.
|
||||
senderSet = new FsfwDemoSet(senderIF);
|
||||
if (senderSet == nullptr) {
|
||||
FSFW_LOGE("initialize: Sender dataset invalid\n");
|
||||
@ -99,25 +100,37 @@ ReturnValue_t FsfwExampleTask::initializeAfterTaskCreation() {
|
||||
return poolManager.initializeAfterTaskCreation();
|
||||
}
|
||||
|
||||
object_id_t FsfwExampleTask::getObjectId() const { return SystemObject::getObjectId(); }
|
||||
object_id_t FsfwExampleTask::getObjectId() const {
|
||||
return SystemObject::getObjectId();
|
||||
}
|
||||
|
||||
MessageQueueId_t FsfwExampleTask::getMessageQueueId() { return commandQueue->getId(); }
|
||||
MessageQueueId_t FsfwExampleTask::getMessageQueueId() {
|
||||
return commandQueue->getId();
|
||||
}
|
||||
|
||||
void FsfwExampleTask::setTaskIF(PeriodicTaskIF* task) { this->task = task; }
|
||||
void FsfwExampleTask::setTaskIF(PeriodicTaskIF *task) { this->task = task; }
|
||||
|
||||
LocalPoolDataSetBase* FsfwExampleTask::getDataSetHandle(sid_t sid) { return &demoSet; }
|
||||
LocalPoolDataSetBase *FsfwExampleTask::getDataSetHandle(sid_t sid) {
|
||||
return &demoSet;
|
||||
}
|
||||
|
||||
uint32_t FsfwExampleTask::getPeriodicOperationFrequency() const { return task->getPeriodMs(); }
|
||||
uint32_t FsfwExampleTask::getPeriodicOperationFrequency() const {
|
||||
return task->getPeriodMs();
|
||||
}
|
||||
|
||||
ReturnValue_t FsfwExampleTask::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) {
|
||||
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE_LIMIT, new PoolEntry<uint16_t>({0}));
|
||||
ReturnValue_t
|
||||
FsfwExampleTask::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) {
|
||||
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE,
|
||||
new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE_LIMIT,
|
||||
new PoolEntry<uint16_t>({0}));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t FsfwExampleTask::performMonitoringDemo() {
|
||||
ReturnValue_t result = demoSet.variableLimit.read(MutexIF::TimeoutType::WAITING, 20);
|
||||
ReturnValue_t result =
|
||||
demoSet.variableLimit.read(MutexIF::TimeoutType::WAITING, 20);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
/* Configuration error */
|
||||
FSFW_LOGE("DummyObject::performOperation: Could not read variableLimit\n");
|
||||
@ -180,8 +193,9 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
#if OBSW_VERBOSE_LEVEL >= 2
|
||||
sif::debug << "Message Received by " << getObjectId() << " from Queue "
|
||||
<< receivedMessage.getSender() << " ObjectId " << receivedMessage.getParameter()
|
||||
<< " Queue " << receivedMessage.getParameter2() << std::endl;
|
||||
<< receivedMessage.getSender() << " ObjectId "
|
||||
<< receivedMessage.getParameter() << " Queue "
|
||||
<< receivedMessage.getParameter2() << std::endl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -204,6 +218,10 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
|
||||
return result;
|
||||
}
|
||||
|
||||
MessageQueueId_t FsfwExampleTask::getCommandQueue() const { return commandQueue->getId(); }
|
||||
MessageQueueId_t FsfwExampleTask::getCommandQueue() const {
|
||||
return commandQueue->getId();
|
||||
}
|
||||
|
||||
LocalDataPoolManager* FsfwExampleTask::getHkManagerHandle() { return &poolManager; }
|
||||
LocalDataPoolManager *FsfwExampleTask::getHkManagerHandle() {
|
||||
return &poolManager;
|
||||
}
|
||||
|
@ -24,8 +24,10 @@ class PeriodicTaskIF;
|
||||
* value directly from the sender via the local data pool interface.
|
||||
* If the timing is set up correctly, the values will always be the same.
|
||||
*/
|
||||
class FsfwExampleTask : public ExecutableObjectIF, public SystemObject, public HasLocalDataPoolIF {
|
||||
public:
|
||||
class FsfwExampleTask : public ExecutableObjectIF,
|
||||
public SystemObject,
|
||||
public HasLocalDataPoolIF {
|
||||
public:
|
||||
enum OpCodes { SEND_RAND_NUM, RECEIVE_RAND_NUM, DELAY_SHORT };
|
||||
|
||||
static constexpr uint8_t MONITOR_ID = 2;
|
||||
@ -72,27 +74,28 @@ class FsfwExampleTask : public ExecutableObjectIF, public SystemObject, public H
|
||||
* task interface handle can be cached to access task specific properties.
|
||||
* @param task
|
||||
*/
|
||||
void setTaskIF(PeriodicTaskIF* task) override;
|
||||
void setTaskIF(PeriodicTaskIF *task) override;
|
||||
|
||||
object_id_t getObjectId() const override;
|
||||
|
||||
MessageQueueId_t getMessageQueueId();
|
||||
|
||||
private:
|
||||
private:
|
||||
LocalDataPoolManager poolManager;
|
||||
FsfwDemoSet* senderSet = nullptr;
|
||||
FsfwDemoSet *senderSet = nullptr;
|
||||
FsfwDemoSet demoSet;
|
||||
AbsLimitMonitor<int32_t> monitor;
|
||||
PeriodicTaskIF* task = nullptr;
|
||||
MessageQueueIF* commandQueue = nullptr;
|
||||
PeriodicTaskIF *task = nullptr;
|
||||
MessageQueueIF *commandQueue = nullptr;
|
||||
|
||||
/* HasLocalDatapoolIF overrides */
|
||||
MessageQueueId_t getCommandQueue() const override;
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override;
|
||||
uint32_t getPeriodicOperationFrequency() const override;
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
LocalDataPoolManager* getHkManagerHandle() override;
|
||||
ReturnValue_t
|
||||
initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) override;
|
||||
LocalDataPoolManager *getHkManagerHandle() override;
|
||||
|
||||
object_id_t getNextRecipient();
|
||||
object_id_t getSender();
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include <fsfw/timemanager/Stopwatch.h>
|
||||
|
||||
FsfwReaderTask::FsfwReaderTask(object_id_t objectId, bool enablePrintout)
|
||||
: SystemObject(objectId),
|
||||
printoutEnabled(enablePrintout),
|
||||
opDivider(10),
|
||||
readSet(this->getObjectId(), gp_id_t(objects::TEST_DUMMY_1, FsfwDemoSet::PoolIds::VARIABLE),
|
||||
: SystemObject(objectId), printoutEnabled(enablePrintout), opDivider(10),
|
||||
readSet(this->getObjectId(),
|
||||
gp_id_t(objects::TEST_DUMMY_1, FsfwDemoSet::PoolIds::VARIABLE),
|
||||
gp_id_t(objects::TEST_DUMMY_2, FsfwDemoSet::PoolIds::VARIABLE),
|
||||
gp_id_t(objects::TEST_DUMMY_3, FsfwDemoSet::PoolIds::VARIABLE)) {
|
||||
/* Special protection for set reading because each variable is read from a different pool */
|
||||
/* Special protection for set reading because each variable is read from a
|
||||
* different pool */
|
||||
readSet.setReadCommitProtectionBehaviour(true);
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,14 @@
|
||||
#include "testdefinitions/demoDefinitions.h"
|
||||
|
||||
class FsfwReaderTask : public ExecutableObjectIF, public SystemObject {
|
||||
public:
|
||||
public:
|
||||
FsfwReaderTask(object_id_t objectId, bool enablePrintout);
|
||||
~FsfwReaderTask() override;
|
||||
|
||||
ReturnValue_t initializeAfterTaskCreation() override;
|
||||
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
bool printoutEnabled = false;
|
||||
PeriodicOperationDivider opDivider;
|
||||
CompleteDemoReadSet readSet;
|
||||
|
@ -6,15 +6,16 @@
|
||||
#include "fsfw_tests/integration/task/TestTask.h"
|
||||
|
||||
class FsfwTestTask : public TestTask {
|
||||
public:
|
||||
public:
|
||||
FsfwTestTask(object_id_t objectId, bool periodicEvent);
|
||||
|
||||
ReturnValue_t performPeriodicAction() override;
|
||||
|
||||
private:
|
||||
private:
|
||||
bool periodicEvent = false;
|
||||
static constexpr uint8_t subsystemId = SUBSYSTEM_ID::TEST_TASK_ID;
|
||||
static constexpr Event TEST_EVENT = event::makeEvent(subsystemId, 0, severity::INFO);
|
||||
static constexpr Event TEST_EVENT =
|
||||
event::makeEvent(subsystemId, 0, severity::INFO);
|
||||
};
|
||||
|
||||
#endif /* EXAMPLE_COMMON_EXAMPLE_TEST_FSFWTESTTASK_H_ */
|
||||
|
@ -4,10 +4,11 @@
|
||||
#include <fsfw/serviceinterface.h>
|
||||
|
||||
void MutexExample::example() {
|
||||
MutexIF* mutex = MutexFactory::instance()->createMutex();
|
||||
MutexIF* mutex2 = MutexFactory::instance()->createMutex();
|
||||
MutexIF *mutex = MutexFactory::instance()->createMutex();
|
||||
MutexIF *mutex2 = MutexFactory::instance()->createMutex();
|
||||
|
||||
ReturnValue_t result = mutex->lockMutex(MutexIF::TimeoutType::WAITING, 2 * 60 * 1000);
|
||||
ReturnValue_t result =
|
||||
mutex->lockMutex(MutexIF::TimeoutType::WAITING, 2 * 60 * 1000);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
FSFW_LOGET("MutexExample::example: Lock Failed with {}\n", result);
|
||||
}
|
||||
|
@ -12,21 +12,22 @@
|
||||
* pool variables (for read and write access respectively).
|
||||
*/
|
||||
class FsfwDemoSet : public StaticLocalDataSet<3> {
|
||||
public:
|
||||
public:
|
||||
static constexpr uint32_t DEMO_SET_ID = 0;
|
||||
|
||||
enum PoolIds { VARIABLE, VARIABLE_LIMIT };
|
||||
|
||||
FsfwDemoSet(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, DEMO_SET_ID) {}
|
||||
FsfwDemoSet(HasLocalDataPoolIF *hkOwner)
|
||||
: StaticLocalDataSet(hkOwner, DEMO_SET_ID) {}
|
||||
|
||||
lp_var_t<uint32_t> variableRead =
|
||||
lp_var_t<uint32_t>(sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_READ);
|
||||
lp_var_t<uint32_t> variableWrite =
|
||||
lp_var_t<uint32_t>(sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_WRITE);
|
||||
lp_var_t<uint32_t> variableRead = lp_var_t<uint32_t>(
|
||||
sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_READ);
|
||||
lp_var_t<uint32_t> variableWrite = lp_var_t<uint32_t>(
|
||||
sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_WRITE);
|
||||
lp_var_t<uint16_t> variableLimit =
|
||||
lp_var_t<uint16_t>(sid.objectId, PoolIds::VARIABLE_LIMIT, this);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
/**
|
||||
@ -35,10 +36,11 @@ class FsfwDemoSet : public StaticLocalDataSet<3> {
|
||||
* which reads multiple sensor values at once.
|
||||
*/
|
||||
class CompleteDemoReadSet : public StaticLocalDataSet<3> {
|
||||
public:
|
||||
public:
|
||||
static constexpr uint32_t DEMO_SET_ID = 0;
|
||||
|
||||
CompleteDemoReadSet(object_id_t owner, gp_id_t variable1, gp_id_t variable2, gp_id_t variable3)
|
||||
CompleteDemoReadSet(object_id_t owner, gp_id_t variable1, gp_id_t variable2,
|
||||
gp_id_t variable3)
|
||||
: StaticLocalDataSet(sid_t(owner, DEMO_SET_ID)),
|
||||
variable1(variable1, this, pool_rwm_t::VAR_READ),
|
||||
variable2(variable2, this, pool_rwm_t::VAR_READ),
|
||||
@ -48,7 +50,7 @@ class CompleteDemoReadSet : public StaticLocalDataSet<3> {
|
||||
lp_var_t<uint32_t> variable2;
|
||||
lp_var_t<uint32_t> variable3;
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEMO_DEMODEFINITIONS_H_ */
|
||||
|
Reference in New Issue
Block a user