Midnight Sun Firmware
|
Class that manages receiving and transmitting Gpio commands and JSON logging. More...
#include <gpio_manager.h>
Public Member Functions | |
GpioManager ()=default | |
Constructs a GpioManager object. More... | |
void | setGpioPinState (std::string &payload) |
Sets a Gpio Pin state given the data payload. More... | |
void | setGpioAllStates (std::string &payload) |
Sets all Gpio Pin state given the data payload. More... | |
std::string | processGpioPinState (std::string &payload) |
Process a get Gpio Pin state command given the data payload. More... | |
std::string | processGpioAllStates () |
Process a get all Gpio Pin states command. More... | |
std::string | processGpioPinMode (std::string &payload) |
Process a get Gpio Pin mode command given the data payload. More... | |
std::string | processGpioAllModes () |
Process a get all Gpio Pin modes command. More... | |
std::string | processGpioPinAltFunction (std::string &payload) |
Process a get Gpio Pin alternate function command given the data payload. More... | |
std::string | processGpioAllAltFunctions () |
Process a get all Gpio Pin alternate functions command. More... | |
GpioManager ()=default | |
Constructs a GpioManager object. More... | |
void | updateGpioPinState (std::string &projectName, std::string &payload) |
Update a Gpio Pin state for a provided project given the data payload. More... | |
void | updateGpioAllStates (std::string &projectName, std::string &payload) |
Update all Gpio Pin states for a provided project given the data payload. More... | |
void | updateGpioPinMode (std::string &projectName, std::string &payload) |
Update a Gpio Pin mode for a provided project given the data payload. More... | |
void | updateGpioAllModes (std::string &projectName, std::string &payload) |
Update all Gpio Pin modes for a provided project given the data payload. More... | |
void | updateGpioPinAltFunction (std::string &projectName, std::string &payload) |
Update a Gpio Pin alternate function for a provided project given the data payload. More... | |
void | updateGpioAllAltFunctions (std::string &projectName, std::string &payload) |
Update all Gpio Pin alternate functions for a provided project given the data payload. More... | |
std::string | createGpioCommand (CommandCode commandCode, std::string &gpioPortPin, std::string data) |
Create a Gpio command given a CommandCode and if required, a specific Port/Pin map and data. More... | |
Private Types | |
using | PinInfo = std::unordered_map< std::string, std::string > |
Hash-map to store Pin specific data such as state, mode, or alternate function. | |
Private Member Functions | |
std::string | stringifyPinMode (Datagram::Gpio::Mode mode) |
Matches a string based on the received Gpio mode. More... | |
std::string | stringifyPinAltFunction (Datagram::Gpio::AltFunction altFunction) |
Matches a string based on the received Gpio mode. More... | |
void | loadGpioInfo (std::string &projectName) |
Loads the Hash-map cache with a projects Gpio data. More... | |
void | saveGpioInfo (std::string &projectName) |
Saves the Hash-map cache to a projects Gpio data. More... | |
Private Attributes | |
Datagram::Gpio | m_gpioDatagram |
std::unordered_map< std::string, PinInfo > | m_gpioInfo |
Class that manages receiving and transmitting Gpio commands and JSON logging.
This class is responsible for handling and transmitting serialized messages for reading pin modes, alternate functions and states. It shall support reading all pins or individual pins The class shall perform procedures as soon as commands are queued by the client
This class is responsible for transmitting serialized messages for reading pin modes, alternate functions and states. It shall support reading all pins or individual pins The class shall cache current Gpio data using a hash-map
|
default |
Constructs a GpioManager object.
Default constructor
|
default |
Constructs a GpioManager object.
Default constructor
std::string createGpioCommand | ( | CommandCode | commandCode, |
std::string & | gpioPortPin, | ||
std::string | data | ||
) |
Create a Gpio command given a CommandCode and if required, a specific Port/Pin map and data.
This function shall support all Gpio CommandCodes If the command is requesting data from all pins, no gpioPortPin and data is required
commandCode | Command reference to be transmitted to the client |
gpioPortPin | Request reference to the port and pin. Must be in this form: 'A9' or 'B12' or 'C14' etc. |
data | Data payload to be transmitted. This parameter currently only supports SET_STATE commands and can be set to 'LOW' or 'HIGH' |
|
private |
Loads the Hash-map cache with a projects Gpio data.
projectName | Selector for which project shall be loaded into the cache |
std::string processGpioAllAltFunctions | ( | ) |
Process a get all Gpio Pin alternate functions command.
This function shall be called upon receiving a payload containing all pin data This function is not responsible for handling update errors
std::string processGpioAllModes | ( | ) |
Process a get all Gpio Pin modes command.
This function shall be called upon receiving a payload containing all pin data This function is not responsible for handling update errors
std::string processGpioAllStates | ( | ) |
Process a get all Gpio Pin states command.
This function shall be called upon receiving a payload containing all pin data This function is not responsible for handling update errors
std::string processGpioPinAltFunction | ( | std::string & | payload | ) |
Process a get Gpio Pin alternate function command given the data payload.
This function shall be called upon receiving a pin-specific payload This function is not responsible for handling update errors
payload | Message data payload to be parsed |
std::string processGpioPinMode | ( | std::string & | payload | ) |
Process a get Gpio Pin mode command given the data payload.
This function shall be called upon receiving a pin-specific payload This function is not responsible for handling update errors
payload | Message data payload to be parsed |
std::string processGpioPinState | ( | std::string & | payload | ) |
Process a get Gpio Pin state command given the data payload.
This function shall be called upon receiving a pin-specific payload This function is not responsible for handling update errors
payload | Message data payload to be parsed |
|
private |
Saves the Hash-map cache to a projects Gpio data.
projectName | Selector for which project shall be updated with the current cache |
void setGpioAllStates | ( | std::string & | payload | ) |
Sets all Gpio Pin state given the data payload.
This function shall be called upon receiving a payload containing all pin data This function is not responsible for handling update errors
payload | Message data payload to be parsed |
void setGpioPinState | ( | std::string & | payload | ) |
Sets a Gpio Pin state given the data payload.
This function shall be called upon receiving a pin-specific payload This function is not responsible for handling update errors
payload | Message data payload to be parsed |
|
private |
Matches a string based on the received Gpio mode.
altFunction | Received alternate function that shall be stringified |
|
private |
Matches a string based on the received Gpio mode.
mode | Received mode that shall be stringified |
void updateGpioAllAltFunctions | ( | std::string & | projectName, |
std::string & | payload | ||
) |
Update all Gpio Pin alternate functions for a provided project given the data payload.
This function shall be called upon receiving a payload containing all pin data Determining if this function is applicable is the responsibility of the terminal/UI
projectName | Name of the project to be updated |
payload | Message data payload to be parsed |
void updateGpioAllModes | ( | std::string & | projectName, |
std::string & | payload | ||
) |
Update all Gpio Pin modes for a provided project given the data payload.
This function shall be called upon receiving a payload containing all pin data Determining if this function is applicable is the responsibility of the terminal/UI
projectName | Name of the project to be updated |
payload | Message data payload to be parsed |
void updateGpioAllStates | ( | std::string & | projectName, |
std::string & | payload | ||
) |
Update all Gpio Pin states for a provided project given the data payload.
This function shall be called upon receiving a payload containing all pin data Determining if this function is applicable is the responsibility of the terminal/UI
projectName | Name of the project to be updated |
payload | Message data payload to be parsed |
void updateGpioPinAltFunction | ( | std::string & | projectName, |
std::string & | payload | ||
) |
Update a Gpio Pin alternate function for a provided project given the data payload.
This function shall be called upon receiving a payload containing all pin data Determining if this function is applicable is the responsibility of the terminal/UI
projectName | Name of the project to be updated |
payload | Message data payload to be parsed |
void updateGpioPinMode | ( | std::string & | projectName, |
std::string & | payload | ||
) |
Update a Gpio Pin mode for a provided project given the data payload.
This function shall be called upon receiving a payload containing all pin data Determining if this function is applicable is the responsibility of the terminal/UI
projectName | Name of the project to be updated |
payload | Message data payload to be parsed |
void updateGpioPinState | ( | std::string & | projectName, |
std::string & | payload | ||
) |
Update a Gpio Pin state for a provided project given the data payload.
This function shall be called upon receiving a pin-specific payload Determining if this function is applicable is the responsibility of the terminal/UI
projectName | Name of the project to be updated |
payload | Message data payload to be parsed |
|
private |
Datagram class to serialize/deserialize commands
|
private |
Hash-map to cache all Gpio data