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

  1. Define the plane Header
    • Add plane header into ApplicationConfigurationHeaderKey
  2. Add Variables under the plane header
    • Add the class PlaneConfigurationKey and add a variable called DRAG: str = "drag"
  3. Define the drag property
    • In ApplicationConfiguration create the following method
    @property
    def plane_drag(self) -> float:
        return self.__get_variable(
            ApplicationConfigurationHeaderKey.PLANE,
            PlaneConfigurationKey.DRAG,
        )
    

:information_source: See how we use ApplicationConfigurationHeaderKey and PlaneConfigurationKey to get our variable.

  1. Add plane header & drag variable in yaml
plane:
  drag: 0.25  # Float value for the drag value