Submodules

This article describes how the submodules should be coded

Framework

Each submodule should extend the Submodule class

from submodules.submodule import Submodule


class Telemetry(Submodule):

The Submodule class defines the following methods:

  • __init__

    • defines self.name, self.modules, self.config, self.logger, self.processes

    • self.name and self.config should be passed through the constructor

    • self.modules and self.processes are initialized as empty and can be overridden

    • Submodule.__init__(self,name,config)should be called in each submodules constructor

      • A submodule's constructor should initialize any and all variables and processes, but it should NOT start any processes.

      • The constructor basically "arms" the submodule and makes it ready to start

  • start

    • generic start method

    • The start method should initialize any runtime objects and start all processes

      • Basically tells the submodule to begin working

    • this method can, and is meant to be, overridden

  • set_modules

    • Accessor method for self.modules

    • Assigns dependencies to the submodule

  • has_module

    • Checks if a submodule is in self.modulesand returns True if present

    • Does not raise RuntimeError

  • get_object_or_raise_error

    • Checks if a submodule is in self.modules and returns the module if present

    • raise RuntimeError(f"[{self.name}]:[{module_name}] not found")

    • The submodule should use this method when it needs to access an instance of one of its dependencies modules.

  • enter_normal_mode

    • Not implemented in Submodule

  • enter_low_power_mode

    • Not implemented in Submodule

The Submodule class is below. View this file on GitHub.

Last updated

Was this helpful?