<calculator>{parameter} + 1</calculator>
<string name="MyString">1000</string>
<calculator name="MyCalc">{MyString} + 1</calculator>
See Example 1.
<calculator name="MyCalc">{equipment.Custom1} + 1</calculator>
See Example 2.
<calculator name="MyCalc">{equipment.param_list[Param1]} + 1</calculator>
See Example 3.
<calculator name="MyCalc">{equipment.ParamGroup[Param2]} + 1</calculator>
These can then be used in fields for an element:
<field name="addr">MW_{MyCalc}_2</field>
See Example 3.
<output name="Element" file="variable.dbf" filter="'{equipment.type}={type.name}'">
<calculator name="TagAddress">{equipment.TagAddressing[StructOffset]} + 0</calculator>
...
</output>
These can then be used in fields for an element:
<field name="addr">MW_{MyCalc}_2</field>
See Example 4.
<?xml version="1.0" encoding="utf-8"?>
<template desc="">
<param name="type">
<string name="name">TypeWithCalc</string>
<string name="ref">TypeWithCalc</string>
<string name="blank"></string>
<string name="wildcard"></string>
<string name="parameter-definitions">param_list.param1=;Addr.BaseAddr=</string>
</param>
<input name="equipment" file="equip.dbf" desc="Equipment Database">
<field name="PARAM" />
<field name="TAGPREFIX" />
<field name="IODEVICE" />
<field name="CLUSTER" />
<field name="NAME" />
<field name="AREA" />
<field name="LOCATION" />
<field name="COMMENT" />
<field name="CUSTOM1" />
<field name="CUSTOM2" />
<field name="CUSTOM3" />
<field name="CUSTOM4" />
<field name="CUSTOM5" />
<field name="CUSTOM6" />
<field name="CUSTOM7" />
<field name="CUSTOM8" />
<field name="PAGE" />
<field name="HELP" />
<field name="DEFSTATE" />
<field name="SCHEDULED" />
<field name="COMPOSITE" />
<field name="TYPE" />
<array name="param_list">{ToProperty('{param}','=',';')}</array>
<array name="Addr">{ToProperty('{equipment.param_list[Addr]}',':',',')}</array>
<string name="MyAddrString">250</string>
<calculator name="myaddrcalc">{MyAddrString}+5</calculator>
</input>
<output name="Element" file="variable.dbf" filter="'{equipment.type}={type.name}'">
<field name="NAME" key="true">{equipment.TAGPREFIX}_Tag1</field>
<field name="TYPE">INT</field>
<field name="UNIT">{equipment.IODEVICE}</field>
<field name="ADDR">{myaddrcalc}</field>
<field name="ENG_ZERO">0</field>
<field name="ENG_FULL">1000</field>
<field name="CLUSTER" key="true">{equipment.CLUSTER}</field>
<field name="EQUIP">{equipment.name}</field>
<field name="ITEM">Tag1</field>
<field name="TAGGENLINK" load="true">TypeWithCalc_0006</field>
<field name="LINKED">1</field>
<field name="EDITCODE">3938511</field>
</output>
</template>
<?xml version="1.0" encoding="utf-8"?>
<template desc="">
<param name="type">
<string name="name">TypeWithCalc</string>
<string name="ref">TypeWithCalc</string>
<string name="blank"></string>
<string name="wildcard"></string>
<string name="parameter-definitions">param_list.param1=;Addr.BaseAddr=</string>
</param>
<input name="equipment" file="equip.dbf" desc="Equipment Database">
<field name="PARAM" />
<field name="TAGPREFIX" />
<field name="IODEVICE" />
<field name="CLUSTER" />
<field name="NAME" />
<field name="AREA" />
<field name="LOCATION" />
<field name="COMMENT" />
<field name="CUSTOM1" />
<field name="CUSTOM2" />
<field name="CUSTOM3" />
<field name="CUSTOM4" />
<field name="CUSTOM5" />
<field name="CUSTOM6" />
<field name="CUSTOM7" />
<field name="CUSTOM8" />
<field name="PAGE" />
<field name="HELP" />
<field name="DEFSTATE" />
<field name="SCHEDULED" />
<field name="COMPOSITE" />
<field name="TYPE" />
<array name="param_list">{ToProperty('{param}','=',';')}</array>
<array name="Addr">{ToProperty('{equipment.param_list[Addr]}',':',',')}</array>
<string name="MyAddrString">250</string>
<calculator name="myaddrcalc">{equipment.CUSTOM1}+5</calculator>
</input>
<output name="Element" file="variable.dbf" filter="'{equipment.type}={type.name}'">
<field name="NAME" key="true">{equipment.TAGPREFIX}_Tag1</field>
<field name="TYPE">INT</field>
<field name="UNIT">{equipment.IODEVICE}</field>
<field name="ADDR">{myaddrcalc}</field>
<field name="ENG_ZERO">0</field>
<field name="ENG_FULL">1000</field>
<field name="CLUSTER" key="true">{equipment.CLUSTER}</field>
<field name="EQUIP">{equipment.name}</field>
<field name="ITEM">Tag1</field>
<field name="TAGGENLINK" load="true">TypeWithCalc_0006</field>
<field name="LINKED">1</field>
<field name="EDITCODE">3938511</field>
</output>
</template>
<?xml version="1.0" encoding="utf-8"?>
<template desc="">
<param name="type">
<string name="name">TypeWithCalc</string>
<string name="ref">TypeWithCalc</string>
<string name="blank"></string>
<string name="wildcard"></string>
<string name="parameter-definitions">param_list.param1=;Addr.BaseAddr=</string>
</param>
<input name="equipment" file="equip.dbf" desc="Equipment Database">
<field name="PARAM" />
<field name="TAGPREFIX" />
<field name="IODEVICE" />
<field name="CLUSTER" />
<field name="NAME" />
<field name="AREA" />
<field name="LOCATION" />
<field name="COMMENT" />
<field name="CUSTOM1" />
<field name="CUSTOM2" />
<field name="CUSTOM3" />
<field name="CUSTOM4" />
<field name="CUSTOM5" />
<field name="CUSTOM6" />
<field name="CUSTOM7" />
<field name="CUSTOM8" />
<field name="PAGE" />
<field name="HELP" />
<field name="DEFSTATE" />
<field name="SCHEDULED" />
<field name="COMPOSITE" />
<field name="TYPE" />
<array name="param_list">{ToProperty('{param}','=',';')}</array>
<array name="Addr">{ToProperty('{equipment.param_list[Addr]}',':',',')}</array>
<calculator name="myaddrcalc">{equipment.param_list[param1]}+5</calculator>
<calculator name="myaddrcalc2">{equipment.Addr[BaseAddr]}+10</calculator>
</input>
<output name="Element" file="variable.dbf" filter="'{equipment.type}={type.name}'">
<field name="NAME" key="true">{equipment.TAGPREFIX}_Tag1</field>
<field name="TYPE">INT</field>
<field name="UNIT">{equipment.IODEVICE}</field>
<field name="ADDR">MW{myaddrcalc}_2</field>
<field name="ENG_ZERO">0</field>
<field name="ENG_FULL">1000</field>
<field name="CLUSTER" key="true">{equipment.CLUSTER}</field>
<field name="EQUIP">{equipment.name}</field>
<field name="ITEM">Tag1</field>
<field name="TAGGENLINK" load="true">TypeWithCalc_0006</field>
<field name="LINKED">1</field>
<field name="EDITCODE">3938511</field>
</output>
</template>
<?xml version="1.0" encoding="utf-8"?>
<template desc="">
<param name="type">
<string name="name">TypeWithCalculator</string>
<string name="ref">TypeWithCalculator</string>
<string name="blank"></string>
<string name="wildcard"></string>
<string name="parameter-definitions">TagAddressing.PLC.DBNumber=;TagAddressing.StructOffset=</string>
</param>
<input name="equipment" file="equip.dbf" desc="Equipment Database">
<field name="PARAM" />
<field name="TAGPREFIX" />
<field name="NAME" />
<field name="IODEVICE" />
<field name="CLUSTER" />
<field name="AREA" />
<field name="LOCATION" />
<field name="COMMENT" />
<field name="CUSTOM1" />
<field name="CUSTOM2" />
<field name="CUSTOM3" />
<field name="CUSTOM4" />
<field name="CUSTOM5" />
<field name="CUSTOM6" />
<field name="CUSTOM7" />
<field name="CUSTOM8" />
<field name="PAGE" />
<field name="HELP" />
<field name="DEFSTATE" />
<field name="SCHEDULED" />
<field name="COMPOSITE" />
<field name="TYPE" />
<array name="param_list">{ToProperty('{param}','=',';')}</array>
<array name="TagAddressing">{ToProperty('{equipment.param_list[TagAddressing]}',':',',')}</array>
</input>
<output name="Element" file="variable.dbf" filter="'{equipment.type}={type.name}'">
<calculator name="TagAddress">{equipment.TagAddressing[StructOffset]} + 0</calculator>
<field name="NAME" key="true">{equipment.tagprefix}_Enable</field>
<field name="EQUIP">{equipment.name}</field>
<field name="UNIT">{equipment.iodevice}</field>
<field name="CLUSTER" key="true">{equipment.cluster}</field>
<field name="TYPE">DIGITAL</field>
<field name="COMMENT">Machine Enable</field>
<field name="ADDR">DB{equipment.TagAddressing[PLC.DBNumber]},{TagAddress}.0</field>
<field name="ITEM">Enable</field>
<field name="TAGGENLINK" load="true">12345</field>
<field name="LINKED">1</field>
<field name="EDITCODE">3939343</field>
</output>
</template>
See Also
Published June 2018