73 lines
1.8 KiB
C++
73 lines
1.8 KiB
C++
#include <test/testtasks/TestTask.h>
|
|
#include <fsfw/objectmanager/frameworkObjects.h>
|
|
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
|
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
|
#include <fsfw/timemanager/Stopwatch.h>
|
|
#include <fsfw/globalfunctions/arrayprinter.h>
|
|
|
|
#include <array>
|
|
#include <cstring>
|
|
|
|
bool TestTask::oneShotAction = true;
|
|
MutexIF* TestTask::testLock = nullptr;
|
|
|
|
TestTask::TestTask(object_id_t objectId_):
|
|
SystemObject(objectId_), testMode(testModes::A) {
|
|
if(testLock == nullptr) {
|
|
testLock = MutexFactory::instance()->createMutex();
|
|
}
|
|
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
|
}
|
|
|
|
TestTask::~TestTask() {
|
|
}
|
|
|
|
ReturnValue_t TestTask::performOperation(uint8_t operationCode) {
|
|
ReturnValue_t result = RETURN_OK;
|
|
sif::info << "Hallo EIVE!" << std::endl;
|
|
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;
|
|
}
|
|
|
|
ReturnValue_t TestTask::performOneShotAction() {
|
|
// Everything here will only be performed once.
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
}
|
|
|
|
|
|
ReturnValue_t TestTask::performPeriodicAction() {
|
|
ReturnValue_t result = RETURN_OK;
|
|
return result;
|
|
}
|
|
|
|
ReturnValue_t TestTask::performActionA() {
|
|
ReturnValue_t result = RETURN_OK;
|
|
// Add periodically executed code here
|
|
return result;
|
|
}
|
|
|
|
ReturnValue_t TestTask::performActionB() {
|
|
ReturnValue_t result = RETURN_OK;
|
|
// Add periodically executed code here
|
|
return result;
|
|
}
|