Rockwell Automation 9307 FactoryTalk EnergyMetrix User Manual

Page 95

Advertising
background image

4

Set up Your System Architecture

95

GetTagData Function

Returns the value of the most recent logged value of the selected MeterTagId, looking
back from the current time (or the optional utcTimeStamp argument if specified) for a
duration of one logging interval. The result is an Object variable which contains the tag
value or Nothing if no tag value can be found. If data is found, the expression

‘Not GetTagData(argument) Is Nothing’

evaluates as True.

Result = GetTagData(MeterTagId[, utcTimeStamp])

Enumeration Values - DateRange

The DateRange argument specifies how far back in time that logged data is evaluated in
the function. The DateRange is referenced to the current timestamp of the Derived Tag
(recall that Derived Tags are executed 5 minutes after the nominal log rate time). For
instance, DateRange.DayToDate used in a Derived Tag script that executes at 12:05 pm on
a particular day specifies a time period beginning at noon the day before.

MinuteToDate

HourToDate

DayToDate

WeekToDate

MonthToDate

Variables

Two predefined variables are available in Derived tags for use in Derived tag scripting.

TagGenerationTimestamp

TagGenerationTimestampUTC

These variables are of DateTime type and hold the time stamp that a derived tag script
executes for. TagGenerationTimestamp is the time stamp for the meter's time zone and the
TagGenerationTimestampUTC is the time stamp in the UTC time zone.

Example

These variables will allow derived tag scripts the ability to control when they insert a
record into the database. For example, you can create a ‘once-per-month’ derived tag that
only inserts a record into the database on the first of each month by creating a derived tag
with a daily log rate and then testing the time stamp in the derived tag script as follows:

If TagGenerationTimestamp.Day == 1 Then

Result = <perform your calculation here>

End If

If a derived tag script does not set the Result variable then no
value will be inserted into the database.

Advertising