FOCUS Software Engineering has a new name: proconX - Professional Fieldbus Connections   

MbusTcpMasterProtocol Class Reference
[MODBUS/TCP Protocol]

Inheritance diagram for MbusTcpMasterProtocol:

Inheritance graph
Collaboration diagram for MbusTcpMasterProtocol:

Collaboration graph
List of all members.

Detailed Description

MODBUS/TCP Master Protocol.

This class realises the MODBUS/TCP master protocol. It provides functions to establish and to close a TCP/IP connection to the slave as well as data and control functions which can be used after a connection to a slave device has been established successfully. The data and control functions are organised in three different conformance classes. This implementation implements all functions of conformance class 0 and class 1. In addition some frequently used funtions of conformance class 2 are also implemented. This rich function set enables a user to solve nearly every Modbus® data transfer problem. For a more detailed description of the data and control functions see section Data and Control Functions for all Protocols.

All functions have been implemented thread-safe. It is also possible to instantiate multiple instances for establishing multiple connections to either the same or different hosts.

Version:
1.1
See also:
mbusmaster


TCP/IP Connection Management Functions

synchronized void openProtocol (String hostName) throws IOException
 Connects to a MODBUS/TCP slave.

synchronized void closeProtocol () throws IOException
 Closes a TCP/IP connection to a MODBUS/TCP slave and releases any system resources associated with the connection.

synchronized void setPort (int portNo)
 Sets the TCP port number to be used by the protocol.

int getPort ()
 Returns the TCP port number used by the protocol.

boolean isOpen ()
 Returns whether currently connected or not.


Advantec ADAM 5000/6000 Series Commands

String adamSendReceiveAsciiCmd (String commandStr) throws IOException, BusProtocolException
 Send/Receive ADAM 5000/6000 ASCII command.


Class 0 Modbus Functions

synchronized void writeMultipleRegisters (int slaveAddr, int startRef, short[] regArr) throws IOException, BusProtocolException
 Modbus function 16 (10 hex), Preset Multiple Registers/Write Multiple Registers.

synchronized void writeMultipleRegisters (int slaveAddr, int startRef, int[] int32Arr) throws IOException, BusProtocolException
 Modbus function 16 (10 hex) for 32-bit int data types, Preset Multiple Registers/Write Multiple Registers with int data.

synchronized void writeMultipleRegisters (int slaveAddr, int startRef, float[] float32Arr) throws IOException, BusProtocolException
 Modbus function 16 (10 hex) for 32-bit float data types, Preset Multiple Registers/Write Multiple Registers with float data.

synchronized void readMultipleRegisters (int slaveAddr, int startRef, short[] regArr) throws IOException, BusProtocolException
 Modbus function 3 (03 hex), Read Holding Registers/Read Multiple Registers.

synchronized void readMultipleRegisters (int slaveAddr, int startRef, int[] int32Arr) throws IOException, BusProtocolException
 Modbus function 3 (03 hex) for 32-bit int data types, Read Holding Registers/Read Multiple Registers as int data.

synchronized void readMultipleRegisters (int slaveAddr, int startRef, float[] float32Arr) throws IOException, BusProtocolException
 Modbus function 3 (03 hex) for 32-bit float data types, Read Holding Registers/Read Multiple Registers as float data.


Class 1 Modbus Functions

synchronized void readCoils (int slaveAddr, int startRef, boolean[] bitArr) throws IOException, BusProtocolException
 Modbus function 1 (01 hex), Read Coil Status/Read Coils.

synchronized void readInputDiscretes (int slaveAddr, int startRef, boolean[] bitArr) throws IOException, BusProtocolException
 Modbus function 2 (02 hex), Read Inputs Status/Read Input Discretes.

synchronized void readInputRegisters (int slaveAddr, int startRef, short[] regArr) throws IOException, BusProtocolException
 Modbus function 4 (04 hex), Read Input Registers.

synchronized void readInputRegisters (int slaveAddr, int startRef, int[] int32Arr) throws IOException, BusProtocolException
 Modbus function 4 (04 hex) for 32-bit int data types, Read Input Registers as int data.

synchronized void readInputRegisters (int slaveAddr, int startRef, float[] float32Arr) throws IOException, BusProtocolException
 Modbus function 4 (04 hex) for 32-bit float data types, Read Input Registers as float data.

