PlcWrapperCommunicator Class

Creates a new instance of PlcWrapperCommunicator.

Definition

Namespace: OddPrg.Communication.Plc
Assembly: OddPrg.Communication.PlcWrapper (in OddPrg.Communication.PlcWrapper.dll) Version: 1.0.0.0 (1.0.0.0)
C#
public class PlcWrapperCommunicator : SecondLayerCommunicator
Inheritance
Object    Communicator    SecondLayerCommunicator    PlcWrapperCommunicator

Constructors

PlcWrapperCommunicator Creates a new instance of PlcWrapperCommunicator class.

Properties

Active true - communicator is sending or receiving data false - communicator does not perform communication at this time
(Inherited from Communicator)
BroadcastTimeout Time in ms to wait after broadcast command is sent.
ClientAddress Current client (base node) 432 address used for communication. It is based on ConnectionParams.
ClientSap Current client SAP address used for communication. It is based on ConnectionParams.
Connected true - communicator is connected and ready to send and receive data false - communicator is not connected
(Inherited from Communicator)
ConnectionParams Communicator connection parameters. They must be assigned before calling Connect method.
(Inherited from Communicator)
FirstRequest Flag indicating the first request will be done. This property is initialized to true in the constructor and set automatically to false after first successfull request. But it can be set before any request.
InnerCommunicator Communicator used for sending/receiving data.
(Inherited from SecondLayerCommunicator)
IsBroadcast Indicates if ServerWPort is set to broadcast.
LastError Returns kind of last error stored in RaiseComException(). If no error has occured, ComExceptionKind.Unknow is returned. You may test LastRequestFailed to indicate if some error has occured.
(Inherited from Communicator)
LastRequestFailed Indicates if last request/response operation failed.
(Inherited from Communicator)
MaxNumberOfRepeats Maximal number or request repeat. It should be 0 or more.
Name Name of the communicator
(Inherited from Communicator)
RepeatFirstRequest Whether to repeat a first, usually create association request.
SerialNo Serial no of meter that is read. It is used if meter is yet connected before response is dispatched.
ServerAddress Current server (meter) 432 address used for communication. It is based on ConnectionParams.
ServerSap Current server SAP address used for communication. It is based on ConnectionParams.
TimeoutExpired Indicates if last request/response operation timed out.
(Inherited from Communicator)
TotalBytesTransfered Number of bytes transfered beginning since construction of communicator or since call of ClearTransferCounters.
(Inherited from Communicator)
TotalTransferTime Number of milliseconds that consumed in/out byte transfer since construction of communicator or since call of ClearTransferCounters.
(Inherited from Communicator)

Methods

