Lucon SDK 1.0.7
Loading...
Searching...
No Matches
Gefasoft.LuconV2.DeviceConnection Class Referenceabstract

Base class encapsulating a connection to a Lucon Device. More...

Inheritance diagram for Gefasoft.LuconV2.DeviceConnection:
Gefasoft.LuconV2.Infrastructure.InteropObject Gefasoft.LuconV2.FakeDeviceConnection Gefasoft.LuconV2.Rs232DeviceConnection Gefasoft.LuconV2.UdpDeviceConnection

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< CommunicationEventArgsDataReceived [add, remove]
 The event is raised, after a ASCII message is received on the connection.
EventHandler< CommunicationEventArgsDataSent [add, remove]
 The event is raised, after a ASCII message is sent on the connection.
EventHandler< HintReceivedEventArgsHintReceived [add, remove]
 The event handler is raised asynchronously, when a hint message from the device is received.

Detailed Description

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.

Constructor & Destructor Documentation

◆ DeviceConnection()

Gefasoft.LuconV2.DeviceConnection.DeviceConnection ( IntPtr handle,
uint timeoutMilliseconds = 0 )
protected

create a new instance using a Lucon handle

Parameters
handleLuconHandle
timeoutMilliseconds

Member Function Documentation

◆ Close()

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!

See also
Device.Connect

◆ Dispose()

override void Gefasoft.LuconV2.DeviceConnection.Dispose ( bool disposing)
protectedvirtual

Implements the IDisposable pattern.

Parameters
disposing

Reimplemented from Gefasoft.LuconV2.Infrastructure.InteropObject.

◆ GetInfo()

string Gefasoft.LuconV2.DeviceConnection.GetInfo ( )

Compose a human-readable descriptive string which contains information on the configuration and state of the connection.

Returns
A human-readable description.

◆ Open()

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.

See also
Device.Connect

◆ SendCommand()

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.

Parameters
commandWithParamsthe ASCII command to send, e.g. "S01V|15000"
maxResponseLengthlength of the output string buffer to receive the response
Returns
the response received from the device

Property Documentation

◆ IsOpened

bool Gefasoft.LuconV2.DeviceConnection.IsOpened
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.

See also
IDevice.IsConnected, IDevice.CheckIsConnected

Event Documentation

◆ DataReceived

EventHandler<CommunicationEventArgs> Gefasoft.LuconV2.DeviceConnection.DataReceived
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.

◆ DataSent

EventHandler<CommunicationEventArgs> Gefasoft.LuconV2.DeviceConnection.DataSent
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.

◆ HintReceived

EventHandler<HintReceivedEventArgs> Gefasoft.LuconV2.DeviceConnection.HintReceived
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.


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