38
edits
m (→Data Transformations: example added) |
|||
Line 143: | Line 143: | ||
On the second step, custom transformation script is executed (if presented). By default, newly created DCI does not have a transformation script. If transformation script is presented, the resulting value of the first step is passed to the transformation script as a parameter; and a result of script execution is a final DCI value. Transformation script gets original value as first argument (available via special variable '''$1'''), and also has two predefined global variables: '''$node''' (reference to current node object), and '''$dci''' (reference to current DCI object). For more information about NetXMS scripting language, please consult [[UM:NetXMS_Scripting_Language_(NXSL)|NetXMS Scripting Language]] chapter in this manual. | On the second step, custom transformation script is executed (if presented). By default, newly created DCI does not have a transformation script. If transformation script is presented, the resulting value of the first step is passed to the transformation script as a parameter; and a result of script execution is a final DCI value. Transformation script gets original value as first argument (available via special variable '''$1'''), and also has two predefined global variables: '''$node''' (reference to current node object), and '''$dci''' (reference to current DCI object). For more information about NetXMS scripting language, please consult [[UM:NetXMS_Scripting_Language_(NXSL)|NetXMS Scripting Language]] chapter in this manual. | ||
Simple example: | |||
<pre> | <pre> | ||
$1 * 8 / 1000 | $1 * 8 / 1000 | ||
</pre> | |||
Table data transformations example: | |||
<pre> | |||
idxVoltage = $1->getColumnIndex("VOLTAGE"); | |||
idxStatus = $1->getColumnIndex("STATUS"); | |||
for(i = 0; i < $1->rowCount; i++) | |||
{ | |||
$1->set(i, idxVoltage, $1->get(i, idxVoltage) / 1000); | |||
if ($1->get(i, idxStatus) == 3) | |||
{ | |||
$1->set(i, idxStatus, "OK"); | |||
} | |||
} | |||
</pre> | </pre> | ||
edits