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.processesself.nameandself.configshould be passed through the constructorself.modulesandself.processesare initialized as empty and can be overriddenSubmodule.__init__(self,name,config)should be called in eachsubmodulesconstructorA
submodule's constructor should initialize any and all variables and processes, but it should NOT start any processes.The constructor basically "arms" the
submoduleand makes it ready tostart
startgeneric 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_modulesAccessor method for
self.modulesAssigns dependencies to the
submodule
has_moduleChecks if a
submoduleis inself.modulesand returnsTrueif presentDoes not
raise RuntimeError
get_object_or_raise_errorChecks if a
submoduleis inself.modulesand returns the module if presentraise RuntimeError(f"[{self.name}]:[{module_name}] not found")The
submoduleshould use this method when it needs to access an instance of one of its dependencies modules.
enter_normal_modeNot implemented in
Submodule
enter_low_power_modeNot implemented in
Submodule
The Submodule class is below. View this file on GitHub.
Last updated
Was this helpful?