InTouch Statistical Script Functions

Posted on 206 views

The InTouch Statistical script functions allow you to track a variety of
statistical values for up to 512 InTouch tagnames. The tagname could be a Real,
Integer, or even a Discrete tag. The statistics which can be tracked are the
average, maximum, minimum, and standard deviation.
Additional script functions are provided to trigger sampling and to reset the
statistics. Sampling and resetting can be performed on individual tagnames or on
all tagnames that are being monitored.

Note The InTouch Statistical script functions are
compatible with InTouch 5.1 and later for Windows NT only.

Here is the list of script functions provided:

  • StatReset()
  • StatResetAll()
  • StatSample()
  • StatSampleAll()
  • StatGetAverage()
  • StatGetMax()
  • StatGetMin()
  • StatGetStdDev()
  • StatGetSampleCount()
  • StatGetSumXSquared()

Installing the InTouch Statistical Script Functions

Download
the Stat32.zip file
from the Wonderware Knowledge Base.

Complete documentation on the use of these script functions is provided in an
online help file, Statfunc.hlp, which comes with the script function
files.

Create a Stattags.csv File First

Before using the InTouch Statistical script functions, you must create a
Stattags.csv file in the InTouch application directory. The easiest way
to create this file is to use the wizard that is provided in the InTouch
Statistical script functions’ Statfunc.dll file. To install the wizard,
select Special/Install Wizards from the WindowMaker Configuration
dialog box.

For more information on configuring the Stattags.csv file, see the online
help file, Statfunc.hlp.
Usage : StatReset(TagName);
Example :StatReset(TIC101PV.Name);
This function will reset the statistics for the specified tag name.  The tag name can be passed as a string value, as a message tag, or as the .name field of a specific tag (recommended).

Usage : StatResetAll();
Example :StatResetAll();
This function will reset the statistics for all tags being monitored.

Usage : StatSample(TagName);
Example :StatSample(TIC101PV.Name);
This function will take a sample for the specified tag name by reading its current value from the InTouch real-time database.  The tag name can be passed as a string value, as a message tag, or as the .name field of a specific tag (recommended).

Usage : StatSampleAll();
Example :StatSampleAll();
This function will take a sample for each of the tags currently being monitored by reading the current values from the InTouch real-time database.

Usage : TagAverageValue = StatGetAverage(TagName, TriggerTag);
Example :TagAverageValue = StatGetAverage(TIC101PV.Name, DummyTag);
If using this function as an expression for a real-time trend link or an analog output link, the value will only be updated when the trigger tags value changes.  Two approaches are to either use an integer variable of your choosing that is periodically changed at some time interval, or to keep track of the current sample count (for one or all of the tags being monitored) in an integer tag each time you take a sample for one or all tags and use this tag as the trigger (recommended).
This function will then return the accumulated average value of the tag as a floating point value (real-type tag value).  Note that if no samples have been taken, this function will return zero (0.0).

Usage : TagMaxValue = StatGetMax(TagName, TriggerTag);
Example :TagMaxValue = StatGetMax(TIC101PV.Name, DummyTag);
If using this function as an expression for a real-time trend link or an analog output link, the value will only be updated when the trigger tags value changes.  Two approaches are to either use an integer variable of your choosing that is periodically changed at some time interval, or to keep track of the current sample count (for one or all of the tags being monitored) in an integer tag each time you take a sample for one or all tags and use this tag as the trigger (recommended).
This function will then return the maximum value of the tag since the last reset as a floating point value (real-type tag value).  Note that if no samples have been taken, this function will return zero (0.0).

Usage : TagMinValue = StatGetMin(TagName, TriggerTag);
Example :TagMinValue = StatGetMin(TIC101PV.Name, DummyTag);
If using this function as an expression for a real-time trend link or an analog output link, the value will only be updated when the trigger tags value changes.  Two approaches are to either use an integer variable of your choosing that is periodically changed at some time interval, or to keep track of the current sample count (for one or all of the tags being monitored) in an integer tag each time you take a sample for one or all tags and use this tag as the trigger (recommended).
This function will then return the minimum value of the tag since the last reset as a floating point value (real-type tag value).  Note that if no samples have been taken, this function will return zero (0.0).

Usage : TagStdDevValue = StatGetStdDev(TagName, TriggerTag);
Example :TagStdDevValue = StatGetStdDev(TIC101PV.Name, DummyTag);
If using this function as an expression for a real-time trend link or an analog output link, the value will only be updated when the trigger tags value changes.  Two approaches are to either use an integer variable of your choosing that is periodically changed at some time interval, or to keep track of the current sample count (for one or all of the tags being monitored) in an integer tag each time you take a sample for one or all tags and use this tag as the trigger (recommended).
This function will then return the accumulated standard deviation value of the tag as a floating point value (real-type tag value).  Note that if no samples have been taken, this function will return zero (0.0).

Usage : CurrentSampleCount = StatGetSampleCount(TagName, TriggerTag);
Example :CurrentSampleCount = StatGetSampleCount(TIC101PV.Name, DummyTag);
If using this function as an expression for a real-time trend link or an analog output link, the value will only be updated when the trigger tags value changes.  Two approaches are to either use an integer variable of your choosing that is periodically changed at some time interval, or to keep track of the current sample count (for one or all of the tags being monitored) in an integer tag each time you take a sample for one or all tags and use this tag as the trigger (recommended).
This function will then return the accumulated average value of the tag as an integer value.  Note that if no samples have been taken, this function will return zero (0).

Usage : TagSumXSquared = StatGetSumXSquared(TagName, TriggerTag);
Example :TagSumXSquared = StatGetStdDev(TIC101PV.Name, DummyTag);
If using this function as an expression for a real-time trend link or an analog output link, the value will only be updated when the trigger tags value changes.  Two approaches are to either use an integer variable of your choosing that is periodically changed at some time interval, or to keep track of the current sample count (for one or all of the tags being monitored) in an integer tag each time you take a sample for one or all tags and use this tag as the trigger (recommended).
This function will then return the accumulated sum of the squared sample value (SUM(X2)) of the tag as a floating point value (real-type tag value).  Note that if no samples have been taken, this function will return zero (0.0).

Leave a Reply

Your email address will not be published. Required fields are marked *

65 − 55 =