BeginWaiting Resets waiting events. This method is used to initialize usage of WaitForWithoutSend which performs continuous waiting for incoming data stream.
(Inherited from Communicator)
ClearTransferCounters Clears total bytes transfered and total transfer time.
(Inherited from Communicator)
Connect(CancellationToken) Call this method to connect to a remote device with standard "connecting" message displayed in a log.
(Inherited from Communicator)
Connect(String, CancellationToken) Call this method to connect to a remote device. It must be called before any sending operation unless AutoConnect is set to true.
(Inherited from Communicator)
Disconnect Call this method to disconnect from a remote device with standard "disconnecting" message displayed in a log.
(Inherited from Communicator)
Disconnect(String) Call this method to disconnect from a remote device.
(Inherited from Communicator)
Dispatch Call this method from a data receive handler to accept new incoming data and to add them to the receive buffer and test if all data are received.
(Inherited from Communicator)
DisplayReceivedBytes Displays all received bytes that were processed by Dispatch method in a log.
(Inherited from Communicator)
Dispose IDisposable.Dispose implementation - Resets instance members
(Inherited from Communicator)
EndWaiting Sets waiting event, escapes the waiting loop and displays possible error message.
(Inherited from Communicator)
GetCurrentTime Function that returns current date/time. It should be used insted of DateTime.Now in all communicator methods.
(Inherited from Communicator)
GetDefaultStartReceiveTimeout Returns maximal time to wait for the first response counted after a request is sent. This method should be used to compute StartReceiveTimeout and NextReceiveTimeout before every communication id CheckDataReceive is set to true.
(Inherited from Communicator)
GetDefaultTimeout Returns the maximal time for communication with a device. TimeoutScale and ReplyDelay properties will be used for computation. This method should be used to compute Rimeout before every communication id CheckTimeout is set to true.
(Inherited from Communicator)
GetDetailedInfo Returns a string with detailed communicator settings including information about timeouts.
(Inherited from Communicator)
GetInfo Returns a string with brief description of current communicator settings.
(Inherited from Communicator)
GetParamsDetailedInfo Returns a detailed description of communicator configuration. If it is not overriden, it returns list of names and values of all connection params and it includes also timeouts.
(Inherited from Communicator)
GetParamsInfo Returns a brief description of communicator configuration. If it is not overriden, it returns a comma delimited string containing all values of connection params.
(Inherited from Communicator)
PduWaitingProc Returns true if current DLMS PLC communication is done. It means that whole PDU was received.
PrepareReceived Clears receive buffers.
(Inherited from Communicator)
PrepareSent Stores copy of data to sent for further echo check. Displays bytes to send in a log.
(Inherited from Communicator)
RaiseComException(String) Displays error message and raises the unknown communication exception.
(Inherited from Communicator)
RaiseComException(String, ComExceptionComExceptionKind) Displays error message and raises the communication exception.
(Inherited from Communicator)
RaiseComException(String, Exception) Displays error message and raises the communication exception.
(Inherited from Communicator)
RaiseComException(String, ComExceptionComExceptionKind, Exception) Displays error message without description and raises the communication exception.
(Inherited from Communicator)
RaiseComException(String, Boolean, ComExceptionComExceptionKind) Displays error message and raises the communication exception.
(Inherited from Communicator)
RaiseComException(String, Boolean, ComExceptionComExceptionKind, Exception) Displays error message and raises the communication exception.
(Inherited from Communicator)
RefreshState Refreshes a displaying of communicator status.
(Inherited from Communicator)
Send(ByteBuffer, CancellationToken) Sends data to a remote device and returns. This method does not wait for a response.
(Inherited from Communicator)
Send(String, CancellationToken) Sends data to a remote device and returns. This method does not wait for a response.
(Inherited from Communicator)
Send(ByteBuffer, ByteBuffer, CancellationToken) Sends data to a remote device and returns. This method does not wait for a response.
(Inherited from Communicator)
ShowProgress Shows communication progress message usualy used to write a message into a log.
(Inherited from Communicator)
Wait Waits required count of milliseconds. Waiting loop can be breaked via OnTestTerminate callback only. All incomming data are ignored and not displayed in a log.
(Inherited from Communicator)
WaitFor(ByteBuffer, WaitingTerminateProc, CancellationToken) Sends specified data and waits for the response. The waiting loop will be terminated if waitingTerminateProc returns true. If ByteBuffer data is empty, nothing is sent. Incomming bytes are returned using parametr data (so data parameter cannot be null). The procedure clears ByteBuffer data before start of receiving. If multiple incomming streams should be received without sending output bytes, WaitForWithoutSend method should be used.
(Inherited from Communicator)
WaitFor(String, WaitingTerminateProc, CancellationToken) Sends specified data and waits for the response. The waiting loop will be terminated if waitingTerminateProc returns true. If string data is empty, nothing is sent. Incomming chars are returned using parametr data (so data parameter cannot be null).
(Inherited from Communicator)
WaitFor(ByteBuffer, WaitingTerminateProc, ByteBuffer, CancellationToken) Sends specified data and waits for the response. The waiting loop will be terminated if waitingTerminateProc returns true. If ByteBuffer data is empty, nothing is sent. Incomming bytes are returned using parametr data (so data parameter cannot be null). The procedure clears ByteBuffer data before start of receiving. If multiple incomming streams should be received without sending output bytes, WaitForWithoutSend method should be used.
(Inherited from Communicator)
WaitForAnyData Sends content of data argument and waits until some data are received. Incomming data are returned in the data argument. This procedure is useful when data are sent/received in whole packets (e.g. HTTP).
(Inherited from Communicator)
WaitForByte(ByteBuffer, Byte, CancellationToken) Sends the content of data argument and waits until specified byte is received. Incomming data are returned in the data argument.
(Inherited from Communicator)
WaitForByte(ByteBuffer, Byte, CancellationToken) Sends the content of data argument and waits until any byte from byteSet array is received. Incomming data are returned in the data argument.
(Inherited from Communicator)
WaitForBytes Sends the content of data argument and waits until specified byte sequence is received. Incomming data are returned in the data argument.
(Inherited from Communicator)
WaitForChar(ByteBuffer, Char, CancellationToken) Sends the content of data argument and waits until specified char is received. Incomming data are returned in the data argument.
(Inherited from Communicator)
WaitForChar(ByteBuffer, Char, CancellationToken) Sends the content of data argument and waits until any char from charSet array is received. Incomming data are returned in the data argument.
(Inherited from Communicator)
WaitForChar(String, Char, CancellationToken) Sends the content of data argument and waits until specified char is received. Incomming data are returned in the data argument.
(Inherited from Communicator)
WaitForChar(String, Char, CancellationToken) Sends the content of data argument and waits until any char from charSet array is received. Incomming data are returned in the data argument.
(Inherited from Communicator)
WaitForLength Sends the content of data argument and waits until specified count of bytes is received. Incomming data are returned in the data argument.
(Inherited from Communicator)
WaitForPdu Sends data using DLMS PLC layer, waits for whole response from the server and returns DLMS frame in data.
WaitForStr(ByteBuffer, String, CancellationToken) Sends the content of data argument and waits until specified string is received. Incomming data are returned in the data argument. Incoming bytes are transformed using InputEncoding.
(Inherited from Communicator)
WaitForStr(String, String, CancellationToken) Sends the content of data argument and waits until specified string is received. Incomming data are returned in the data argument. Incoming bytes are transformed using InputEncoding.
(Inherited from Communicator)
WaitForStrings(ByteBuffer, String, CancellationToken) Sends the content of data argument and waits until any string from specified list is received. Incomming data are returned in the data argument. Incoming bytes are transformed using InputEncoding.
(Inherited from Communicator)
WaitForStrings(ByteBuffer, String, CancellationToken) Sends the content of data argument and waits until any string from specified list is received. Incomming data are returned in the data argument. Incoming bytes are transformed using InputEncoding.
(Inherited from Communicator)
WaitForStrings(String, String, CancellationToken) Sends the content of data argument and waits until any string from specified list is received. Incomming data are returned in the data argument. Incoming bytes are transformed using InputEncoding.
(Inherited from Communicator)
WaitForStrings(String, String, CancellationToken) Sends the content of data argument and waits until any string from specified list is received. Incomming data are returned in the data argument. Incoming bytes are transformed using InputEncoding.
(Inherited from Communicator)
WaitForStrings(ByteBuffer, String, ByteBuffer, CancellationToken) Sends the content of data argument and waits until any string from specified list is received. Incomming data are returned in the data argument. Incoming bytes are transformed using InputEncoding.
(Inherited from Communicator)
WaitForTime Sends the content of data argument and waits required count of milliseconds. Waiting loop can be breaked via OnTestTerminate callback only. Incomming data are returned in the data argument.
(Inherited from Communicator)
WaitForWithoutSend Receives incomming data until waitingTerminate returns true. Input buffer is not cleared, incomming bytes are appended to the input buffer content, so the method can be called multiple times. If some data were received in the meantime and waitingTerminate returns true for that data, method returns immediately to process returned data. Method waitingTerminate checks always whole receive buffer. Before call of WaitForwithoutSend, waiting must be initialized by calling BeginWaiting wich sets up timeout-check events. Todo: BeginWaiting ands WaitForWithoutSend can be unified in one method - ???
(Inherited from Communicator)

