2022-02-18 19:08:06 +01:00
|
|
|
#ifndef FSFW_UNITTEST_TESTS_MOCKS_PERIODICTASKMOCK_H_
|
|
|
|
#define FSFW_UNITTEST_TESTS_MOCKS_PERIODICTASKMOCK_H_
|
|
|
|
|
|
|
|
#include <fsfw/tasks/ExecutableObjectIF.h>
|
2022-02-22 13:42:56 +01:00
|
|
|
#include <fsfw/tasks/PeriodicTaskIF.h>
|
2022-02-18 19:08:06 +01:00
|
|
|
|
2022-02-22 13:42:56 +01:00
|
|
|
class PeriodicTaskMock : public PeriodicTaskIF {
|
|
|
|
public:
|
|
|
|
PeriodicTaskMock(uint32_t period = 5) : period(period) {}
|
2022-02-18 19:08:06 +01:00
|
|
|
/**
|
|
|
|
* @brief A virtual destructor as it is mandatory for interfaces.
|
|
|
|
*/
|
|
|
|
virtual ~PeriodicTaskMock() {}
|
|
|
|
/**
|
|
|
|
* @brief With the startTask method, a created task can be started
|
|
|
|
* for the first time.
|
|
|
|
*/
|
2022-02-22 13:42:56 +01:00
|
|
|
virtual ReturnValue_t startTask() override { return HasReturnvaluesIF::RETURN_OK; };
|
2022-02-18 19:08:06 +01:00
|
|
|
|
2022-02-22 13:42:56 +01:00
|
|
|
virtual ReturnValue_t addComponent(object_id_t object) override {
|
|
|
|
ExecutableObjectIF* executableObject =
|
|
|
|
ObjectManager::instance()->get<ExecutableObjectIF>(objects::INTERNAL_ERROR_REPORTER);
|
|
|
|
if (executableObject == nullptr) {
|
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
2022-02-18 19:08:06 +01:00
|
|
|
}
|
|
|
|
executableObject->setTaskIF(this);
|
|
|
|
executableObject->initializeAfterTaskCreation();
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
};
|
|
|
|
|
2022-02-22 13:42:56 +01:00
|
|
|
virtual ReturnValue_t sleepFor(uint32_t ms) override { return HasReturnvaluesIF::RETURN_OK; };
|
2022-02-18 19:08:06 +01:00
|
|
|
|
2022-02-22 13:42:56 +01:00
|
|
|
virtual uint32_t getPeriodMs() const override { return period; };
|
2022-02-18 19:08:06 +01:00
|
|
|
uint32_t period;
|
|
|
|
};
|
|
|
|
|
2022-02-22 13:42:56 +01:00
|
|
|
#endif // FSFW_UNITTEST_TESTS_MOCKS_PERIODICTASKMOCK_H_
|