![]() |
RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
|
Holds the library's runtime configuration, loaded from a JSON file. More...
#include <RumPiConfig.h>
Public Member Functions | |
| RumPiConfig () | |
| Builds a configuration with every value set to its built-in default. More... | |
| bool | LoadFromJson (const nlohmann::json &configJson) |
| Loads settings from an already-parsed config JSON over the current values, so any key missing from the JSON keeps its default. More... | |
| unsigned int | GetUpdateDelayMilliseconds () const |
| Gets the update-loop delay between sensor polls, in milliseconds. More... | |
| bool | GetReceiverEnabled () const |
| Gets whether the remote-client receiver should be started. More... | |
| unsigned int | GetReceiverPort () const |
| Gets the TCP port the receiver listens on. More... | |
| float | GetLightCutoffDark () const |
| Gets the lux boundary for the "dark" light-level bucket. More... | |
| float | GetLightCutoffVeryDim () const |
| Gets the lux boundary for the "very dim" light-level bucket. More... | |
| float | GetLightCutoffDim () const |
| Gets the lux boundary for the "dim" light-level bucket. More... | |
| float | GetLightCutoffNormal () const |
| Gets the lux boundary for the "normal" light-level bucket. More... | |
| float | GetLightCutoffBright () const |
| Gets the lux boundary for the "bright" light-level bucket. More... | |
| void | SetUpdateDelayMilliseconds (unsigned int updateDelayMilliseconds) |
| Sets the update-loop delay between sensor polls, in milliseconds. More... | |
| void | SetReceiverEnabled (bool receiverEnabled) |
| Sets whether the remote-client receiver should be started. More... | |
| void | SetReceiverPort (unsigned int receiverPort) |
| Sets the TCP port the receiver listens on. More... | |
| void | SetLightCutoffDark (float lightCutoffDark) |
| Sets the lux boundary for the "dark" light-level bucket. More... | |
| void | SetLightCutoffVeryDim (float lightCutoffVeryDim) |
| Sets the lux boundary for the "very dim" light-level bucket. More... | |
| void | SetLightCutoffDim (float lightCutoffDim) |
| Sets the lux boundary for the "dim" light-level bucket. More... | |
| void | SetLightCutoffNormal (float lightCutoffNormal) |
| Sets the lux boundary for the "normal" light-level bucket. More... | |
| void | SetLightCutoffBright (float lightCutoffBright) |
| Sets the lux boundary for the "bright" light-level bucket. More... | |
Private Member Functions | |
| void | SetDefaults () |
| Sets every configuration value to its built-in default. More... | |
Private Attributes | |
| unsigned int | myUpdateDelayMilliseconds |
| How long the update loop waits between sensor polls, in milliseconds. More... | |
| bool | myReceiverEnabled |
| Whether the remote-client receiver is started during Initialize(). More... | |
| unsigned int | myReceiverPort |
| TCP port the receiver listens on (1-65535). More... | |
| float | myLightCutoffDark |
| Lux boundary below which the light level is considered "dark" (the buckets ascend from here). More... | |
| float | myLightCutoffVeryDim |
| Lux boundary for the "very dim" bucket. More... | |
| float | myLightCutoffDim |
| Lux boundary for the "dim" bucket. More... | |
| float | myLightCutoffNormal |
| Lux boundary for the "normal" bucket. More... | |
| float | myLightCutoffBright |
| Lux boundary for the "bright" bucket. More... | |
Holds the library's runtime configuration, loaded from a JSON file.
Every value defaults (in the constructor) to what used to be hard-coded around the library, so a missing file or a missing key simply leaves that value at its default. Hardware/datasheet constants (register addresses, lux coefficients, etc.) are deliberately NOT here - they are fixed by the hardware and stay compile-time constants.
| RumPi::RumPiConfig::RumPiConfig | ( | ) |
Builds a configuration with every value set to its built-in default.
| float RumPi::RumPiConfig::GetLightCutoffBright | ( | ) | const |
Gets the lux boundary for the "bright" light-level bucket.
| float RumPi::RumPiConfig::GetLightCutoffDark | ( | ) | const |
Gets the lux boundary for the "dark" light-level bucket.
| float RumPi::RumPiConfig::GetLightCutoffDim | ( | ) | const |
Gets the lux boundary for the "dim" light-level bucket.
| float RumPi::RumPiConfig::GetLightCutoffNormal | ( | ) | const |
Gets the lux boundary for the "normal" light-level bucket.
| float RumPi::RumPiConfig::GetLightCutoffVeryDim | ( | ) | const |
Gets the lux boundary for the "very dim" light-level bucket.
| bool RumPi::RumPiConfig::GetReceiverEnabled | ( | ) | const |
Gets whether the remote-client receiver should be started.
| unsigned int RumPi::RumPiConfig::GetReceiverPort | ( | ) | const |
Gets the TCP port the receiver listens on.
| unsigned int RumPi::RumPiConfig::GetUpdateDelayMilliseconds | ( | ) | const |
Gets the update-loop delay between sensor polls, in milliseconds.
| bool RumPi::RumPiConfig::LoadFromJson | ( | const nlohmann::json & | configJson | ) |
Loads settings from an already-parsed config JSON over the current values, so any key missing from the JSON keeps its default.
A non-object (e.g. a missing or unparseable file) leaves the clean defaults in place. Bad values are validated and reverted: light cutoffs must strictly ascend, the update delay must be within 1..3,600,000 ms, and the receiver port must be 1-65535. Problems are reported through the AlertManager.
| [in] | configJson | The parsed configuration object to read values from. |
|
private |
Sets every configuration value to its built-in default.
Called by the constructor and used to reset the configuration after a bad load.
| void RumPi::RumPiConfig::SetLightCutoffBright | ( | float | lightCutoffBright | ) |
Sets the lux boundary for the "bright" light-level bucket.
| [in] | lightCutoffBright | The new "bright" cutoff, in lux. |
| void RumPi::RumPiConfig::SetLightCutoffDark | ( | float | lightCutoffDark | ) |
Sets the lux boundary for the "dark" light-level bucket.
| [in] | lightCutoffDark | The new "dark" cutoff, in lux. |
| void RumPi::RumPiConfig::SetLightCutoffDim | ( | float | lightCutoffDim | ) |
Sets the lux boundary for the "dim" light-level bucket.
| [in] | lightCutoffDim | The new "dim" cutoff, in lux. |
| void RumPi::RumPiConfig::SetLightCutoffNormal | ( | float | lightCutoffNormal | ) |
Sets the lux boundary for the "normal" light-level bucket.
| [in] | lightCutoffNormal | The new "normal" cutoff, in lux. |
| void RumPi::RumPiConfig::SetLightCutoffVeryDim | ( | float | lightCutoffVeryDim | ) |
Sets the lux boundary for the "very dim" light-level bucket.
| [in] | lightCutoffVeryDim | The new "very dim" cutoff, in lux. |
| void RumPi::RumPiConfig::SetReceiverEnabled | ( | bool | receiverEnabled | ) |
Sets whether the remote-client receiver should be started.
| [in] | receiverEnabled | true to enable the receiver; false to disable it. |
| void RumPi::RumPiConfig::SetReceiverPort | ( | unsigned int | receiverPort | ) |
Sets the TCP port the receiver listens on.
| [in] | receiverPort | The new receiver port (should be 1-65535). |
| void RumPi::RumPiConfig::SetUpdateDelayMilliseconds | ( | unsigned int | updateDelayMilliseconds | ) |
Sets the update-loop delay between sensor polls, in milliseconds.
| [in] | updateDelayMilliseconds | The new delay between polls, in milliseconds. |
|
private |
Lux boundary for the "bright" bucket.
|
private |
Lux boundary below which the light level is considered "dark" (the buckets ascend from here).
|
private |
Lux boundary for the "dim" bucket.
|
private |
Lux boundary for the "normal" bucket.
|
private |
Lux boundary for the "very dim" bucket.
|
private |
Whether the remote-client receiver is started during Initialize().
|
private |
TCP port the receiver listens on (1-65535).
|
private |
How long the update loop waits between sensor polls, in milliseconds.