Metratec devices library 3.1.1.0
Public Member Functions | Properties | List of all members
CommunicationInterfaces.ICommunicationInterface Interface Reference

The common interface definition for different hardware communication options. More...

Inheritance diagram for CommunicationInterfaces.ICommunicationInterface:
CommunicationInterfaces.EthernetInterface CommunicationInterfaces.SerialInterface

Public Member Functions

void Connect ()
 The method to connect the communication interface.
 
void Disconnect ()
 The method to close the communication interface.
 
void Send (byte[] data, int offset, int count)
 Method to write a byte-array to the device (e.g. a binary file)
 
void Send (byte[] data)
 Method to write a byte-array to the device (e.g. a binary file)
 
void Send (string data)
 Method to write a string to the device.
 
void SendCommand (string command)
 The method used to send a command to the reader.
 
byte[] Read (int count)
 Method to read a stream of bytes from device.
 
string ReadResponse ()
 The method used to synchronously read a reader response.
 

Properties

int ReceiveTimeout [get, set]
 The communication receive timeout.
 
int BaudRate [get, set]
 The communication baud rate.
 
string NewlineString [get, set]
 The communication new line string.
 
bool DataAvailable [get]
 Indicates whether data is available for reading.
 
bool IsConnected [get]
 Connection flag.
 

Detailed Description

The common interface definition for different hardware communication options.

Member Function Documentation

◆ Connect()

void CommunicationInterfaces.ICommunicationInterface.Connect ( )

The method to connect the communication interface.

Exceptions
T:System.InvalidOperationExceptionThrown when the serial port could not be set up (e.g. wrong parameters, insufficient permissions, invalid port state).

Implemented in CommunicationInterfaces.EthernetInterface, and CommunicationInterfaces.SerialInterface.

◆ Disconnect()

void CommunicationInterfaces.ICommunicationInterface.Disconnect ( )

The method to close the communication interface.

Implemented in CommunicationInterfaces.EthernetInterface, and CommunicationInterfaces.SerialInterface.

◆ Read()

byte[] CommunicationInterfaces.ICommunicationInterface.Read ( int  count)

Method to read a stream of bytes from device.

Parameters
countNumber of bytes to read
Returns
The bytes read

Implemented in CommunicationInterfaces.EthernetInterface, and CommunicationInterfaces.SerialInterface.

◆ ReadResponse()

string CommunicationInterfaces.ICommunicationInterface.ReadResponse ( )

The method used to synchronously read a reader response.

Returns
The string read - without the newline character
Exceptions
T:System.TimeoutExceptionThrown when no answer is received for more than 400ms.
T:System.ObjectDisposedExceptionThrown when the underlying function reports a broken stream

Implemented in CommunicationInterfaces.EthernetInterface, and CommunicationInterfaces.SerialInterface.

◆ Send() [1/3]

void CommunicationInterfaces.ICommunicationInterface.Send ( byte[]  data)

Method to write a byte-array to the device (e.g. a binary file)

Parameters
dataThe overall byte-array of data

◆ Send() [2/3]

void CommunicationInterfaces.ICommunicationInterface.Send ( byte[]  data,
int  offset,
int  count 
)

Method to write a byte-array to the device (e.g. a binary file)

Parameters
dataThe overall byte-array of data
offsetThe starting address in the array
countThe number of characters to write

Implemented in CommunicationInterfaces.EthernetInterface, and CommunicationInterfaces.SerialInterface.

◆ Send() [3/3]

void CommunicationInterfaces.ICommunicationInterface.Send ( string  data)

Method to write a string to the device.

Parameters
dataThe overall byte-array of data

◆ SendCommand()

void CommunicationInterfaces.ICommunicationInterface.SendCommand ( string  command)

The method used to send a command to the reader.

Parameters
commandThe data / command sent to the reader
Exceptions
T:System.ArgumentNullExceptionThrown when the specified command is null.
T:System.InvalidOperationExceptionThrown when an exception occurs when trying to access the port (e.g. port closed, timeout).
T:System.ObjectDisposedExceptionThrown when the underlying function reports a broken stream

Implemented in CommunicationInterfaces.SerialInterface, and CommunicationInterfaces.EthernetInterface.

Property Documentation

◆ BaudRate

int CommunicationInterfaces.ICommunicationInterface.BaudRate
getset

The communication baud rate.

Exceptions
T:System.InvalidOperationExceptionThrown in case baud rate setting did not work

Implemented in CommunicationInterfaces.EthernetInterface, and CommunicationInterfaces.SerialInterface.

◆ DataAvailable

bool CommunicationInterfaces.ICommunicationInterface.DataAvailable
get

Indicates whether data is available for reading.

Exceptions
T:System.ObjectDisposedExceptionThrown when the underlying function reports a broken stream

Implemented in CommunicationInterfaces.EthernetInterface, and CommunicationInterfaces.SerialInterface.

◆ IsConnected

bool CommunicationInterfaces.ICommunicationInterface.IsConnected
get

◆ NewlineString

string CommunicationInterfaces.ICommunicationInterface.NewlineString
getset

The communication new line string.

Implemented in CommunicationInterfaces.EthernetInterface, and CommunicationInterfaces.SerialInterface.

◆ ReceiveTimeout

int CommunicationInterfaces.ICommunicationInterface.ReceiveTimeout
getset

The communication receive timeout.

Exceptions
T:System.InvalidOperationExceptionThrown in case baud rate setting did not work

Implemented in CommunicationInterfaces.EthernetInterface, and CommunicationInterfaces.SerialInterface.


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