Lesson 2 exercises
- Last UpdatedMay 16, 2023
- 2 minute read
- PI System
- AF SDK 2.10
- PI Server
For each of the following exercises, your task is to add logic to each method. Add the methods to your console application and test each one by writing output to the console.
-
Exercise 1
Find all meters that were created from the provided element template and derived templates. Print the names of each found meter in a list and their element template names. Count the number of derived templates that were found.
void FindMetersByTemplate( AFDatabase database, string templateName)
When the method is run, it should product the following output:
Find Meters by Name: Meter00*
Element: Meter001, Template: MeterBasic, Categories: Measures Energy;
Element: Meter002, Template: MeterBasic, Categories: Measures Energy;
Element: Meter003, Template: MeterBasic, Categories: Measures Energy;
Element: Meter004, Template: MeterBasic, Categories: Measures Energy;
Element: Meter005, Template: MeterBasic, Categories: Measures Energy;
Element: Meter006, Template: MeterBasic, Categories: Measures Energy;
Element: Meter007, Template: MeterBasic, Categories: Measures Energy;
Element: Meter008, Template: MeterBasic, Categories: Measures Energy;
Element: Meter009, Template: MeterAdvanced, Categories: Measures Energy;Shows Status; -
Exercise 2
Find all meters supplied by the provided substation. Print the names of each of the meters that were found.
void FindMetersBySubstation( AFDatabase database, string substationLocation)
When the method is run, it should product the following output:
Find Meters by Template: MeterBasic
Element: Meter001, Template: MeterBasic
Element: Meter002, Template: MeterBasic
Element: Meter003, Template: MeterBasic
Element: Meter004, Template: MeterBasic
Element: Meter005, Template: MeterBasic
Element: Meter006, Template: MeterBasic
Element: Meter007, Template: MeterBasic
Element: Meter008, Template: MeterBasic
Element: Meter009, Template: MeterAdvanced
Element: Meter010, Template: MeterAdvanced
Element: Meter011, Template: MeterAdvanced
Element: Meter012, Template: MeterAdvanced
Found 4 derived templates -
Exercise 3
Find all meters with energy usage greater than the supplied limit. Print the names of each meter that was found.
void FindMetersAboveUsage( AFDatabase database, double limit)
When the method is run, it should product the following output:
Find Meters above Usage: 300
Meter003, Meter005, Meter006, Meter008, Meter009, Meter012 -
Exercise 4
Find all attributes belonging to the Building Info attribute category that are part of the provided element template. Print the number of attributes found.
void FindBuildingInfo( AFDatabase database, string templateName)
When the method is run, it should product the following output:
Find Building Info: MeterAdvanced
Found 8 attributes.