Midnight Sun Firmware
Loading...
Searching...
No Matches

Class that manages receiving and transmitting Gpio commands and JSON logging. More...

#include <gpio_manager.h>

Collaboration diagram for GpioManager:

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, PinInfom_gpioInfo
 

Detailed Description

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

Constructor & Destructor Documentation

◆ GpioManager() [1/2]

GpioManager ( )
default

Constructs a GpioManager object.

Default constructor

◆ GpioManager() [2/2]

GpioManager ( )
default

Constructs a GpioManager object.

Default constructor

Member Function Documentation

◆ createGpioCommand()

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

Parameters
commandCodeCommand reference to be transmitted to the client
gpioPortPinRequest reference to the port and pin. Must be in this form: 'A9' or 'B12' or 'C14' etc.
dataData payload to be transmitted. This parameter currently only supports SET_STATE commands and can be set to 'LOW' or 'HIGH'
Returns
Fully serialized data payload to be transmitted to the client

◆ loadGpioInfo()

void loadGpioInfo ( std::string &  projectName)
private

Loads the Hash-map cache with a projects Gpio data.

Parameters
projectNameSelector for which project shall be loaded into the cache

◆ processGpioAllAltFunctions()

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

Returns
Fully serialized data payload to be transmitted in response to the server

◆ processGpioAllModes()

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

Returns
Fully serialized data payload to be transmitted in response to the server

◆ processGpioAllStates()

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

Returns
Fully serialized data payload to be transmitted in response to the server

◆ processGpioPinAltFunction()

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

Parameters
payloadMessage data payload to be parsed
Returns
Fully serialized data payload to be transmitted in response to the server

◆ processGpioPinMode()

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

Parameters
payloadMessage data payload to be parsed
Returns
Fully serialized data payload to be transmitted in response to the server

◆ processGpioPinState()

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

Parameters
payloadMessage data payload to be parsed
Returns
Fully serialized data payload to be transmitted in response to the server

◆ saveGpioInfo()

void saveGpioInfo ( std::string &  projectName)
private

Saves the Hash-map cache to a projects Gpio data.

Parameters
projectNameSelector for which project shall be updated with the current cache

◆ setGpioAllStates()

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

Parameters
payloadMessage data payload to be parsed

◆ setGpioPinState()

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

Parameters
payloadMessage data payload to be parsed

◆ stringifyPinAltFunction()

std::string stringifyPinAltFunction ( Datagram::Gpio::AltFunction  altFunction)
private

Matches a string based on the received Gpio mode.

Parameters
altFunctionReceived alternate function that shall be stringified
Returns
String that matches the input altFunction

◆ stringifyPinMode()

std::string stringifyPinMode ( Datagram::Gpio::Mode  mode)
private

Matches a string based on the received Gpio mode.

Parameters
modeReceived mode that shall be stringified
Returns
String that matches the input mode

◆ updateGpioAllAltFunctions()

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

Parameters
projectNameName of the project to be updated
payloadMessage data payload to be parsed

◆ updateGpioAllModes()

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

Parameters
projectNameName of the project to be updated
payloadMessage data payload to be parsed

◆ updateGpioAllStates()

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

Parameters
projectNameName of the project to be updated
payloadMessage data payload to be parsed

◆ updateGpioPinAltFunction()

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

Parameters
projectNameName of the project to be updated
payloadMessage data payload to be parsed

◆ updateGpioPinMode()

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

Parameters
projectNameName of the project to be updated
payloadMessage data payload to be parsed

◆ updateGpioPinState()

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

Parameters
projectNameName of the project to be updated
payloadMessage data payload to be parsed

Member Data Documentation

◆ m_gpioDatagram

Datagram::Gpio m_gpioDatagram
private

Datagram class to serialize/deserialize commands

◆ m_gpioInfo

std::unordered_map<std::string, PinInfo> m_gpioInfo
private

Hash-map to cache all Gpio data


The documentation for this class was generated from the following files: