fsfw-example-common/config/commonPollingSequenceFactory.cpp

67 lines
3.1 KiB
C++
Raw Normal View History

2021-06-08 13:46:45 +02:00
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
2021-10-17 23:21:38 +02:00
2022-05-05 20:55:28 +02:00
#include "example/test/FsfwExampleTask.h"
#include "objects/systemObjectList.h"
#include "pollingsequence/pollingSequenceFactory.h"
2021-06-08 13:46:45 +02:00
2022-05-22 15:30:08 +02:00
ReturnValue_t pst::pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence) {
2022-05-05 20:55:28 +02:00
uint32_t length = thisSequence->getPeriodMs();
2022-08-08 12:32:06 +02:00
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0, FsfwExampleTask::OpCodes::SEND_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0, FsfwExampleTask::OpCodes::SEND_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0, FsfwExampleTask::OpCodes::SEND_RAND_NUM);
2022-05-05 20:55:28 +02:00
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0.2,
FsfwExampleTask::OpCodes::RECEIVE_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0.2,
FsfwExampleTask::OpCodes::RECEIVE_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0.2,
FsfwExampleTask::OpCodes::RECEIVE_RAND_NUM);
2022-08-08 12:32:06 +02:00
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0.5, FsfwExampleTask::OpCodes::DELAY_SHORT);
thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0.5, FsfwExampleTask::OpCodes::DELAY_SHORT);
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0.5, FsfwExampleTask::OpCodes::DELAY_SHORT);
2022-05-05 20:55:28 +02:00
2022-09-07 17:40:06 +02:00
if (thisSequence->checkSequence() == returnvalue::OK) {
return returnvalue::OK;
2022-05-05 20:55:28 +02:00
} else {
2021-06-08 13:46:45 +02:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2022-08-08 12:32:06 +02:00
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!" << std::endl;
2021-06-08 13:46:45 +02:00
#else
2022-08-08 12:32:06 +02:00
sif::printError("pst::pollingSequenceInitFunction: Initialization errors!\n");
2021-06-08 13:46:45 +02:00
#endif
2022-09-07 17:40:06 +02:00
return returnvalue::OK;
2022-05-05 20:55:28 +02:00
}
2021-06-08 13:46:45 +02:00
}
2022-05-22 15:30:08 +02:00
ReturnValue_t pst::pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence) {
2022-05-05 20:55:28 +02:00
uint32_t length = thisSequence->getPeriodMs();
2021-06-08 13:46:45 +02:00
2022-08-08 12:32:06 +02:00
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0, DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0, DeviceHandlerIF::PERFORM_OPERATION);
2021-06-08 13:46:45 +02:00
2022-08-08 12:32:06 +02:00
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.3 * length, DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.3 * length, DeviceHandlerIF::SEND_WRITE);
2021-06-08 13:46:45 +02:00
2022-08-08 12:32:06 +02:00
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.45 * length, DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.45 * length, DeviceHandlerIF::GET_WRITE);
2021-06-08 13:46:45 +02:00
2022-08-08 12:32:06 +02:00
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.6 * length, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.6 * length, DeviceHandlerIF::SEND_READ);
2021-06-08 13:46:45 +02:00
2022-08-08 12:32:06 +02:00
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.8 * length, DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.8 * length, DeviceHandlerIF::GET_READ);
2021-06-08 13:46:45 +02:00
2022-09-07 17:40:06 +02:00
if (thisSequence->checkSequence() == returnvalue::OK) {
return returnvalue::OK;
2022-05-05 20:55:28 +02:00
} else {
2021-06-08 13:46:45 +02:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2022-08-08 12:32:06 +02:00
sif::error << "pst::pollingSequenceTestFunction: Initialization errors!" << std::endl;
2021-06-08 13:46:45 +02:00
#else
2022-08-08 12:32:06 +02:00
sif::printError("pst::pollingSequenceTestFunction: Initialization errors!\n");
2021-06-08 13:46:45 +02:00
#endif
2022-09-07 17:40:06 +02:00
return returnvalue::OK;
2022-05-05 20:55:28 +02:00
}
2021-06-08 13:46:45 +02:00
}