fsfw-from-zero/main.cpp

43 lines
1.3 KiB
C++
Raw Normal View History

2022-10-04 10:26:12 +02:00
#include "fsfw/objectmanager.h"
2022-10-04 11:20:21 +02:00
#include "fsfw/tasks/TaskFactory.h"
#include <thread>
2022-10-04 10:35:03 +02:00
#include <iostream>
2022-10-04 10:26:12 +02:00
#include <iomanip>
2022-09-28 19:44:30 +02:00
2022-09-02 09:07:20 +02:00
using namespace std;
2022-10-04 11:20:21 +02:00
enum ObjectIds {
TEST_OBJECT = 0x10101010
};
class MyObject: public ExecutableObjectIF, public SystemObject {
2022-10-04 10:26:12 +02:00
public:
2022-10-04 11:20:21 +02:00
MyObject(object_id_t objectId): SystemObject(objectId) {}
ReturnValue_t performOperation(uint8_t opCode) override {
cout << "MyObject::performOperation: Periodic handling" << endl;
return returnvalue::OK;
}
2022-10-04 10:26:12 +02:00
ReturnValue_t initialize() override {
2022-10-04 11:20:21 +02:00
cout << "MyObject::initialize: Custom init" << endl;
return returnvalue::OK;
2022-10-04 10:26:12 +02:00
}
};
2022-09-02 09:07:20 +02:00
int main() {
2022-10-04 11:20:21 +02:00
new MyObject(ObjectIds::TEST_OBJECT);
2022-10-04 10:35:03 +02:00
auto* objManager = ObjectManager::instance();
2022-10-04 11:09:29 +02:00
objManager->initialize();
2022-10-04 11:20:21 +02:00
auto* mySysObj = objManager->get<MyObject>(ObjectIds::TEST_OBJECT);
2022-10-04 10:35:03 +02:00
cout << "Object ID: " << setfill('0') << hex << "0x" << setw(8) <<
2022-10-04 10:26:12 +02:00
mySysObj->getObjectId() << endl;
2022-10-04 11:20:21 +02:00
auto* taskFactory = TaskFactory::instance();
PeriodicTaskIF* periodicTask = taskFactory->createPeriodicTask("TEST_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr);
periodicTask->addComponent(ObjectIds::TEST_OBJECT);
periodicTask->startTask();
while(true) {
using namespace std::chrono_literals;
this_thread::sleep_for(5000ms);
}
2022-10-04 10:35:03 +02:00
return 0;
2022-09-28 14:35:09 +02:00
}