completed 02

This commit is contained in:
Robin Müller 2022-10-04 11:09:29 +02:00
parent 96106f096c
commit 535840a831
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 50 additions and 5 deletions

2
fsfw

@ -1 +1 @@
Subproject commit 6f562e5f3ed6ff971cad6e95f3f689f0a9c6e953
Subproject commit fd46784d0dada73a97983700d6428aada377e911

View File

@ -13,10 +13,11 @@ public:
};
int main() {
auto* mySysObj = new MySystemObject();
new MySystemObject();
auto* objManager = ObjectManager::instance();
objManager->initialize();
auto* mySysObj = objManager->get<MySystemObject>(0x10101010);
cout << "Object ID: " << setfill('0') << hex << "0x" << setw(8) <<
mySysObj->getObjectId() << endl;
objManager->initialize();
return 0;
}

View File

@ -66,9 +66,12 @@ when inserting new entries.
The `SystemObject` base class will take care of automatically registering the object at the
global object manager as part of its constructor. The object manager stores all inserted objects
by the `SystemObject` base class pointer inside a hash map, so all inserted objects can be
by the `SystemObjectIF` base class pointer inside a hash map, so all inserted objects can be
retrieved at a later stage. The object manager is also able to call the `initialize` method of
all its registered objects.
all its registered objects. The initialize method allows to return an explicit returnvalue
for failed object initialization. This is generally not possible for object constructors.
The usual way to have an object construction fail is to use exceptions, which might or might not
be available to your project.
## Subtasks
@ -78,3 +81,21 @@ all its registered objects.
automatically in its own destructor
3. Retrieve the global instance of the object manager using its static `instance` method
and use it to initialize all system objects including your custom system object.
4. Retrieve the concrete instance of your object using the `ObjectManager` `get` method.
Please note that you explicitely have to specify the target type you want to retrieve
using a template argument to `get`. Use that instance to retrieve and print the object ID
instead of using the instance returned by `new`
# 3. Schedule your object using its object ID
The object ID is now an addressing unit which can be used at various places in the framework.
One example is to schedule the object. This means that instead of passing the concrete instance
of the object, you can also add units to schedule by using their object ID
## Subtasks
1. Retrieve the global instance of the `TaskFactory` using its static `instance` method.
2. Create a new enum called `ObjectIds` and make your object ID an enum number
if it. If this is not the case already, refactor your `MySystemObject` to expect
the Object ID via constructor argument.
2. Create a `PeriodicTask` and add your custom system object using its object ID

View File

@ -0,0 +1,23 @@
#include "fsfw/objectmanager.h"
#include <iostream>
#include <iomanip>
using namespace std;
class MySystemObject: public SystemObject {
public:
MySystemObject(): SystemObject(0x10101010) {}
ReturnValue_t initialize() override {
cout << "MySystemObject::initialize: Custom init" << endl;
}
};
int main() {
new MySystemObject();
auto* objManager = ObjectManager::instance();
objManager->initialize();
auto* mySysObj = objManager->get<MySystemObject>(0x10101010);
cout << "Object ID: " << setfill('0') << hex << "0x" << setw(8) <<
mySysObj->getObjectId() << endl;
return 0;
}