├── PI-AF-SDK-Basic-Samples
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── PI-AF-SDK-Basic-Samples-Console.csproj
├── ExamplesLibrary
├── IExample.cs
├── ConnectionExamples
│ ├── PIConnectionExample.cs
│ └── AFConnectionExample.cs
├── Properties
│ └── AssemblyInfo.cs
├── ReadingValuesExamples
│ ├── ReadFromPIExample.cs
│ └── ReadFromAFExample.cs
├── AFAttributeExamples
│ ├── FindAttributeWalkDownExample.cs
│ ├── FindAttributesByPathExample.cs
│ └── FindElementAttributesExample.cs
├── PIPointExamples
│ ├── CreatePIPointsExample.cs
│ └── FindPIPointsExample.cs
├── AFElementExamples
│ ├── FindElementsExample.cs
│ ├── LoadElementsExample.cs
│ └── PartialLoadElementsExample.cs
├── AFEventFrameExamples
│ ├── FindEventFramesExample.cs
│ └── CreateEventFrameExample.cs
├── WriteValuesExample
│ ├── WriteValuesUsingPIExample.cs
│ └── WriteValuesUsingAFExample.cs
├── ExamplesLibrary.csproj
└── BuildAFDatabaseExamples
│ └── BuildSimpleDatabaseExample.cs
├── PI-AF-SDK-Basic-Samples.sln
├── .gitattributes
├── .gitignore
├── README.md
└── LICENSE.MD
/PI-AF-SDK-Basic-Samples/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ExamplesLibrary/IExample.cs:
--------------------------------------------------------------------------------
1 | namespace ExamplesLibrary
2 | {
3 | ///
4 | /// All examples should implement this interface.
5 | /// The Console application should call the Run() method on this interface.
6 | ///
7 | public interface IExample
8 | {
9 | void Run();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/PI-AF-SDK-Basic-Samples/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ExamplesLibrary;
3 |
4 |
5 | namespace PI_AF_SDK_Basic_Samples
6 | {
7 | ///
8 | /// Choose the example you want run by creating a new object of the example type.
9 | /// For instances, the example below runs the AFConnection example.
10 | /// Before running the examples, please replace the AF Server or PI Data Archive name with your own.
11 | ///
12 | class Program
13 | {
14 | static void Main(string[] args)
15 | {
16 | IExample example = new AFConnectionExample();
17 | example.Run();
18 |
19 | Console.WriteLine();
20 | Console.WriteLine("Press any key to end");
21 | Console.ReadKey();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ExamplesLibrary/ConnectionExamples/PIConnectionExample.cs:
--------------------------------------------------------------------------------
1 | using OSIsoft.AF.PI;
2 |
3 |
4 | namespace ExamplesLibrary
5 | {
6 | ///
7 | /// This example demonstrates making a connection to an PI Data Archive using an implicit connection and an explicit connection.
8 | ///
9 | ///
10 | /// none
11 | ///
12 | public class PIConnectionExample : IExample
13 | {
14 | public void Run()
15 | {
16 | ImplicitConnection();
17 | ExplicitConnection();
18 | }
19 |
20 | public void ImplicitConnection()
21 | {
22 | PIServers piServers = new PIServers();
23 | PIServer piServer = piServers["PIServerName"];
24 | // At this point, no connection is made.
25 |
26 | PIPoint piPoint = PIPoint.FindPIPoint(piServer, "sinusoid");
27 | // Now a connection is made by first data access.
28 | }
29 |
30 | public void ExplicitConnection()
31 | {
32 | PIServers piServers = new PIServers();
33 | PIServer piServer = piServers["PIServerName"];
34 | // At this point, no connection is made.
35 |
36 | piServer.Connect();
37 | // Now a connection is made by explicit call.
38 |
39 | PIPoint piPoint = PIPoint.FindPIPoint(piServer, "sinusoid");
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/ExamplesLibrary/ConnectionExamples/AFConnectionExample.cs:
--------------------------------------------------------------------------------
1 | using OSIsoft.AF;
2 | using OSIsoft.AF.Asset;
3 |
4 |
5 | namespace ExamplesLibrary
6 | {
7 | ///
8 | /// This example demonstrates making a connection to an AF Server using an implicit connection and an explicit connection.
9 | ///
10 | ///
11 | /// none
12 | ///
13 | public class AFConnectionExample : IExample
14 | {
15 | public void Run()
16 | {
17 | ImplicitConnection();
18 | ExplicitConnection();
19 | }
20 |
21 | private void ImplicitConnection()
22 | {
23 | PISystems piSystems = new PISystems();
24 | PISystem piSystem = piSystems[""];
25 | // At this point, no connection is made.
26 |
27 | AFAttribute afAttribute = AFAttribute.FindAttribute(@"NuGreen\NuGreen\Houston|Environment", piSystem);
28 | // Now a connection is made by first data access.
29 | }
30 |
31 | private void ExplicitConnection()
32 | {
33 | PISystems piSystems = new PISystems();
34 | PISystem piSystem = piSystems[""];
35 | // At this point, no connection is made.
36 |
37 | piSystem.Connect();
38 | // Now a connection is made by explicit call.
39 |
40 | AFAttribute afAttribute = AFAttribute.FindAttribute(@"NuGreen\NuGreen\Houston|Environment", piSystem);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ExamplesLibrary/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("ExamplesLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ExamplesLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("7f3b7e46-6c71-47f2-97ba-f28b1e79d879")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/PI-AF-SDK-Basic-Samples/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("PI-AF-SDK-Basic-Samples")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("PI-AF-SDK-Basic-Samples")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("62331726-9c1f-42b0-9228-9912173cb83c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ExamplesLibrary/ReadingValuesExamples/ReadFromPIExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using OSIsoft.AF;
4 | using OSIsoft.AF.Asset;
5 | using OSIsoft.AF.PI;
6 |
7 |
8 | namespace ExamplesLibrary
9 | {
10 | ///
11 | /// Retrieving values from PIPoints is best done in bulk.
12 | /// By bulk retrieving the data, the number of round-trips to the PI Data Archive are reduced.
13 | /// This example makes a bulk snapshot call for SINUSOID, SINUSOIDU, CDT158, and CDM158 PI Points.
14 | ///
15 | ///
16 | /// none
17 | ///
18 | public class ReadFromPIExample : IExample
19 | {
20 | public void Run()
21 | {
22 | PIServers piServers = new PIServers();
23 | PIServer piServer = piServers[""];
24 |
25 | IList points = PIPoint.FindPIPoints(piServer, new[] { "sinusoid", "sinusoidu", "cdt158", "cdm158" });
26 |
27 | // Create an PIPointList object in order to make the bulk call later.
28 | PIPointList pointList = new PIPointList(points);
29 |
30 | if (pointList == null) return;
31 |
32 | // MAKE A BULK CALL TO THE PI DATA ARCHIVE
33 | AFListResults values = pointList.CurrentValue(); // Requires AF SDK 2.7+
34 |
35 | foreach (AFValue val in values)
36 | {
37 | Console.WriteLine("Point: {0}, Timestamp: {1}, Value: {2}", val.PIPoint, val.Timestamp, val.Value.ToString());
38 | }
39 | }
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/ExamplesLibrary/AFAttributeExamples/FindAttributeWalkDownExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.Asset;
4 |
5 |
6 | namespace ExamplesLibrary
7 | {
8 | ///
9 | /// This example "walks-down" the AF hierarchy to locate an attribute of interest and then get its current value.
10 | /// The target attribute is \\Server\NuGreen\NuGreen\Houston\Cracking Process\Equipment\B-210|Process Feedrate.
11 | /// There are more direct methods to find this attribute, but this example is merely to demonstrate the behavior of
12 | /// some basic operations.
13 | /// Contrast this example with DirectLocateExample.
14 | ///
15 | ///
16 | /// none
17 | ///
18 | public class FindAttributeWalkDownExample : IExample
19 | {
20 | public void Run()
21 | {
22 | PISystems piSystems = new PISystems();
23 | PISystem piSystem = piSystems[""];
24 |
25 | AFDatabase afDatabase = piSystem.Databases["NuGreen"];
26 |
27 | AFElement nuGreen = afDatabase.Elements["NuGreen"];
28 | AFElement houston = nuGreen.Elements["Houston"];
29 | AFElement crackingProcess = houston.Elements["Cracking Process"];
30 | AFElement equipment = crackingProcess.Elements["Equipment"];
31 | AFElement b210 = equipment.Elements["B-210"];
32 |
33 | AFAttribute processFeedRate = b210.Attributes["Process Feedrate"];
34 |
35 | AFValue val = processFeedRate.GetValue();
36 |
37 | Console.WriteLine("Timestamp: {0}, Value: {1}", val.Timestamp, val.Value.ToString());
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/PI-AF-SDK-Basic-Samples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.23107.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PI-AF-SDK-Basic-Samples-Console", "PI-AF-SDK-Basic-Samples\PI-AF-SDK-Basic-Samples-Console.csproj", "{62331726-9C1F-42B0-9228-9912173CB83C}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExamplesLibrary", "ExamplesLibrary\ExamplesLibrary.csproj", "{7F3B7E46-6C71-47F2-97BA-F28B1E79D879}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9EFAAAF2-D85C-4370-9E2D-2A35F821A982}"
11 | ProjectSection(SolutionItems) = preProject
12 | NuGreen.xml = NuGreen.xml
13 | EndProjectSection
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Any CPU = Debug|Any CPU
18 | Release|Any CPU = Release|Any CPU
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {62331726-9C1F-42B0-9228-9912173CB83C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {62331726-9C1F-42B0-9228-9912173CB83C}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {62331726-9C1F-42B0-9228-9912173CB83C}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {62331726-9C1F-42B0-9228-9912173CB83C}.Release|Any CPU.Build.0 = Release|Any CPU
25 | {7F3B7E46-6C71-47F2-97BA-F28B1E79D879}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {7F3B7E46-6C71-47F2-97BA-F28B1E79D879}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {7F3B7E46-6C71-47F2-97BA-F28B1E79D879}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {7F3B7E46-6C71-47F2-97BA-F28B1E79D879}.Release|Any CPU.Build.0 = Release|Any CPU
29 | EndGlobalSection
30 | GlobalSection(SolutionProperties) = preSolution
31 | HideSolutionNode = FALSE
32 | EndGlobalSection
33 | EndGlobal
34 |
--------------------------------------------------------------------------------
/ExamplesLibrary/AFAttributeExamples/FindAttributesByPathExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.Asset;
4 |
5 |
6 | namespace ExamplesLibrary
7 | {
8 | ///
9 | /// This example locates an attribute of interest and then get its current value.
10 | /// The target attribute is \\AFServer\NuGreen\NuGreen\Houston\Cracking Process\Equipment\B-210|Process Feedrate.
11 | /// The alternative is traversing down the AF hierarchy, as shown in HierarchyWalkDownExample.
12 | ///
13 | ///
14 | /// none
15 | ///
16 | public class FindAttributesByPathExample : IExample
17 | {
18 | public void Run()
19 | {
20 | string processFeedRate = @"\\\NuGreen\NuGreen\Houston\Cracking Process\Equipment\B-210|Process Feedrate";
21 | string waterFlow = @"\\\NuGreen\NuGreen\Houston\Cracking Process\Equipment\B-210|Water Flow";
22 |
23 | // Directly locate the AFAttribute of interest by passing in the AF path.
24 | // A similar method FindElementsByPath can be used to directly locate elements.
25 | AFKeyedResults results = AFAttribute.FindAttributesByPath(new[] { processFeedRate, waterFlow }, null);
26 |
27 | AFAttribute processFeedRateAttribute = results[processFeedRate];
28 | AFAttribute waterFlowAttribute = results[waterFlow];
29 |
30 | AFAttributeList attrList = new AFAttributeList(new[] { processFeedRateAttribute, waterFlowAttribute });
31 | // Make a bulk call to get values.
32 | AFValues values = attrList.GetValue();
33 |
34 | foreach (AFValue val in values)
35 | {
36 | Console.WriteLine("Attribute: {0}", val.Attribute);
37 | Console.WriteLine("Timestamp: {0}, Value: {1}", val.Timestamp, val.Value.ToString());
38 | Console.WriteLine();
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/ExamplesLibrary/PIPointExamples/CreatePIPointsExample.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.PI;
4 |
5 |
6 | namespace ExamplesLibrary
7 | {
8 | ///
9 | /// This example creates a floating and digital PI Point on the server.
10 | ///
11 | ///
12 | /// none
13 | ///
14 | public class CreatePIPointsExample : IExample
15 | {
16 | public void Run()
17 | {
18 | PIServers piServers = new PIServers();
19 | PIServer piServer = piServers[""];
20 |
21 | // Use PICommonPointAttributes so we don't have to remember the strings for point attributes.
22 |
23 | string floatpoint = "sample_floatpoint";
24 | Dictionary floatpoint_attributes = new Dictionary();
25 | floatpoint_attributes.Add(PICommonPointAttributes.PointClassName, "classic");
26 | floatpoint_attributes.Add(PICommonPointAttributes.Descriptor, "Hello floating world");
27 | floatpoint_attributes.Add(PICommonPointAttributes.PointType, "float32");
28 |
29 | string digitalpoint = "sample_digitalpoint";
30 | Dictionary digitalpoint_attributes = new Dictionary();
31 | digitalpoint_attributes.Add(PICommonPointAttributes.PointClassName, "classic");
32 | digitalpoint_attributes.Add(PICommonPointAttributes.Descriptor, "Hello digital world");
33 | digitalpoint_attributes.Add(PICommonPointAttributes.PointType, "digital");
34 | digitalpoint_attributes.Add(PICommonPointAttributes.DigitalSetName, "modes");
35 |
36 | Dictionary> pointDict = new Dictionary>();
37 | pointDict.Add(floatpoint, floatpoint_attributes);
38 | pointDict.Add(digitalpoint, digitalpoint_attributes);
39 |
40 | AFListResults results = piServer.CreatePIPoints(pointDict);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ExamplesLibrary/AFElementExamples/FindElementsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.Asset;
4 |
5 |
6 | namespace ExamplesLibrary
7 | {
8 | ///
9 | /// Find a collection of elements instantiated from the Boiler template.
10 | /// Print each found element name to the console.
11 | ///
12 | ///
13 | /// none
14 | ///
15 | public class FindElementsExample : IExample
16 | {
17 | public void Run()
18 | {
19 | PISystems piSystems = new PISystems();
20 | PISystem piSystem = piSystems[""];
21 |
22 | AFDatabase afDatabase = piSystem.Databases["NuGreen"];
23 |
24 | const int pageSize = 1000;
25 | int startIndex = 0;
26 | int totalCount;
27 | do
28 | {
29 | // Find a collection of elements instantiated from the Boiler tempplate.
30 | // Only the Elements' header information (Name, Description, Template, Type, etc.)
31 | // are loaded from the AF Server by this call.
32 | AFNamedCollection elements = AFElement.FindElements(
33 | database: afDatabase,
34 | searchRoot: null,
35 | query: "Boiler",
36 | field: AFSearchField.Template,
37 | searchFullHierarchy: true,
38 | sortField: AFSortField.Name,
39 | sortOrder: AFSortOrder.Ascending,
40 | startIndex: startIndex,
41 | maxCount: pageSize,
42 | totalCount: out totalCount);
43 | if (elements == null) break;
44 |
45 | // Because we are just retrieving the element's name, no additional calls
46 | // to the AF Server are made.
47 | Console.WriteLine("Found {0} Elements.", elements.Count);
48 | foreach (AFElement item in elements)
49 | {
50 | Console.WriteLine(" Element name is {0}.", item.Name);
51 | }
52 |
53 | startIndex += pageSize;
54 |
55 | } while (startIndex < totalCount);
56 |
57 | }
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/ExamplesLibrary/AFEventFrameExamples/FindEventFramesExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.Asset;
4 | using OSIsoft.AF.EventFrame;
5 |
6 |
7 | namespace ExamplesLibrary
8 | {
9 | ///
10 | /// This example retrieves 2 event frames created previously by CreateEventFramesExample.
11 | ///
12 | ///
13 | /// BuildSimpleDatabaseExample, CreateEventFramesExample
14 | ///
15 | public class FindEventFramesExample : IExample
16 | {
17 | public void Run()
18 | {
19 | PISystems piSystems = new PISystems();
20 | PISystem piSystem = piSystems[""];
21 |
22 | AFDatabase afDatabase = piSystem.Databases["Basic-AFSDK-Sample"];
23 |
24 | const int pageSize = 1000;
25 | int startIndex = 0;
26 | int returnLimit = 100000;
27 | do
28 | {
29 | AFElementTemplate efTemplate = afDatabase.ElementTemplates["BasicEventFrameTemplate"];
30 |
31 | // Get event frames that started the past two days.
32 | AFNamedCollectionList eventFrames = AFEventFrame.FindEventFrames(
33 | database: afDatabase,
34 | searchRoot: null,
35 | startTime: "t-2d",
36 | startIndex: startIndex,
37 | maxCount: pageSize,
38 | searchMode: AFEventFrameSearchMode.ForwardFromStartTime,
39 | nameFilter: "*",
40 | referencedElementNameFilter: "BoilerA",
41 | elemCategory: null,
42 | elemTemplate: efTemplate,
43 | searchFullHierarchy: true);
44 |
45 | foreach (AFEventFrame ef in eventFrames)
46 | {
47 | //Note: We should make a bulk call on the attribute values via AFAttributeList if we had many event frames.
48 | Console.WriteLine("Name: {0}, Start: {1}, End: {2}, Max temp: {3}",
49 | ef.Name, ef.StartTime, ef.EndTime, ef.Attributes["Maximum temperature"].GetValue());
50 | }
51 |
52 | startIndex += pageSize;
53 |
54 | } while (startIndex < returnLimit);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ExamplesLibrary/WriteValuesExample/WriteValuesUsingPIExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using OSIsoft.AF.Asset;
4 | using OSIsoft.AF.Data;
5 | using OSIsoft.AF.PI;
6 | using OSIsoft.AF.Time;
7 |
8 |
9 | namespace ExamplesLibrary
10 | {
11 | ///
12 | /// This example demonstrates how to write values to the PI Data Archive using the methods in OSIsoft.AF.PI.
13 | /// An example for numeric and digital tags is given.
14 | ///
15 | ///
16 | /// CreatePIPointsExample
17 | ///
18 | public class WriteValuesUsingPIExample : IExample
19 | {
20 | public void Run()
21 | {
22 | PIServers piServers = new PIServers();
23 | PIServer piServer = piServers[""];
24 |
25 | IList points = PIPoint.FindPIPoints(piServer, new[] { "sample_floatpoint", "sample_digitalpoint" });
26 |
27 | PIPoint floatingPIPoint = points[0];
28 | PIPoint digitalPIPoint = points[1];
29 |
30 | AFEnumerationSet digSet = piServer.StateSets["Modes"];
31 |
32 | IList valuesToWrite = new List();
33 | for (int i = 0; i < 10; i++)
34 | {
35 | AFTime time = new AFTime(new DateTime(2015, 1, 1, i, 0, 0, DateTimeKind.Local));
36 |
37 | AFValue afValueFloat = new AFValue(i, time);
38 | // Associate the AFValue to a PI Point so we know where to write to.
39 | afValueFloat.PIPoint = floatingPIPoint;
40 |
41 | AFEnumerationValue digSetValue = i % 2 == 0 ? digSet["Auto"] : digSet["Manual"];
42 | AFValue afValueDigital = new AFValue(digSetValue, time);
43 | afValueDigital.PIPoint = digitalPIPoint;
44 |
45 | valuesToWrite.Add(afValueFloat);
46 | valuesToWrite.Add(afValueDigital);
47 | }
48 |
49 | // Perform a bulk write. Use a single local call to PI Buffer Subsystem if possible.
50 | // Otherwise, make a single call to the PI Data Archive.
51 | // We use no compression just so we can check all the values are written.
52 | piServer.UpdateValues(valuesToWrite, AFUpdateOption.InsertNoCompression, AFBufferOption.BufferIfPossible);
53 |
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/ExamplesLibrary/AFAttributeExamples/FindElementAttributesExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.Asset;
4 |
5 |
6 | namespace ExamplesLibrary
7 | {
8 | ///
9 | /// This example uses FindElementAttributes to return a list of AFAttribute objects to the client.
10 | ///
11 | ///
12 | /// none
13 | ///
14 | public class FindElementAttributesExample : IExample
15 | {
16 | public void Run()
17 | {
18 | PISystems piSystems = new PISystems();
19 | PISystem piSystem = piSystems[""];
20 |
21 | AFDatabase afDatabase = piSystem.Databases["NuGreen"];
22 |
23 | AFCategory elementCategory = afDatabase.ElementCategories["Equipment Assets"];
24 | AFCategory attributeCategory = afDatabase.AttributeCategories["Real-Time Data"];
25 |
26 | AFElementTemplate elementTemplate = afDatabase.ElementTemplates["Boiler"];
27 |
28 | const int pageSize = 1000;
29 | int startIndex = 0;
30 | int totalCount;
31 | do
32 | {
33 | // Find all "Water Flow" attributes in the NuGreen database.
34 | AFAttributeList attrList = AFAttribute.FindElementAttributes(
35 | database: afDatabase,
36 | searchRoot: null,
37 | nameFilter: "*",
38 | elemCategory: elementCategory,
39 | elemTemplate: elementTemplate,
40 | elemType: AFElementType.Any,
41 | attrNameFilter: "*",
42 | attrCategory: attributeCategory,
43 | attrType: TypeCode.Double,
44 | searchFullHierarchy: true,
45 | sortField: AFSortField.Name,
46 | sortOrder: AFSortOrder.Ascending,
47 | startIndex: startIndex,
48 | maxCount: pageSize,
49 | totalCount: out totalCount);
50 |
51 | foreach (AFAttribute attr in attrList)
52 | {
53 | Console.WriteLine("Parent element name: {0}", attr.Element);
54 | }
55 |
56 | startIndex += pageSize;
57 |
58 | } while (startIndex < totalCount);
59 |
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ExamplesLibrary/PIPointExamples/FindPIPointsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using OSIsoft.AF.PI;
4 | using OSIsoft.AF.Search;
5 |
6 |
7 | namespace ExamplesLibrary
8 | {
9 | ///
10 | /// This example finds PI Points based off of a query and prints the point attributes to the console.
11 | ///
12 | ///
13 | /// none
14 | ///
15 | public class FindPIPointsExample : IExample
16 | {
17 | public void Run()
18 | {
19 | PIServers piServers = new PIServers();
20 | PIServer piServer = piServers[""];
21 |
22 | // Use PICommonPointAttributes so we don't have to remember the strings for point attributes.
23 | PIPointQuery compressionFilter = new PIPointQuery {
24 | AttributeName = PICommonPointAttributes.Compressing,
25 | AttributeValue = "1",
26 | Operator = AFSearchOperator.Equal };
27 |
28 | PIPointQuery nameFilter = new PIPointQuery
29 | {
30 | AttributeName = PICommonPointAttributes.PointSource,
31 | AttributeValue = "R",
32 | Operator = AFSearchOperator.Equal
33 | };
34 |
35 | IEnumerable attributesToLoad = new[]
36 | {
37 | PICommonPointAttributes.Compressing,
38 | PICommonPointAttributes.Descriptor,
39 | PICommonPointAttributes.PointSource,
40 | PICommonPointAttributes.Span,
41 | PICommonPointAttributes.Zero
42 | };
43 |
44 | IEnumerable points = PIPoint.FindPIPoints(piServer, new[] { compressionFilter, nameFilter }, attributesToLoad);
45 |
46 | foreach (PIPoint pt in points)
47 | {
48 | Console.WriteLine("Name: {0}", pt.GetAttribute(PICommonPointAttributes.Tag));
49 | Console.WriteLine("Compressing: {0}", pt.GetAttribute(PICommonPointAttributes.Compressing));
50 | Console.WriteLine("Descriptor: {0}", pt.GetAttribute(PICommonPointAttributes.Descriptor));
51 | Console.WriteLine("PointSource: {0}", pt.GetAttribute(PICommonPointAttributes.PointSource));
52 | Console.WriteLine("Span: {0}", pt.GetAttribute(PICommonPointAttributes.Span));
53 | Console.WriteLine("Zero: {0}", pt.GetAttribute(PICommonPointAttributes.Zero));
54 | Console.WriteLine();
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/ExamplesLibrary/AFElementExamples/LoadElementsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.Asset;
4 |
5 |
6 | namespace ExamplesLibrary
7 | {
8 | ///
9 | /// Find and load a collection of elements instantiated from the Boiler template.
10 | /// Print each found element name and attribute count to the console.
11 | ///
12 | ///
13 | /// none
14 | ///
15 | public class LoadElementsExample : IExample
16 | {
17 | public void Run()
18 | {
19 | PISystems piSystems = new PISystems();
20 | PISystem piSystem = piSystems[""];
21 |
22 | AFDatabase afDatabase = piSystem.Databases["NuGreen"];
23 |
24 | const int pageSize = 1000;
25 | int startIndex = 0;
26 | int totalCount;
27 | do
28 | {
29 | // Find a collection of elements instantiated from the Boiler tempplate.
30 | // Only the Elements' header information (Name, Description, Template, Type, etc.)
31 | // are loaded from the AF Server by this call.
32 | AFNamedCollection elements = AFElement.FindElements(
33 | database: afDatabase,
34 | searchRoot: null,
35 | query: "Boiler",
36 | field: AFSearchField.Template,
37 | searchFullHierarchy: true,
38 | sortField: AFSortField.Name,
39 | sortOrder: AFSortOrder.Ascending,
40 | startIndex: startIndex,
41 | maxCount: pageSize,
42 | totalCount: out totalCount);
43 | if (elements == null) break;
44 |
45 | // This call goes to the AF Server to fully load the found elements in one call,
46 | // so further AF Server calls can be avoided.
47 | AFElement.LoadElements(elements);
48 |
49 | // Now we can use the elements without having to make any additional server calls.
50 | // In the example below, accessing the Attributes collection would have
51 | // caused an additional call per element if we had not called LoadElements previously.
52 | Console.WriteLine("Found {0} Elements.", elements.Count);
53 | foreach (AFElement item in elements)
54 | {
55 | Console.WriteLine(" Element {0} has {1} Attributes", item.Name, item.Attributes.Count);
56 | }
57 |
58 | startIndex += pageSize;
59 |
60 | } while (startIndex < totalCount);
61 |
62 |
63 | }
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/ExamplesLibrary/WriteValuesExample/WriteValuesUsingAFExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using OSIsoft.AF;
4 | using OSIsoft.AF.Asset;
5 | using OSIsoft.AF.Data;
6 | using OSIsoft.AF.Time;
7 |
8 |
9 | namespace ExamplesLibrary
10 | {
11 | ///
12 | /// This example demonstrates how to write values to the PI Data Archive via an AF Server.
13 | /// An example for numeric and digital tags is given.
14 | ///
15 | ///
16 | /// BuildSimpleDatabaseExample
17 | ///
18 | public class WriteValuesUsingAFExample : IExample
19 | {
20 | public void Run()
21 | {
22 | PISystems piSystems = new PISystems();
23 | PISystem piSystem = piSystems[""];
24 |
25 | AFDatabase afDatabase = piSystem.Databases["Basic-AFSDK-Sample"];
26 |
27 | AFElement boilerA = afDatabase.Elements["Region_0"].Elements["BoilerA"];
28 |
29 | AFElementTemplate elementTemplate = afDatabase.ElementTemplates["BasicBoilerTemplate"];
30 | AFAttributeTemplate temperatureAttrTemplate = elementTemplate.AttributeTemplates["Temperature"];
31 | AFAttributeTemplate modeAttrTemplate = elementTemplate.AttributeTemplates["Mode"];
32 | AFElement.LoadAttributes(new[] { boilerA }, new[] { temperatureAttrTemplate, modeAttrTemplate });
33 |
34 | AFEnumerationSet digSet = afDatabase.EnumerationSets["Modes"];
35 |
36 | IList valuesToWrite = new List();
37 | for (int i = 0; i < 10; i++)
38 | {
39 | AFTime time = new AFTime(new DateTime(2015, 1, 1, i, 0, 0, DateTimeKind.Local));
40 |
41 | AFValue afValueFloat = new AFValue(i, time);
42 | // Associate the AFValue to an attribute so we know where to write to.
43 | afValueFloat.Attribute = boilerA.Attributes["Temperature"];
44 |
45 | AFEnumerationValue digSetValue = i % 2 == 0 ? digSet["Auto"] : digSet["Manual"];
46 | AFValue afValueDigital = new AFValue(digSetValue, time);
47 | afValueDigital.Attribute = boilerA.Attributes["Mode"];
48 |
49 | valuesToWrite.Add(afValueFloat);
50 | valuesToWrite.Add(afValueDigital);
51 | }
52 |
53 | // Perform a bulk write. Use a single local call to PI Buffer Subsystem if possible.
54 | // Otherwise, make a single call to the PI Data Archive.
55 | // We use no compression just so we can check all the values are written.
56 | // AFListData is the class that provides the bulk write method.
57 | AFListData.UpdateValues(valuesToWrite, AFUpdateOption.InsertNoCompression, AFBufferOption.BufferIfPossible);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/ExamplesLibrary/AFEventFrameExamples/CreateEventFrameExample.cs:
--------------------------------------------------------------------------------
1 | using OSIsoft.AF;
2 | using OSIsoft.AF.Asset;
3 | using OSIsoft.AF.EventFrame;
4 | using OSIsoft.AF.Time;
5 |
6 |
7 | namespace ExamplesLibrary
8 | {
9 | ///
10 | /// This example creates 5 event frames of 1 day periods spanning the last 5 days.
11 | /// The primary referenced element for the event frames are set to the Region_0\BoilerA element.
12 | ///
13 | ///
14 | /// BuildSimpleDatabaseExample
15 | ///
16 | public class CreateEventFrameExample : IExample
17 | {
18 | public void Run()
19 | {
20 | PISystems piSystems = new PISystems();
21 | PISystem piSystem = piSystems[""];
22 |
23 | AFDatabase afDatabase = piSystem.Databases["Basic-AFSDK-Sample"];
24 |
25 | CreateEventFrameTemplate(afDatabase);
26 | CreateEventFrames(afDatabase);
27 | }
28 |
29 | private void CreateEventFrameTemplate(AFDatabase afDatabase)
30 | {
31 | AFElementTemplate efTemplate = afDatabase.ElementTemplates.Add("BasicEventFrameTemplate");
32 | // Specify that this is an Event Frame Template.
33 | efTemplate.InstanceType = typeof(AFEventFrame);
34 |
35 | AFAttributeTemplate tempAttr = efTemplate.AttributeTemplates.Add("Maximum temperature");
36 | tempAttr.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(afDatabase.PISystem);
37 |
38 | AFAttributeTemplate pressAttr = efTemplate.AttributeTemplates.Add("Maximum pressure");
39 | pressAttr.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(afDatabase.PISystem);
40 |
41 | tempAttr.ConfigString = @".\Elements[.]|Temperature;TimeMethod=NotSupported;TimeRangeMethod=Maximum";
42 | pressAttr.ConfigString = @".\Elements[.]|Pressure;TimeMethod=NotSupported;TimeRangeMethod=Maximum";
43 |
44 | // Do a bulk check in of all changes made so far.
45 | afDatabase.CheckIn();
46 | }
47 |
48 | private void CreateEventFrames(AFDatabase afDatabase)
49 | {
50 | AFElementTemplate efTemplate = afDatabase.ElementTemplates["BasicEventFrameTemplate"];
51 | for (int i = 0; i < 5; i++)
52 | {
53 | AFEventFrame ef = new AFEventFrame(afDatabase, "EF_" + i, efTemplate);
54 | ef.SetStartTime(new AFTime(string.Format("t-{0}d", i + 1)));
55 | ef.SetEndTime(new AFTime(string.Format("t-{0}d", i)));
56 |
57 | AFElement element = afDatabase.Elements["Region_0"].Elements["BoilerA"];
58 | ef.PrimaryReferencedElement = element;
59 | }
60 |
61 | // Do a bulk check in of all changes made so far.
62 | afDatabase.CheckIn();
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/PI-AF-SDK-Basic-Samples/PI-AF-SDK-Basic-Samples-Console.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {62331726-9C1F-42B0-9228-9912173CB83C}
8 | Exe
9 | Properties
10 | PI_AF_SDK_Basic_Samples
11 | PI-AF-SDK-Basic-Samples
12 | v4.5.2
13 | 512
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | {7f3b7e46-6c71-47f2-97ba-f28b1e79d879}
55 | ExamplesLibrary
56 |
57 |
58 |
59 |
66 |
--------------------------------------------------------------------------------
/ExamplesLibrary/AFElementExamples/PartialLoadElementsExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.Asset;
4 |
5 |
6 | namespace ExamplesLibrary
7 | {
8 | ///
9 | /// Find and partially load a collection of elements instantiated from the Boiler template.
10 | /// Print the current values of the Water Flow attribute to the console.
11 | ///
12 | ///
13 | /// none
14 | ///
15 | public class PartialLoadElementsExample : IExample
16 | {
17 | public void Run()
18 | {
19 | PISystems piSystems = new PISystems();
20 | PISystem piSystem = piSystems[""];
21 |
22 | AFDatabase afDatabase = piSystem.Databases["NuGreen"];
23 |
24 | AFElementTemplate boilerTemplate = afDatabase.ElementTemplates["Boiler"];
25 |
26 | const int pageSize = 1000;
27 | int startIndex = 0;
28 | int totalCount;
29 | do
30 | {
31 | // Find a collection of elements instantiated from the Boiler tempplate.
32 | // Only the Elements' header information (Name, Description, Template, Type, etc.)
33 | // are loaded from the AF Server by this call.
34 | AFNamedCollection elements = AFElement.FindElements(
35 | database: afDatabase,
36 | searchRoot: null,
37 | query: "Boiler",
38 | field: AFSearchField.Template,
39 | searchFullHierarchy: true,
40 | sortField: AFSortField.Name,
41 | sortOrder: AFSortOrder.Ascending,
42 | startIndex: startIndex,
43 | maxCount: pageSize,
44 | totalCount: out totalCount);
45 | if (elements == null) break;
46 |
47 | // Partially load the element by retrieving information only for the Water Flow attribute.
48 | AFElement.LoadAttributes(elements, new[] { boilerTemplate.AttributeTemplates["Water Flow"] });
49 |
50 | Console.WriteLine("Found {0} Elements.", elements.Count);
51 |
52 | AFAttributeList attrList = new AFAttributeList();
53 |
54 | // Because we are retrieving the Water Flow attribute which was previously loaded,
55 | // no additional server calls are made.
56 | // If LoadAttributes had not been called previously, then a server call would have been made for each element
57 | // in the loop below.
58 | foreach (AFElement item in elements)
59 | {
60 | attrList.Add(item.Attributes["Water Flow"]);
61 | }
62 |
63 | AFValues values = attrList.GetValue();
64 |
65 | Console.WriteLine(" Water Flow values");
66 | foreach (AFValue val in values)
67 | {
68 | Console.WriteLine(" Element: {0}, Timestamp: {1}, Value: {2}",
69 | val.Attribute.Element, val.Timestamp, val.Value.ToString());
70 | }
71 |
72 | startIndex += pageSize;
73 |
74 | } while (startIndex < totalCount);
75 |
76 | }
77 |
78 |
79 |
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/ExamplesLibrary/ExamplesLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {7F3B7E46-6C71-47F2-97BA-F28B1E79D879}
8 | Library
9 | Properties
10 | ExamplesLibrary
11 | ExamplesLibrary
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
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 |
73 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | # DNX
42 | project.lock.json
43 | artifacts/
44 |
45 | *_i.c
46 | *_p.c
47 | *_i.h
48 | *.ilk
49 | *.meta
50 | *.obj
51 | *.pch
52 | *.pdb
53 | *.pgc
54 | *.pgd
55 | *.rsp
56 | *.sbr
57 | *.tlb
58 | *.tli
59 | *.tlh
60 | *.tmp
61 | *.tmp_proj
62 | *.log
63 | *.vspscc
64 | *.vssscc
65 | .builds
66 | *.pidb
67 | *.svclog
68 | *.scc
69 |
70 | # Chutzpah Test files
71 | _Chutzpah*
72 |
73 | # Visual C++ cache files
74 | ipch/
75 | *.aps
76 | *.ncb
77 | *.opensdf
78 | *.sdf
79 | *.cachefile
80 |
81 | # Visual Studio profiler
82 | *.psess
83 | *.vsp
84 | *.vspx
85 |
86 | # TFS 2012 Local Workspace
87 | $tf/
88 |
89 | # Guidance Automation Toolkit
90 | *.gpState
91 |
92 | # ReSharper is a .NET coding add-in
93 | _ReSharper*/
94 | *.[Rr]e[Ss]harper
95 | *.DotSettings.user
96 |
97 | # JustCode is a .NET coding add-in
98 | .JustCode
99 |
100 | # TeamCity is a build add-in
101 | _TeamCity*
102 |
103 | # DotCover is a Code Coverage Tool
104 | *.dotCover
105 |
106 | # NCrunch
107 | _NCrunch_*
108 | .*crunch*.local.xml
109 |
110 | # MightyMoose
111 | *.mm.*
112 | AutoTest.Net/
113 |
114 | # Web workbench (sass)
115 | .sass-cache/
116 |
117 | # Installshield output folder
118 | [Ee]xpress/
119 |
120 | # DocProject is a documentation generator add-in
121 | DocProject/buildhelp/
122 | DocProject/Help/*.HxT
123 | DocProject/Help/*.HxC
124 | DocProject/Help/*.hhc
125 | DocProject/Help/*.hhk
126 | DocProject/Help/*.hhp
127 | DocProject/Help/Html2
128 | DocProject/Help/html
129 |
130 | # Click-Once directory
131 | publish/
132 |
133 | # Publish Web Output
134 | *.[Pp]ublish.xml
135 | *.azurePubxml
136 | ## TODO: Comment the next line if you want to checkin your
137 | ## web deploy settings but do note that will include unencrypted
138 | ## passwords
139 | #*.pubxml
140 |
141 | *.publishproj
142 |
143 | # NuGet Packages
144 | *.nupkg
145 | # The packages folder can be ignored because of Package Restore
146 | **/packages/*
147 | # except build/, which is used as an MSBuild target.
148 | !**/packages/build/
149 | # Uncomment if necessary however generally it will be regenerated when needed
150 | #!**/packages/repositories.config
151 |
152 | # Windows Azure Build Output
153 | csx/
154 | *.build.csdef
155 |
156 | # Windows Store app package directory
157 | AppPackages/
158 |
159 | # Visual Studio cache files
160 | # files ending in .cache can be ignored
161 | *.[Cc]ache
162 | # but keep track of directories ending in .cache
163 | !*.[Cc]ache/
164 |
165 | # Others
166 | ClientBin/
167 | [Ss]tyle[Cc]op.*
168 | ~$*
169 | *~
170 | *.dbmdl
171 | *.dbproj.schemaview
172 | *.pfx
173 | *.publishsettings
174 | node_modules/
175 | orleans.codegen.cs
176 |
177 | # RIA/Silverlight projects
178 | Generated_Code/
179 |
180 | # Backup & report files from converting an old project file
181 | # to a newer Visual Studio version. Backup files are not needed,
182 | # because we have git ;-)
183 | _UpgradeReport_Files/
184 | Backup*/
185 | UpgradeLog*.XML
186 | UpgradeLog*.htm
187 |
188 | # SQL Server files
189 | *.mdf
190 | *.ldf
191 |
192 | # Business Intelligence projects
193 | *.rdl.data
194 | *.bim.layout
195 | *.bim_*.settings
196 |
197 | # Microsoft Fakes
198 | FakesAssemblies/
199 |
200 | # Node.js Tools for Visual Studio
201 | .ntvs_analysis.dat
202 |
203 | # Visual Studio 6 build log
204 | *.plg
205 |
206 | # Visual Studio 6 workspace options file
207 | *.opt
208 |
209 | # LightSwitch generated files
210 | GeneratedArtifacts/
211 | _Pvt_Extensions/
212 | ModelManifest.xml
213 |
--------------------------------------------------------------------------------
/ExamplesLibrary/ReadingValuesExamples/ReadFromAFExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.Asset;
4 |
5 |
6 | namespace ExamplesLibrary
7 | {
8 | ///
9 | /// Retrieving values from AF Attributes is best done in bulk, in particular, if any of the data is coming from the PI Data Archive.
10 | /// By bulk retrieving the data, the number of round-trips to the PI Data Archive are reduced.
11 | /// This example uses the AFAttributeList to illustrate how to retrieve attribute values in bulk.
12 | /// We will retrieve the current vaues for the Process Feedrate and Steam Flow attributes for all Compressor template elements and print to console.
13 | /// This example is very similar to the PartialLoadElementsExample.
14 | ///
15 | ///
16 | /// none
17 | ///
18 | public class ReadFromAFExample : IExample
19 | {
20 | public void Run()
21 | {
22 | PISystems piSystems = new PISystems();
23 | PISystem piSystem = piSystems[""];
24 |
25 | AFDatabase afDatabase = piSystem.Databases["NuGreen"];
26 | if (afDatabase != null)
27 | {
28 | AFElementTemplate boilerTemplate = afDatabase.ElementTemplates["Compressor"];
29 |
30 | const int pageSize = 1000;
31 | int startindex = 0;
32 | int totalCount;
33 | do
34 | {
35 | // Find a collection of elements instantiated from the Boiler tempplate.
36 | // Only the Elements' header information (Name, Description, Template, Type, etc.)
37 | // are loaded from the AF Server by this call.
38 | AFNamedCollection elements = AFElement.FindElements(
39 | database: afDatabase,
40 | searchRoot: null,
41 | query: "Compressor",
42 | field: AFSearchField.Template,
43 | searchFullHierarchy: true,
44 | sortField: AFSortField.Name,
45 | sortOrder: AFSortOrder.Ascending,
46 | startIndex: startindex,
47 | maxCount: pageSize,
48 | totalCount: out totalCount);
49 | if (elements == null) break;
50 |
51 | // Partially load the element by retrieving information only for the Water Flow attribute.
52 | AFElement.LoadAttributes(elements, new[] {
53 | boilerTemplate.AttributeTemplates["Process Feedrate"], boilerTemplate.AttributeTemplates["Steam Flow"],
54 | });
55 |
56 | Console.WriteLine("Found {0} Elements.", elements.Count);
57 |
58 | // Create an AFAttributeList object in order to make the bulk call later.
59 | AFAttributeList attrList = new AFAttributeList();
60 |
61 | // Because we are retrieving attributes which were previously loaded,
62 | // no additional server calls are made.
63 | // If LoadAttributes had not been called previously, then a server call would have been made for each element
64 | // in the loop below.
65 | foreach (AFElement item in elements)
66 | {
67 | attrList.Add(item.Attributes["Process Feedrate"]);
68 | attrList.Add(item.Attributes["Steam Flow"]);
69 | }
70 |
71 | // MAKE A BULK CALL TO THE PI DATA ARCHIVE
72 | AFValues values = attrList.GetValue();
73 |
74 | Console.WriteLine(" Water Flow values");
75 | foreach (AFValue val in values)
76 | {
77 | Console.WriteLine(" Element: {0}, Attribute: {1}",
78 | val.Attribute.Element, val.Attribute, val.Timestamp, val.Value.ToString());
79 | Console.WriteLine(" Timestamp: {0}, Value: {1}",
80 | val.Timestamp, val.Value.ToString());
81 | }
82 |
83 | startindex += pageSize;
84 |
85 | } while (startindex < totalCount);
86 |
87 | }
88 |
89 | }
90 |
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PI-AF-SDK-Basic-Samples
2 | This repository provides self-contained and reproducible samples of basic operations using AF SDK.
3 |
4 | Each example is a separate class and outputs results to the Console.
5 |
6 | ## Solution contents
7 |
8 | `PI-AF-SDK-Basic-Samples-Console` contains the Console application that runs the examples.
9 |
10 | `ExamplesLibrary` contains the examples.
11 |
12 | ## Requirements
13 |
14 | 1. AF Client 2.5+
15 | 2. .NET Framework 4+
16 | 3. Visual Studio 2012+
17 | 4. AF Server and PI Data Archive
18 |
19 | ## Getting started
20 |
21 | ### Import the NuGreen database.
22 |
23 | Many of the examples uses the NuGreen database. To use the NuGreen database, follow these steps:
24 |
25 | 1. Create an AF Database named "NuGreen".
26 | 2. Import the database from the provided NuGreen.xml via PI System Explorer>File>Import from File.
27 | 3. Verify that a root element "NuGreen" is created inside the NuGreen database.
28 | 4. Check in the changes if not done so already.
29 |
30 | ### AF Server and PI Data Archive Names
31 |
32 | The code examples come with simple placeholders such as `` and ``.
33 |
34 | Please replace these with your server names before starting.
35 |
36 | ### Dependencies
37 |
38 | Some examples depend on having run prior examples successfully. This is because these dependent examples require AF objects and/or PI Points to have been created by the prior examples. The comments in the code above each class will explicitly list out the dependencies of each example. For instance,
39 |
40 | ```
41 | ///
42 | /// BuildSimpleDatabaseExample, CreateEventFramesExample
43 | ///
44 | ```
45 |
46 | ###
47 |
48 | To run a particular example, simply instantiate a new object from the example type and call its Run() method.
49 |
50 | To run the AFConnectionExample, for instance, use:
51 | ```csharp
52 | IExample example = new AFConnectionExample();
53 | example.Run()
54 | ```
55 |
56 | ## Recommended learning path
57 |
58 | A recommended learning path for going through the examples is as follows:
59 |
60 | ### 1.0 Connecting
61 |
62 | - [ConnectionExamples/AFConnectionExample](/ExamplesLibrary/ConnectionExamples/AFConnectionExample.cs)
63 | - [ConnectionExamples/PIConnectionExample](/ExamplesLibrary/ConnectionExamples/PIConnectionExample.cs)
64 |
65 | ### 2.0 Finding and loading AF Elements
66 |
67 | - [AFElementExamples/FindElementsExample](/ExamplesLibrary/AFElementExamples/FindElementsExample.cs)
68 | - [AFElementExamples/PartialLoadElementsExample](/ExamplesLibrary/AFElementExamples/PartialLoadElementsExample.cs)
69 | - [AFElementExamples/LoadElementsExample](/ExamplesLibrary/AFElementExamples/LoadElementsExample.cs)
70 |
71 | ### 3.0 Finding AF attributes
72 |
73 | - [AFAttributeExamples/FindAttributeWalkDownExample](/ExamplesLibrary/AFAttributeExamples/FindAttributeWalkDownExample.cs)
74 | - [AFAttributeExamples/FindAttributesByPathExample](/ExamplesLibrary/AFAttributeExamples/FindAttributesByPathExample.cs)
75 | - [AFAttributeExamples/FindElementAttributesExample](/ExamplesLibrary/AFAttributeExamples/FindElementAttributesExample.cs)
76 |
77 | ### 4.0 Finding PIPoints
78 |
79 | - [PIPointExamples/FindPIPointsExample](/ExamplesLibrary/PIPointExamples/FindPIPointsExample.cs)
80 |
81 | ### 5.0 Reading values
82 |
83 | - [ReadingValuesExamples/ReadFromAFExample](/ExamplesLibrary/ReadingValuesExamples/ReadFromAFExample.cs)
84 | - [ReadingValuesExamples/ReadFromPIExample](/ExamplesLibrary/ReadingValuesExamples/ReadFromPIExample.cs)
85 |
86 | ### 6.0 Creating AF objects
87 |
88 | - [BuildAFDatabaseExamples/BuildSimpleDatabaseExample](/ExamplesLibrary/BuildAFDatabaseExamples/BuildSimpleDatabaseExample.cs)
89 |
90 | ### 7.0 Create PI Points
91 |
92 | - [PIPointExamples/CreatePIPointsExample](/ExamplesLibrary/PIPointExamples/CreatePIPointsExample.cs)
93 |
94 | ### 8.0 Writing values
95 |
96 | - [WriteValuesExample/WriteValuesUsingAFExample](/ExamplesLibrary/WriteValuesExample/WriteValuesUsingAFExample.cs)
97 | - [WriteValuesExample/WriteValuesUsingPIExample](/ExamplesLibrary/WriteValuesExample/WriteValuesUsingPIExample.cs)
98 |
99 | ### 9.0 Creating and Finding Event Frames
100 |
101 | - [AFEventFrameExamples/CreateEventFrameExample](/ExamplesLibrary/AFEventFrameExamples/CreateEventFrameExample.cs)
102 | - [AFEventFrameExamples/FindEventFramesExample](/ExamplesLibrary/AFEventFrameExamples/FindEventFramesExample.cs)
103 |
--------------------------------------------------------------------------------
/ExamplesLibrary/BuildAFDatabaseExamples/BuildSimpleDatabaseExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OSIsoft.AF;
3 | using OSIsoft.AF.Asset;
4 |
5 |
6 | namespace ExamplesLibrary
7 | {
8 | public class BuildSimpleDatabaseExample : IExample
9 | {
10 | ///
11 | /// This example creates a sample AF database from basic element and attribute templates.
12 | ///
13 | ///
14 | /// none
15 | ///
16 | public void Run()
17 | {
18 | PISystems piSystems = new PISystems();
19 | PISystem piSystem = piSystems[""];
20 |
21 | AFDatabase afDatabase = piSystem.Databases.Add("Basic-AFSDK-Sample");
22 |
23 | CreateTemplates(afDatabase);
24 | CreateEnumerationSet(afDatabase);
25 | CreateElements(afDatabase);
26 | CreatePIPoints(afDatabase);
27 | }
28 |
29 | private void CreateTemplates(AFDatabase afDatabase)
30 | {
31 | AFElementTemplate elemTemplate = afDatabase.ElementTemplates.Add("BasicBoilerTemplate");
32 |
33 | AFAttributeTemplate attrTemplate_Temperature = elemTemplate.AttributeTemplates.Add("Temperature");
34 | AFAttributeTemplate attrTemplate_Pressure = elemTemplate.AttributeTemplates.Add("Pressure");
35 | AFAttributeTemplate attrTemplate_Limit = elemTemplate.AttributeTemplates.Add("Limit");
36 | AFAttributeTemplate attrTemplate_Mode = elemTemplate.AttributeTemplates.Add("Mode");
37 |
38 | attrTemplate_Temperature.Type = typeof(float);
39 | attrTemplate_Pressure.Type = typeof(float);
40 | attrTemplate_Limit.Type = typeof(string);
41 |
42 | AFEnumerationSet modes = afDatabase.EnumerationSets["Modes"];
43 | attrTemplate_Mode.TypeQualifier = modes;
44 |
45 | attrTemplate_Temperature.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(afDatabase.PISystem);
46 | attrTemplate_Pressure.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(afDatabase.PISystem);
47 | attrTemplate_Mode.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(afDatabase.PISystem);
48 |
49 | attrTemplate_Temperature.ConfigString = @"%Database%.%..\Element%.%Element%.%Attribute%;ptclassname=classic;pointtype=float32;";
50 | attrTemplate_Pressure.ConfigString = @"%Database%.%..\Element%.%Element%.%Attribute%;ptclassname=classic;pointtype=float32;";
51 | attrTemplate_Mode.ConfigString = @"%Database%.%..\Element%.%Element%.%Attribute%;ptclassname=classic;pointtype=digital;digitalset=modes;";
52 |
53 | // Do a bulk check in of all changes made so far.
54 | afDatabase.CheckIn();
55 | }
56 |
57 | private void CreateEnumerationSet(AFDatabase afDatabase)
58 | {
59 | AFEnumerationSet modes = afDatabase.EnumerationSets.Add("Modes");
60 | modes.Add("Manual", 0);
61 | modes.Add("Auto", 1);
62 | modes.Add("Cascade", 2);
63 | modes.Add("Program", 3);
64 | modes.Add("Prog-Auto", 4);
65 | }
66 |
67 | private void CreateElements(AFDatabase afDatabase)
68 | {
69 | AFElementTemplate elemTemplate = afDatabase.ElementTemplates["BasicBoilerTemplate"];
70 |
71 | for (int i = 0; i < 5; i++)
72 | {
73 | AFElement element = afDatabase.Elements.Add("Region_" + i);
74 | }
75 |
76 | foreach (AFElement element in afDatabase.Elements)
77 | {
78 | AFElement childA = element.Elements.Add("BoilerA", elemTemplate);
79 | AFElement childB = element.Elements.Add("BoilerB", elemTemplate);
80 |
81 | childA.Attributes["Limit"].SetValue(new AFValue("10"));
82 | childB.Attributes["Limit"].SetValue(new AFValue("50"));
83 | }
84 |
85 | // Do a bulk check in of all changes made so far.
86 | afDatabase.CheckIn();
87 | }
88 |
89 | private void CreatePIPoints(AFDatabase afDatabase)
90 | {
91 | AFElementTemplate elemTemplate = afDatabase.ElementTemplates["BasicBoilerTemplate"];
92 | AFNamedCollectionList baseElements = elemTemplate.FindInstantiatedElements(
93 | includeDerived: false,
94 | sortField: AFSortField.Name,
95 | sortOrder: AFSortOrder.Ascending,
96 | maxCount: 1000);
97 |
98 | foreach (AFBaseElement baseElement in baseElements)
99 | {
100 | int numModified = AFDataReference.CreateConfig(baseElement, false, null);
101 | Console.WriteLine("Modified or created: {0}", numModified);
102 | }
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/LICENSE.MD:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2015 OSIsoft, LLC
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------