2023-03-09 17:44:05 +01:00
|
|
|
#include "LiveTmTask.h"
|
|
|
|
|
|
|
|
#include <fsfw/tasks/TaskFactory.h>
|
2023-03-10 02:05:51 +01:00
|
|
|
#include <fsfw/timemanager/Stopwatch.h>
|
2023-03-09 17:44:05 +01:00
|
|
|
|
2023-03-10 02:05:51 +01:00
|
|
|
LiveTmTask::LiveTmTask(object_id_t objectId, PusTmFunnel& pusFunnel, CfdpTmFunnel& cfdpFunnel,
|
|
|
|
VirtualChannelWithQueue& channel)
|
|
|
|
: SystemObject(objectId), pusFunnel(pusFunnel), cfdpFunnel(cfdpFunnel), channel(channel) {}
|
2023-03-09 17:44:05 +01:00
|
|
|
|
|
|
|
ReturnValue_t LiveTmTask::performOperation(uint8_t opCode) {
|
|
|
|
while (true) {
|
2023-03-10 02:05:51 +01:00
|
|
|
// The funnel tasks are scheduled here directly as well.
|
2023-03-09 17:44:05 +01:00
|
|
|
ReturnValue_t result = channel.sendNextTm();
|
2023-03-20 14:31:10 +01:00
|
|
|
if (result == DirectTmSinkIF::IS_BUSY) {
|
|
|
|
sif::error << "Lost live TM, PAPB busy" << std::endl;
|
|
|
|
}
|
2023-03-09 17:44:05 +01:00
|
|
|
if (result == MessageQueueIF::EMPTY) {
|
2023-03-10 02:05:51 +01:00
|
|
|
if (tmFunnelCd.hasTimedOut()) {
|
|
|
|
pusFunnel.performOperation(0);
|
|
|
|
cfdpFunnel.performOperation(0);
|
|
|
|
tmFunnelCd.resetTimer();
|
|
|
|
}
|
|
|
|
// 40 ms IDLE delay. Might tweak this in the future.
|
|
|
|
TaskFactory::delayTask(40);
|
2023-03-09 17:44:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|