Modbus TCP
The element allows to get data from MODBUS TCP device and to write data to MODBUS TCP device.
Requests for management:
addvirtual - add a virtual sensor. Extra options are:
k - user session ID;
id - the identifier of the element; if the identifier is absent, a new element is created; otherwise the existing one is modified;
name - the name of the element, the length is not more than 63 characters;
virtual_type - type of virtual sensor:
modbus tcp - for reading Modbus data;
modbus tcp write - for writing Modbus data.
Options for reading Modbus data only (analog virtual sensor):
vmax - maximum value for the measuring range;
vmin - minimum value for the measuring range;
low_alarm - threshold level for notification;
low_warning - threshold level for notification;
high_warning - threshold level for notification;
high_alarm - threshold level for notification;
hyst_type - the type of algorithm used to calculate the hysteresis:
disable - the hysteresis is disabled;
value - hysteresis by the value measured by the sensor value;
time - hysteresis using time (used by default).
hyst_value - the value of the deviation of the sensor value when calculating the hysteresis by value, the value with a floating point (minimum 0, maximum 10,000, default 0.3);
hyst_low_alarm - the time in seconds, during which the sensor should keep its value in this range, for transition of the sensor to this state (minimum 0, maximum 1000, default 1);
hyst_low_warning - same as previous (default 1);
hyst_normal - same as previous (default is 0);
hyst_high_warning - same as previous (default 1);
hyst_high_alarm - same as previous (default 1).
expr - expression for calculating the output value, by default "x";
um - unit of measurement of this element;
utype - custom type, defines the sensor icon: current, factor, frequency, humidity, power, temperature, vibration, voltage;
Options for Modbus protocol (reading only):
mb_ip_addr - IP4 address of device, default 192.168.0.15;
mb_port - port of device, default 502;
mb_reg - register index for modbus function, hexademal string;
mb_func - function code for modbus:
1 - Read Coil Status (01);
2 - Read Input Status (02);
3 - Read Holding Register (03);
4 - Read Input Register (04).
mb_type - data type:
1 - 16 bits signed int;
2 - 16 bits unsigned int;
3 - 32 bits signed int;
4 - 32 bits unsigned int;
5 - 32 bits IEEE 754 floating point.
mb_order - data ordering:
1 - low byte first, low word first;
2 - low byte first, high word first;
3 - high byte first, low word first;
4 - high byte first, high word first.
mb_period - the polling period, seconds;
mb_wol_enable - Wake-On-LAN function enable flag, function will not supported if mb_period is less than 60 seconds;
mb_wol_timeout - waiting time for awakening remote device after sent Wake-On-LAN magic packet, from 1 to 15 seconds, default 3 seconds;
mb_wol_mac - MAC address of remote device for send Wake-On-LAN magic packet.
Options for Modbus protocol (writing only):
mb_ip_addr - IP4 address of device, default 192.168.0.15;
mb_port - port of device, default 502;
mb_reg - register index for modbus function, hexademal string;
mb_func - function code for modbus:
5 - Write Single Coil (05);
6 - Write Single Register (06);
16 - Write Multiple Registers (16).
mb_type - data type:
1 - 16 bits signed int;
2 - 16 bits unsigned int;
3 - 32 bits signed int;
4 - 32 bits unsigned int;
5 - 32 bits IEEE 754 floating point;
6 - hexadecimal string.
mb_order - data ordering:
1 - low byte first, low word first;
2 - low byte first, high word first;
3 - high byte first, low word first;
4 - high byte first, high word first.
mb_wrval - writing value, string, interpretation depends on the mb_type;
mb_wol_enable - Wake-On-LAN function enable flag;
mb_wol_timeout - waiting time for awakening remote device after sent Wake-On-LAN magic packet, from 1 to 15 seconds, default 3 seconds;
mb_wol_mac - MAC address of remote device for send Wake-On-LAN magic packet.
If the new element is successfully created, the response is:
<error type="no error" id="214002" /> |
When creating a new sensor (id is not specified), some parameters are mandatory. For reading: name, virtual_type, vmax, vmin, mb_ip_addr, mb_port, mb_reg, mb_func, mb_type, mb_order, mb_period. For writing: name, virtual_type, mb_ip_addr, mb_port, mb_reg, mb_func, mb_type, mb_order, mb_wrval. The rest of the query parameters are optional, and if not set, they will be set to the default values.
When editing an element, you can change individual fields.
delvirtual - remove the virtual sensor. Extra options:
k - user session ID;
id - ID of the element.
getelement - read the element. Extra options are:
k - the user session ID;
id - the ID of the item.
Information about the element looks like:
<element id="214003" index="4" module="2009" clas="analog" type="modbus tcp" name="Virtual modbus" state="normal" hwport="99" value="12.1" vmax="110.0" vmin="-55.0" low_alarm="-31.4" low_warning="-27.9" high_warning="35.0" high_alarm="69.7" expr="2.3*x" um="C" hyst_type="value" hyst_low_alarm="1" hyst_low_warning="1" hyst_normal="0" hyst_high_warning="1" hyst_high_alarm="1" hyst_value="0.340" mb_ip_addr="192.168.0.31" mb_port="502" mb_reg="00F2" mb_func="4" mb_type="5" mb_order="1" mb_period="30" >
|
Modbus TCP communication test
Requests for management:
testvirtual - communication test of Modbus TCP. Extra options are:
k - user session ID;
virtual_type - type of virtual sensor:
modbus tcp - for reading Modbus data;
modbus tcp write - for writing Modbus data.
mb_ip_addr - IP4 address of device, default 192.168.0.15;
mb_port - port of device, default 502;
mb_reg - register index for modbus function, hexademal string;
mb_func - function code for modbus:
1 - Read Coil Status (01);
2 - Read Input Status (02);
3 - Read Holding Register (03);
4 - Read Input Register (04);
5 - Write Single Coil (05);
6 - Write Single Register (06);
16 - Write Multiple Registers (16), for writing only.
mb_type - data type (for reading only):
1 - 16 bits signed int;
2 - 16 bits unsigned int;
3 - 32 bits signed int;
4 - 32 bits unsigned int;
5 - 32 bits IEEE 754 floating point;
6 - hexadecimal string, for writing only.
mb_order - data ordering:
1 - low byte first, low word first;
2 - low byte first, high word first;
3 - high byte first, low word first;
4 - high byte first, high word first.
mb_wrval - writing value, string, interpretation depends on the mb_type, for writing only.
Information about the reading test looks like:
<modbustcp mb_raw_ans="1F 04 04 43 63 55 19" mb_value="227.332413" /> |
If an error occurs, example:
<modbustcp mb_raw_ans="answer error" mb_value="value error"/> |
If no error occurs, the writing test looks like:
<error type="no error" /> |