Add leading zero when using equipment editor

Hello all,

I want to use the equipment editor to create tags for a PSDirect device with addresses that contain leading zeros (for display and sorting purposes).

For example, I want to create a custom parameter for the DB number and offset and then create addresses that look like this: DB003,0001, DB003,0002, DB003,10001.

Is this possible?

Parents
  • Hi,
    I added custom parameters to my equipment types, one for the DB number (PLC.DBNumber) and one for the initial offset of the block of data (StructOffset). The parameters are grouped under a section called TagAddressing.
    I use the calculator function in the XML templates to create the variable tag addresses.

    The first item looks like this:
    <output name="Element_1" file="variable.dbf" filter="'{equipment.type}={type.name}'">
    <calculator name="TagAddress">{equipment.TagAddressing[StructOffset]} + 5</calculator>
    <field name="ADDR">DB{equipment.TagAddressing[PLC.DBNumber]},{TagAddress}</field>
    The second:
    <output name="Element_2" file="variable.dbf" filter="'{equipment.type}={type.name}'">
    <calculator name="TagAddress">{equipment.TagAddressing[StructOffset]} + 8</calculator>
    <field name="ADDR">DB{equipment.TagAddressing[PLC.DBNumber]},{TagAddress}</field>
    And so on, where each adds to the initial offset.

    If I insert PLC.DBNumber=1 and StructOffset=1 to the custom parameters, I get these values:
    first item -> DB1,6 second item -> DB1,9
    If I insert PLC.DBNumber=11 and StructOffset=101 to the custom parameters, I get these values:
    first item -> DB11,106 second item -> DB11,109

    I want all my addresses to have the same structure: DBxxx,yyyy. So I need to add leading zeros to how I build them.

    I hope this is more clear (although a bit long).
Reply
  • Hi,
    I added custom parameters to my equipment types, one for the DB number (PLC.DBNumber) and one for the initial offset of the block of data (StructOffset). The parameters are grouped under a section called TagAddressing.
    I use the calculator function in the XML templates to create the variable tag addresses.

    The first item looks like this:
    <output name="Element_1" file="variable.dbf" filter="'{equipment.type}={type.name}'">
    <calculator name="TagAddress">{equipment.TagAddressing[StructOffset]} + 5</calculator>
    <field name="ADDR">DB{equipment.TagAddressing[PLC.DBNumber]},{TagAddress}</field>
    The second:
    <output name="Element_2" file="variable.dbf" filter="'{equipment.type}={type.name}'">
    <calculator name="TagAddress">{equipment.TagAddressing[StructOffset]} + 8</calculator>
    <field name="ADDR">DB{equipment.TagAddressing[PLC.DBNumber]},{TagAddress}</field>
    And so on, where each adds to the initial offset.

    If I insert PLC.DBNumber=1 and StructOffset=1 to the custom parameters, I get these values:
    first item -> DB1,6 second item -> DB1,9
    If I insert PLC.DBNumber=11 and StructOffset=101 to the custom parameters, I get these values:
    first item -> DB11,106 second item -> DB11,109

    I want all my addresses to have the same structure: DBxxx,yyyy. So I need to add leading zeros to how I build them.

    I hope this is more clear (although a bit long).
Children
No Data