Submodules
This article describes how the submodules should be coded
Framework
Each submodule should extend the Submodule
class
The Submodule
class defines the following methods:
__init__
defines
self.name
,self.modules
,self.config
,self.logger
,self.processes
self.name
andself.config
should be passed through the constructorself.modules
andself.processes
are initialized as empty and can be overriddenSubmodule.__init__(self,name,config)
should be called in eachsubmodules
constructorA
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 tostart
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 inself.modules
and returnsTrue
if presentDoes not
raise RuntimeError
get_object_or_raise_error
Checks if a
submodule
is inself.modules
and returns the module if presentraise 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