Referencing tags

Top  Previous  Next

If all you want to do is display the value of a tag, you can simply click on the down arrow to the right of the expression box and select the data source and the corresponding tag and it will be placed in the expression box for you.  If you need to do extra math, or are using script, you'll need to enter the tag names yourself.  Tags are always specified in the following format:

dataSourceName.tagName()

 

where dataSourceName is the name of the data source the tag is on, and tagName is the name of the tag.  So, for example:

remote.alsingDemand()

 

Using this format returns the most recent reading for the given tag, unless you are specifying a trace in a trend graph, in which case you get all the historical values that are within the X axis range in an array.

Sometimes, however, you want the last 5 readings, perhaps to take the average of those readings.  In this case, simply list the indexes of the desired range in parenthesis after the tag name:

remote.alsingDemand(0,4)

 

0 is always the most recent data point, so 0,4 returns the last 5 readings.  You can also select by time, so to get the data from the last hour you can put:

remote.alsingDemand(dataTime.systemTime(), dateTime.systemTime() - 3600000)

 

dateTime.systemTime() is a function that returns the current system time in Javascript format, which is milliseconds since 1970.  The only problem with dateTime.systemTime() is that it returns the time of the local browser, which may not be in sync with the data stream.  Instead you probably want to reference the time of the data point.  To do this, add .time after the tag name.  So, the time of the most recent data point is, for example:

remote.alsingDemand.time()

 

or the last 5 data points:

remote.alsingDemand.time(0,4)