#include <PicoModel.h>
Inheritance diagram for PicoModel:
Collaboration diagram for PicoModel:Public Member Functions | |
| PicoModel () | |
| void | onStart () |
| float | getTemperature () |
| void | setLedState (bool state) |
| bool | getLedState () |
| bool | getGpioState (int pin) |
| void | setGpioState (int pin, bool state) |
| void | saveState () |
| void | restoreState () |
| void | onNetworkReady () |
Public Member Functions inherited from FrameworkModel | |
| FrameworkModel (const std::string &path) | |
| Constructor. | |
| bool | load () |
| Loads the JSON collection from storage. | |
| bool | save () |
| Saves the current collection to storage. | |
| std::vector< nlohmann::json > | all () const |
| Returns all items in the collection. | |
| std::optional< nlohmann::json > | find (const std::string &id) const |
| Finds an item by ID. | |
| bool | create (const nlohmann::json &item) |
| Adds a new item to the collection. | |
| bool | update (const std::string &id, const nlohmann::json &updatedItem) |
| Updates an item by ID. | |
| bool | remove (const std::string &id) |
| Removes an item by ID. | |
| nlohmann::json | toJson () const |
| Returns the full collection as a JSON array object. | |
| nlohmann::json | findAsJson (const std::string &id) const |
| Finds a single item by ID and returns it as JSON or null. | |
| bool | save (const std::string &id, const json &data) |
| Saves a single item by ID and JSON object. | |
| bool | createFromJson (const nlohmann::json &obj) |
| bool | updateFromJson (const std::string &id, const nlohmann::json &updates) |
| nlohmann::json | deleteAsJson (const std::string &id) |
| bool | saveAll () |
| template<typename T > | |
| T | getValue (const std::string &key, const T &defaultValue=T()) |
| Reads a single top-level key from the model file. | |
| template<typename T > | |
| void | setValue (const std::string &key, const T &value) |
| Sets a single top-level key in the model file. | |
Private Attributes | |
| std::vector< int > | activePins = { 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19 } |
| bool | suppressSave = false |
Additional Inherited Members | |
Protected Member Functions inherited from FrameworkModel | |
| virtual std::string | getIdField () const |
| Returns the JSON key used as the record ID. | |
Protected Attributes inherited from FrameworkModel | |
| nlohmann::json | collection = nlohmann::json::array() |
| In-memory array of records. | |
Definition at line 5 of file PicoModel.h.
| PicoModel::PicoModel | ( | ) |
Definition at line 13 of file PicoModel.cpp.
| bool PicoModel::getGpioState | ( | int | pin | ) |
Definition at line 53 of file PicoModel.cpp.
Referenced by GpioController::getState(), GpioController::handleGetMultipleGpios(), and saveState().
Here is the caller graph for this function:| bool PicoModel::getLedState | ( | ) |
Definition at line 43 of file PicoModel.cpp.
Referenced by DashboardController::getLedState(), saveState(), and setLedState().
Here is the caller graph for this function:| float PicoModel::getTemperature | ( | ) |
Definition at line 24 of file PicoModel.cpp.
Referenced by DashboardController::getTemperature().
Here is the caller graph for this function:| void PicoModel::onNetworkReady | ( | ) |
Definition at line 86 of file PicoModel.cpp.
References FrameworkModel::getValue(), setLedState(), and suppressSave.
Referenced by App::onEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| void PicoModel::onStart | ( | ) |
Definition at line 18 of file PicoModel.cpp.
References restoreState().
Referenced by App::onStart().
Here is the call graph for this function:
Here is the caller graph for this function:| void PicoModel::restoreState | ( | ) |
Definition at line 95 of file PicoModel.cpp.
References FrameworkModel::getValue(), Network::isConnected(), FrameworkModel::load(), setGpioState(), setLedState(), and suppressSave.
Referenced by onStart().
Here is the call graph for this function:
Here is the caller graph for this function:| void PicoModel::saveState | ( | ) |
Definition at line 70 of file PicoModel.cpp.
References activePins, getGpioState(), getLedState(), FrameworkModel::save(), and FrameworkModel::setValue().
Referenced by setGpioState(), and setLedState().
Here is the call graph for this function:
Here is the caller graph for this function:| void PicoModel::setGpioState | ( | int | pin, |
| bool | state | ||
| ) |
Definition at line 59 of file PicoModel.cpp.
References saveState(), and suppressSave.
Referenced by restoreState(), and GpioController::setState().
Here is the call graph for this function:
Here is the caller graph for this function:| void PicoModel::setLedState | ( | bool | state | ) |
Definition at line 34 of file PicoModel.cpp.
References getLedState(), saveState(), FrameworkModel::setValue(), and suppressSave.
Referenced by onNetworkReady(), restoreState(), and DashboardController::setLedState().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 31 of file PicoModel.h.
Referenced by saveState().
|
private |
Definition at line 33 of file PicoModel.h.
Referenced by onNetworkReady(), restoreState(), setGpioState(), and setLedState().