LoomModule class
Abstract root of Loom component modules inheritance hierarchy.
Contents
All modules in Loom inherit from LoomModule
Derived classes
- class Loom_Interrupt_Manager
- Submanager for managing interrupts, timers, and stopwatches.
- class Loom_Multiplexer
- Multiplexer manager for interfacing with multiple I2C sensors.
- class Loom_Sleep_Manager
- Submanager to manage sleep functionality.
- class LoomActuator
- Abstract base class of actuator modules.
- class LoomCommPlat
- Abstract base of communication platform modules.
- class LoomInternetPlat
- Abstract internet communication module.
- class LoomLogPlat
- Abstract base of logging platforms.
- class LoomNTPSync
- Glue code to synchronize an RTC using an InternetPlat.
- class LoomPublishPlat
- Abstract internet publishing module, implementing google sheets and mongodb functionality.
- class LoomRTC
- Abstract base class of RTC modules.
- class LoomSensor
- Abstract root of Loom sensor modules hierarchy.
- class LoomSubscribePlat
- Abstract subscribe platform module.
- class LoomTempSync
- Used to synchronize temperatures between sensors that read sensors and modules that need it.
Public types
- enum Type { Unknown = 0, Other =1000, Interrupt_Manager, Sleep_Manager, Multiplexer, NTP, TempSync, WarmUp_Manager, Sensor =2000, Analog, Digital, I2C =2100, ADS1115, AS7262, AS7263, AS7265X, FXAS21002, FXOS8700, LIS3DH, MB1232, MMA8451, MPU6050, MS5803, SHT31D, TMP007, TSL2561, TSL2591, ZXGesture, STEMMA, SDI12 =2200, Decagon5TM, DecagonGS3, SPI =2300, MAX31855, MAX31856, L_SERIAL =2400, K30, L_RTC =3000, DS3231, PCF8523, Actuator =4000, Neopixel, Relay, Servo, Stepper, LogPlat =5000, OLED, SDCARD, BATCHSD, CommPlat =6000, LoRa, nRF, Bluetooth, InternetPlat =7000, Ethernet, WiFi, LTE, PublishPlat =8000, GoogleSheets, MaxPub, SpoolPub, SubscribePlats =9000, MaxSub }
- Enum to check against to when finding individual component managed by a LoomManager.
- enum Category { Unknown =0, Other =1, Sensor =2, L_RTC =3, Actuator =4, LogPlat =5, CommPlat =6, InternetPlat =7, PublishPlat =8, SubscribePlat =9 }
- Enum to classify modules.
Protected variables
- const Type module_type
- Module type.
- LoomManager* device_manager
- Pointer to manager.
- const String module_name_base
- The name of the module (Should have a DEFAULT but can be overriden if provided to constructor)
- bool active
- Whether or not the module should be treated as active.
- Verbosity print_verbosity
- Print verbosity.
- Verbosity package_verbosity
- Package verbosity.
CONSTRUCTORS / DESTRUCTOR
-
LoomModule(LoomManager* manager,
const char* module_name = "Unknown",
const Type module_type = Type::
Unknown) - Constructor.
- ~LoomModule() defaulted virtual
- Destructor.
- void second_stage_ctor() virtual
- Second stage construction.
OPERATION
- void package(JsonObject json) pure virtual
- Package a modules measurements or state.
- auto dispatch(JsonObject json) -> bool virtual
- Route command to driver.
- void power_down() virtual
- Turn off any hardware.
- void power_up() virtual
- Turn on any hardware.
- void add_config(JsonObject json) virtual
- Add configuration information to JsonObject.
PRINT INFORMATION
- void print_config() const virtual
- Display the configuration settings of the module.
- void print_state() const virtual
- Display current state of the module.
- void print_module_label() const protected
- Print the module name as a label.
GETTERS
- auto get_module_type() const -> Type
- Get module type.
- auto get_device_manager() const -> LoomManager*
- Get the device manager class if linked.
- void get_module_name(char* buf) const
- Copy module name into buffer.
- auto get_module_name() const -> const char*
- Get module name.
- auto get_print_verbosity() const -> Verbosity
- Get print verbosity.
- auto get_package_verbosity() const -> Verbosity
- Get package verbosity.
- auto get_active() const -> bool
- Get whether or not the module should be treated as active.
- auto category() const -> Category
- Get the category of the module.
SETTERS
- void link_device_manager(LoomManager* LM) virtual
- Add pointer back to device manager.
- void set_print_verbosity(const Verbosity v)
- Set print verbosity Controlls level of detail included in debug prints.
- void set_package_verbosity(const Verbosity v)
- Set package verbosity.
- void set_active(const bool enable)
- Set whether or not the module should be treated as active.
MISCELLANEOUS
- static auto enum_verbosity_string(const Verbosity v) -> const char*
- Get string of name associated with verbosity enum.
- static auto enum_category_string(const Category c) -> const char*
- Get string of the category associated with a Category.
Enum documentation
enum LoomModule:: Type
Enum to check against to when finding individual component managed by a LoomManager.
Used because we cannot use dynamic_cast to check type of modules (rtti disabled by Arduino IDE)
enum LoomModule:: Category
Enum to classify modules.
Similar LoomModule::
Enumerators | |
---|---|
Unknown |
Unknown. |
Other |
Other. |
Sensor |
Sensors. |
L_RTC |
RTC. |
Actuator |
Actuators. |
LogPlat |
LogPlats. |
CommPlat |
CommPlats. |
InternetPlat |
InternetPlats. |
PublishPlat |
PublishPlats. |
SubscribePlat |
SubscribePlats. |
Function documentation
LoomModule:: LoomModule(LoomManager* manager,
const char* module_name = "Unknown",
const Type module_type = Type:: Unknown)
Constructor.
Parameters | |
---|---|
manager | |
module_name in | Name of the module (provided by derived classes) |
module_type in | Type of the module (provided by derived classes) |
void LoomModule:: second_stage_ctor() virtual
Second stage construction.
Perform any actions that need all of the devices to be initized beforehand - such as looking up an internet platform This function is guranteed to be called AFTER all modules have been constructed.
void LoomModule:: package(JsonObject json) pure virtual
Package a modules measurements or state.
Parameters | |
---|---|
json out | Object to put data into |
void LoomModule:: add_config(JsonObject json) virtual
Add configuration information to JsonObject.
Parameters | |
---|---|
json in | Json configuration object to add to |
LoomManager iterates over modules to build complete configuration
void LoomModule:: print_module_label() const protected
Print the module name as a label.
Used for matching debug prints to corresponding module
LoomManager* LoomModule:: get_device_manager() const
Get the device manager class if linked.
Returns | Pointer to the LoomManager, Null if not linked |
---|
void LoomModule:: get_module_name(char* buf) const
Copy module name into buffer.
Parameters | |
---|---|
buf out | The buffer to copy module name into |
Verbosity LoomModule:: get_print_verbosity() const
Get print verbosity.
Returns | The current verbosity setting |
---|
Verbosity LoomModule:: get_package_verbosity() const
Get package verbosity.
Returns | The current verbosity setting |
---|
bool LoomModule:: get_active() const
Get whether or not the module should be treated as active.
Returns | Whether or not the module is active |
---|
void LoomModule:: link_device_manager(LoomManager* LM) virtual
Add pointer back to device manager.
Parameters | |
---|---|
LM in | LoomManager to point to |
Generally only called when device manager links module to provide pointer both directions. Derived modules may override this for increased function, such as linking a submanager or RTC module.
void LoomModule:: set_package_verbosity(const Verbosity v)
Set package verbosity.
Parameters | |
---|---|
v in | The verbosity setting |
Controlls level of detail included in bundles
void LoomModule:: set_active(const bool enable)
Set whether or not the module should be treated as active.
Parameters | |
---|---|
enable in | Whether or not to enable module |
static const char* LoomModule:: enum_verbosity_string(const Verbosity v)
Get string of name associated with verbosity enum.
Parameters | |
---|---|
v in | Verbosity value to get string representation of |
Returns | String of verbosity |
static const char* LoomModule:: enum_category_string(const Category c)
Get string of the category associated with a Category.
Parameters | |
---|---|
c in | Category value to get string representation of |
Returns | String of category |
Variable documentation
LoomManager* LoomModule:: device_manager protected
Pointer to manager.
LoomManager provides to any modules passed to add_module
bool LoomModule:: active protected
Whether or not the module should be treated as active.
If inactive at setup (due to failed initialization, module will be deleted)