Click or drag to resize

ModbusTCPProtocol Class

The ModBus TCP Protocol for more information on supported commands see http://www.brainboxes.com/modbus
Inheritance Hierarchy

Namespace:  Brainboxes.IO
Assembly:  Brainboxes.IO (in Brainboxes.IO.dll) Version: 1.5.0.0 (1.5.0.0)
Syntax
public class ModbusTCPProtocol : Protocol, 
	IIOProtocol, IProtocol

The ModbusTCPProtocol type exposes the following members.

Constructors
  NameDescription
Public methodModbusTCPProtocol
Create an Modbus TCP Protocol object,
Top
Properties
  NameDescription
Public propertyDeviceName
The name of the ED Device
Public propertyLastRequest
The last Modbus TCP Request sent encoded as string
Public propertyLastResponse
The Modbus TCP Response for the last Request sent note this could be null as the request may not have completed at time of asking
Public propertyProtocolId
The ModbusTCP protocol, always 0 From Modbus.org: Protocol Identifier – It is used for intra-system multiplexing. The MODBUS protocol is identified by the value 0.
Public propertyRequestLength
The Modbus TCP Length of Request From Modbus.rog: Length - The length field is a byte count of the following fields, including the Unit Identifier and data fields.
Public propertyResponseLength
The Modbus TCP Length of Response From Modbus.rog: Length - The length field is a byte count of the following fields, including the Unit Identifier and data fields.
Public propertyStream
Set the stream which the protocol data is written and read from
(Inherited from Protocol.)
Public propertyTransactionId
The ModbusTCP transaction Id starts at one and should be incremented each time from Modbus.org: Transaction Identifier - It is used for transaction pairing, the MODBUS server copies in the response the transaction identifier of the request.
Public propertyUnitId
The ModbusTCP Unit identifier, From Modbus.org: Unit Identifier – This field is used for intra-system routing purpose. It is typically used to communicate to a MODBUS+ or a MODBUS serial line slave through a gateway between an Ethernet TCP-IP network and a MODBUS serial line.This field is set by the MODBUS Client in the request and must be returned with the same value in the response by the server. For our purposes: always 0xff
Top
Methods
  NameDescription
