|
Robot Raconteur Core C++ Library
|
Wire connection used to transmit "most recent" values. More...
#include <WireMember.h>
Public Member Functions | |
| boost::function< void(boost::shared_ptr< WireConnection< T > >)> | GetWireConnectionClosedCallback () |
| Get the currently configured connection closed callback function. | |
| void | SetWireConnectionClosedCallback (boost::function< void(const boost::shared_ptr< WireConnection< T > > &)> callback) |
| Set the connection closed callback function. | |
| virtual T | GetInValue () |
| Get the current InValue. | |
| virtual T | GetOutValue () |
| Get the current OutValue. | |
| virtual void | SetOutValue (typename boost::call_traits< T >::param_type value) |
| Set the OutValue and transmit to the peer connection. | |
| bool | TryGetInValue (T &value, TimeSpec &time) |
| Try getting the InValue, returning true on success or false on failure. | |
| bool | TryGetOutValue (T &value, TimeSpec &time) |
| Try getting the OutValue, returning true on success or false on failure. | |
| RR_OVIRTUAL void | Close () RR_OVERRIDE |
| Close the wire connection. | |
| RR_OVIRTUAL void | AsyncClose (boost::function< void(const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=2000) RR_OVERRIDE |
| Asynchronously close the wire connection. | |
| virtual uint32_t | GetEndpoint () |
| Returns the Robot Raconteur node Endpoint ID. | |
| virtual TimeSpec | GetLastValueReceivedTime () |
| Get the timestamp of the last received value. | |
| virtual TimeSpec | GetLastValueSentTime () |
| Get the timestamp of the last sent value. | |
| virtual bool | GetInValueValid () |
| Get if the InValue is valid. | |
| virtual bool | GetOutValueValid () |
| Get if the OutValue is valid. | |
| bool | WaitInValueValid (int32_t timeout=RR_TIMEOUT_INFINITE) |
| Waits for InValue to be valid. | |
| bool | WaitOutValueValid (int32_t timeout=RR_TIMEOUT_INFINITE) |
| Waits for OutValue to be valid. | |
| virtual bool | GetIgnoreInValue () |
| Get if wire connection is ignoring incoming values. | |
| virtual void | SetIgnoreInValue (bool ignore) |
| Set whether wire connection should ignore incoming values. | |
| MemberDefinition_Direction | Direction () |
| The direction of the wire. | |
| virtual int32_t | GetInValueLifespan () |
| Get the lifespan of InValue. | |
| virtual void | SetInValueLifespan (int32_t millis) |
| Set the lifespan of InValue. | |
| virtual int32_t | GetOutValueLifespan () |
| Get the lifespan of OutValue. | |
| virtual void | SetOutValueLifespan (int32_t millis) |
| Set the lifespan of OutValue. | |
Public Attributes | |
| boost::signals2::signal< void(const boost::shared_ptr< WireConnection< T > > &connection, T value, TimeSpec time)> | WireValueChanged |
| Signal invoked when the InValue is changed. | |
Wire connection used to transmit "most recent" values.
Wire connections are used to transmit "most recent" values between connected wire members. See Wire for more information on wire members.
Wire connections are created by clients using the Wire::Connect() or Wire::AsyncConnect() functions. Services receive incoming wire connection requests through a callback function specified using the Wire::SetWireConnectCallback() function. Services may also use the WireBroadcaster class to automate managing wire connection lifecycles and sending values to all connected clients, or use WireUnicastReceiver to receive an incoming value from the most recently connected client.
Wire connections are used to transmit "most recent" values between clients and services. Connection the wire creates a connection pair, one in the client, and one in the service. Each wire connection object has an InValue and an OutValue. Setting the OutValue of one will cause the specified value to be transmitted to the InValue of the peer. See Wire for more information.
Values can optionally be specified to have a finite lifespan using SetInValueLifespan() and SetOutValueLifespan(). Lifespans can be used to prevent using old values that have not been recently updated.
This class is instantiated by the Wire class. It should not be instantiated by the user.
| T | The value data type |
|
inlinevirtual |
Asynchronously close the wire connection.
Same as Close() but returns asynchronously
| handler | A handler function to call on completion, possibly with an exception |
| timeout | Timeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout |
Reimplemented from RobotRaconteur::WireConnectionBase.
|
inlinevirtual |
Close the wire connection.
Close the wire connection. Blocks until close complete. The peer wire connection is destroyed automatically.
Reimplemented from RobotRaconteur::WireConnectionBase.
|
inherited |
The direction of the wire.
Wires may be declared readonly or writeonly in the service definition file. (If neither is specified, the wire is assumed to be full duplex.) readonly wire may only send out values from service to client. writeonly wires may only send out values from client to service.
|
virtualinherited |
Returns the Robot Raconteur node Endpoint ID.
Returns the endpoint associated with the ClientContext or ServerEndpoint associated with the wire connection.
|
virtualinherited |
|
inlinevirtual |
Get the current InValue.
Gets the current InValue that was transmitted from the peer. Throws ValueNotSetException if no value has been received, or the most recent value lifespan has expired.
|
virtualinherited |
Get the lifespan of InValue.
InValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after reception has expired, the InValue is cleared, and becomes invalid. Attempts to access InValue will result in a ValueNotSetException.
|
virtualinherited |
Get if the InValue is valid.
The InValue is valid if a value has been received and the value has not expired
|
virtualinherited |
Get the timestamp of the last received value.
Returns the timestamp of the value in the senders clock
|
virtualinherited |
Get the timestamp of the last sent value.
Returns the timestamp of the last sent value in the local clock
|
inlinevirtual |
Get the current OutValue.
Gets the current OutValue that was transmitted to the peer. Throws ValueNotSetException if no value has been received, or the most recent value lifespan has expired.
|
virtualinherited |
Get the lifespan of OutValue.
OutValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after sending has expired, the OutValue is cleared, and becomes invalid. Attempts to access OutValue will result in a ValueNotSetException.
|
virtualinherited |
Get if the OutValue is valid.
The OutValue is valid if a value has been set using SetOutValue()
|
inline |
Get the currently configured connection closed callback function.
|
virtualinherited |
Set whether wire connection should ignore incoming values.
Wire connections may optionally desire to ignore incoming values. This is useful if the connection is only being used to send out values, and received values may create a potential memory . If ignore is true, incoming values will be discarded.
| ignore | If true, incoming values are ignored. If false, the most recent value is stored. |
|
virtualinherited |
Set the lifespan of InValue.
InValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after reception has expired, the InValue is cleared and becomes invalid. Attempts to access InValue will result in ValueNotSetException.
InValue lifespans may be used to avoid using a stale value received by the wire. If the lifespan is not set, the wire will continue to return the last received value, even if the value is old.
| millis | The lifespan in millisecond, or RR_VALUE_LIFESPAN_INFINITE for infinite lifespan |
|
inlinevirtual |
Set the OutValue and transmit to the peer connection.
Sets the OutValue for the wire connection. The specified value will be transmitted to the peer, and will become the peers InValue. The transmission is unreliable, meaning that values may be dropped if newer values arrive.
| value | The new out value |
|
virtualinherited |
Set the lifespan of OutValue.
OutValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after sending has expired, the OutValue is cleared and becomes invalid. Attempts to access OutValue will result in ValueNotSetException.
OutValue lifespans may be used to avoid using a stale value sent by the wire. If the lifespan is not set, the wire will continue to return the last sent value, even if the value is old.
| millis | The lifespan in millisecond, or RR_VALUE_LIFESPAN_INFINITE for infinite lifespan |
|
inline |
Set the connection closed callback function.
Sets a function to invoke when the wire connection has been closed.
Callback function must accept one argument, receiving the WireConnectionPtr<T> that was closed.
| callback | The callback function |
|
inline |
Try getting the InValue, returning true on success or false on failure.
Get the current InValue and InValue timestamp. Return true or false on success or failure instead of throwing exception.
| value | [out] The current InValue |
| time | [out] The current InValue timestamp in the senders clock |
|
inline |
Try getting the OutValue, returning true on success or false on failure.
Get the current OutValue and OutValue timestamp. Return true or false on success and failure instead of throwing exception.
| value | [out] The current OutValue |
| time | [out] The current OutValue timestamp in the local clock |
|
inherited |
Waits for InValue to be valid.
Blocks the current thread until InValue is valid, with an optional timeout. Returns true if InValue is valid, or false if timeout occurred.
| timeout | Timeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout |
|
inherited |
Waits for OutValue to be valid.
Blocks the current thread until OutValue is valid, with an optional timeout. Returns true if OutValue is valid, or false if timeout occurred.
| timeout | Timeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout |
| boost::signals2::signal<void(const boost::shared_ptr<WireConnection<T> >& connection, T value, TimeSpec time)> RobotRaconteur::WireConnection< T >::WireValueChanged |
Signal invoked when the InValue is changed.
Callback function must accept three arguments, receiving the WireConnectionPtr<T> that received a packet, the new value, and the value's TimeSpec timestamp