Getunit function – Rockwell Automation 9307 FactoryTalk EnergyMetrix User Manual

Page 124

Advertising
background image

FactoryTalk EnergyMetrix Software

124

Comments

The value selected is the last value logged within one logging interval before the Report
Start Date or the specified Time Stamp. It returns an Object value.

The time stamp may be expressed in a few different formats, for example ‘1/30/2003
12:30 PM’ or ‘2/28/1999’.

The most reliable method is to use the .NET DateTime object:

new DateTime(year, month, day, hour, minute, second)

Example

The following example returns the Real Energy Net value logged from the selected meters

Quantity = GetData(ValueType.RealEnergyNet, new DateTime(2003,
5, 9, 15, 0, 0))

The GetData function will return either Nothing or a Double value. If the above sample
code returns Nothing (a null object), the quantity will appear as 0. If you intend to use the
value from the GetData function for further calculations, you can use this code to check
the return value:

Dim result

result = GetData(ValueType.RealEnergyNet, new DateTime(2003, 7,
9, 15, 0, 0))

If result = Nothing Then

Quantity = 0

Else

Quantity = result * 10

End If

GetUnit Function

The GetUnit function returns the units associated with the selected value from the
database. It returns a String value.

Usage

Unit = GetUnit(ValueType.enumValue)

Comments

Normally used with the predefined variable Unit to display the correct units in the report.
The GetUnit function is used when the ValueType is assigned by the script. If the units do
not change, it is more efficient to assign a string value in the script. Example:

Unit = "kWh"

Example

This example line item script shows a simple energy charge by using the GetUnit function
and the report output.

Quantity = Total(ValueType.RealEnergyNet)

Unit = GetUnit(ValueType.RealEnergyNet)

Charge = Quantity*RatePerUnit

Advertising