fsfw/tests/src/fsfw_tests/integration/task/TestTask.cpp

63 lines
1.7 KiB
C++
Raw Normal View History

2021-10-17 23:27:31 +02:00
#include "TestTask.h"
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
MutexIF* TestTask::testLock = nullptr;
2022-02-02 10:29:30 +01:00
TestTask::TestTask(object_id_t objectId) : SystemObject(objectId), testMode(testModes::A) {
if (testLock == nullptr) {
testLock = MutexFactory::instance()->createMutex();
}
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
2021-10-17 23:27:31 +02:00
}
2022-05-29 16:05:59 +02:00
TestTask::~TestTask() = default;
2021-10-17 23:27:31 +02:00
ReturnValue_t TestTask::performOperation(uint8_t operationCode) {
2022-02-02 10:29:30 +01:00
ReturnValue_t result = RETURN_OK;
testLock->lockMutex(MutexIF::TimeoutType::WAITING, 20);
if (oneShotAction) {
// Add code here which should only be run once
performOneShotAction();
oneShotAction = false;
}
testLock->unlockMutex();
// Add code here which should only be run once per performOperation
performPeriodicAction();
// Add code here which should only be run on alternating cycles.
if (testMode == testModes::A) {
performActionA();
testMode = testModes::B;
} else if (testMode == testModes::B) {
performActionB();
testMode = testModes::A;
}
return result;
2021-10-17 23:27:31 +02:00
}
ReturnValue_t TestTask::performOneShotAction() {
2022-02-02 10:29:30 +01:00
/* Everything here will only be performed once. */
return HasReturnvaluesIF::RETURN_OK;
2021-10-17 23:27:31 +02:00
}
ReturnValue_t TestTask::performPeriodicAction() {
2022-02-02 10:29:30 +01:00
/* This is performed each task cycle */
ReturnValue_t result = RETURN_OK;
return result;
2021-10-17 23:27:31 +02:00
}
ReturnValue_t TestTask::performActionA() {
2022-02-02 10:29:30 +01:00
/* This is performed each alternating task cycle */
ReturnValue_t result = RETURN_OK;
return result;
2021-10-17 23:27:31 +02:00
}
ReturnValue_t TestTask::performActionB() {
2022-02-02 10:29:30 +01:00
/* This is performed each alternating task cycle */
ReturnValue_t result = RETURN_OK;
return result;
2021-10-17 23:27:31 +02:00
}