DataHub scripting lets you modify data as it passes through the DataHub. This example script makes a linear transformation, writes the results to a different DataHub point, and incidentally prints the value of point and the conversion.
method ModifyData.convert (pt1, !pt2, multiplier, adder)
{
local output;
set(pt2, ((pt1 * multiplier) + adder));
princ(format("The sine is: %2.3f Converted it is: %2.3f\n",
pt1, eval(pt2)));
}
method ModifyData.constructor ()
{
multiplier = 3;
adder = 5;
if (undefined_p($default:ConvertedSine))
datahub_command ("(cset default:ConvertedSine \"\")", 1);
.OnChange(#$DataSim:DataSim.Sine,
`(@self).convert($DataSim:DataSim.Sine,
$default:ConvertedSine, multiplier, adder));
after(3, `destroy(@self));
}Copyright © 1995-2006 by Cogent Real-Time Systems, Inc. All rights reserved.