opensensorhub / osh-core

OpenSensorHub Core Modules
http://docs.opensensorhub.org
Mozilla Public License 2.0
32 stars 16 forks source link

[CORE] Resolve issue (#237) with SensorSystem submodules #262

Closed earocorn closed 2 months ago

earocorn commented 3 months ago

Currently, general problems with the SensorSystem module can be reduced to two main issues.

Issue 1

Sensor system submodules' configs do not save when the sensor system's config is saved.

Reason

Sensor system configs include a list of submodule configs. When a submodule's config is updated, the sensor system's config for that submodule does not get updated. This is because the AdminUI submits a new instance of the submodule's config, but the sensor system's config for this submodule is not updated to the new instance.

Solution

My solution involves an additional method to replace the sensor system's config for the submodule, when the submodule is configured. Ideally, updates to a module's configuration should be listened to by the parent system, if one exists.

Issue 2

Sensor system submodules will not show up unless the sensor system has auto-start enabled.

Reason

Sensor system submodules are only loaded upon initialization of sensor system itself. This is an issue because submodules will not show up in the UI unless they are loaded by the module registry. Modules that are loaded without auto-start will not be initialized. This is not a problem unless you are loading submodules in the initialization procedure, which is the case for this module.

Solution

My solution is to load all submodules of a sensor system when the sensor system itself is loaded, so the module only has to initialize them when the sensor system initializes. Ideally, I believe the ISystemGroupDriver should have a more uniform definition for its getMembers() method, so that members can be loaded upon parent system load, or an abstract loadSubsystems() or loadMembers() should be implemented for each ISystemGroupDriver.

earocorn commented 3 months ago

Also added a change to the getMembers() map in SensorSystem to have keys of the module IDs instead of the module names. With module name as key, you cannot add another submodule with the same name/default name and save.