|
Lucon SDK 1.0.7
|
Base class encapsulating a connection to a Lucon Device. More...
Public Member Functions | |
| string | GetInfo () |
| Compose a human-readable descriptive string which contains information on the configuration and state of the connection. | |
| void | Open () |
| Open the connection to the device. Once opened, connection, the connection listens for incoming messages and may be used for communication. | |
| void | Close () |
| Close the connection to the device. The call blocks, until the related OS resources are freed. | |
| string | SendCommand (string commandWithParams, int maxResponseLength=255) |
| Sends a command-string to the LUCON and waits for a device response. Throws a LuconException, if the request times out or an error is received. | |
| Public Member Functions inherited from Gefasoft.LuconV2.Infrastructure.InteropObject | |
| void | Dispose () |
| Dispose the object and free all related resources. | |
Protected Member Functions | |
| DeviceConnection (IntPtr handle, uint timeoutMilliseconds=0) | |
| create a new instance using a Lucon handle | |
| override void | Dispose (bool disposing) |
| Implements the IDisposable pattern. | |
Properties | |
| bool | IsOpened [get] |
| Indicates, whether the connection is opened and ready for communication. | |
Events | |
| EventHandler< CommunicationEventArgs > | DataReceived [add, remove] |
| The event is raised, after a ASCII message is received on the connection. | |
| EventHandler< CommunicationEventArgs > | DataSent [add, remove] |
| The event is raised, after a ASCII message is sent on the connection. | |
| EventHandler< HintReceivedEventArgs > | HintReceived [add, remove] |
| The event handler is raised asynchronously, when a hint message from the device is received. | |
Base class encapsulating a connection to a Lucon Device.
Lucon connections take care of the Lucon protocol for device communication. The communication can be monitored using the DataSent and DataReceived events. Asynchronous hints from the device may be received at any time using the HintReceived event. Users can send commands using the SendCommand function.
The connection internally serializes all requests: at any time there may be only one pending command to which incoming device messages are associated. If no proper answer to a command is received within the timespan set in the constructor, it will time out.
|
protected |
create a new instance using a Lucon handle
| handle | LuconHandle |
| timeoutMilliseconds |
| void Gefasoft.LuconV2.DeviceConnection.Close | ( | ) |
Close the connection to the device. The call blocks, until the related OS resources are freed.
Invocation from or synchronization with the event handlers DataSent or DataReceived may deadlock!
|
protectedvirtual |
Implements the IDisposable pattern.
| disposing |
Reimplemented from Gefasoft.LuconV2.Infrastructure.InteropObject.
| string Gefasoft.LuconV2.DeviceConnection.GetInfo | ( | ) |
Compose a human-readable descriptive string which contains information on the configuration and state of the connection.
| void Gefasoft.LuconV2.DeviceConnection.Open | ( | ) |
Open the connection to the device. Once opened, connection, the connection listens for incoming messages and may be used for communication.
Open will always succeed, if the configuration is valid and the the resources are available. It does not(!) check, whether the device is actually responding.
| string Gefasoft.LuconV2.DeviceConnection.SendCommand | ( | string | commandWithParams, |
| int | maxResponseLength = 255 ) |
Sends a command-string to the LUCON and waits for a device response. Throws a LuconException, if the request times out or an error is received.
| commandWithParams | the ASCII command to send, e.g. "S01V|15000" |
| maxResponseLength | length of the output string buffer to receive the response |
|
get |
Indicates, whether the connection is opened and ready for communication.
This property does not indicate, whether there is any device listening or responding on the remote site: it only state, whether all local resources are properly set up and operational.
|
addremove |
The event is raised, after a ASCII message is received on the connection.
The event handler is called synchronously from the background worker which dispatches the device messages. Work done in the event handler will delay processing of device messages and may cause commands to time out. Do not call any other Lucon function within the event handler, as will always timeout or might deadlock.
|
addremove |
The event is raised, after a ASCII message is sent on the connection.
The event handler is called synchronously from the background worker which dispatches the device messages. Work done in the event handler will delay processing of device messages and may cause commands to time out. Do not call any other Lucon function within the event handler, as will always timeout or might deadlock.
|
addremove |
The event handler is raised asynchronously, when a hint message from the device is received.
Hint messages may be sent by a Lucon at any time, independent of any hots request. They may inform the host about errors on the device or contain information about its internal processing state.