Public methodClearAllLatchedDigitalInputs
Clear the INPUT latches
Public methodClearAllLatchedInputs Obsolete.
Clear the Digital INPUT latches
Public methodClearDigitalInputLineCount
Clears the digital input counter of the specified line.
Public methodClearLineCount Obsolete.
Clears the digital input counter of the specified line,
Public methodEquals (Inherited from Object.)
Public methodGetAllAnalogInputLineStates
Get all analog input values
Public methodGetAllAnalogOutputLineStates
Get all analog output values
Public methodGetAllDigitalLineStates
Get the state of all the Digital IOLines of the device as an integer the top 16 bits are the outputs, the bottom 16 bits are the inputs
Public methodGetAllInputStates
Get the state of the inputs on the device
Public methodGetAllLatchedHighDigitalInputStates
Get the HIGH LATCH states of all the Digital Inputs
Public methodGetAllLatchedHighInputStates Obsolete.
Get the HIGH LATCH states of all the Digital Inputs
Public methodGetAllLatchedLowDigitalInputStates
Get the LOW LATCH state of all the Digital INPUTS
Public methodGetAllLatchedLowInputStates Obsolete.
Get the LOW LATCH state of all the Digital INPUTS
Public methodGetAllLineStates Obsolete.
Get the state of all the Digital IOLines of the device as an integer the top 16 bits are the outputs, the bottom 16 bits are the inputs
Public methodGetAllOutputStates
Get all output line states
Public methodGetAnalogLineState
Get an individual analog line value
Public methodGetDeviceConfiguration
Read the device configuration
Public methodGetDeviceName
Get the name of the Device
Public methodGetDigitalInputLineCount
Reads the digital input counter of the specified channel
Public methodGetDigitalLineState
Get the state of a digital IO Line
Public methodGetHashCode (Inherited from Object.)
Public methodGetLineCount Obsolete.
Reads the digital input counter of the specified channel
Public methodGetLineState Obsolete.
Get the state of a digital IO Line
Public methodGetRequestForTransactionId
Get Modbus TCP Request for a particular TransactionId
Public methodGetResponseForTransactionId
Get Modbus TCP response for particular TransactionId
Public methodGetType (Inherited from Object.)
Public methodPrettyPrintModbusADU(Byte)
Take a Modbus Command written in a hex byte array representation and prettifies it. e.g. 0x006600000006ff0100000010 0066 0000 0006 ff 01 0000 0010 TranID|ProtID|Len|UnitID|Func|DATA there is a space every 4 characters, and also a space at the 15 char between the UnitID and the Function code
Public methodPrettyPrintModbusADU(String)
Take a Modbus Command written in ASCII as a hex representation and prettifies it. e.g. 006600000006ff0100000010 0066 0000 0006 ff 01 0000 0010 TranID|ProtID|Len|UnitID|Func|DATA there is a space every 4 characters, and also a space at the 14 char between the UnitID and the Function code
Public methodResetToFactoryDefaultSettings
Reset the ED device to factory default settings
Public methodRestart
Power Off and the On the ED Device
Public methodSendCommand(Byte)
Send a ModbusTCP command (ADU) to a Brainboxes Device and return response The MBAP header is handled internally by this class, only the function and data need to be sent as a command Any spacing is ignore, commands as encoded hex byte array e.g. 0x0100000001 Modbus TCP commands are defined as follows: ADU: Application Data Unit, split into: MBAP and PDU MBAP Header - the header contains 4 fields: * transactionId (2 bytes) = id starting at 01 increments by 1 for each new ADU sent * protocol Id (2 bytes) = always 0x00 = modbus for brainboxes devices * Length (2 bytes) = the total length in bytes of rest of the ADU from that point * Unit Id (1 byte) = set by the client in the request the response must contain the same data, always 0xff PDU: Protocol Data Unit, consists of 2 fields: Function Code (2 bytes)- the type of function requested can be: * 0x01 = Read Coils * 0x02 = Read Discrete Inputs * 0x03 = Read Holding Registers * 0x04 = Read Input Registers * 0x05 = Write Single Coil * 0x06 = Write Single Register Data (variable length) - The end of the modbusTCP command, which contains data relevant to the function code The format of the command is hex encoded values in ASCII,
Public methodSendCommand(String)
Send a ModbusTCP command (ADU) to a Brainboxes Device and return response The MBAP header is handled internally by this class, only the function and data need to be sent as a command Any spacing is ignore, commands are hex encoded ASCII (e.g. "01 0000 0001") Modbus TCP commands are defined as follows: ADU - Application Data Unit, split into: MBAP Header - the header contains 4 fields: * transactionId (2 bytes) = id starting at 01 increments by 1 for each new ADU sent * protocol Id (2 bytes) = always 0x00 = modbus for brainboxes devices * Length (2 bytes) = the total length in bytes of rest of the ADU from that point * Unit Id (1 byte)= set by the client in the request the response must contain the same data, always 0xff Function Code (2 bytes)- the type of function requested can be: * 0x01 = Read Coils * 0x02 = Read Discrete Inputs * 0x03 = Read Holding Registers * 0x04 = Read Input Registers * 0x05 = Write Single Coil * 0x06 = Write Single Register Data (variable length) - The end of the modbusTCP command, which contains data relevant to the function code The format of the command is hex encoded values in ASCII,
Public methodSetAllDigitalOutputLineStates
Set all output lines on the device open (0) or closed (1) The bit position represents the line number
Public methodSetAllOutputLineStates Obsolete.
Set all output lines on the device open (0) or closed (1) The bit position represents the line number
Public methodSetAnalogOutputLineState
Set an individual analog output line value
Public methodSetDigitalOutputLineState
Set an individual output line state open (0) or closed (1)
Public methodSetOutputLineState Obsolete.
Set an individual output line state open (0) or closed (1)
Public methodToString (Inherited from Object.)
Top
See Also