2023-03-09 19:42:20 +01:00
|
|
|
#ifndef MISSION_TMTC_TMSTORETASKBASE_H_
|
|
|
|
#define MISSION_TMTC_TMSTORETASKBASE_H_
|
|
|
|
|
2023-03-09 20:16:00 +01:00
|
|
|
#include <fsfw/timemanager/Countdown.h>
|
2023-03-09 19:42:20 +01:00
|
|
|
#include <mission/tmtc/PersistentTmStoreWithTmQueue.h>
|
|
|
|
#include <mission/tmtc/VirtualChannel.h>
|
|
|
|
|
|
|
|
class TmStoreTaskBase : public SystemObject {
|
|
|
|
public:
|
2023-03-11 14:59:55 +01:00
|
|
|
struct DumpContext {
|
|
|
|
DumpContext(Event eventIfDone) : eventIfDone(eventIfDone) {}
|
|
|
|
void reset() {
|
|
|
|
numberOfDumpedPackets = 0;
|
|
|
|
dumpedBytes = 0;
|
|
|
|
}
|
|
|
|
const Event eventIfDone;
|
|
|
|
uint32_t numberOfDumpedPackets = 0;
|
|
|
|
uint32_t dumpedBytes = 0;
|
2023-03-23 18:31:47 +01:00
|
|
|
uint32_t ptmeBusyCounter = 0;
|
2023-03-11 14:59:55 +01:00
|
|
|
};
|
|
|
|
|
2023-03-09 20:16:00 +01:00
|
|
|
TmStoreTaskBase(object_id_t objectId, StorageManagerIF& ipcStore, VirtualChannel& channel,
|
|
|
|
SdCardMountedIF& sdcMan);
|
|
|
|
|
|
|
|
protected:
|
2023-03-09 19:42:20 +01:00
|
|
|
/**
|
|
|
|
* Handling for one store. Returns if anything was done.
|
|
|
|
* @param store
|
|
|
|
* @return
|
|
|
|
*/
|
2023-03-11 14:59:55 +01:00
|
|
|
bool handleOneStore(PersistentTmStoreWithTmQueue& store, DumpContext& dumpContext);
|
2023-03-09 19:42:20 +01:00
|
|
|
|
2023-03-09 20:16:00 +01:00
|
|
|
/**
|
|
|
|
* Occasionally check whether SD card is okay to be used. If not, poll whether it is ready to
|
|
|
|
* be used again and re-initialize stores. Returns whether store is okay to be used.
|
|
|
|
*/
|
|
|
|
bool cyclicStoreCheck();
|
|
|
|
|
2023-03-10 02:05:51 +01:00
|
|
|
virtual bool initStoresIfPossible() = 0;
|
2023-03-09 20:16:00 +01:00
|
|
|
|
2023-03-09 19:42:20 +01:00
|
|
|
StorageManagerIF& ipcStore;
|
2023-03-09 20:16:00 +01:00
|
|
|
Countdown sdCardCheckCd = Countdown(800);
|
2023-03-10 20:32:11 +01:00
|
|
|
// 20 minutes are allowed as maximum dump time.
|
|
|
|
Countdown cancelDumpCd = Countdown(60 * 20 * 1000);
|
|
|
|
// If the TM sink is busy for 1 minute for whatever reason, cancel the dump.
|
|
|
|
Countdown tmSinkBusyCd = Countdown(60 * 1000);
|
2023-03-09 19:42:20 +01:00
|
|
|
VirtualChannel& channel;
|
2023-03-09 20:16:00 +01:00
|
|
|
bool storesInitialized = false;
|
2023-03-21 14:09:59 +01:00
|
|
|
bool fileHasSwapped = false;
|
2023-03-09 20:16:00 +01:00
|
|
|
SdCardMountedIF& sdcMan;
|
2023-03-09 19:42:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MISSION_TMTC_TMSTORETASKBASE_H_ */
|