Fields

AfterDataReceived Performs some action after the communicator has recieved the data. If this procedure throws an exception, it has no effect. The parameter contains the received data.
(Inherited from Communicator)
AutoConnect If it is true, the communicator calls Connect method before any send/receive operation. After finishing this operation it calls Disconnect method.
(Inherited from Communicator)
AutoConnectInnerLayer Indicates if InnerCommunicator should be automatically connected while calling Connect and automatically disconnected while calling Disconnect.
(Inherited from SecondLayerCommunicator)
AutoConnectRepeatCount The maximal connection retries per one communication. The number of all connection tries is AutoConnectRepeatCount + 1. Applies only if AutoConnect is true.
(Inherited from Communicator)
BeforeDataSend Performs some action before sending the data throught the communicator. If this procedure throws an exception, it has no effect. The parametr contains data that should be send.
(Inherited from Communicator)
ByteDisplayMode Gets/Sets How to display sent and received bytes in a communication log. Default value is hexadecimal separated by |.
(Inherited from Communicator)
ClearEcho If it is true, echoed data from the beginning of receive buffer are cleared (but all data are displayed in a log)
(Inherited from Communicator)
DefaultParamValues Parameter default values. ClientAddress = 0x10 = Public client
DeviceName The name of a device to communicate with. Used in error messages.
(Inherited from Communicator)
DisplayBytesLength Count of bytes to display on a single line in a log. It is applicable only if DefaultByteDisplayMode is set to ByteDisplayModes.Hex.
(Inherited from Communicator)
DisplayCycleCount If this value is equal to displayCycleCountWholeLine communicator waits for whole line (DisplayCycleCount bytes) to display. If this value is equal to e.g. 3, communicator displays all received bytes every 3 cycles of waiting loop.
(Inherited from Communicator)
DisplaySystemChars Applies to ByteDisplayMode is Chars or Lines. Whether to display characters lower than 32. These characters are displayed as names surroundex in < and >.
(Inherited from Communicator)
DisplayTicks Whether to display time from creating a communicator for each line in communication log.
(Inherited from Communicator)
DoEvents If the communicator runs in main application thread, use this event to call Application.DoEvents. The reason is that if it runs as a part of some service, the namespace System.Windows.Forms.Application could not be accessible to call Application.DoEvents.
(Inherited from Communicator)
CheckDataReceive Whether "Device is not responding" or "Reply is invalid or incomplete" errors will be raised.
(Inherited from Communicator)
CheckTimeout Whether "Timeout expired" errors will be raised.
(Inherited from Communicator)
IgnoreNoResponse Whether not to display "No data received" message.
(Inherited from Communicator)
InputEncoding Encoding used to convert incomming bytes to string. It is used to display correct characters in a log if ByteDisplayMode is set to Chars or Lines.
(Inherited from Communicator)
InputLineSeparator Line separators for input to control displaying bytes if ByteDisplayMode is equal to ByteDisplayModes.Lines
(Inherited from Communicator)
NextReceiveTimeout The count of miliseconds to display error "Reply is invalid or incomplete" if no data comes in time counted from a previos data receive. It is applied only if CheckTimeout is set to true.
(Inherited from Communicator)
NoTerminateTest Whether to check a user termination. It could be useful for some disconnect operations when user termination is not desirable.
(Inherited from Communicator)
OnActivityChange Event raised when communicator activity is changed. It can be uset to enable/disable user controls. Remember to use BeginInvoke in this procedure if it changes UI and communication runs in a separate thread.
(Inherited from Communicator)
OnAfterConnect Performs some special action (e.g. authentication) after the communicator is successfully connected. This procedure should throw ComException if the current opening operation was not successfull, which aborts the communicator connection.
(Inherited from Communicator)
OnGetCurrentTime Procedure that returns current date/time. This procedure can be set if other time than DateTime.Now needs to be returned as current date/time. If this property is null, DateTime.Now is used as current date/time.
(Inherited from Communicator)
OnShowProgress Event to display communication progress in a log. Remember to use BeginInvoke in this procedure if it changes UI and communication runs in a separate thread.
(Inherited from Communicator)
OnShowState Event tot display a communicator status. It can be used e.g. to display in status bar. Remember to use BeginInvoke in this procedure if it changes UI and communication runs in a separate thread.
(Inherited from Communicator)
OutputEncoding Applies to output/input of string data. It is used to display correct characters in a log if ByteDisplayMode is set to Chars or Lines.
(Inherited from Communicator)
OutputLineSeparator Line separators for output to control displaying bytes if ByteDisplayMode is equal to ByteDisplayModes.Lines
(Inherited from Communicator)
PlcWrapperBroadcastTimeout Time in ms to wait after broadcast command is sent.
PlcWrapperClientAddress Two byte client (base node) 432 address.
PlcWrapperClientSap One byte client SAP address.
PlcWrapperMaxNumberOfRepeats (>= 0) Number of request retries if no response or invalid response is received.
PlcWrapperParamNames Parameter names.
PlcWrapperRepeatFirstRequest Whether to repeat a first, usually create association request.
PlcWrapperSerialNo Serial no of meter that is read. It is used if meter is yet connected before response is dispatched.
PlcWrapperServerAddress Two byte server (meter) 432 address.
PlcWrapperServerSap One byte server (meter) SAP address.
ReplyDelay Device reaction time in miliseconds. Used in GetDefaultTimeout to compute a communication timeout.
(Inherited from Communicator)
SleepTime Sleep time in every repeat of main waiting loop in miliseconds.
(Inherited from Communicator)
StartReceiveTimeout The count of miliseconds to display error "Device is not responding" if no data comes after sending a request. It can be computed using GetDefaultStartReceiveTimeout method. It is applied only if CheckTimeout is set to true.
(Inherited from Communicator)
Timeout The count of miliseconds to display error "Timeout expired" counted from sending a request. It must be initialized before every communication. It can be computed using GetDefaultTimeout method. It is applied only if CheckTimeout is set to true.
(Inherited from Communicator)
TimeoutScale Multiplier for time to send and receive. Used in GetDefaultTimeout to compute a communication timeout. This value is expected to be greater or equal to 1 (1 = exact expected time).
(Inherited from Communicator)
WaitBeforeSend Wait miliseconds in before sending any data. It can be used for protocols that require it by definition, e.g. M-bus needs 67 ms.
(Inherited from Communicator)

See Also