-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration system #5
Comments
Configuration. Happy to learn |
So the basic goal here is to store all the things needed to instantiate the app. The instantiation itself might be handled by the glue layer, but needs to inform the design of the config.
|
Are there any suggestions on how to start? Or any documentation you think might be helpful. |
From a high level, I think the in-memory config could look something like this: class RootConfig
{
List<SensorConfig> Sensors;
List<Theme> Themes;
}
class SensorConfig
{
// used to lookup a sensor factory.
string SensorName;
GpioAddress Address;
// used by e.g. the SCD40 that has a dependency on barometric pressure.
List<Measure> Dependencies;
}
class GpioAddress
{
int? I2cBus;
int? I2cAddress;
// I2C is well defined right now, but others aren't. We can add on later.
// int? SpiAddress;
// List<int> GpioPins;
}
class ThemeConfig
{
// used to lookup a theme factory similar to SensorInfo factories; not made yet.
string ThemeName;
// a theme can have more than one spot to draw a measurement; this fills in the spots.
List<Measure> ThemeMeasures;
// the display to run the theme on.
DisplayConfig Display;
}
class DisplayConfig
{
// used to lookup a display factory similar to SensorInfo factories; not made yet.
string DisplayName;
GpioAddress Address;
} And then we'll need some sort of load/save mechanism that the glue layer can call: RootConfig config = await RootConfig.LoadAsync("path/to/config.txt");
await RootConfig.SaveAsync("path/to/config.txt", config); In existing code, you can see an I2C sensor factory being looked up by name and instantiated, by user-provided "config" (command line inputs) here: Lines 36 to 45 in 6df481e
And binding a theme to a display and (as a Subject) sensor output: Lines 65 to 69 in 6df481e
|
I am assuming all these properties for the various classes should allow for getting and setting the values |
In the process of initializing a giving sensor, is it safe to assume that the user knows information about the address of the device, name and other properties needed to establish the communication? Are we using any pre-made methods? |
If they are editing the file directly, yes. If they use UI, some additional help is available: the |
aether/src/Aether/Devices/Sensors/Metadata/SensorInfo.cs Lines 11 to 19 in 6df481e
aether/src/Aether/Devices/Sensors/Metadata/SensorInfo.cs Lines 21 to 26 in 6df481e
aether/src/Aether/Devices/Sensors/Metadata/I2cSensorInfo.cs Lines 5 to 8 in 6df481e
|
Aether requires a configuration system. It must be able to save to a file to survive reboots.
This would describe things like:
The text was updated successfully, but these errors were encountered: