public class HdlcCommunicator1 : SecondLayerCommunicator
HdlcCommunicator1 | Creates an instance of HdlcCommunicator |
Active |
true - communicator is sending or receiving data
false - communicator does not perform communication at this time
(Inherited from Communicator) |
AssociationActive | Indicates if HDLC association was created using Connect and was not timed out (see inactivityTimer). |
BroadcastTimeout | Timeout in ms to wait after broadcast command is sent. |
ClientAddress | Current client address used for communication. It is based on ConnectionParams. |
ClientAddressingScheme | Client addressing scheme. |
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) |
FlagAddress | Flag address of the meter used for switching to mode E. |
FlagIdentification | Gets currently connected device flag identification. Initialized after HDLC is connected. |
CheckActiveAssociation | Whether to check if association is active before sending any data. It is based on ConnectionParams. |
InactivityTimeout | Inactivity timeout |
InnerCommunicator |
Communicator used for sending/receiving data.
(Inherited from SecondLayerCommunicator) |
IsBroadcast | Returns true if server address is set to broadcast. |
KeepAssociation | Whether to keep HDLC association by periodic sending test frames. |
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. Layer parameter 1 from GB 8.4.5.6.2. It should be 0 or more. |
Name |
Name of the communicator
(Inherited from Communicator) |
Negotiate | Whether to negotiate parameters during a link setup. |
NegotiatedParameters | Hdlc parameters used in current communication. They are initialized from ConnectionParams and can be negotiated by a server (meter) during a data link setup procedure in openChannel. |
OperationalBaudrate | Operational baudrate for HDLC. Used if SwitchToModeE is set to true. Zero means by meter reply. |
ServerAddress | Current server address used for communication. It is based on ConnectionParams. |
ServerAddressingScheme | Server addressing scheme. |
SwitchToModeE | Whether to switch to mode E before creating a HDLC association. |
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) |
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) |
HdlcWaitingProc | Returns true if current HDLC communication is done. It means that last received hdlc frame has segmentation bit not set. |
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) |
ResetAssociation | Allowes to call creating association (openCahnnel) without previous call of closeChannel. It can be used e.g. after meter reset. |
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) |
WaitForHdlc | |
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) |
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) |
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) |
BaudrateChangeSupported | Indicates if communicator supports baudrate for communication. Used by entering to HDLC mode from IEC. |
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) |
ComParamsChangeSupported | Indicates if communicator supports changing serial port parameters. Used by entering to HDLC mode from IEC. |
DefaultParamValues | Default parameter values Default values for parameters HdlcInformationSizeTx, HdlcInformationSizeRx, HdlcWindowSizeTx, HdlcWindowSizeRx see GB 8.4.5.3.2 |
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) |
HdlcBroadcastTimeout | Time in ms to wait after broadcast command is sent. |
HdlcClientAddressingScheme | One of HDLCFrame.AddressingScheme values as string. It is used for client (service) address. |
HdlcClientLowerAddress | One (byte) or two (ushort) bytes depending on HdlcAddressingScheme. It can be also omitted for OneByte addressing scheme. It is used for client (service) address. |
HdlcClientUpperAddress | One byte SAP address of the client (service). |
HdlcFlagAddress | Address used for switching to mode E |
HdlcCheckActiveAssociation | Whether to check if association is active before sending any data. |
HdlcInactivityTimeout | Timeout in seconds the server stays in association with client in the case the client does not send any request. After this timeout expires the association must be created again by Connect method. |
HdlcInformationSizeRx | Max size of packet in bytes - receive |
HdlcInformationSizeTx | Max size of packet in bytes - transmit |
HdlcKeepAssociation | Whether to keep the HDLC association. If the parameter is true and association timeout expires, Test frame is sent to the server. If the parameter is false and association timeout expires, OnActivityTimeoutExpired event is called. |
HdlcMaxNumberOfRepeats | (>= 0) Number of request retries if no response or invalid response is received. Layer parameter 1 from GB 8.4.5.6.2. |
HdlcNegotiateParameters | True/False - whether to negotiate/acknowledge parameters during the connection phase |
HdlcOperationalBaudrate | Baudrate used for HDLC. It can be 0 for baudrate returend by a meter while entering mode E, or any other value to force communication using baudtrate other than one returned by a meter. This parameter applies only if HdlcSwitchToModeE parameter is set to true. |
HdlcParamNames | Parameter names |
HdlcServerAddressingScheme | One of HDLCFrame.AddressingScheme values as string. It is used for server (meter) address. |
HdlcServerLowerAddress | One (byte) or two (ushort) bytes depending on HdlcAddressingScheme. It is used for server (meter) address. |
HdlcServerUpperAddress | One (byte) or two (ushort) bytes depending on HdlcAddressingScheme. It is used for server (meter) address. |
HdlcSwitchToModeE | True/False - whether to switch to flag mode E before HDLC association |
HdlcWindowSizeRx | Max count of packets that can be sent by meter without ack from a client |
HdlcWindowSizeTx | Max count af packets that can be sent by client without ack from a meter |
ChangeBaudrate | Procedura pro zmenu rychlosti. Used by entering to HDLC mode from IEC. |
ChangeComParams | Procedure for changing of more than one communication parameter in one step (procedure). This procedure is primary executed, if it is assigned. Then the ChangeBaudrate, ChangeParity, ChangeDataBits and ChangeStopBits procedures will not be executed. Null value of parameter for those parameters can be used to declare, that you want to keep this parameter without change. |
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) |
OnActivityTimeoutExpired | Executes when inactivity timeout expires and KeepAssociation is set to false. If changing an user interace by this event, remember to execute it in main app thread using Invoke or BeginInvoke. |
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) |
OnNextInformationAdded | Executes when next information frame is successfully parsed and retuns an information part of the frame. If changing an user interace in this event, remember to execute it in main app thread using Invoke or BeginInvoke. |
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) |
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) |