synchronized void writeCoil (int slaveAddr, int bitAddr, boolean bitVal) throws IOException, BusProtocolException
 Modbus function 5 (05 hex), Force Single Coil/Write Coil.

synchronized void writeSingleRegister (int slaveAddr, int regAddr, short regVal) throws IOException, BusProtocolException
 Modbus function 6 (06 hex), Preset Single Register/Write Single Register.

synchronized byte readExceptionStatus (int slaveAddr) throws IOException, BusProtocolException
 Modbus function 7 (07 hex), Read Exception Status.


Class 2 Modbus Functions

synchronized void forceMultipleCoils (int slaveAddr, int startRef, boolean[] bitArr) throws IOException, BusProtocolException
 Modbus function 15 (0F hex), Force Multiple Coils.

synchronized void maskWriteRegister (int slaveAddr, int regAddr, short andMask, short orMask) throws IOException, BusProtocolException
 Modbus function 22 (16 hex), Mask Write Register.

synchronized void readWriteRegisters (int slaveAddr, int readRef, short[] readArr, int writeRef, short[] writeArr) throws IOException, BusProtocolException
 Modbus function 23 (17 hex), Read/Write Registers.


Vendor Specific Modbus Function Codes

synchronized void readHistoryLog (int slaveAddr, int channelNo, int resolution, short readArr[]) throws IOException, BusProtocolException
 Vendor Specific Modbus function 100 (64 hex), Read History Log.


Protocol Configuration

synchronized void setTimeout (int timeOut)
 Configures time-out.

int getTimeout ()
 Returns the operation time-out value.

synchronized void setPollDelay (int pollDelay)
 Configures poll delay.

int getPollDelay ()
 Returns the poll delay time.

synchronized void setRetryCnt (int retryCnt)
 Configures the automatic retry setting.

int getRetryCnt ()
 Returns the automatic retry count.


Transmission Statistic Functions

synchronized long getTotalCounter ()
 Returns how often a transmit/receive cycle has been executed.

synchronized void resetTotalCounter ()
 Resets total transmit/receive cycle counter.

synchronized long getSuccessCounter ()
 Returns how often a transmit/receive cycle was successful.

synchronized void resetSuccessCounter ()
 Resets successful transmit/receive counter.


Slave Configuration

void configureStandard32BitMode ()
 Configures all slaves for Standard 32-bit Mode.

synchronized void configureStandard32BitMode (int slaveAddr)
 Configures a slave for Standard 32-bit Register Mode.

void configureSingleReg32BitMode ()
 Configures all slaves for Single Register 32-bit Mode.

synchronized void configureSingleReg32BitMode (int slaveAddr)
 Configures all slaves for Single Register 32-bit Mode.

void configureCountFromOne ()
 Configures the reference counting scheme to start with one for all slaves.

synchronized void configureCountFromOne (int slaveAddr)
 Configures a slave's reference counting scheme to start with one.

void configureCountFromZero ()
 Configures the reference counting scheme to start with zero for all slaves.

synchronized void configureCountFromZero (int slaveAddr)
 Configures a slave's reference counting scheme to start with zero.

void configureLittleEndianInts ()
 Disables word swapping for int data type functions for all slaves.

synchronized void configureLittleEndianInts (int slaveAddr)
 Disables word swapping for int data type functions on a per slave basis.

void configureBigEndianInts ()
 Configures int data type functions to do a word swap for all slaves.

synchronized void configureBigEndianInts (int slaveAddr)
 Enables int data type functions to do a word swap on a per slave basis.

void configureLittleEndianFloats ()
 Disables float data type functions to do a word swap for all slaves.

synchronized void configureLittleEndianFloats (int slaveAddr)
 Disables float data type functions to do a word swap on a per slave basis.

void configureSwappedFloats ()
 Configures float data type functions to do a word swap for all slaves.

synchronized void configureSwappedFloats (int slaveAddr)
 Enables float data type functions to do a word swap on a per slave basis.


Protected Attributes

int portNo = 502
 TCP port number, defaults to 502.

   Back | Top of page Info | Support | Contact | About   
Information in this document is subject to change without notice. Copyright © 2000-2007 proconX Pty Ltd. All rights reserved.
All product and brand names mentioned on this page may be trademarks or registered trademarks of their respective owners.