Click or drag to resize
OSIsoft, LLC

PIStateSets Class

The PIStateSets collection represents the available State Sets on a particular PIServer. The State Sets are represented as a collection of AFEnumerationSet objects.

Inheritance Hierarchy
SystemObject
  OSIsoft.AF.PIPIStateSets

Namespace:  OSIsoft.AF.PI
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 2.10.6.195
Syntax
public sealed class PIStateSets : IEnumerable<AFEnumerationSet>, 
	IEnumerable, IAFList, IList, ICollection, IList<AFEnumerationSet>, 
	ICollection<AFEnumerationSet>

The PIStateSets type exposes the following members.

Properties
Methods
  NameDescription
Public methodAdd(String)
Creates a new PI Digital State set with the passed in name.
Public methodAdd(AFEnumerationSet)
Adds the passed in AFEnumerationSet to the PI Digital State Sets collection.
Public methodContains(Guid)
This method determines whether the collection contains a specific item referenced by id.
Public methodContains(String)
This method determines whether the collection contains a specific item referenced by name.
Public methodContains(AFEnumerationSet)
This method determines whether the collection contains a specific state set.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through the collection.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodRefresh
This method updates the PIStateSets collection by checking for updates on the PIServer.
Public methodRemove(Guid)
Removes a PI Digital State Set from the PI Data Archive by ID
Public methodRemove(String)
Removes a PI Digital State Set from the PI Data Archive by name
Public methodRemove(AFEnumerationSet)
Removes a PI Digital State Set from the PI Data Archive
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodAggregateAFEnumerationSet
Performs all requested aggregates on the specified items.
(Defined by AFAggregate.)
Public Extension MethodAggregateAsyncAFEnumerationSet
Performs all requested aggregates on the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension MethodBinnedSummaryAFEnumerationSet, TBin
Generates a summary broken down by the specified bins for items matching the search criteria.
(Defined by AFAggregate.)
Public Extension MethodBinnedSummaryAsyncAFEnumerationSet, TBin
Generates a summary broken down by the specified bins for items matching the search criteria asynchronously.
(Defined by AFAggregate.)
Public Extension MethodCode exampleChunkedByAFEnumerationSet
This extension method breaks up search results into chunks to make it easier to page through and process IEnumerableT collections in chunks.
(Defined by AFSDKExtension.)
Public Extension MethodFrequencyDistributionAFEnumerationSet
Generates a frequency distribution for the specified items.
(Defined by AFAggregate.)
Public Extension MethodFrequencyDistributionAsyncAFEnumerationSet
Generates a frequency distribution for the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension MethodGroupedSummaryAFEnumerationSet
Generates a summary broken down by group for the specified items.
(Defined by AFAggregate.)
Public Extension MethodGroupedSummaryAsyncAFEnumerationSet
Generates a histogram for the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension MethodHistogramAFEnumerationSet, TBin
Generates a histogram for the specified items with the specified weighting.
(Defined by AFAggregate.)
Public Extension MethodHistogramAsyncAFEnumerationSet, TBin
Generates a histogram for the specified items with the specified weighting asynchronously.
(Defined by AFAggregate.)
Public Extension MethodSummaryAFEnumerationSet(String, AFSummaryTypes)Overloaded.
Summarizes the specified items.
(Defined by AFAggregate.)
Public Extension MethodSummaryAFEnumerationSet(String, AFSummaryTypes, String)Overloaded.
Summarizes the specified items with the specified weighting.
(Defined by AFAggregate.)
Public Extension MethodSummaryAsyncAFEnumerationSet(String, AFSummaryTypes, CancellationToken)Overloaded.
Summarizes the specified items asynchronously.
(Defined by AFAggregate.)
Public Extension MethodSummaryAsyncAFEnumerationSet(String, AFSummaryTypes, String, CancellationToken)Overloaded.
Summarizes the specified items with the specified weighting asynchronously.
(Defined by AFAggregate.)
Top
Examples
// Get the PIServers collection for the current user and default PIServer.
myPIServer = new PIServers().DefaultPIServer;

// Create a new state set
AFEnumerationSet myColorsSet = myPIServer.StateSets.Add("myColors");

// Add values to the new set
myColorsSet.Add("Red", 0);
myColorsSet.Add("Blue", 1);
myColorsSet.Add("Green", 2);

// Commit the new state set to the PI Data Archive
myColorsSet.CheckIn();

// Print set values out
PrintStateSetValues(myColorsSet);

// Create a new PI Point with this digital state set
Dictionary<string, object> pointAttributes = new Dictionary<string, object>();
pointAttributes[PICommonPointAttributes.PointType] = PIPointType.Digital;
pointAttributes[PICommonPointAttributes.DigitalSetName] = "myColors";

PIPoint myColorPoint = myPIServer.CreatePIPoint("myColorPoint", pointAttributes);

// Write three color values to the points using different techniques
AFValue redValue = new AFValue(myColorsSet["Red"], new AFTime("t"));
myColorPoint.UpdateValue(redValue, AFUpdateOption.Insert);

AFValue blueValue = new AFValue(new AFEnumerationValue("Blue", 1), new AFTime("t+5s"));
myColorPoint.UpdateValue(blueValue, AFUpdateOption.Insert);

AFValue greenValue = new AFValue(2, new AFTime("t+10s"));
myColorPoint.UpdateValue(greenValue, AFUpdateOption.Insert);

// Write system state set values using different techniques
AFValue ioTimeoutValue = new AFValue(
    AFEnumerationSet.GetBySystemStateCode(AFSystemStateCode.IOTimeout),
    new AFTime("t+15s"));

myColorPoint.UpdateValue(ioTimeoutValue, AFUpdateOption.Insert);

AFValue sampleBadValue = new AFValue(
    AFEnumerationSet.SystemStateSet["Sample Bad"],
    new AFTime("t+20s"));

myColorPoint.UpdateValue(sampleBadValue, AFUpdateOption.Insert);

// Use system state specific to this PI Data Archive
AFValue noLabDataValue = new AFValue(
    myPIServer.StateSets["SYSTEM"]["No Lab Data"],
    new AFTime("t+25s"));

myColorPoint.UpdateValue(noLabDataValue, AFUpdateOption.Insert);

// Read the values
AFValues colorValues = myColorPoint.RecordedValues(
    new AFTimeRange("t", "t+25s"), AFBoundaryType.Inside, null, false);

// Print them out
foreach (AFValue colorValue in colorValues)
{
    AFEnumerationValue setValue = colorValue.Value as AFEnumerationValue;

    if (!ReferenceEquals(setValue, null))
    {
        Console.WriteLine("Set Name: {0} Value Name: {1} Value Code: {2}",
            setValue.EnumerationSet.Name, setValue.Name, setValue.Value);
    }
}
Version Information

AFSDK

Supported in: 2.10.5, 2.10, 2.9.5, 2.9, 2.8.5, 2.8, 2.7.5, 2.7, 2.6
See Also
Enabling Operational Intelligence