Configuration - AvionCargo-UL/SkyAvionics GitHub Wiki
Application Configuration
The ApplicationConfiguration class is responsible for loading and accessing application-specific configuration values stored in a YAML file. It provides methods to retrieve configuration data and handles exceptions when a configuration key is not found.
Constructor
Initializes the class and loads the YAML configuration file.
config = ApplicationConfiguration("config.yaml")
Exception
ApplicationVariableNotFoundException
This exception is raised when a requested configuration variable is not found in the specified section or header.
Adding Variables to the YAML Configuration File
The ApplicationConfiguration
class reads configuration values from a YAML file. In this section, we will walk through how to add a new configuration variable under the plane header.
Example Configuration
- Define the
plane
Header- Add
plane
header intoApplicationConfigurationHeaderKey
- Add
- Add Variables under the plane header
- Add the class
PlaneConfigurationKey
and add a variable calledDRAG: str = "drag"
- Add the class
- Define the drag property
- In
ApplicationConfiguration
create the following method
@property def plane_drag(self) -> float: return self.__get_variable( ApplicationConfigurationHeaderKey.PLANE, PlaneConfigurationKey.DRAG, )
- In
:information_source: See how we use ApplicationConfigurationHeaderKey
and PlaneConfigurationKey
to get our variable.
- Add plane header & drag variable in yaml
plane:
drag: 0.25 # Float value for the drag value