ModbusSlaveAddRange

ModbusSlaveAddRange — configures a range of Modbus points.

Synopsis

(ModbusSlaveAddRange slaveName pointName blockType pointType address 
 allowWrite xformType xformArgs conversion itemCount, nameStart)
    

Arguments

slaveName

The name of the Modbus slave, as a string.

pointName

A pattern that contains the sequence {0} in at least once place. This sequence will be replaced by an incrementing number for each point in the range. The pattern may optionally include :Dn after the 0, to indicate the number of digits. For example, for sequence number 7, {0} will produce 7 and {0:D3} will produce 007. For example, a point name could be myPoint{0:D3}_Sp.

blockType

A string, one of

  • MB_DI for digital input

  • MB_DO for digital output

  • MB_AI for analog input

  • MB_AO for analog output

pointType

The type of point, as a string, consisting of typesize.flags, where:

  • type is one of:

    • i for integer

    • r for real (floating point)

    • s for string

    • b for bit

  • size is one of

    • 1 for one bit (b) or one byte (s)

    • 2 for two bytes (i or s)

    • 4 for four bytes (i or r)

    • 8 for eight bytes (i or r)

  • flags is any combination of

    • - (a minus sign) to indicate a signed integer (i)

    • b to swap bytes within words for 2, 4, or 8 byte sizes

    • w to swap words within dwords for 4 or 8 byte sizes

    • d to swap dwords within quadwords for 8 byte sizes

    • u to indicate UTF-8 for string (s) types of size 1, otherwise ASCII. s2 strings are always UTF-16.

    For example, "i4.-b" would be a signed, 4-bit integer with bytes swapped within words.

address

The Modbus address, as a string, consisting of one of the following:

  • number - the Modbus address offset, starting from 0 or 1 depending on the slave definition

  • number.bit - a single bit within the integer starting at address number

  • number.bit-bit - a bit field consisting of all bits between the first and last, inclusive

  • number[length] - an array, starting at address number

allowWrite

0 for not writable, 1 for writable

xformType

The type of transformation to make, one of: direct, linear or range

[Note]

For more information about transformations, please refer to the Transform section of the Modbus option of the Properties window.

xformArgs

One of the following, that corresponds to the transformation you specified above for xformType.

  • direct: an empty list (a list with zero elements).

  • linear: a list containing two elements: (multiply, add) where multiply is the amount to multiply the original value, and add is the amount to add to the original value.

  • range: a list containing these six elements: (modbusMin, modbusMax, pointMin, pointMax, clampMin, clampMax) where:

    • modbusMin is the minium value for the Modbus value.

    • modbusMax is the maximum value for the Modbus value.

    • pointMin is the minium value for the point value.

    • pointMax is the maximum value for the point value.

    • clampMin is the minium clamp value.

    • clampMax is the maximum clamp value.

conversion

A list of (enabled, targetType), where:

  • enabled is 0 or 1

  • targetType is a type name, as a string, such as "i4" or "r8"

itemCount

A number greater than 0 indicating the number of points to define.

nameStart

A number indicating the starting number for point name incremental numbering.

Returns

A message indicating success or error. Please refer to Return Syntax for details.

Description

This command configures a range of Modbus points. For more information about ranges, please refer to the Ranges section of the Modbus option of the Properties window.