|
BAOS SDK v2
1.2.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
|
A specialization for (connection-less) connection to the BAOS device via a TCP connection. More...
#include <baos/ip/BaosTcpConnection.h>
Inheritance diagram for BaosConLessTcpConnection:Public Types | |
| using | UPtr = std::unique_ptr< BaosConLessTcpConnection > |
| Alias for a std::unique_ptr to this class. | |
Public Types inherited from BaosTcpConnection | |
| using | UPtr = std::unique_ptr< BaosTcpConnection > |
| Alias for a std::unique_ptr to this class. | |
| using | TcpTransportFrame = Buffer |
| Alias on how a TcpTransportFrame is represented. | |
Public Types inherited from BaosConnection | |
| using | Clock = std::chrono::system_clock |
| An alias for the clock internaly used. | |
| using | BaosFrame = Buffer |
| An alias for the container type to store frame/packets/telegrams in. | |
| using | BaosFrame_UPtr = std::unique_ptr< BaosFrame > |
| An alias for a std::unique_ptr holding a BaosFrame. | |
| using | UPtr = std::unique_ptr< BaosConnection > |
| An alias for an unqiue pointer to this class. | |
| using | ConnectionEventCb = std::function< void(ConnectionEvent &)> |
| Function signature for connection events callbacks. | |
| using | ServerItemIndicationCb = std::function< void(const protocol::ServerItems &)> |
| Function signature for serveritem indication callbacks. | |
| using | DatapointValueCb = std::function< void(const protocol::DatapointValueStates &)> |
| Function signature for datapoint value indication callbacks. | |
Public Member Functions | |
| BaosConLessTcpConnection (std::unique_ptr< ip::Ip4Driver > &driver) | |
Public Member Functions inherited from BaosTcpConnection | |
| void | enableEnsureAutoConnect (bool enable) |
| Enables the option for ensure auto connect in legacy mode (e.g. 774.1 with auto connect mode). The default value is true (enabled). | |
| void | enableVerifyProtocolVersion (bool enable) |
| Enables the option for verify the BAOS binary protocol version. The default value is true (enabled). | |
| void | open (const std::string &ip4Address, std::uint16_t port=12004) |
| Open a connection to physical BAOS device. | |
| void | reopen () override |
| Reopens the underlying connection, has to be implemented by derived classes. | |
Public Member Functions inherited from BaosConnection | |
| BaosConnection () | |
| Default constructor. | |
| virtual | ~BaosConnection () |
| Default destructor. | |
| void | start () |
| Start the client side of the connection. | |
| void | stop () |
| Stop the client side of the connection. | |
| void | close () |
| Close the connection to the BAOS device. | |
| bool | isOpen () |
| Returns the open state of the connection. | |
| void | setConnectionEventCallback (ConnectionEventCb callback) |
| void | setServerItemsIndCallback (ServerItemIndicationCb callback) |
| void | setDatapointValueIndCallback (DatapointValueCb callback) |
| std::optional< protocol::ServerItem > | getServerItem (protocol::ServerItemId id) |
| Get a single the ServerItem. | |
| protocol::ServerItems | getServerItems (std::uint16_t startItem, std::uint16_t numberOfItems) |
| Get a list of serveritems from the device. | |
| void | setServerItem (const protocol::ServerItem &serverItem) |
| void | setServerItem (protocol::ServerItem &&serverItem) |
| void | setServerItems (protocol::ServerItems &&serverItems) |
| std::optional< protocol::DatapointDescription > | getDpDescription (std::uint16_t dpId) |
| Get the datapoint description for one datapoint. | |
| protocol::DatapointDescriptions | getDpDescriptions (std::uint16_t startDpId, std::uint16_t numberOfItems) |
| Get a list of DatapointDescriptions. | |
| std::optional< protocol::DatapointDescriptionString > | getDpDescriptionString (std::uint16_t dpId) |
| Get the datapoint description string for one datapoint. | |
| protocol::DatapointDescriptionStrings | getDpDescriptionStrings (std::uint16_t startDpId, std::uint16_t numberOfStrings) |
| Get a list of DatapointDescriptionsStrings. | |
| std::optional< std::uint8_t > | getParameterByte (std::uint16_t byteIndex) |
| Get a single parameter byte. | |
| protocol::ParameterBytes | getParameterBytes (std::uint16_t byteIndex, std::uint16_t numberOfBytes) |
| Get a list of parameter bytes. | |
| std::optional< protocol::DatapointValueState > | getDpValue (std::uint16_t dpId) |
| Get a single datapoint value with its associated state. | |
| protocol::DatapointValueStates | getDpValues (std::uint16_t startDpId, std::uint16_t numberOfValues, protocol::DatapointValueFilter filter=protocol::DatapointValueFilter::ALL) |
| Get a map with the datapoint id as key and the DatapointValueState as value. | |
| void | setDpValue (std::uint16_t dpId, protocol::DatapointChangeValue &&dpValue) |
| Send a SetDatapointValue request to the BAOS device for one datapoint. | |
| void | setDpValues (std::map< std::uint16_t, protocol::DatapointChangeValue > &&dpValues) |
| Send a SetDatapointValue request to the BAOS device with given datapoint values. | |
| protocol::ResponseFuture | getServerItemAsync (protocol::ServerItemId id) |
| protocol::ResponseFuture | getServerItemsAsync (std::uint16_t startItem, std::uint16_t numberOfItems) |
| Get a list of serveritems from the device. | |
| protocol::ResponseFuture | setServerItemAsync (protocol::ServerItem &&serverItem) |
| protocol::ResponseFuture | setServerItemsAsync (protocol::ServerItems &&serverItems) |
| protocol::ResponseFuture | getDpDescriptionAsync (std::uint16_t dpId) |
| Get the datapoint description for one datapoint. | |
| protocol::ResponseFuture | getDpDescriptionsAsync (std::uint16_t startDpId, std::uint16_t numberOfItems) |
| Get a list of DatapointDescriptions. | |
| protocol::ResponseFuture | getDpDescriptionStringAsync (std::uint16_t dpId) |
| Get the datapoint description string for one datapoint. | |
| protocol::ResponseFuture | getDpDescriptionStringsAsync (std::uint16_t startDpId, std::uint16_t numberOfStrings) |
| Get a list of DatapointDescriptionsStrings. | |
| protocol::ResponseFuture | getParameterByteAsync (std::uint16_t byteIndex) |
| Get a single parameter byte. | |
| protocol::ResponseFuture | getParameterBytesAsync (std::uint16_t byteIndex, std::uint16_t numberOfBytes) |
| Get a list of parameter bytes. | |
| protocol::ResponseFuture | getDpValueAsync (std::uint16_t dpId) |
| Get a single datapoint value with its associated state. | |
| protocol::ResponseFuture | getDpValuesAsync (std::uint16_t startDpId, std::uint16_t numberOfValues, protocol::DatapointValueFilter filter=protocol::DatapointValueFilter::ALL) |
| Get a map with the datapoint id as key and the DatapointValueState as value. | |
| protocol::ResponseFuture | setDpValueAsync (std::uint16_t dpId, protocol::DatapointChangeValue &&dpValue) |
| Send a SetDatapointValue request to the BAOS device for one datapoint. | |
| protocol::ResponseFuture | setDpValuesAsync (std::map< std::uint16_t, protocol::DatapointChangeValue > &&dpValues) |
| Send a SetDatapointValue request to the BAOS device with given datapoint values. | |
| protocol::ResponseFuture | closeAsync () |
| Close the connection. | |
Additional Inherited Members | |
Protected Types inherited from BaosConnection | |
| enum class | State { RUNNING , STOPPING , STOPPED , CONOPENING , SENDING , SENDCOMPLETE , WAITRESPONSE , IDLE , CONCLOSING , CONERROR , CONCLOSED , CONCLOSED_BY_ERROR , FATALERROR } |
| Represents the internal state of this connection. More... | |
| enum class | PromiseState { UNUSED , SET , RESOLVED } |
| The asynchronous functions return a promise to keep internal track of their state this enum is used. | |
Protected Member Functions inherited from BaosTcpConnection | |
| virtual void | postOpen (protocol::ResponsePromise &&prom) |
| bool | isOpenImpl () override |
| The implementation function for getting the opened state of the connection. | |
| protocol::ResponseFuture | closeImplAsync () override |
| The implementation function for closing a connection. | |
| void | startImpl () override |
| The implementation function for starting the connection class. | |
| void | eventHandler () |
| Handles the incoming IOEvents. | |
| void | handleRxTcp (IOEvent &&event) |
| Called for every Rx IOEvent (incoming, received) | |
| void | handleTxTcp (IOEvent &&event) |
| Called for every Tx IOEvent (outgoing, send, transmit) | |
| protocol::ResponseFuture | sendImpl (BaosFrame &&frame) override |
| The implementation function for sending bytes to the connected device. | |
| void | onStateChange (State oldState, State newState) override |
| Invoked if the internal connection state should be changed. | |
| void | resolveMsgQPromises (std::exception_ptr eptr) noexcept |
| transport::TransportTcpIO & | getTransportIO () |
Protected Member Functions inherited from BaosConnection | |
| protocol::ResponseFuture | send (BaosFrame &&frame) |
| Sends a generic frame( a byte list) to the BAOS device. | |
| BaosParseStatus | handleBaosFrame (BaosFrame_UPtr &&frame) |
| For every received BAOS frame this handler is internally called. | |
| BaosParseStatus | handleBaosIndication (BaosFrame_UPtr &&frame) |
| For every received BAOS indication this handler is internally called. | |
| protocol::BaosResponseCode | handleBaosResponse (BaosFrame_UPtr &&frame) |
| For every received BAOS response this handler is internally called. | |
| State | setState (State newState) |
| Set the internal state of this connections state machine. | |
| State | getState () const |
| Get the current internal state of this connections state machine. | |
| protocol::BaosBaseResponse::SPtr | decodeResponse (BaosFrame_UPtr &&frame) |
| Decodes the baos response. | |
| virtual void | stopImpl () |
| The implementation function for stopping the connection class. | |
| void | emitConnectionEvent (State oldState, State newState) |
| void | emitConnectionEvent (ConnectionEvent::Type event) |
| virtual void | onTimerExpired (std::vector< std::uint64_t > ids) |
| Invoked if on of the timers has expired. | |
| ConnectionEvent::Type | getConnectionEvent (State state) |
Static Protected Member Functions inherited from BaosConnection | |
| static std::string | stateToString (State state) |
| Get human readable string from internal state. | |
Protected Attributes inherited from BaosTcpConnection | |
| transport::TransportTcpIO::UPtr | transportIO_ |
| ip::Ip4SocketAddress | socketAddress_ |
| std::uint64_t | msgId_ {0} |
| bool | ensureAutoConnect_ {true} |
| bool | verifyProtocolVersion_ {true} |
Protected Attributes inherited from BaosConnection | |
| std::atomic< bool > | shouldStop_ {false} |
| Flag to indicate that the connection should stop at the next opportunity. | |
| std::atomic< bool > | isRunning_ {false} |
| Keep track if the connection is in running state or stopping / stopped. | |
| wzcpp::ThreadPoolExecutor | executor_ {5} |
| wzcpp::TimerManager< Clock > | timerManager_ |
| Manages the timers for this connection. | |
| wzcpp::Timer< Clock > | respTimeoutTimer_ |
| The actual timer objects for respone timeouts. | |
| wzcpp::Timer< Clock > | heartBeatTimer_ |
| The actual timer objects for heartbeats. | |
| Buffer | waitResponse_ |
| While waiting for a response this holds the pattern of the response we expect. | |
| protocol::ResponsePromise | responsePromise_ |
| If a packet is send out via handleTxTcp the corresponding promise is stored here. | |
| PromiseState | responsePromiseState_ {PromiseState::UNUSED} |
| The state of the responsePromise_. | |
| std::uint64_t | currentMessageId_ {0} |
| For internal use a unique message id. | |
| std::queue< IOEvent > | txQueue_ |
| Holds the packets to send waiting to be processed. | |
| BaosMsgQueue | bMsgQ_ |
| Hold the event for the main connection loop. | |
| BaosIndQueue | bIndQ_ |
| Holds the indication to be send out to clients. | |
| BaosIndicationSender | indSender_ |
| Responsible for sending out the indications. | |
A specialization for (connection-less) connection to the BAOS device via a TCP connection.
This connection type is supported by BAOS 771 BAOS 772 BAOS 773 BAOS 774 BAOS 777 BAOS 774.1 when configured as auto-connect BAOS 777.1 when configured as auto-connect