Sample mpr scripts – Rockwell Automation 9307 FactoryTalk EnergyMetrix User Manual
Page 280

FactoryTalk EnergyMetrix Software
280
Sample MPR Scripts
The following sections describe sample MPR scripts.
Consumption and Cost Per Meter Grid
The report generated by this sample MPR script uses a Grid object to list real energy
consumption and cost by meter. Each meter shows up on the report as a row of data within
the grid. Meters must be selected ‘By Meter’ in the report setup selection tree. The grid
will be sorted by cost, descending. Costs are calculated by using the Cost Allocate method
of the Meter object. Rate schedules must be set up to support cost allocation. See
MPR for Cost Allocation on page 228
.
Sub Main()
Dim actualConsumption As Double
Dim actualCost As Double
Dim meter As Meter
Dim grid As New Grid
Dim col As Col
Dim row As Row
col = grid.AddCol("Meter") : col.Width = 1.75
col = grid.AddCol("Actual Consumption") : col.Width = 1 : _
col.Alignment = TextAlignment.Right : col.OutputFormat = "##.##0"
col = grid.AddCol() : col.Width = 0.5 'this column is for the
units label
col = grid.AddCol("Actual Cost") : col.Width = 0.9 :
col.Alignment = _
TextAlignment.Right : col.OutputFormat = "$##.##0"
For Each meter In Report.Meters
actualConsumption = meter.Total(ValueType.RealEnergyNet)
actualCost = meter.CostAllocate("Electric Billing Report",
"Electric Cost Allocation")
row = grid.AddRow()
row(0) = meter.Name
row(1) = actualConsumption
row(2) = "kWh"
row(3) = actualCost
Next meter
grid.HeaderHeight = 0.5
grid.Sort(3, SortOrder.Descending) 'sorts the grid by cost
(column 3), descending
report.Add(grid, 0.2, CursorPos)
End Sub
Consumption by Group Trend Chart
The report generated by this script contains a trend chart that plots real energy
consumption by group per interval. The report will handle any number of groups, plotting
a separate line on the chart for each one.