|
BS120x Ethernet Library 1.0.0
BS120x Ethernet Library
|
Ethernet client for communicating with the Bloomy Controls Battery Simulator (BS120x). More...
#include <EthernetClient.h>
Ethernet client for communicating with the Bloomy Controls Battery Simulator (BS120x).
This class implements commands and readbacks for all BS120x IO, as well as configuration utilities.
Public Member Functions | |
| EthernetClient () | |
| Default constructor. | |
| EthernetClient (const EthernetClient &)=delete | |
| EthernetClient & | operator= (const EthernetClient &)=delete |
| EthernetClient (EthernetClient &&other) noexcept=delete | |
| EthernetClient & | operator= (EthernetClient &&rhs) noexcept=delete |
| ~EthernetClient () | |
| Default destructor. | |
| ErrorCode | Connect (std::string_view interface_ip, std::string_view device_ip, std::uint16_t udp_port, std::int32_t udp_timeout=1000, std::uint16_t tcp_port=12345) noexcept |
| Connect to a unit. | |
| void | Disconnect () noexcept |
| Disconnect from the unit. | |
| ErrorCode | SetDIOStates (std::span< const bool > outputs, std::span< const bool > directions) const |
| Set the output states and directions for all DIO. | |
| ErrorCode | SetAnalogOutputs (std::span< const float > voltages) const |
| Set the voltages for the all analog outputs. | |
| ErrorCode | SetOpModeConfig (OpModeConfig config) const |
| Configures the operating mode of the unit. | |
| ErrorCode | SetAllCellCurrents (float isrc, float isnk) const |
| Sets the sinking and sourcing current limits for all cells. | |
| ErrorCode | SetCellSinkCurrent (unsigned int cell, float isnk) const |
| Sets the sinking current limit for a single cell. | |
| ErrorCode | SetCellSourceCurrent (unsigned int cell, float isrc) const |
| Sets the sourcing current limit for a cell. | |
| ErrorCode | SetAllCellVoltage (float voltage) const |
| Sets the voltage for all cells. | |
| ErrorCode | SetCellVoltage (unsigned int cell, float voltage) const |
| Sets the voltage for a single cell. | |
| ErrorCode | EnableAllCells (bool enable) const |
| Enables or disables all cells. | |
| ErrorCode | EnableCell (unsigned int cell, bool enable) const |
| Enables or disables a single cell. | |
| Result< float > | GetCellVoltage (unsigned int cell) const |
| Gets the voltage of a cell. | |
| Result< std::array< float, kCellCount > > | GetAllCellVoltage () const |
| Gets the voltages of all cells. | |
| ErrorCode | GetAllCellVoltage (std::span< float > voltages) const |
| Gets the voltages of all cells. | |
| Result< float > | GetCellCurrent (unsigned int cell) const |
| Gets the current of a cell in Amps. | |
| Result< std::array< float, kCellCount > > | GetAllCellCurrent () const |
| Get the currents of all cells in Amps. | |
| ErrorCode | GetAllCellCurrent (std::span< float > currents) const |
| Get the currents of all cells in Amps. | |
| Result< float > | GetAnalogInput (unsigned int analog_input) const |
| Gets the voltage of an analog input. | |
| Result< std::array< float, kAnalogInputCount > > | GetAllAnalogInput () const |
| Gets the voltages of all analog inputs. | |
| ErrorCode | GetAllAnalogInput (std::span< float > analog_inputs) const |
| Gets the voltages of all analog inputs. | |
| Result< bool > | GetDIOState (unsigned int dio) const |
| Gets the state of a DIO. | |
| Result< std::array< bool, kDioCount > > | GetAllDIOState () const |
| Gets the states of all DIO. | |
| ErrorCode | GetAllDIOState (std::span< bool > states) const |
| Gets the states of all DIO. | |
| Result< UnitStatus > | GetStatus () const |
| Gets the status of the unit. | |
| Result< UnitConfig > | GetUnitConfig () const |
| Gets the configuration values of a unit. | |
| ErrorCode | Reset () const |
| Commands the unit to reset. | |
| ErrorCode | SetIPAddress (std::string_view ip) const |
| Sets the unit IP address. | |
| ErrorCode | QueryConfig () const |
| Sends a request to the unit for its configuration information. | |
| ErrorCode | SetConfigOption (std::string_view opt, int value) const |
| Sets a configuration option for the unit. | |
| ErrorCode | SetConfigOption (std::string_view opt, bool value) const |
| Sets a configuration option for the unit. | |
| ErrorCode | SetConfigOption (std::string_view opt, std::string_view value) const |
| Sets a configuration option for the unit. | |
| ErrorCode | SetConfigOption (std::string_view opt, double value) const |
| Sets a configuration option for the unit. | |
| ErrorCode | EnableUDPData (bool enable) const |
| Enables the UDP data broadcast for the unit. | |
| ErrorCode | SetUDPDataPort (std::uint16_t port) const |
| Sets the port for the unit's UDP data broadcast. | |
| ErrorCode | SetUDPDataPeriod (std::uint32_t period) const |
| Sets the period for the unit's UDP data broadcast. | |
| ErrorCode | SetBoxID (std::uint8_t id) const |
| Sets the unit's box id. | |
| ErrorCode | SetCANPeriod (std::uint32_t period) const |
| Sets the period for the unit's CAN broadcast. | |
| ErrorCode | EnableCellInhibit (bool enable) const |
| Enables or disables the cell inhibit lines. | |
| Result< bool > | GetConfigValueBool (std::string_view opt) const |
| Get a boolean configuration value. | |
| Result< int > | GetConfigValueInt (std::string_view opt) const |
| Get an integer configuration value. | |
| Result< float > | GetConfigValueFloat (std::string_view opt) const |
| Get a floating point configuration value. | |
| Result< std::string > | GetConfigValueString (std::string_view opt) const |
| Get a string configuration value. | |
Static Public Member Functions | |
| static unsigned int | Version () noexcept |
| Get the library version as a decimal integer. | |
|
noexcept |
Connect to a unit.
| [in] | interface_ip | IP address of the local NIC to connect from. |
| [in] | device_ip | IP address of the unit. |
| [in] | udp_port | UDP data port for the unit. |
| [in] | udp_timeout | Timeout in milliseconds to receive UDP data broadcast. A negative value will wait infinitely. |
| [in] | tcp_port | TCP port to send commands on. BS120x default is 12345. |
| ErrorCode EnableAllCells | ( | bool | enable | ) | const |
Enables or disables all cells.
| [in] | enable | The state for the cells. A value of TRUE will enable all cells. |
| ErrorCode EnableCell | ( | unsigned int | cell, |
| bool | enable | ||
| ) | const |
Enables or disables a single cell.
| [in] | cell | The cell to target. Cells are 0-indexed. |
| [in] | enable | The state for the cell. A value of TRUE will enable the cell. |
| ErrorCode EnableCellInhibit | ( | bool | enable | ) | const |
Enables or disables the cell inhibit lines.
| [in] | enable | The enable state for the cell inhibit lines. |
| ErrorCode EnableUDPData | ( | bool | enable | ) | const |
Enables the UDP data broadcast for the unit.
| [in] | enable | A value of TRUE will enable the UDP data broadcast. |
| Result< std::array< float, kAnalogInputCount > > GetAllAnalogInput | ( | ) | const |
Gets the voltages of all analog inputs.
| ErrorCode GetAllAnalogInput | ( | std::span< float > | analog_inputs | ) | const |
Gets the voltages of all analog inputs.
| [out] | analog_inputs | Array to store the returned voltages. Length must be equal to the number of analog inputs. |
| Result< std::array< float, kCellCount > > GetAllCellCurrent | ( | ) | const |
Get the currents of all cells in Amps.
| ErrorCode GetAllCellCurrent | ( | std::span< float > | currents | ) | const |
Get the currents of all cells in Amps.
| [out] | currents | Array to store the returned cell currents. Length must be equal to the number of cells. |
| Result< std::array< float, kCellCount > > GetAllCellVoltage | ( | ) | const |
Gets the voltages of all cells.
| ErrorCode GetAllCellVoltage | ( | std::span< float > | voltages | ) | const |
Gets the voltages of all cells.
| [out] | voltages | Array to store the returned cell voltages. Length must be equal to the number of cells. |
Gets the states of all DIO.
| ErrorCode GetAllDIOState | ( | std::span< bool > | states | ) | const |
Gets the states of all DIO.
| [out] | states | Array to store the returned states. Length must be equal to the number of DIO. |
| Result< float > GetAnalogInput | ( | unsigned int | analog_input | ) | const |
Gets the voltage of an analog input.
| [in] | analog_input | The analog input to target. |
| Result< float > GetCellCurrent | ( | unsigned int | cell | ) | const |
Gets the current of a cell in Amps.
| [in] | cell | The cell to target. Cells are 0-indexed. |
| Result< float > GetCellVoltage | ( | unsigned int | cell | ) | const |
Gets the voltage of a cell.
| [in] | cell | The cell to target. Cells are 0-indexed. |
| Result< bool > GetConfigValueBool | ( | std::string_view | opt | ) | const |
Get a boolean configuration value.
| [in] | opt | The configuration option to look up. |
| Result< float > GetConfigValueFloat | ( | std::string_view | opt | ) | const |
Get a floating point configuration value.
| [in] | opt | The configuration option to look up. |
| Result< int > GetConfigValueInt | ( | std::string_view | opt | ) | const |
Get an integer configuration value.
| [in] | opt | The configuration option to look up. |
| Result< std::string > GetConfigValueString | ( | std::string_view | opt | ) | const |
Get a string configuration value.
| [in] | opt | The configuration option to look up. |
| Result< bool > GetDIOState | ( | unsigned int | dio | ) | const |
Gets the state of a DIO.
| [in] | dio | The DIO to target. |
| Result< UnitStatus > GetStatus | ( | ) | const |
Gets the status of the unit.
| Result< UnitConfig > GetUnitConfig | ( | ) | const |
Gets the configuration values of a unit.
| ErrorCode QueryConfig | ( | ) | const |
Sends a request to the unit for its configuration information.
| ErrorCode Reset | ( | ) | const |
Commands the unit to reset.
| ErrorCode SetAllCellCurrents | ( | float | isrc, |
| float | isnk | ||
| ) | const |
Sets the sinking and sourcing current limits for all cells.
| [in] | isrc | The sourcing current limit in Amps. |
| [in] | isnk | The sinking current limit in Amps. |
| ErrorCode SetAllCellVoltage | ( | float | voltage | ) | const |
Sets the voltage for all cells.
| [in] | voltage | The voltage setpoint. |
| ErrorCode SetAnalogOutputs | ( | std::span< const float > | voltages | ) | const |
Set the voltages for the all analog outputs.
| [in] | voltages | The voltage setpoints for the analog outputs. Must have a length equal to the number of unit analog outputs. |
| ErrorCode SetBoxID | ( | std::uint8_t | id | ) | const |
Sets the unit's box id.
| [in] | id | The new box ID. Valid values are 0-15. |
| ErrorCode SetCANPeriod | ( | std::uint32_t | period | ) | const |
Sets the period for the unit's CAN broadcast.
| [in] | period | The new period in milliseconds. |
| ErrorCode SetCellSinkCurrent | ( | unsigned int | cell, |
| float | isnk | ||
| ) | const |
Sets the sinking current limit for a single cell.
| [in] | cell | The cell to target. Cells are 0-indexed. |
| [in] | isnk | The sinking current limit in Amps for the cell. |
| ErrorCode SetCellSourceCurrent | ( | unsigned int | cell, |
| float | isrc | ||
| ) | const |
Sets the sourcing current limit for a cell.
| [in] | cell | The cell to target. Cells are 0-indexed. |
| [in] | isrc | The sourcing current limit in Amps for the cell. |
| ErrorCode SetCellVoltage | ( | unsigned int | cell, |
| float | voltage | ||
| ) | const |
Sets the voltage for a single cell.
| [in] | cell | The cell to target. Cells are 0-indexed. |
| [in] | voltage | The voltage setpoint. |
| ErrorCode SetConfigOption | ( | std::string_view | opt, |
| bool | value | ||
| ) | const |
Sets a configuration option for the unit.
| [in] | opt | The configuration option to set. |
| [in] | value | The value to set the configuration option to. |
| ErrorCode SetConfigOption | ( | std::string_view | opt, |
| double | value | ||
| ) | const |
Sets a configuration option for the unit.
| [in] | opt | The configuration option to set. |
| [in] | value | The value to set the configuration option to. |
| ErrorCode SetConfigOption | ( | std::string_view | opt, |
| int | value | ||
| ) | const |
Sets a configuration option for the unit.
| [in] | opt | The configuration option to set. |
| [in] | value | The value to set the configuration option to. |
| ErrorCode SetConfigOption | ( | std::string_view | opt, |
| std::string_view | value | ||
| ) | const |
Sets a configuration option for the unit.
| [in] | opt | The configuration option to set. |
| [in] | value | The value to set the configuration option to. |
| ErrorCode SetDIOStates | ( | std::span< const bool > | outputs, |
| std::span< const bool > | directions | ||
| ) | const |
Set the output states and directions for all DIO.
| [in] | outputs | The output states for the DIO. Must have a length equal to the number of unit DIO. A TRUE value corresponds to a HIGH output. |
| [in] | directions | The directions for the DIO. Must have a length equal to the number of unit DIO. A TRUE value corresponds to an output. |
| ErrorCode SetIPAddress | ( | std::string_view | ip | ) | const |
Sets the unit IP address.
| [in] | ip | New IP address for the unit. Last octet may not have a value of 1 or 255. |
| ErrorCode SetOpModeConfig | ( | OpModeConfig | config | ) | const |
Configures the operating mode of the unit.
| [in] | config | The operating mode options to set. |
| ErrorCode SetUDPDataPeriod | ( | std::uint32_t | period | ) | const |
Sets the period for the unit's UDP data broadcast.
| [in] | period | The new period in milliseconds. |
| ErrorCode SetUDPDataPort | ( | std::uint16_t | port | ) | const |
Sets the port for the unit's UDP data broadcast.
| [in] | port | The new UDP port. |
|
staticnoexcept |
Get the library version as a decimal integer.
For example, version 1.3.2 would return 10302.