.. _object_ModbusTcpClient: :index:`ModbusTcpClient` ------------------------ Description *********** The ModbusTcpClient object implements a Modbus TCP client which communicates with Modbus slaves (servers) via TCP network connections. :**› Inherits**: :ref:`ModbusClient ` Overview ******** Properties ++++++++++ .. hlist:: :columns: 2 * :ref:`lowDelay ` * :ref:`networkAddress ` * :ref:`networkPort ` * :ref:`ModbusClient.numberOfRetries ` * :ref:`ModbusClient.slaves ` * :ref:`ModbusClient.timeout ` * :ref:`ModbusDevice.activityLed ` * :ref:`ModbusDevice.autoConnect ` * :ref:`ModbusDevice.error ` * :ref:`ModbusDevice.errorString ` * :ref:`ModbusDevice.state ` * :ref:`Object.objectId ` * :ref:`Object.parent ` Methods +++++++ .. hlist:: :columns: 1 * :ref:`ModbusClient.pollSlaves() ` * :ref:`ModbusDevice.connectDevice() ` * :ref:`ModbusDevice.disconnectDevice() ` * :ref:`Object.deserializeProperties() ` * :ref:`Object.fromJson() ` * :ref:`Object.serializeProperties() ` * :ref:`Object.toJson() ` Signals +++++++ .. hlist:: :columns: 1 * :ref:`ModbusClient.slavesDataChanged() ` * :ref:`ModbusDevice.connected() ` * :ref:`ModbusDevice.disconnected() ` * :ref:`ModbusDevice.errorOccurred() ` * :ref:`Object.completed() ` Enumerations ++++++++++++ .. hlist:: :columns: 1 * :ref:`ModbusDevice.BusInterface ` * :ref:`ModbusDevice.Error ` * :ref:`ModbusDevice.State ` Properties ********** .. _property_ModbusTcpClient_lowDelay: .. _signal_ModbusTcpClient_lowDelayChanged: .. index:: single: lowDelay lowDelay ++++++++ This property holds whether to optimize the underlying TCP/IP socket for low latency by setting the ``TCP_NODELAY`` option and disabling Nagle's algorithm. This property was introduced in InCore 2.5. :**› Type**: Boolean :**› Default**: ``false`` :**› Signal**: lowDelayChanged() :**› Attributes**: Writable .. _property_ModbusTcpClient_networkAddress: .. _signal_ModbusTcpClient_networkAddressChanged: .. index:: single: networkAddress networkAddress ++++++++++++++ This property holds the host address of the Modbus TCP server which to connect to. :**› Type**: String :**› Default**: ``127.0.0.1`` :**› Signal**: networkAddressChanged() :**› Attributes**: Writable .. _property_ModbusTcpClient_networkPort: .. _signal_ModbusTcpClient_networkPortChanged: .. index:: single: networkPort networkPort +++++++++++ This property holds the network port of the Modbus TCP server which to connect to. :**› Type**: SignedInteger :**› Default**: ``502`` :**› Signal**: networkPortChanged() :**› Attributes**: Writable .. _example_ModbusTcpClient: Example ******* .. code-block:: qml import InCore.Foundation 2.5 import InCore.Modbus 2.5 Application { name: "Modbus TCP client example" ModbusTcpClient { // set address to connect to networkAddress: "192.168.10.19" // change retry and timeout configuration numberOfRetries: 1 timeout: 500 ModbusSlave { address: 1 // define Modbus register for temperature ModbusRegister { id: temperature type: ModbusRegister.Input address: 1 onDataChanged: console.log("Temperature", data) } // define special Modbus register device name stored as string ModbusRegister { type: ModbusRegister.Holding address: 0x1000 count: 8 dataType: ModbusRegister.String onDataChanged: console.log("Device name", data) } // read all registers every 50 ms Polling on registers { interval: 50 } } // print information message when connected onConnected: console.log("Connected to Modbus TCP slave") // print error message if something goes wrong onErrorOccurred: console.log(errorString) } }