Lesson 1 exercises
- Last UpdatedMay 16, 2023
- 2 minute read
- PI System
- AF SDK 2.10
- PI Server
For each of the following exercises, add logic to each method to accomplish the given task. Add the methods to your console application and test each one by writing to the console.
-
Exercise 1
Create a method with the definition and arguments shown below. Incorporate the method into your console application and print the name of each AFElementTemplate. For each element template, also print the name of each AFCategory in its Categories collection.
void PrintElementTemplates( AFDatabase database )
When the method is run, it should produce the following output:
Print Element Templates
Name: City; Categories:
Name: MeterAdvanced; Categories: Shows Status;
Name: MeterBasic; Categories: Measures Energy; -
Exercise 2
Create a method with the definition and arguments shown below. Incorporate the method into your console application and print the name of each AFAttributeTemplate for the passed-in element template. For each attribute template, also print the name of its data reference plug-in.
void PrintAttributeTemplates(AFDatabase database, string elemTempName)
When the method is run, it should produce the following output:
Print Attribute Templates for Element Template: MeterAdvanced
Name: Status, DRPlugin: PI Point -
Exercise 3
Create a method with the definition and arguments shown below. Incorporate the method into your console application and print the name of each unit of measure (UOM) and its abbreviation under the UOMClass Energy.
void PrintEnergyUOMs( PISystem system )
When the method is run, it should produce the following output:
Print Energy UOMs
UOM: gigawatt hour, Abbreviation: GWh
UOM: megawatt hour, Abbreviation: MWh
UOM: watt hour, Abbreviation: Wh
UOM: joule, Abbreviation: J
UOM: British thermal unit, Abbreviation: Btu
UOM: calorie, Abbreviation: cal
UOM: gigajoule, Abbreviation: GJ
UOM: kilojoule, Abbreviation: kJ
UOM: kilowatt hour, Abbreviation: kWh
UOM: megajoule, Abbreviation: MJ
UOM: watt second, Abbreviation: Ws
UOM: kilocalorie, Abbreviation: kcal
UOM: million calorie, Abbreviation: MMcal
UOM: million British thermal unit, Abbreviation: MM Btu -
Exercise 4
Create a method with the definition and arguments shown below. Incorporate the method into your console application and print the name of each AFEnumerationSet object. For each set, print its list of states.
void PrintEnumerationSets( AFDatabase database )
When the method is run, it should produce the following output:
Print Enumeration Sets
Building Type
0 - A
1 - B
Meter Status
0 - Good
1 - Bad -
Exercise 5
Create a method with the definition and arguments shown below. Incorporate the method into your console application and print the name of each element category and attribute category.
void PrintCategories( AFDatabase database )
When the method is run, it should produce the following output:
Print Categories
Element Categories
Measures Energy
Shows Status
Attribute Categories
Building Info
Location
Time-Series Data