├── .editorconfig
├── .gitattributes
├── .gitignore
├── AF Database - Green Power Company.xml
├── CODEOWNERS
├── Directory.Build.props
├── Ex1-Connection-And-Hierarchy-Basics-Sln
├── App.config
├── AppSettings.cs
├── Ex1-Connection-And-Hierarchy-Basics-Sln.GeneratedMSBuildEditorConfig.editorconfig
├── Ex1-Connection-And-Hierarchy-Basics-Sln.csproj
├── Program1.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Ex1-Connection-And-Hierarchy-Basics
├── App.config
├── AppSettings.cs
├── Ex1-Connection-And-Hierarchy-Basics.GeneratedMSBuildEditorConfig.editorconfig
├── Ex1-Connection-And-Hierarchy-Basics.csproj
├── Program1.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Ex2-Searching-For-Assets-Sln
├── App.config
├── AppSettings.cs
├── Ex2-Searching-For-Assets-Sln.GeneratedMSBuildEditorConfig.editorconfig
├── Ex2-Searching-For-Assets-Sln.csproj
├── Program2.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Ex2-Searching-For-Assets
├── App.config
├── AppSettings.cs
├── Ex2-Searching-For-Assets.GeneratedMSBuildEditorConfig.editorconfig
├── Ex2-Searching-For-Assets.csproj
├── Program2.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Ex3-Reading-And-Writing-Data-Sln
├── App.config
├── AppSettings.cs
├── Ex3-Reading-And-Writing-Data-Sln.GeneratedMSBuildEditorConfig.editorconfig
├── Ex3-Reading-And-Writing-Data-Sln.csproj
├── Program3.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Ex3-Reading-And-Writing-Data
├── App.config
├── AppSettings.cs
├── Ex3-Reading-And-Writing-Data.GeneratedMSBuildEditorConfig.editorconfig
├── Ex3-Reading-And-Writing-Data.csproj
├── Program3.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Ex4-Building-An-AF-Hierarchy-Sln
├── App.config
├── AppSettings.cs
├── Bonus.cs
├── Ex4-Building-An-AF-Hierarchy-Sln.GeneratedMSBuildEditorConfig.editorconfig
├── Ex4-Building-An-AF-Hierarchy-Sln.csproj
├── Program4.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Ex4-Building-An-AF-Hierarchy
├── App.config
├── AppSettings.cs
├── Bonus.cs
├── Ex4-Building-An-AF-Hierarchy.GeneratedMSBuildEditorConfig.editorconfig
├── Ex4-Building-An-AF-Hierarchy.csproj
├── Program4.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Ex5-Working-With-Event-Frames-Sln
├── App.config
├── AppSettings.cs
├── Ex5-Working-With-Event-Frames-Sln.GeneratedMSBuildEditorConfig.editorconfig
├── Ex5-Working-With-Event-Frames-Sln.csproj
├── Program5.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Ex5-Working-With-EventFrames
├── App.config
├── AppSettings.cs
├── Ex5-Working-With-Event-Frames.GeneratedMSBuildEditorConfig.editorconfig
├── Ex5-Working-With-Event-Frames.csproj
├── Program5.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Getting-Started-With-PI-AF-SDK.sln
├── HISTORY.md
├── LICENSE
├── README.md
├── Tests
├── AppSettings.cs
├── Properties
│ └── AssemblyInfo.cs
├── Tests.GeneratedMSBuildEditorConfig.editorconfig
├── Tests.cs
├── Tests.csproj
├── app.config
└── packages.config
├── appsettings.placeholder.json
├── azure-pipelines.yml
├── polaris.yml
└── stylecop.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*]
2 | quote_type = single
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Coverlet is a free, cross platform Code Coverage Tool
141 | coverage*[.json, .xml, .info]
142 |
143 | # Visual Studio code coverage results
144 | *.coverage
145 | *.coveragexml
146 |
147 | # NCrunch
148 | _NCrunch_*
149 | .*crunch*.local.xml
150 | nCrunchTemp_*
151 |
152 | # MightyMoose
153 | *.mm.*
154 | AutoTest.Net/
155 |
156 | # Web workbench (sass)
157 | .sass-cache/
158 |
159 | # Installshield output folder
160 | [Ee]xpress/
161 |
162 | # DocProject is a documentation generator add-in
163 | DocProject/buildhelp/
164 | DocProject/Help/*.HxT
165 | DocProject/Help/*.HxC
166 | DocProject/Help/*.hhc
167 | DocProject/Help/*.hhk
168 | DocProject/Help/*.hhp
169 | DocProject/Help/Html2
170 | DocProject/Help/html
171 |
172 | # Click-Once directory
173 | publish/
174 |
175 | # Publish Web Output
176 | *.[Pp]ublish.xml
177 | *.azurePubxml
178 | # Note: Comment the next line if you want to checkin your web deploy settings,
179 | # but database connection strings (with potential passwords) will be unencrypted
180 | *.pubxml
181 | *.publishproj
182 |
183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
184 | # checkin your Azure Web App publish settings, but sensitive information contained
185 | # in these scripts will be unencrypted
186 | PublishScripts/
187 |
188 | # NuGet Packages
189 | *.nupkg
190 | # NuGet Symbol Packages
191 | *.snupkg
192 | # The packages folder can be ignored because of Package Restore
193 | **/[Pp]ackages/*
194 | # except build/, which is used as an MSBuild target.
195 | !**/[Pp]ackages/build/
196 | # Uncomment if necessary however generally it will be regenerated when needed
197 | #!**/[Pp]ackages/repositories.config
198 | # NuGet v3's project.json files produces more ignorable files
199 | *.nuget.props
200 | *.nuget.targets
201 |
202 | # Microsoft Azure Build Output
203 | csx/
204 | *.build.csdef
205 |
206 | # Microsoft Azure Emulator
207 | ecf/
208 | rcf/
209 |
210 | # Windows Store app package directories and files
211 | AppPackages/
212 | BundleArtifacts/
213 | Package.StoreAssociation.xml
214 | _pkginfo.txt
215 | *.appx
216 | *.appxbundle
217 | *.appxupload
218 |
219 | # Visual Studio cache files
220 | # files ending in .cache can be ignored
221 | *.[Cc]ache
222 | # but keep track of directories ending in .cache
223 | !?*.[Cc]ache/
224 |
225 | # Others
226 | ClientBin/
227 | ~$*
228 | *~
229 | *.dbmdl
230 | *.dbproj.schemaview
231 | *.jfm
232 | *.pfx
233 | *.publishsettings
234 | orleans.codegen.cs
235 |
236 | # Including strong name files can present a security risk
237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
238 | #*.snk
239 |
240 | # Since there are multiple workflows, uncomment next line to ignore bower_components
241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
242 | #bower_components/
243 |
244 | # RIA/Silverlight projects
245 | Generated_Code/
246 |
247 | # Backup & report files from converting an old project file
248 | # to a newer Visual Studio version. Backup files are not needed,
249 | # because we have git ;-)
250 | _UpgradeReport_Files/
251 | Backup*/
252 | UpgradeLog*.XML
253 | UpgradeLog*.htm
254 | ServiceFabricBackup/
255 | *.rptproj.bak
256 |
257 | # SQL Server files
258 | *.mdf
259 | *.ldf
260 | *.ndf
261 |
262 | # Business Intelligence projects
263 | *.rdl.data
264 | *.bim.layout
265 | *.bim_*.settings
266 | *.rptproj.rsuser
267 | *- [Bb]ackup.rdl
268 | *- [Bb]ackup ([0-9]).rdl
269 | *- [Bb]ackup ([0-9][0-9]).rdl
270 |
271 | # Microsoft Fakes
272 | FakesAssemblies/
273 |
274 | # GhostDoc plugin setting file
275 | *.GhostDoc.xml
276 |
277 | # Node.js Tools for Visual Studio
278 | .ntvs_analysis.dat
279 | node_modules/
280 |
281 | # Visual Studio 6 build log
282 | *.plg
283 |
284 | # Visual Studio 6 workspace options file
285 | *.opt
286 |
287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
288 | *.vbw
289 |
290 | # Visual Studio LightSwitch build output
291 | **/*.HTMLClient/GeneratedArtifacts
292 | **/*.DesktopClient/GeneratedArtifacts
293 | **/*.DesktopClient/ModelManifest.xml
294 | **/*.Server/GeneratedArtifacts
295 | **/*.Server/ModelManifest.xml
296 | _Pvt_Extensions
297 |
298 | # Paket dependency manager
299 | .paket/paket.exe
300 | paket-files/
301 |
302 | # FAKE - F# Make
303 | .fake/
304 |
305 | # CodeRush personal settings
306 | .cr/personal
307 |
308 | # Python Tools for Visual Studio (PTVS)
309 | __pycache__/
310 | *.pyc
311 |
312 | # Cake - Uncomment if you are using it
313 | # tools/**
314 | # !tools/packages.config
315 |
316 | # Tabs Studio
317 | *.tss
318 |
319 | # Telerik's JustMock configuration file
320 | *.jmconfig
321 |
322 | # BizTalk build output
323 | *.btp.cs
324 | *.btm.cs
325 | *.odx.cs
326 | *.xsd.cs
327 |
328 | # OpenCover UI analysis results
329 | OpenCover/
330 |
331 | # Azure Stream Analytics local run output
332 | ASALocalRun/
333 |
334 | # MSBuild Binary and Structured Log
335 | *.binlog
336 |
337 | # NVidia Nsight GPU debugger configuration file
338 | *.nvuser
339 |
340 | # MFractors (Xamarin productivity tool) working folder
341 | .mfractor/
342 |
343 | # Local History for Visual Studio
344 | .localhistory/
345 |
346 | # BeatPulse healthcheck temp database
347 | healthchecksdb
348 |
349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
350 | MigrationBackup/
351 |
352 | # Ionide (cross platform F# VS Code tools) working folder
353 | .ionide/
354 |
355 | ##
356 | ## Visual studio for Mac
357 | ##
358 |
359 |
360 | # globs
361 | Makefile.in
362 | *.userprefs
363 | *.usertasks
364 | config.make
365 | config.status
366 | aclocal.m4
367 | install-sh
368 | autom4te.cache/
369 | *.tar.gz
370 | tarballs/
371 | test-results/
372 |
373 | # Mac bundle stuff
374 | *.dmg
375 | *.app
376 |
377 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
378 | # General
379 | .DS_Store
380 | .AppleDouble
381 | .LSOverride
382 |
383 | # Icon must end with two \r
384 | Icon
385 |
386 |
387 | # Thumbnails
388 | ._*
389 |
390 | # Files that might appear in the root of a volume
391 | .DocumentRevisions-V100
392 | .fseventsd
393 | .Spotlight-V100
394 | .TemporaryItems
395 | .Trashes
396 | .VolumeIcon.icns
397 | .com.apple.timemachine.donotpresent
398 |
399 | # Directories potentially created on remote AFP share
400 | .AppleDB
401 | .AppleDesktop
402 | Network Trash Folder
403 | Temporary Items
404 | .apdisk
405 |
406 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
407 | # Windows thumbnail cache files
408 | Thumbs.db
409 | ehthumbs.db
410 | ehthumbs_vista.db
411 |
412 | # Dump file
413 | *.stackdump
414 |
415 | # Folder config file
416 | [Dd]esktop.ini
417 |
418 | # Recycle Bin used on file shares
419 | $RECYCLE.BIN/
420 |
421 | # Windows Installer files
422 | *.cab
423 | *.msi
424 | *.msix
425 | *.msm
426 | *.msp
427 |
428 | # Windows shortcuts
429 | *.lnk
430 |
431 | # JetBrains Rider
432 | .idea/
433 | *.sln.iml
434 |
435 | ##
436 | ## Visual Studio Code
437 | ##
438 | .vscode/*
439 | !.vscode/settings.json
440 | !.vscode/tasks.json
441 | !.vscode/launch.json
442 | !.vscode/extensions.json
443 |
444 | # Credential Config Files
445 | product-readiness.*
446 | appsettings.json
447 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Lines starting with '#' are comments.
2 | # Each line is a file pattern followed by one or more owners.
3 |
4 | # These owners will be the default owners for everything in the repo.
5 | * @osisoft/product-readiness-guild
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildThisFileDirectory)Extensions.ruleset
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics-Sln/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics-Sln/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Ex1ConnectionAndHierarchyBasicsSln
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics-Sln/Ex1-Connection-And-Hierarchy-Basics-Sln.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics-Sln/Program1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text.Json;
4 | using OSIsoft.AF;
5 | using OSIsoft.AF.Asset;
6 | using OSIsoft.AF.UnitsOfMeasure;
7 |
8 | namespace Ex1ConnectionAndHierarchyBasicsSln
9 | {
10 | public static class Program1
11 | {
12 | public static string AFServer { get; set; }
13 | public static string DatabaseString { get; set; }
14 |
15 | public static void Main()
16 | {
17 | Setup();
18 | AFDatabase database = GetDatabase(AFServer, DatabaseString);
19 |
20 | if (database == null) throw new NullReferenceException("Database is null");
21 |
22 | PrintRootElements(database);
23 | PrintElementTemplates(database);
24 | PrintAttributeTemplates(database, "MeterAdvanced");
25 | PrintEnergyUOMs(database.PISystem);
26 | PrintEnumerationSets(database);
27 | PrintCategories(database);
28 |
29 | Console.WriteLine("Press ENTER key to close");
30 | Console.ReadLine();
31 | }
32 |
33 | public static AFDatabase GetDatabase(string server, string database)
34 | {
35 | PISystems piSystems = new PISystems();
36 | PISystem assetServer = piSystems[server];
37 | AFDatabase afDatabase = assetServer.Databases[database];
38 | return afDatabase;
39 | }
40 |
41 | public static void PrintRootElements(AFDatabase database)
42 | {
43 | if (database == null) throw new ArgumentNullException(nameof(database));
44 | Console.WriteLine("Print Root Elements: {0}", database.Elements.Count);
45 | foreach (AFElement element in database.Elements)
46 | {
47 | Console.WriteLine(" {0}", element.Name);
48 | }
49 |
50 | Console.WriteLine();
51 | }
52 |
53 | public static void PrintElementTemplates(AFDatabase database)
54 | {
55 | if (database == null) throw new ArgumentNullException(nameof(database));
56 | Console.WriteLine("Print Element Templates");
57 | AFNamedCollectionList elemTemplates = database.ElementTemplates.FilterBy(typeof(AFElement));
58 | foreach (AFElementTemplate elemTemp in elemTemplates)
59 | {
60 | Console.WriteLine("Name: {0}; Categories: {1}", elemTemp.Name, elemTemp.CategoriesString);
61 | }
62 |
63 | Console.WriteLine();
64 | }
65 |
66 | public static void PrintAttributeTemplates(AFDatabase database, string elemTempName)
67 | {
68 | if (database == null) throw new ArgumentNullException(nameof(database));
69 | Console.WriteLine("Print Attribute Templates for Element Template: {0}", elemTempName);
70 | AFElementTemplate elemTemp = database.ElementTemplates[elemTempName];
71 | foreach (AFAttributeTemplate attrTemp in elemTemp.AttributeTemplates)
72 | {
73 | string drName = attrTemp.DataReferencePlugIn == null ? "None" : attrTemp.DataReferencePlugIn.Name;
74 | Console.WriteLine("Name: {0}, DRPlugin: {1}", attrTemp.Name, drName);
75 | }
76 |
77 | Console.WriteLine();
78 | }
79 |
80 | public static void PrintEnergyUOMs(PISystem system)
81 | {
82 | if (system == null) throw new ArgumentNullException(nameof(system));
83 | Console.WriteLine("Print Energy UOMs");
84 | UOMClass uomClass = system.UOMDatabase.UOMClasses["Energy"];
85 | foreach (UOM uom in uomClass.UOMs)
86 | {
87 | Console.WriteLine("UOM: {0}, Abbreviation: {1}", uom.Name, uom.Abbreviation);
88 | }
89 |
90 | Console.WriteLine();
91 | }
92 |
93 | public static void PrintEnumerationSets(AFDatabase database)
94 | {
95 | if (database == null) throw new ArgumentNullException(nameof(database));
96 | Console.WriteLine("Print Enumeration Sets");
97 | AFEnumerationSets enumSets = database.EnumerationSets;
98 | foreach (AFEnumerationSet enumSet in enumSets)
99 | {
100 | Console.WriteLine(enumSet.Name);
101 | foreach (AFEnumerationValue state in enumSet)
102 | {
103 | Console.WriteLine("{0} - {1}", state.Value, state.Name);
104 | }
105 |
106 | Console.WriteLine();
107 | }
108 | }
109 |
110 | public static void PrintCategories(AFDatabase database)
111 | {
112 | if (database == null) throw new ArgumentNullException(nameof(database));
113 | Console.WriteLine("Print Categories");
114 | Console.WriteLine("Element Categories");
115 | foreach (AFCategory category in database.ElementCategories)
116 | {
117 | Console.WriteLine(category.Name);
118 | }
119 |
120 | Console.WriteLine();
121 | Console.WriteLine("Attribute Categories");
122 | foreach (AFCategory category in database.AttributeCategories)
123 | {
124 | Console.WriteLine(category.Name);
125 | }
126 |
127 | Console.WriteLine();
128 | }
129 |
130 | public static void Setup()
131 | {
132 | AppSettings settings = JsonSerializer.Deserialize(File.ReadAllText(Directory.GetCurrentDirectory() + "/appsettings.json"));
133 |
134 | // ==== Client constants ====
135 | AFServer = settings.AFServerName;
136 | DatabaseString = settings.AFDatabaseName;
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics-Sln/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Ex1_Sln")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Ex1_Sln")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("abb540d9-4b9f-4a83-9578-5e33ee7c5cf6")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics-Sln/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Ex1ConnectionAndHierarchyBasics
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics/Ex1-Connection-And-Hierarchy-Basics.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics/Program1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.Asset;
4 | using OSIsoft.AF.UnitsOfMeasure;
5 |
6 | namespace Ex1ConnectionAndHierarchyBasics
7 | {
8 | public static class Program1
9 | {
10 | public static void Main()
11 | {
12 | AFDatabase database = GetDatabase("PISRV01", "Green Power Company");
13 |
14 | if (database == null) throw new NullReferenceException("Database is null");
15 |
16 | PrintRootElements(database);
17 | PrintElementTemplates(database);
18 | PrintAttributeTemplates(database, "MeterAdvanced");
19 | PrintEnergyUOMs(database.PISystem);
20 | PrintEnumerationSets(database);
21 | PrintCategories(database);
22 |
23 | Console.WriteLine("Press ENTER key to close");
24 | Console.ReadLine();
25 | }
26 |
27 | public static AFDatabase GetDatabase(string server, string database)
28 | {
29 | PISystems piSystems = new PISystems();
30 | PISystem assetServer = piSystems[server];
31 | AFDatabase afDatabase = assetServer.Databases[database];
32 | return afDatabase;
33 | }
34 |
35 | public static void PrintRootElements(AFDatabase database)
36 | {
37 | if (database == null) throw new ArgumentNullException(nameof(database));
38 | Console.WriteLine("Print Root Elements: {0}", database.Elements.Count);
39 | foreach (AFElement element in database.Elements)
40 | {
41 | Console.WriteLine(" {0}", element.Name);
42 | }
43 |
44 | Console.WriteLine();
45 | }
46 |
47 | public static void PrintElementTemplates(AFDatabase database)
48 | {
49 | /// Your code here
50 | }
51 |
52 | public static void PrintAttributeTemplates(AFDatabase database, string elemTempName)
53 | {
54 | /// Your code here
55 | }
56 |
57 | public static void PrintEnergyUOMs(PISystem system)
58 | {
59 | /// Your code here
60 | }
61 |
62 | public static void PrintEnumerationSets(AFDatabase database)
63 | {
64 | /// Your code here
65 | }
66 |
67 | public static void PrintCategories(AFDatabase database)
68 | {
69 | /// Your code here
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Ex1")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Ex1")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("b8a590e4-2fc6-40ed-9aef-07652b8eec8f")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Ex1-Connection-And-Hierarchy-Basics/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets-Sln/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets-Sln/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Ex2SearchingForAssetsSln
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets-Sln/Ex2-Searching-For-Assets-Sln.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets-Sln/Ex2-Searching-For-Assets-Sln.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {A26EEA96-303C-4EF3-B109-09F66462791F}
9 | Exe
10 | Properties
11 | Ex2SearchingForAssetsSln
12 | Ex2-Searching-Sln
13 | v4.8
14 | 512
15 | true
16 |
17 |
18 |
19 |
20 |
21 | AnyCPU
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | AnyCPU
32 | pdbonly
33 | true
34 | bin\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 |
41 | ..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
42 | True
43 |
44 |
45 | C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0\OSIsoft.AFSDK.dll
46 |
47 |
48 |
49 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
50 |
51 |
52 |
53 |
54 | ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
55 | True
56 | True
57 |
58 |
59 | ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
60 |
61 |
62 |
63 | ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
64 |
65 |
66 | ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll
67 | True
68 | True
69 |
70 |
71 | ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
72 |
73 |
74 | ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll
75 | True
76 | True
77 |
78 |
79 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
80 | True
81 | True
82 |
83 |
84 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
85 | True
86 | True
87 |
88 |
89 | ..\packages\System.Text.Encodings.Web.6.0.0\lib\net461\System.Text.Encodings.Web.dll
90 |
91 |
92 | ..\packages\System.Text.Json.6.0.6\lib\net461\System.Text.Json.dll
93 |
94 |
95 | ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
96 |
97 |
98 | ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | Always
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
141 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets-Sln/Program2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text.Json;
4 | using OSIsoft.AF;
5 | using OSIsoft.AF.Asset;
6 | using OSIsoft.AF.Search;
7 |
8 | namespace Ex2SearchingForAssetsSln
9 | {
10 | public static class Program2
11 | {
12 | public static string AFServer { get; set; }
13 | public static string DatabaseString { get; set; }
14 |
15 | public static void Main()
16 | {
17 | Setup();
18 | AFDatabase database = GetDatabase(AFServer, DatabaseString);
19 |
20 | if (database == null) throw new NullReferenceException("Database is null");
21 |
22 | FindMetersByName(database, "Meter00*");
23 | FindMetersByTemplate(database, "MeterBasic");
24 | FindMetersBySubstation(database, "SSA*");
25 | FindMetersAboveUsage(database, 300);
26 | FindBuildingInfo(database, "MeterAdvanced");
27 |
28 | Console.WriteLine("Press ENTER key to close");
29 | Console.ReadLine();
30 | }
31 |
32 | public static AFDatabase GetDatabase(string serverName, string databaseName)
33 | {
34 | PISystems systems = new PISystems();
35 | PISystem assetServer;
36 |
37 | if (!string.IsNullOrEmpty(serverName))
38 | assetServer = systems[serverName];
39 | else
40 | assetServer = systems.DefaultPISystem;
41 |
42 | if (!string.IsNullOrEmpty(databaseName))
43 | return assetServer.Databases[databaseName];
44 | else
45 | return assetServer.Databases.DefaultDatabase;
46 | }
47 |
48 | public static void FindMetersByName(AFDatabase database, string elementNameFilter)
49 | {
50 | Console.WriteLine("Find Meters by Name: {0}", elementNameFilter);
51 |
52 | // Default search is as an element name string mask.
53 | var queryString = $"\"{elementNameFilter}\"";
54 | using (AFElementSearch elementQuery = new AFElementSearch(database, "ElementSearch", queryString))
55 | {
56 | elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
57 | foreach (AFElement element in elementQuery.FindObjects())
58 | {
59 | Console.WriteLine("Element: {0}, Template: {1}, Categories: {2}",
60 | element.Name,
61 | element.Template.Name,
62 | element.CategoriesString);
63 | }
64 | }
65 |
66 | Console.WriteLine();
67 | }
68 |
69 | public static void FindMetersByTemplate(AFDatabase database, string templateName)
70 | {
71 | Console.WriteLine("Find Meters by Template: {0}", templateName);
72 |
73 | using (AFElementSearch elementQuery = new AFElementSearch(database, "TemplateSearch", string.Format("template:\"{0}\"", templateName)))
74 | {
75 | elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
76 | int countDerived = 0;
77 | foreach (AFElement element in elementQuery.FindObjects())
78 | {
79 | Console.WriteLine("Element: {0}, Template: {1}", element.Name, element.Template.Name);
80 | if (element.Template.Name != templateName)
81 | countDerived++;
82 | }
83 |
84 | Console.WriteLine(" Found {0} derived templates", countDerived);
85 | Console.WriteLine();
86 | }
87 | }
88 |
89 | public static void FindMetersBySubstation(AFDatabase database, string substationLocation)
90 | {
91 | Console.WriteLine("Find Meters by Substation: {0}", substationLocation);
92 |
93 | string templateName = "MeterBasic";
94 | string attributeName = "Substation";
95 | using (AFElementSearch elementQuery = new AFElementSearch(database, "AttributeValueEQSearch",
96 | string.Format("template:\"{0}\" \"|{1}\":\"{2}\"", templateName, attributeName, substationLocation)))
97 | {
98 | elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
99 | int countNames = 0;
100 | foreach (AFElement element in elementQuery.FindObjects())
101 | {
102 | Console.Write("{0}{1}", countNames++ == 0 ? string.Empty : ", ", element.Name);
103 | }
104 |
105 | Console.WriteLine(String.Empty);
106 | }
107 | }
108 |
109 | public static void FindMetersAboveUsage(AFDatabase database, double val)
110 | {
111 | Console.WriteLine("Find Meters above Usage: {0}", val);
112 |
113 | string templateName = "MeterBasic";
114 | string attributeName = "Energy Usage";
115 | using (AFElementSearch elementQuery = new AFElementSearch(database, "AttributeValueGTSearch",
116 | string.Format("template:\"{0}\" \"|{1}\":>{2}", templateName, attributeName, val)))
117 | {
118 | elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
119 | int countNames = 0;
120 | foreach (AFElement element in elementQuery.FindObjects())
121 | {
122 | Console.Write("{0}{1}", countNames++ == 0 ? string.Empty : ", ", element.Name);
123 | }
124 |
125 | Console.WriteLine(String.Empty);
126 | }
127 | }
128 |
129 | public static void FindBuildingInfo(AFDatabase database, string templateName)
130 | {
131 | if (database == null) throw new ArgumentNullException(nameof(database));
132 | Console.WriteLine("Find Building Info: {0}", templateName);
133 |
134 | AFCategory buildingInfoCat = database.AttributeCategories["Building Info"];
135 | AFNamedCollectionList foundAttributes = new AFNamedCollectionList();
136 |
137 | using (AFElementSearch elementQuery = new AFElementSearch(database, "AttributeCattegorySearch", string.Format("template:\"{0}\"", templateName)))
138 | {
139 | elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
140 | foreach (AFElement element in elementQuery.FindObjects())
141 | {
142 | foreach (AFAttribute attr in element.Attributes)
143 | {
144 | if (attr.Categories.Contains(buildingInfoCat))
145 | {
146 | foundAttributes.Add(attr);
147 | }
148 | }
149 | }
150 | }
151 |
152 | Console.WriteLine("Found {0} attributes.", foundAttributes.Count);
153 | Console.WriteLine();
154 | }
155 |
156 | public static void Setup()
157 | {
158 | AppSettings settings = JsonSerializer.Deserialize(File.ReadAllText(Directory.GetCurrentDirectory() + "/appsettings.json"));
159 |
160 | // ==== Client constants ====
161 | AFServer = settings.AFServerName;
162 | DatabaseString = settings.AFDatabaseName;
163 | }
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets-Sln/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Ex2_Sln")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Ex2_Sln")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("a26eea96-303c-4ef3-b109-09f66462791f")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets-Sln/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Ex2SearchingForAssets
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets/Ex2-Searching-For-Assets.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets/Ex2-Searching-For-Assets.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {2DFDAF54-68AC-4361-B173-CE5899B455D0}
9 | Exe
10 | Properties
11 | Ex2SearchingForAssets
12 | Ex2-Searching
13 | v4.8
14 | 512
15 | true
16 |
17 |
18 |
19 |
20 |
21 | AnyCPU
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | AnyCPU
32 | pdbonly
33 | true
34 | bin\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 |
41 | ..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
42 | True
43 |
44 |
45 | C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0\OSIsoft.AFSDK.dll
46 |
47 |
48 |
49 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
50 |
51 |
52 |
53 |
54 | ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
55 | True
56 | True
57 |
58 |
59 | ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
60 |
61 |
62 |
63 | ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
64 |
65 |
66 | ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll
67 | True
68 | True
69 |
70 |
71 | ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
72 |
73 |
74 | ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll
75 | True
76 | True
77 |
78 |
79 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
80 | True
81 | True
82 |
83 |
84 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
85 | True
86 | True
87 |
88 |
89 | ..\packages\System.Text.Encodings.Web.6.0.0\lib\net461\System.Text.Encodings.Web.dll
90 |
91 |
92 | ..\packages\System.Text.Json.6.0.6\lib\net461\System.Text.Json.dll
93 |
94 |
95 | ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
96 |
97 |
98 | ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | Always
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
141 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets/Program2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text.Json;
5 | using OSIsoft.AF;
6 | using OSIsoft.AF.Asset;
7 | using OSIsoft.AF.Search;
8 |
9 | namespace Ex2SearchingForAssets
10 | {
11 | public static class Program2
12 | {
13 | public static string AFServer { get; set; }
14 | public static string DatabaseString { get; set; }
15 |
16 | public static void Main()
17 | {
18 | Setup();
19 | AFDatabase database = GetDatabase(AFServer, DatabaseString);
20 |
21 | if (database == null) throw new NullReferenceException("Database is null");
22 |
23 | FindMetersByName(database, "Meter00*");
24 | FindMetersByTemplate(database, "MeterBasic");
25 | FindMetersBySubstation(database, "SSA*");
26 | FindMetersAboveUsage(database, 300);
27 | FindBuildingInfo(database, "MeterAdvanced");
28 |
29 | Console.WriteLine("Press ENTER key to close");
30 | Console.ReadLine();
31 | }
32 |
33 | public static AFDatabase GetDatabase(string serverName, string databaseName)
34 | {
35 | PISystems systems = new PISystems();
36 | PISystem assetServer;
37 |
38 | if (!string.IsNullOrEmpty(serverName))
39 | assetServer = systems[serverName];
40 | else
41 | assetServer = systems.DefaultPISystem;
42 |
43 | if (!string.IsNullOrEmpty(databaseName))
44 | return assetServer.Databases[databaseName];
45 | else
46 | return assetServer.Databases.DefaultDatabase;
47 | }
48 |
49 | public static void FindMetersByName(AFDatabase database, string elementNameFilter)
50 | {
51 | Console.WriteLine("Find Meters by Name: {0}", elementNameFilter);
52 |
53 | // Default search is as an element name string mask.
54 | var queryString = $"\"{elementNameFilter}\"";
55 | using (AFElementSearch elementQuery = new AFElementSearch(database, "ElementSearch", queryString))
56 | {
57 | elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
58 | foreach (AFElement element in elementQuery.FindObjects())
59 | {
60 | Console.WriteLine("Element: {0}, Template: {1}, Categories: {2}",
61 | element.Name,
62 | element.Template.Name,
63 | element.CategoriesString);
64 | }
65 | }
66 |
67 | Console.WriteLine();
68 | }
69 |
70 | public static void FindMetersByTemplate(AFDatabase database, string templateName)
71 | {
72 | /// Your code here
73 | }
74 |
75 | public static void FindMetersBySubstation(AFDatabase database, string substationLocation)
76 | {
77 | /// Your code here
78 | }
79 |
80 | public static void FindMetersAboveUsage(AFDatabase database, double val)
81 | {
82 | /// Your code here
83 | }
84 |
85 | public static void FindBuildingInfo(AFDatabase database, string templateName)
86 | {
87 | /// Your code here
88 | }
89 |
90 | public static void Setup()
91 | {
92 | AppSettings settings = JsonSerializer.Deserialize(File.ReadAllText(Directory.GetCurrentDirectory() + "/appsettings.json"));
93 |
94 | // ==== Client constants ====
95 | AFServer = settings.AFServerName;
96 | DatabaseString = settings.AFDatabaseName;
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Ex2")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Ex2")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("2dfdaf54-68ac-4361-b173-ce5899b455d0")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Ex2-Searching-For-Assets/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data-Sln/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data-Sln/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Ex3ReadingAndWritingDataSln
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data-Sln/Ex3-Reading-And-Writing-Data-Sln.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data-Sln/Ex3-Reading-And-Writing-Data-Sln.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {ECB4566E-725E-4DAF-8543-29FCAF38FF1A}
9 | Exe
10 | Properties
11 | Ex3ReadingAndWritingDataSln
12 | Ex3-Reading-Sln
13 | v4.8
14 | 512
15 | true
16 |
17 |
18 |
19 |
20 |
21 | AnyCPU
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | AnyCPU
32 | pdbonly
33 | true
34 | bin\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 |
41 | ..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
42 | True
43 |
44 |
45 | C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0\OSIsoft.AFSDK.dll
46 |
47 |
48 |
49 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
50 |
51 |
52 |
53 |
54 | ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
55 | True
56 | True
57 |
58 |
59 | ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
60 |
61 |
62 |
63 | ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
64 |
65 |
66 | ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll
67 | True
68 | True
69 |
70 |
71 | ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
72 |
73 |
74 | ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll
75 | True
76 | True
77 |
78 |
79 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
80 | True
81 | True
82 |
83 |
84 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
85 | True
86 | True
87 |
88 |
89 | ..\packages\System.Text.Encodings.Web.6.0.0\lib\net461\System.Text.Encodings.Web.dll
90 |
91 |
92 | ..\packages\System.Text.Json.6.0.6\lib\net461\System.Text.Json.dll
93 |
94 |
95 | ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
96 |
97 |
98 | ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | Always
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
141 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data-Sln/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Ex3_Sln")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Ex3_Sln")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("ecb4566e-725e-4daf-8543-29fcaf38ff1a")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data-Sln/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Ex3ReadingAndWritingData
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data/Ex3-Reading-And-Writing-Data.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data/Ex3-Reading-And-Writing-Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {EBA8F603-D688-4689-AA57-41736EBD894F}
9 | Exe
10 | Properties
11 | Ex3ReadingAndWritingData
12 | Ex3-Reading
13 | v4.8
14 | 512
15 | true
16 |
17 |
18 |
19 |
20 |
21 | AnyCPU
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | AnyCPU
32 | pdbonly
33 | true
34 | bin\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 |
41 | ..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
42 | True
43 |
44 |
45 | C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0\OSIsoft.AFSDK.dll
46 |
47 |
48 |
49 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
50 |
51 |
52 |
53 |
54 | ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
55 | True
56 | True
57 |
58 |
59 | ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
60 |
61 |
62 |
63 | ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
64 |
65 |
66 | ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll
67 | True
68 | True
69 |
70 |
71 | ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
72 |
73 |
74 | ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll
75 | True
76 | True
77 |
78 |
79 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
80 | True
81 | True
82 |
83 |
84 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
85 | True
86 | True
87 |
88 |
89 | ..\packages\System.Text.Encodings.Web.6.0.0\lib\net461\System.Text.Encodings.Web.dll
90 |
91 |
92 | ..\packages\System.Text.Json.6.0.6\lib\net461\System.Text.Json.dll
93 |
94 |
95 | ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
96 |
97 |
98 | ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | Always
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
141 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data/Program3.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text.Json;
6 | using OSIsoft.AF;
7 | using OSIsoft.AF.Asset;
8 | using OSIsoft.AF.Data;
9 | using OSIsoft.AF.PI;
10 | using OSIsoft.AF.Search;
11 | using OSIsoft.AF.Time;
12 |
13 | namespace Ex3ReadingAndWritingData
14 | {
15 | public static class Program3
16 | {
17 | public static string AFServer { get; set; }
18 | public static string DatabaseString { get; set; }
19 |
20 | public static void Main()
21 | {
22 | Setup();
23 | AFDatabase database = GetDatabase(AFServer, DatabaseString);
24 |
25 | if (database == null) throw new NullReferenceException("Database is null");
26 |
27 | PrintHistorical(database, "Meter001", "*-30s", "*");
28 | PrintInterpolated(database, "Meter001", "*-30s", "*", TimeSpan.FromSeconds(10));
29 | PrintHourlyAverage(database, "Meter001", "y", "t");
30 | PrintEnergyUsageAtTime(database, "t+10h");
31 | PrintDailyAverageEnergyUsage(database, "t-7d", "t");
32 | SwapValues(database, "Meter001", "Meter002", "y", "y+1h");
33 |
34 | Console.WriteLine("Press ENTER key to close");
35 | Console.ReadLine();
36 | }
37 |
38 | public static AFDatabase GetDatabase(string serverName, string databaseName)
39 | {
40 | PISystems systems = new PISystems();
41 | PISystem assetServer;
42 |
43 | if (!string.IsNullOrEmpty(serverName))
44 | assetServer = systems[serverName];
45 | else
46 | assetServer = systems.DefaultPISystem;
47 |
48 | if (!string.IsNullOrEmpty(databaseName))
49 | return assetServer.Databases[databaseName];
50 | else
51 | return assetServer.Databases.DefaultDatabase;
52 | }
53 |
54 | public static void PrintHistorical(AFDatabase database, string meterName, string startTime, string endTime)
55 | {
56 | if (database == null) throw new ArgumentNullException(nameof(database));
57 | Console.WriteLine(string.Format("Print Historical Values - Meter: {0}, Start: {1}, End: {2}", meterName, startTime, endTime));
58 |
59 | AFAttribute attr = AFAttribute.FindAttribute(@"\Meters\" + meterName + @"|Energy Usage", database);
60 |
61 | AFTime start = new AFTime(startTime);
62 | AFTime end = new AFTime(endTime);
63 | AFTimeRange timeRange = new AFTimeRange(start, end);
64 | AFValues vals = attr.Data.RecordedValues(
65 | timeRange: timeRange,
66 | boundaryType: AFBoundaryType.Inside,
67 | desiredUOM: database.PISystem.UOMDatabase.UOMs["kilojoule"],
68 | filterExpression: null,
69 | includeFilteredValues: false);
70 |
71 | foreach (AFValue val in vals)
72 | {
73 | Console.WriteLine("Timestamp (UTC): {0}, Value (kJ): {1}", val.Timestamp.UtcTime, val.Value);
74 | }
75 |
76 | Console.WriteLine();
77 | }
78 |
79 | public static void PrintInterpolated(AFDatabase database, string meterName, string startTime, string endTime, TimeSpan timeSpan)
80 | {
81 | AFAttribute attr = AFAttribute.FindAttribute(@"\Meters\" + meterName + @"|Energy Usage", database);
82 |
83 | // Your code here
84 | }
85 |
86 | public static void PrintHourlyAverage(AFDatabase database, string meterName, string startTime, string endTime)
87 | {
88 | AFAttribute attr = AFAttribute.FindAttribute(@"\Meters\" + meterName + @"|Energy Usage", database);
89 |
90 | // Your code here
91 | }
92 |
93 | public static void PrintEnergyUsageAtTime(AFDatabase database, string timeStamp)
94 | {
95 | Console.WriteLine("Print Energy Usage at Time: {0}", timeStamp);
96 | AFAttributeList attrList = new AFAttributeList();
97 |
98 | // Use this method if you get stuck trying to find attributes
99 | // attrList = GetAttributes();
100 |
101 | // Your code here
102 | }
103 |
104 | public static void PrintDailyAverageEnergyUsage(AFDatabase database, string startTime, string endTime)
105 | {
106 | Console.WriteLine(string.Format("Print Daily Energy Usage - Start: {0}, End: {1}", startTime, endTime));
107 | AFAttributeList attrList = new AFAttributeList();
108 |
109 | // Use this method if you get stuck trying to find attributes
110 | // attrList = GetAttributes();
111 | }
112 |
113 | public static void SwapValues(AFDatabase database, string meter1, string meter2, string startTime, string endTime)
114 | {
115 | Console.WriteLine(string.Format("Swap values for meters: {0}, {1} between {2} and {3}", meter1, meter2, startTime, endTime));
116 |
117 | // Your code here
118 | }
119 |
120 | // Helper method used in PrintEnergyUsageAtTime() and PrintDailyAverageEnergyUseage
121 | // Note that this is an optional method, it is used in the solutions, but it is possible
122 | // to get a valid solution without using this method
123 | public static AFAttributeList GetAttributes(AFDatabase database, string templateName, string attributeName)
124 | {
125 | AFAttributeList attrList = new AFAttributeList();
126 |
127 | using (AFElementSearch elementQuery = new AFElementSearch(database, "AttributeSearch", string.Format("template:\"{0}\"", templateName)))
128 | {
129 | elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
130 | foreach (AFElement element in elementQuery.FindObjects())
131 | {
132 | foreach (AFAttribute attr in element.Attributes)
133 | {
134 | if (attr.Name.Equals(attributeName))
135 | {
136 | attrList.Add(attr);
137 | }
138 | }
139 | }
140 | }
141 |
142 | return attrList;
143 | }
144 |
145 | public static void Setup()
146 | {
147 | AppSettings settings = JsonSerializer.Deserialize(File.ReadAllText(Directory.GetCurrentDirectory() + "/appsettings.json"));
148 |
149 | // ==== Client constants ====
150 | AFServer = settings.AFServerName;
151 | DatabaseString = settings.AFDatabaseName;
152 | }
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Ex3")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Ex3")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("eba8f603-d688-4689-aa57-41736ebd894f")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Ex3-Reading-And-Writing-Data/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy-Sln/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy-Sln/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Ex4BuildingAnAFHierarchySln
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy-Sln/Ex4-Building-An-AF-Hierarchy-Sln.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy-Sln/Program4.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text.Json;
4 | using OSIsoft.AF;
5 | using OSIsoft.AF.Asset;
6 |
7 | namespace Ex4BuildingAnAFHierarchySln
8 | {
9 | public static class Program4
10 | {
11 | public static string AFServer { get; set; }
12 | public static string DatabaseString { get; set; }
13 |
14 | public static void Main()
15 | {
16 | Setup();
17 | AFDatabase database = GetDatabase(AFServer, DatabaseString);
18 |
19 | if (database == null) throw new NullReferenceException("Database is null");
20 |
21 | CreateElementTemplate(database);
22 | CreateFeedersRootElement(database);
23 | CreateFeederElements(database);
24 | CreateWeakReference(database);
25 |
26 | Console.WriteLine("Completed - Press ENTER key to close");
27 | Console.ReadLine();
28 | }
29 |
30 | public static AFDatabase GetDatabase(string serverName, string databaseName)
31 | {
32 | PISystems systems = new PISystems();
33 | PISystem assetServer;
34 |
35 | if (!string.IsNullOrEmpty(serverName))
36 | assetServer = systems[serverName];
37 | else
38 | assetServer = systems.DefaultPISystem;
39 |
40 | if (!string.IsNullOrEmpty(databaseName))
41 | return assetServer.Databases[databaseName];
42 | else
43 | return assetServer.Databases.DefaultDatabase;
44 | }
45 |
46 | public static void CreateFeedersRootElement(AFDatabase database)
47 | {
48 | if (database == null) throw new ArgumentNullException(nameof(database));
49 | Console.WriteLine("Creating the Feeders root Element");
50 | if (database.Elements.Contains("Feeders"))
51 | return;
52 |
53 | database.Elements.Add("Feeders");
54 | database.CheckIn();
55 | }
56 |
57 | public static void CreateElementTemplate(AFDatabase database)
58 | {
59 | if (database == null) throw new ArgumentNullException(nameof(database));
60 | Console.WriteLine("Creating the element template: FeederTemplate");
61 | string templateName = "FeederTemplate";
62 | AFElementTemplate feederTemplate;
63 | if (database.ElementTemplates.Contains(templateName))
64 | return;
65 | else
66 | feederTemplate = database.ElementTemplates.Add(templateName);
67 |
68 | AFAttributeTemplate cityAttributeTemplate = feederTemplate.AttributeTemplates.Add("City");
69 | cityAttributeTemplate.Type = typeof(string);
70 |
71 | AFAttributeTemplate power = feederTemplate.AttributeTemplates.Add("Power");
72 | power.Type = typeof(Single);
73 |
74 | power.DefaultUOM = database.PISystem.UOMDatabase.UOMs["watt"];
75 | power.DataReferencePlugIn = database.PISystem.DataReferencePlugIns["PI Point"];
76 |
77 | database.CheckIn();
78 | }
79 |
80 | public static void CreateFeederElements(AFDatabase database)
81 | {
82 | if (database == null) throw new ArgumentNullException(nameof(database));
83 |
84 | Console.WriteLine("Creating a feeder element under the Feeders Element");
85 | AFElementTemplate template = database.ElementTemplates["FeederTemplate"];
86 |
87 | AFElement feeders = database.Elements["Feeders"];
88 | if (template == null || feeders == null) return;
89 |
90 | if (feeders.Elements.Contains("Feeder001")) return;
91 | AFElement feeder001 = feeders.Elements.Add("Feeder001", template);
92 |
93 | AFAttribute city = feeder001.Attributes["City"];
94 | if (city != null) city.SetValue(new AFValue("London"));
95 |
96 | AFAttribute power = feeder001.Attributes["Power"];
97 | power.ConfigString = @"%@\Configuration|PIDataArchiveName%\SINUSOID";
98 |
99 | if (database.IsDirty)
100 | database.CheckIn();
101 | }
102 |
103 | public static void CreateWeakReference(AFDatabase database)
104 | {
105 | if (database == null) throw new ArgumentNullException(nameof(database));
106 |
107 | Console.WriteLine("Adding a weak reference of the Feeder001 under London");
108 | AFReferenceType weakRefType = database.ReferenceTypes["Weak Reference"];
109 |
110 | AFElement london = database.Elements["Geographical Locations"].Elements["London"];
111 | AFElement feeder0001 = database.Elements["Feeders"].Elements["Feeder001"];
112 | if (london == null || feeder0001 == null) return;
113 |
114 | if (!london.Elements.Contains(feeder0001))
115 | london.Elements.Add(feeder0001, weakRefType);
116 | if (database.IsDirty)
117 | database.CheckIn();
118 | }
119 |
120 | public static void Setup()
121 | {
122 | AppSettings settings = JsonSerializer.Deserialize(File.ReadAllText(Directory.GetCurrentDirectory() + "/appsettings.json"));
123 |
124 | // ==== Client constants ====
125 | AFServer = settings.AFServerName;
126 | DatabaseString = settings.AFDatabaseName;
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy-Sln/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Ex4_Sln")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Ex4_Sln")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("7a8a9c6a-1626-431d-a06a-b242c8faad01")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy-Sln/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Ex4BuildingAnAFHierarchy
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy/Bonus.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using OSIsoft.AF;
5 | using OSIsoft.AF.Asset;
6 | using OSIsoft.AF.UnitsOfMeasure;
7 |
8 | namespace Ex4BuildingAnAFHierarchy
9 | {
10 | public static class Bonus
11 | {
12 | public static void Run()
13 | {
14 | Program4.Setup();
15 |
16 | AFDatabase database = GetOrCreateDatabase(Program4.AFServer, "Ethical Power Company");
17 |
18 | CreateCategories(database);
19 | CreateEnumerationSets(database);
20 | CreateTemplates(database);
21 | CreateElements(database);
22 | SetAttributeValues(database);
23 | CreateCityElements(database);
24 | CreateWeakReferences(database);
25 | }
26 |
27 | public static AFDatabase GetOrCreateDatabase(string servername, string databasename)
28 | {
29 | AFDatabase database = null;
30 |
31 | // Your code here
32 | return database;
33 | }
34 |
35 | public static void CreateCategories(AFDatabase database)
36 | {
37 | if (database == null) return;
38 |
39 | // Your code here
40 | }
41 |
42 | public static void CreateEnumerationSets(AFDatabase database)
43 | {
44 | if (database == null) return;
45 |
46 | // Your code here
47 | }
48 |
49 | public static void CreateTemplates(AFDatabase database)
50 | {
51 | if (database == null) return;
52 |
53 | // Your code here
54 | }
55 |
56 | // Helper method for CreateTemplates
57 | public static AFElementTemplate CreateMeterBasicTemplate(AFDatabase database)
58 | {
59 | if (database == null) return null;
60 |
61 | AFElementTemplate meterBasicTemplate = database.ElementTemplates["MeterBasic"];
62 | if (meterBasicTemplate != null)
63 | return meterBasicTemplate;
64 |
65 | // Your code here
66 | return meterBasicTemplate;
67 | }
68 |
69 | public static void CreateMeterAdvancedTemplate(AFElementTemplate meterBasicTemplate)
70 | {
71 | // Your code here
72 | }
73 |
74 | public static void CreateCityTemplate(AFDatabase database)
75 | {
76 | // Your code here
77 | }
78 |
79 | public static void CreateElements(AFDatabase database)
80 | {
81 | if (database == null) return;
82 |
83 | // Your code here
84 | }
85 |
86 | public static void SetAttributeValues(AFDatabase database)
87 | {
88 | if (database == null) return;
89 |
90 | // Your code here
91 | }
92 |
93 | public static void CreateCityElements(AFDatabase database)
94 | {
95 | if (database == null) return;
96 |
97 | // Your code here
98 | }
99 |
100 | public static void CreateWeakReferences(AFDatabase database)
101 | {
102 | if (database == null) return;
103 |
104 | // Your code here
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy/Ex4-Building-An-AF-Hierarchy.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy/Program4.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text.Json;
4 | using OSIsoft.AF;
5 | using OSIsoft.AF.Asset;
6 |
7 | namespace Ex4BuildingAnAFHierarchy
8 | {
9 | public static class Program4
10 | {
11 | public static string AFServer { get; set; }
12 | public static string DatabaseString { get; set; }
13 |
14 | public static void Main()
15 | {
16 | Setup();
17 | AFDatabase database = GetDatabase(AFServer, DatabaseString);
18 |
19 | if (database == null) throw new NullReferenceException("Database is null");
20 |
21 | CreateElementTemplate(database);
22 | CreateFeedersRootElement(database);
23 | CreateFeederElements(database);
24 | CreateWeakReference(database);
25 |
26 | Console.WriteLine("Press ENTER key to close");
27 | Console.ReadLine();
28 | }
29 |
30 | public static AFDatabase GetDatabase(string serverName, string databaseName)
31 | {
32 | PISystems systems = new PISystems();
33 | PISystem assetServer;
34 |
35 | if (!string.IsNullOrEmpty(serverName))
36 | assetServer = systems[serverName];
37 | else
38 | assetServer = systems.DefaultPISystem;
39 |
40 | if (!string.IsNullOrEmpty(databaseName))
41 | return assetServer.Databases[databaseName];
42 | else
43 | return assetServer.Databases.DefaultDatabase;
44 | }
45 |
46 | public static void CreateElementTemplate(AFDatabase database)
47 | {
48 | if (database == null) throw new ArgumentNullException(nameof(database));
49 |
50 | string templateName = "FeederTemplate";
51 | AFElementTemplate feederTemplate;
52 | if (database.ElementTemplates.Contains(templateName))
53 | return;
54 | else
55 | feederTemplate = database.ElementTemplates.Add(templateName);
56 |
57 | AFAttributeTemplate cityattributeTemplate = feederTemplate.AttributeTemplates.Add("City");
58 | cityattributeTemplate.Type = typeof(string);
59 |
60 | AFAttributeTemplate power = feederTemplate.AttributeTemplates.Add("Power");
61 | power.Type = typeof(Single);
62 |
63 | power.DefaultUOM = database.PISystem.UOMDatabase.UOMs["watt"];
64 | power.DataReferencePlugIn = database.PISystem.DataReferencePlugIns["PI Point"];
65 |
66 | database.CheckIn();
67 | }
68 |
69 | public static void CreateFeedersRootElement(AFDatabase database)
70 | {
71 | // Your code here
72 | }
73 |
74 | public static void CreateFeederElements(AFDatabase database)
75 | {
76 | // Your code here
77 | }
78 |
79 | public static void CreateWeakReference(AFDatabase database)
80 | {
81 | // Your code here
82 | }
83 |
84 | public static void Setup()
85 | {
86 | AppSettings settings = JsonSerializer.Deserialize(File.ReadAllText(Directory.GetCurrentDirectory() + "/appsettings.json"));
87 |
88 | // ==== Client constants ====
89 | AFServer = settings.AFServerName;
90 | DatabaseString = settings.AFDatabaseName;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Ex4")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Ex4")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("e649e492-a683-4efe-864e-f5176c934f55")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Ex4-Building-An-AF-Hierarchy/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Ex5-Working-With-Event-Frames-Sln/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Ex5-Working-With-Event-Frames-Sln/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Ex5WorkingWithEventFramesSln
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Ex5-Working-With-Event-Frames-Sln/Ex5-Working-With-Event-Frames-Sln.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Ex5-Working-With-Event-Frames-Sln/Program5.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text.Json;
6 | using OSIsoft.AF;
7 | using OSIsoft.AF.Asset;
8 | using OSIsoft.AF.EventFrame;
9 | using OSIsoft.AF.Search;
10 | using OSIsoft.AF.Time;
11 |
12 | namespace Ex5WorkingWithEventFramesSln
13 | {
14 | public static class Program5
15 | {
16 | public static string AFServer { get; set; }
17 | public static string DatabaseString { get; set; }
18 |
19 | public static void Main()
20 | {
21 | Setup();
22 | AFDatabase database = GetDatabase(AFServer, DatabaseString);
23 |
24 | if (database == null) throw new NullReferenceException("Database is null");
25 |
26 | AFElementTemplate eventFrameTemplate = CreateEventFrameTemplate(database);
27 | CreateEventFrames(database, eventFrameTemplate);
28 | CaptureValues(database, eventFrameTemplate);
29 | PrintReport(database, eventFrameTemplate);
30 |
31 | Console.WriteLine("Press ENTER key to close");
32 | Console.ReadLine();
33 | }
34 |
35 | public static AFDatabase GetDatabase(string serverName, string databaseName)
36 | {
37 | PISystems systems = new PISystems();
38 | PISystem assetServer;
39 |
40 | if (!string.IsNullOrEmpty(serverName))
41 | assetServer = systems[serverName];
42 | else
43 | assetServer = systems.DefaultPISystem;
44 |
45 | if (!string.IsNullOrEmpty(databaseName))
46 | return assetServer.Databases[databaseName];
47 | else
48 | return assetServer.Databases.DefaultDatabase;
49 | }
50 |
51 | public static AFElementTemplate CreateEventFrameTemplate(AFDatabase database)
52 | {
53 | if (database == null) throw new ArgumentNullException(nameof(database));
54 | AFElementTemplate eventFrameTemplate = database.ElementTemplates["Daily Usage"];
55 | if (eventFrameTemplate != null)
56 | return eventFrameTemplate;
57 |
58 | eventFrameTemplate = database.ElementTemplates.Add("Daily Usage");
59 | eventFrameTemplate.InstanceType = typeof(AFEventFrame);
60 | eventFrameTemplate.NamingPattern = @"%TEMPLATE%-%ELEMENT%-%STARTTIME:yyyy-MM-dd%-EF*";
61 |
62 | AFAttributeTemplate usage = eventFrameTemplate.AttributeTemplates.Add("Average Energy Usage");
63 | usage.Type = typeof(Single);
64 | usage.DataReferencePlugIn = AFDataReference.GetPIPointDataReference();
65 | usage.ConfigString = @".\Elements[.]|Energy Usage;TimeRangeMethod=Average";
66 | usage.DefaultUOM = database.PISystem.UOMDatabase.UOMs["kilowatt hour"];
67 |
68 | if (database.IsDirty)
69 | database.CheckIn();
70 |
71 | return eventFrameTemplate;
72 | }
73 |
74 | public static void CreateEventFrames(AFDatabase database, AFElementTemplate eventFrameTemplate)
75 | {
76 | if (database == null) throw new ArgumentNullException(nameof(database));
77 | if (eventFrameTemplate == null) throw new ArgumentNullException(nameof(eventFrameTemplate));
78 | string queryString = "Template:MeterBasic";
79 | {
80 | // This method returns the collection of AFBaseElement objects that were created with this template.
81 | using (AFElementSearch elementQuery = new AFElementSearch(database, "Meters", queryString))
82 | {
83 | DateTime timeReference = DateTime.Today.AddDays(-7);
84 | int count = 0;
85 | foreach (AFElement meter in elementQuery.FindObjects())
86 | {
87 | foreach (int day in Enumerable.Range(1, 7))
88 | {
89 | AFTime startTime = new AFTime(timeReference.AddDays(day - 1));
90 | AFTime endTime = new AFTime(startTime.LocalTime.AddDays(1));
91 | AFEventFrame ef = new AFEventFrame(database, "*", eventFrameTemplate);
92 | ef.SetStartTime(startTime);
93 | ef.SetEndTime(endTime);
94 | ef.PrimaryReferencedElement = meter;
95 |
96 | // It is good practice to periodically check in the database
97 | if (++count % 500 == 0)
98 | database.CheckIn();
99 | }
100 | }
101 | }
102 | }
103 |
104 | if (database.IsDirty)
105 | database.CheckIn();
106 | }
107 |
108 | public static void CaptureValues(AFDatabase database, AFElementTemplate eventFrameTemplate)
109 | {
110 | if (database == null) throw new ArgumentNullException(nameof(database));
111 | if (eventFrameTemplate == null) throw new ArgumentNullException(nameof(eventFrameTemplate));
112 |
113 | // Formulate search constraints on time and template
114 | AFTime startTime = DateTime.Today.AddDays(-7);
115 | string queryString = $"template:\"{eventFrameTemplate.Name}\"";
116 | using (AFEventFrameSearch eventFrameSearch = new AFEventFrameSearch(database, "EventFrame Captures", AFEventFrameSearchMode.ForwardFromStartTime, startTime, queryString))
117 | {
118 | eventFrameSearch.CacheTimeout = TimeSpan.FromMinutes(5);
119 | int count = 0;
120 | foreach (AFEventFrame item in eventFrameSearch.FindObjects())
121 | {
122 | item.CaptureValues();
123 | if ((count++ % 500) == 0)
124 | database.CheckIn();
125 | }
126 |
127 | if (database.IsDirty)
128 | database.CheckIn();
129 | }
130 | }
131 |
132 | public static void PrintReport(AFDatabase database, AFElementTemplate eventFrameTemplate)
133 | {
134 | if (database == null) throw new ArgumentNullException(nameof(database));
135 | if (eventFrameTemplate == null) throw new ArgumentNullException(nameof(eventFrameTemplate));
136 | AFTime startTime = DateTime.Today.AddDays(-7);
137 | AFTime endTime = startTime.LocalTime.AddDays(+8); // Or DateTime.Today.AddDays(1);
138 | string queryString = $"template:'{eventFrameTemplate.Name}' ElementName:Meter003";
139 | using (AFEventFrameSearch eventFrameSearch = new AFEventFrameSearch(database, "EventFrame Captures", AFSearchMode.StartInclusive, startTime, endTime, queryString))
140 | {
141 | eventFrameSearch.CacheTimeout = TimeSpan.FromMinutes(5);
142 | foreach (AFEventFrame ef in eventFrameSearch.FindObjects())
143 | {
144 | Console.WriteLine("{0}, {1}, {2}",
145 | ef.Name,
146 | ef.PrimaryReferencedElement.Name,
147 | ef.Attributes["Average Energy Usage"].GetValue().Value);
148 | }
149 | }
150 | }
151 |
152 | public static void Setup()
153 | {
154 | AppSettings settings = JsonSerializer.Deserialize(File.ReadAllText(Directory.GetCurrentDirectory() + "/appsettings.json"));
155 |
156 | // ==== Client constants ====
157 | AFServer = settings.AFServerName;
158 | DatabaseString = settings.AFDatabaseName;
159 | }
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/Ex5-Working-With-Event-Frames-Sln/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Ex5_Sln")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Ex5_Sln")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("ff41dbfc-2bf3-4786-9a9a-6f13b4328cef")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Ex5-Working-With-Event-Frames-Sln/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Ex5-Working-With-EventFrames/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Ex5-Working-With-EventFrames/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Ex5WorkingWithEventFrames
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Ex5-Working-With-EventFrames/Ex5-Working-With-Event-Frames.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Ex5-Working-With-EventFrames/Ex5-Working-With-Event-Frames.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {336C7E54-66C9-45C0-8BB8-FA9B3A3CB0FC}
9 | Exe
10 | Properties
11 | Ex5WorkingWithEventFrames
12 | Ex5WorkingWithEventFrames
13 | v4.8
14 | 512
15 | true
16 |
17 |
18 |
19 |
20 |
21 | AnyCPU
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | AnyCPU
32 | pdbonly
33 | true
34 | bin\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 |
41 | ..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
42 | True
43 |
44 |
45 | C:\Program Files (x86)\PIPC\AF\PublicAssemblies\4.0\OSIsoft.AFSDK.dll
46 |
47 |
48 |
49 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
50 |
51 |
52 |
53 |
54 | ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
55 | True
56 | True
57 |
58 |
59 | ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
60 |
61 |
62 |
63 | ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
64 |
65 |
66 | ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll
67 | True
68 | True
69 |
70 |
71 | ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
72 |
73 |
74 | ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll
75 | True
76 | True
77 |
78 |
79 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
80 | True
81 | True
82 |
83 |
84 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
85 | True
86 | True
87 |
88 |
89 | ..\packages\System.Text.Encodings.Web.6.0.0\lib\net461\System.Text.Encodings.Web.dll
90 |
91 |
92 | ..\packages\System.Text.Json.6.0.6\lib\net461\System.Text.Json.dll
93 |
94 |
95 | ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
96 |
97 |
98 | ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | Always
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
141 |
--------------------------------------------------------------------------------
/Ex5-Working-With-EventFrames/Program5.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text.Json;
6 | using OSIsoft.AF;
7 | using OSIsoft.AF.Asset;
8 | using OSIsoft.AF.EventFrame;
9 | using OSIsoft.AF.Search;
10 | using OSIsoft.AF.Time;
11 |
12 | namespace Ex5WorkingWithEventFrames
13 | {
14 | public static class Program5
15 | {
16 | public static string AFServer { get; set; }
17 | public static string DatabaseString { get; set; }
18 |
19 | public static void Main()
20 | {
21 | Setup();
22 | AFDatabase database = GetDatabase(AFServer, DatabaseString);
23 |
24 | if (database == null) throw new NullReferenceException("Database is null");
25 |
26 | AFElementTemplate eventFrameTemplate = CreateEventFrameTemplate(database);
27 | CreateEventFrames(database, eventFrameTemplate);
28 | CaptureValues(database, eventFrameTemplate);
29 | PrintReport(database, eventFrameTemplate);
30 |
31 | Console.WriteLine("Press ENTER key to close");
32 | Console.ReadLine();
33 | }
34 |
35 | public static AFDatabase GetDatabase(string serverName, string databaseName)
36 | {
37 | PISystems systems = new PISystems();
38 | PISystem assetServer;
39 |
40 | if (!string.IsNullOrEmpty(serverName))
41 | assetServer = systems[serverName];
42 | else
43 | assetServer = systems.DefaultPISystem;
44 |
45 | if (!string.IsNullOrEmpty(databaseName))
46 | return assetServer.Databases[databaseName];
47 | else
48 | return assetServer.Databases.DefaultDatabase;
49 | }
50 |
51 | public static AFElementTemplate CreateEventFrameTemplate(AFDatabase database)
52 | {
53 | if (database == null) throw new ArgumentNullException(nameof(database));
54 | AFElementTemplate eventFrameTemplate = database.ElementTemplates["Daily Usage"];
55 | if (eventFrameTemplate != null)
56 | return eventFrameTemplate;
57 |
58 | eventFrameTemplate = database.ElementTemplates.Add("Daily Usage");
59 | eventFrameTemplate.InstanceType = typeof(AFEventFrame);
60 | eventFrameTemplate.NamingPattern = @"%TEMPLATE%-%ELEMENT%-%STARTTIME:yyyy-MM-dd%-EF*";
61 |
62 | AFAttributeTemplate usage = eventFrameTemplate.AttributeTemplates.Add("Average Energy Usage");
63 | usage.Type = typeof(Single);
64 | usage.DataReferencePlugIn = AFDataReference.GetPIPointDataReference();
65 | usage.ConfigString = @".\Elements[.]|Energy Usage;TimeRangeMethod=Average";
66 | usage.DefaultUOM = database.PISystem.UOMDatabase.UOMs["kilowatt hour"];
67 |
68 | if (database.IsDirty)
69 | database.CheckIn();
70 |
71 | return eventFrameTemplate;
72 | }
73 |
74 | public static void CreateEventFrames(AFDatabase database, AFElementTemplate eventFrameTemplate)
75 | {
76 | if (database == null) throw new ArgumentNullException(nameof(database));
77 | if (eventFrameTemplate == null) throw new ArgumentNullException(nameof(eventFrameTemplate));
78 |
79 | // Your code here
80 | }
81 |
82 | public static void CaptureValues(AFDatabase database, AFElementTemplate eventFrameTemplate)
83 | {
84 | if (database == null) throw new ArgumentNullException(nameof(database));
85 | if (eventFrameTemplate == null) throw new ArgumentNullException(nameof(eventFrameTemplate));
86 |
87 | // Your code here
88 | }
89 |
90 | public static void PrintReport(AFDatabase database, AFElementTemplate eventFrameTemplate)
91 | {
92 | if (database == null) throw new ArgumentNullException(nameof(database));
93 | if (eventFrameTemplate == null) throw new ArgumentNullException(nameof(eventFrameTemplate));
94 |
95 | // Your code here
96 | }
97 |
98 | public static void Setup()
99 | {
100 | AppSettings settings = JsonSerializer.Deserialize(File.ReadAllText(Directory.GetCurrentDirectory() + "/appsettings.json"));
101 |
102 | // ==== Client constants ====
103 | AFServer = settings.AFServerName;
104 | DatabaseString = settings.AFDatabaseName;
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/Ex5-Working-With-EventFrames/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Ex5")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Ex5")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("336c7e54-66c9-45c0-8bb8-fa9b3a3cb0fc")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Ex5-Working-With-EventFrames/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Getting-Started-With-PI-AF-SDK.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30320.27
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex1-Connection-And-Hierarchy-Basics", "Ex1-Connection-And-Hierarchy-Basics\Ex1-Connection-And-Hierarchy-Basics.csproj", "{B8A590E4-2FC6-40ED-9AEF-07652B8EEC8F}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex1-Connection-And-Hierarchy-Basics-Sln", "Ex1-Connection-And-Hierarchy-Basics-Sln\Ex1-Connection-And-Hierarchy-Basics-Sln.csproj", "{ABB540D9-4B9F-4A83-9578-5E33EE7C5CF6}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex2-Searching-For-Assets", "Ex2-Searching-For-Assets\Ex2-Searching-For-Assets.csproj", "{2DFDAF54-68AC-4361-B173-CE5899B455D0}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex2-Searching-For-Assets-Sln", "Ex2-Searching-For-Assets-Sln\Ex2-Searching-For-Assets-Sln.csproj", "{A26EEA96-303C-4EF3-B109-09F66462791F}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex4-Building-An-AF-Hierarchy", "Ex4-Building-An-AF-Hierarchy\Ex4-Building-An-AF-Hierarchy.csproj", "{E649E492-A683-4EFE-864E-F5176C934F55}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex4-Building-An-AF-Hierarchy-Sln", "Ex4-Building-An-AF-Hierarchy-Sln\Ex4-Building-An-AF-Hierarchy-Sln.csproj", "{7A8A9C6A-1626-431D-A06A-B242C8FAAD01}"
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex5-Working-With-Event-Frames", "Ex5-Working-With-EventFrames\Ex5-Working-With-Event-Frames.csproj", "{336C7E54-66C9-45C0-8BB8-FA9B3A3CB0FC}"
19 | EndProject
20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex5-Working-With-Event-Frames-Sln", "Ex5-Working-With-Event-Frames-Sln\Ex5-Working-With-Event-Frames-Sln.csproj", "{FF41DBFC-2BF3-4786-9A9A-6F13B4328CEF}"
21 | EndProject
22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex3-Reading-And-Writing-Data", "Ex3-Reading-And-Writing-Data\Ex3-Reading-And-Writing-Data.csproj", "{EBA8F603-D688-4689-AA57-41736EBD894F}"
23 | EndProject
24 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ex3-Reading-And-Writing-Data-Sln", "Ex3-Reading-And-Writing-Data-Sln\Ex3-Reading-And-Writing-Data-Sln.csproj", "{ECB4566E-725E-4DAF-8543-29FCAF38FF1A}"
25 | EndProject
26 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DA7066DE-0347-4F9B-A235-40A6F05F6A4F}"
27 | ProjectSection(SolutionItems) = preProject
28 | AF Database - Green Power Company.xml = AF Database - Green Power Company.xml
29 | appsettings.json = appsettings.json
30 | appsettings.placeholder.json = appsettings.placeholder.json
31 | azure-pipeline.yml = azure-pipeline.yml
32 | Directory.Build.props = Directory.Build.props
33 | Extensions.ruleset = Extensions.ruleset
34 | HISTORY.md = HISTORY.md
35 | OSIsoft.ruleset = OSIsoft.ruleset
36 | polaris.yml = polaris.yml
37 | README.md = README.md
38 | stylecop.json = stylecop.json
39 | EndProjectSection
40 | EndProject
41 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{F4CBCAD0-E883-4EDC-91D3-D032EEA2A7E4}"
42 | EndProject
43 | Global
44 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
45 | Debug|Any CPU = Debug|Any CPU
46 | Release|Any CPU = Release|Any CPU
47 | EndGlobalSection
48 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
49 | {B8A590E4-2FC6-40ED-9AEF-07652B8EEC8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50 | {B8A590E4-2FC6-40ED-9AEF-07652B8EEC8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
51 | {B8A590E4-2FC6-40ED-9AEF-07652B8EEC8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
52 | {B8A590E4-2FC6-40ED-9AEF-07652B8EEC8F}.Release|Any CPU.Build.0 = Release|Any CPU
53 | {ABB540D9-4B9F-4A83-9578-5E33EE7C5CF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54 | {ABB540D9-4B9F-4A83-9578-5E33EE7C5CF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
55 | {ABB540D9-4B9F-4A83-9578-5E33EE7C5CF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
56 | {ABB540D9-4B9F-4A83-9578-5E33EE7C5CF6}.Release|Any CPU.Build.0 = Release|Any CPU
57 | {2DFDAF54-68AC-4361-B173-CE5899B455D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
58 | {2DFDAF54-68AC-4361-B173-CE5899B455D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
59 | {2DFDAF54-68AC-4361-B173-CE5899B455D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
60 | {2DFDAF54-68AC-4361-B173-CE5899B455D0}.Release|Any CPU.Build.0 = Release|Any CPU
61 | {A26EEA96-303C-4EF3-B109-09F66462791F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
62 | {A26EEA96-303C-4EF3-B109-09F66462791F}.Debug|Any CPU.Build.0 = Debug|Any CPU
63 | {A26EEA96-303C-4EF3-B109-09F66462791F}.Release|Any CPU.ActiveCfg = Release|Any CPU
64 | {A26EEA96-303C-4EF3-B109-09F66462791F}.Release|Any CPU.Build.0 = Release|Any CPU
65 | {E649E492-A683-4EFE-864E-F5176C934F55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66 | {E649E492-A683-4EFE-864E-F5176C934F55}.Debug|Any CPU.Build.0 = Debug|Any CPU
67 | {E649E492-A683-4EFE-864E-F5176C934F55}.Release|Any CPU.ActiveCfg = Release|Any CPU
68 | {E649E492-A683-4EFE-864E-F5176C934F55}.Release|Any CPU.Build.0 = Release|Any CPU
69 | {7A8A9C6A-1626-431D-A06A-B242C8FAAD01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
70 | {7A8A9C6A-1626-431D-A06A-B242C8FAAD01}.Debug|Any CPU.Build.0 = Debug|Any CPU
71 | {7A8A9C6A-1626-431D-A06A-B242C8FAAD01}.Release|Any CPU.ActiveCfg = Release|Any CPU
72 | {7A8A9C6A-1626-431D-A06A-B242C8FAAD01}.Release|Any CPU.Build.0 = Release|Any CPU
73 | {336C7E54-66C9-45C0-8BB8-FA9B3A3CB0FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
74 | {336C7E54-66C9-45C0-8BB8-FA9B3A3CB0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
75 | {336C7E54-66C9-45C0-8BB8-FA9B3A3CB0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
76 | {336C7E54-66C9-45C0-8BB8-FA9B3A3CB0FC}.Release|Any CPU.Build.0 = Release|Any CPU
77 | {FF41DBFC-2BF3-4786-9A9A-6F13B4328CEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
78 | {FF41DBFC-2BF3-4786-9A9A-6F13B4328CEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
79 | {FF41DBFC-2BF3-4786-9A9A-6F13B4328CEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
80 | {FF41DBFC-2BF3-4786-9A9A-6F13B4328CEF}.Release|Any CPU.Build.0 = Release|Any CPU
81 | {EBA8F603-D688-4689-AA57-41736EBD894F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
82 | {EBA8F603-D688-4689-AA57-41736EBD894F}.Debug|Any CPU.Build.0 = Debug|Any CPU
83 | {EBA8F603-D688-4689-AA57-41736EBD894F}.Release|Any CPU.ActiveCfg = Release|Any CPU
84 | {EBA8F603-D688-4689-AA57-41736EBD894F}.Release|Any CPU.Build.0 = Release|Any CPU
85 | {ECB4566E-725E-4DAF-8543-29FCAF38FF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
86 | {ECB4566E-725E-4DAF-8543-29FCAF38FF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
87 | {ECB4566E-725E-4DAF-8543-29FCAF38FF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
88 | {ECB4566E-725E-4DAF-8543-29FCAF38FF1A}.Release|Any CPU.Build.0 = Release|Any CPU
89 | {F4CBCAD0-E883-4EDC-91D3-D032EEA2A7E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
90 | {F4CBCAD0-E883-4EDC-91D3-D032EEA2A7E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
91 | {F4CBCAD0-E883-4EDC-91D3-D032EEA2A7E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
92 | {F4CBCAD0-E883-4EDC-91D3-D032EEA2A7E4}.Release|Any CPU.Build.0 = Release|Any CPU
93 | EndGlobalSection
94 | GlobalSection(SolutionProperties) = preSolution
95 | HideSolutionNode = FALSE
96 | EndGlobalSection
97 | GlobalSection(ExtensibilityGlobals) = postSolution
98 | SolutionGuid = {1634ED74-B3E1-4392-9981-36EA2177008D}
99 | EndGlobalSection
100 | EndGlobal
101 |
--------------------------------------------------------------------------------
/HISTORY.md:
--------------------------------------------------------------------------------
1 | # Version History
2 |
3 | ## 1.1.2 / 2022-09-28
4 |
5 | - Updated dependencies
6 |
7 | ## 1.1.1 / 2022-03-04
8 |
9 | - Changed pipeline AF database name
10 |
11 | ## 1.1.0 / 2022-02-28
12 |
13 | - Updated dependencies
14 | - Migrated build agent
15 | - Updated analyses
16 | - Removed dependency on Microsoft.Extensions.Configuration
17 |
18 | ## 1.0.4 / 2021-10-11
19 |
20 | - Updated pipelines to use Azure Key Vault for secrets
21 | - Changed parameter names in appsettings.json
22 |
23 | ## 1.0.3 / 2021-08-10
24 |
25 | - Updated gitignore
26 |
27 | ## 1.0.2 / 2021-07-26
28 |
29 | - Migrated from master to main branch
30 |
31 | ## 1.0.1 / 2021-07-19
32 |
33 | - Updated dependencies
34 |
35 | ## 1.0.0 / 2021-01-11
36 |
37 | - Initial commit
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AFSDK Getting Started Guide
2 |
3 | **Version:** 1.1.2
4 |
5 | [](https://dev.azure.com/osieng/engineering/_build/latest?definitionId=2251&branchName=main)
6 |
7 | This sample uses the AFSDK to accomplish some common tasks with the PISystem.
8 |
9 | ## Requirements
10 |
11 | The [.NET Core CLI](https://docs.microsoft.com/en-us/dotnet/core/tools/) is referenced in this sample, and should be installed to run the sample from the command line.
12 |
13 | Replace the placeholders in the appsettings.placeholder.json file and rename it it to appsettings.json.
14 |
15 | This sample is written against AF 2.10.
16 |
17 | ## Setting up the environment
18 |
19 | 1. Clone the GitHub repository
20 | 1. Start PI System Explorer
21 | 1. File > Database
22 | 1. New Database
23 | 1. Name it: Green Power Company
24 | 1. Ok then close
25 | 1. File > import from file
26 | 1. Select downloaded 'AF Database - Green Power Company.xml'
27 | 1. Select create pi points
28 | 1. Import the data
29 | 1. Navigate to new database
30 | 1. Enable Analysis
31 |
32 | ## Sample
33 |
34 | This sample is based off of a PI World class and it includes projects that need to be filled out and completed pojects. The completed solutions to the skeleton projects are just one way you can accomplish the tasks set for the exercise. For instructions about what is expected to be filled go go [here](https://livelibrary.osisoft.com/LiveLibrary/web/pub.xql?c=t&action=home&pub=af-sdk-getting-started-v1&lang=en#addHistory=true&filename=GUID-781248C8-0952-4393-9F44-C9BFCDA54364.xml&docid=GUID-5EEFEEBC-A4EE-40D4-B8F9-21049E7F7C41&inner_id=&tid=&query=&scope=&resource=&toc=false&eventType=lcContent.loadDocGUID-5EEFEEBC-A4EE-40D4-B8F9-21049E7F7C41). Included in this samples are tests you can run against both the completed samples and the skeleton code to be filled in to see if your code works as expected. The tests are reasonably exact in making sure it was followed, given that timestamps and values are not predetermined.
35 |
36 | As indicated above, there is a provided AF database, 'AF Database - Green Power Company.xml', that you need to use for this sample.
37 |
38 | ## Running the Automated Test
39 |
40 | From the command line, run:
41 |
42 | ```shell
43 | dotnet restore
44 | dotnet test
45 | ```
46 |
47 | This runs all of the tests for all completed solutions. You can also configure this command to run a subset of the tests.
48 |
49 | ```shell
50 | dotnet restore
51 | dotnet test --filter Category~Solution
52 | ```
53 |
54 | Depending on the exercise, the test either does a unit test or an integrated test. The unit tests make sure functions behave as expected based on expected inputs and outputs, while integrated tests make sure the whole solution and the underlying functions behave as expected when run in sequence.
55 |
56 | ---
57 |
58 | For the PI System landing page [ReadMe](https://github.com/osisoft/OSI-Samples-PI-System)
59 | For the OSIsoft Samples landing page [ReadMe](https://github.com/osisoft/OSI-Samples)
60 |
--------------------------------------------------------------------------------
/Tests/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Tests
4 | {
5 | public class AppSettings
6 | {
7 | ///
8 | /// The name of the AF Server to use
9 | ///
10 | public string AFServerName { get; set; }
11 |
12 | ///
13 | /// The name of the AF Database to use
14 | ///
15 | public string AFDatabaseName { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Tests")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("f4cbcad0-e883-4edc-91d3-d032eea2a7e4")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Tests/Tests.GeneratedMSBuildEditorConfig.editorconfig:
--------------------------------------------------------------------------------
1 | is_global = true
2 | build_property.TargetFramework =
3 | build_property.TargetPlatformMinVersion =
4 | build_property.UsingMicrosoftNETSdkWeb =
5 | build_property.ProjectTypeGuids =
6 | build_property.PublishSingleFile =
7 | build_property.IncludeAllContentForSelfExtract =
8 | build_property._SupportedPlatformList =
9 |
--------------------------------------------------------------------------------
/Tests/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/appsettings.placeholder.json:
--------------------------------------------------------------------------------
1 | {
2 | "AFServerName": "PLACEHOLDER_REPLACE_WITH_AF_SERVER_NAME",
3 | "AFDatabaseName": "PLACEHOLDER_REPLACE_WITH_AF_DATABASE_NAME"
4 | }
5 |
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | trigger:
2 | batch: true
3 | branches:
4 | include:
5 | - main
6 |
7 | pr:
8 | branches:
9 | include:
10 | - main
11 |
12 | schedules:
13 | - cron: '0 0 * * 0'
14 | displayName: Weekly build
15 | branches:
16 | include:
17 | - main
18 | always: true
19 |
20 | resources:
21 | repositories:
22 | - repository: OpsGuildAutomationRepo
23 | type: git
24 | name: Engineering/OpsGuild.Automation
25 | ref: refs/heads/main
26 | - repository: OpsGuildPipelineTools
27 | type: git
28 | name: Engineering/opsguild.pipeline-tools
29 | ref: refs/heads/main
30 | - repository: templates
31 | type: github
32 | name: osisoft/OSI-Samples
33 | endpoint: osisoft/OSI-Samples
34 |
35 | variables:
36 | - template: '/miscellaneous/build_templates/variables.yml@templates'
37 | - name: analysisProject
38 | value: PI_AFGSG_DotNet
39 | - name: run_import
40 | value: false
41 | - name: run_delete
42 | value: false
43 |
44 | jobs:
45 | - job: Tests
46 | pool:
47 | name: 00-OSIManaged-Containers
48 | demands: Agent.OS -equals Windows_NT
49 | variables:
50 | - name: AFDatabaseName
51 | value: $(AFDatabaseNameAFGSG)
52 | steps:
53 | - checkout: self
54 | - checkout: OpsGuildPipelineTools
55 |
56 | - template: '/miscellaneous/build_templates/appsettings.yml@templates'
57 | parameters:
58 | secrets: 'AFServerName, AFDatabaseNameAFGSG'
59 |
60 | - template: '/Templates/Utilities/InstallAFSDK.step.v0.yml@OpsGuildPipelineTools'
61 |
62 | - script: |
63 | for /D %%a in (".\*.*") do xcopy /y /d appsettings.json "%%a\"
64 | displayName: 'copy file to subfolders'
65 | workingDirectory: $(Build.SourcesDirectory)\AF-SDK-Getting-Started-Guide
66 |
67 | - script: |
68 | "%pihome64%\af\afimport" "\\OCSSAMPLESAPI01\Green Power Company" /F:"AF Database - Green Power Company.xml" /P
69 | condition: eq(variables.run_import, true)
70 | displayName: 'import database2'
71 | workingDirectory: $(Build.SourcesDirectory)\AF-SDK-Getting-Started-Guide
72 |
73 | - script: |
74 | nuget restore
75 | displayName: 'Nuget restore'
76 | workingDirectory: $(Build.SourcesDirectory)\AF-SDK-Getting-Started-Guide
77 |
78 | - task: DotNetCoreCLI@2
79 | displayName: 'Run tests'
80 | inputs:
81 | command: test
82 | arguments: --filter Category=Solution
83 | publishTestResults: true
84 | testRunTitle: '$(Agent.JobName) on $(Agent.OS)'
85 | projects: '$(Build.SourcesDirectory)\AF-SDK-Getting-Started-Guide\Getting-Started-With-PI-AF-SDK.sln'
86 |
87 | - task: DotNetCoreCLI@2
88 | displayName: 'Run Delete'
89 | condition: eq(variables.run_delete, true)
90 | inputs:
91 | command: test
92 | arguments: --filter Category=Delete
93 | publishTestResults: true
94 | testRunTitle: '$(Agent.JobName) on $(Agent.OS) (Delete)'
95 |
96 | - template: '/miscellaneous/build_templates/code-analysis.yml@templates'
97 | parameters:
98 | projectPath: '\AF-SDK-Getting-Started-Guide'
99 | buildSteps:
100 | - checkout: self
101 | - checkout: OpsGuildPipelineTools
102 |
103 | - template: '/Templates/Utilities/InstallAFSDK.step.v0.yml@OpsGuildPipelineTools'
104 |
105 | - template: '/miscellaneous/build_templates/appsettings.yml@templates'
106 |
107 | - script: |
108 | for /D %%a in (".\*.*") do xcopy /y /d appsettings.json "%%a\"
109 | displayName: 'copy file to subfolders'
110 | workingDirectory: $(Build.SourcesDirectory)\AF-SDK-Getting-Started-Guide
111 |
112 | - task: NuGetCommand@2
113 | displayName: 'nuget restore'
114 | inputs:
115 | command: 'restore'
116 | restoreSolution: '**/*.sln'
117 |
118 | - task: VSBuild@1
119 | displayName: 'Build solution'
120 | inputs:
121 | vsVersion: 16.0
122 |
123 | - template: '/miscellaneous/build_templates/binskim.yml@templates'
124 | parameters:
125 | deleteBinSkim: 'AFSDKInstallKit/*'
126 |
--------------------------------------------------------------------------------
/polaris.yml:
--------------------------------------------------------------------------------
1 | version: '1'
2 | serverUrl: https://osisoft.polaris.synopsys.com
3 | install:
4 | coverity:
5 | version: default
6 | project:
7 | organization: osisoft
8 | name: ${env.POLARIS_PROJECT_NAME}
9 | branch: ${scm.git.branch}
10 | revision:
11 | name: ${scm.git.commit}
12 | date: ${scm.git.commit.date}
13 | capture:
14 | coverity:
15 | buildless:
16 | project:
17 | languages:
18 | - cs
19 | analyze:
20 | mode: central
21 |
--------------------------------------------------------------------------------
/stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3 | "settings": {
4 | "namingRules": {
5 | "allowedHungarianPrefixes": [
6 | "af",
7 | "ai",
8 | "db",
9 | "dr",
10 | "ef",
11 | "ex",
12 | "id",
13 | "ip",
14 | "my",
15 | "ns",
16 | "ok",
17 | "pi"
18 | ]
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------