Click or drag to resize
OSIsoft, LLC

AFTimeRange Structure

This structure represents a time range which is defined by a start time and an end time.

Namespace:  OSIsoft.AF.Time
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 2.10.6.195
Syntax
[SerializableAttribute]
public struct AFTimeRange : IComparable, 
	IComparable<AFTimeRange>, IEquatable<AFTimeRange>, IFormattable

The AFTimeRange type exposes the following members.

Constructors
  NameDescription
Public methodAFTimeRange(String, String)
Creates a new AFTimeRange object with the specified string representations of start and end times.
Public methodAFTimeRange(AFTime, AFTime)
Creates a new AFTimeRange object with the specified start and end AFTime values.
Public methodAFTimeRange(String, String, IFormatProvider)
Creates a new AFTimeRange object with the specified string representations of start and end times using the specified culture-specific information and formatting style.
Top
Properties
  NameDescription
Public propertyEndTime
The ending time of the time range represented by this object.
Public propertySpan
The amount of time between the start and end times.
Public propertyStartTime
The starting time of the time range represented by this object.
Top
Methods
  NameDescription
Public methodAdjustForSyncTime
Adjust the time range so that the start time and end time are in sync with the syncTime.
Public methodCompareTo(Object)
Compares this instance with a specified Object.
Public methodCompareTo(AFTimeRange)
Compares this instance with a specified AFTimeRange.
Public methodEquals(Object)
Determines whether the specified Object is equal to the current object.
(Overrides ValueTypeEquals(Object).)
Public methodEquals(AFTimeRange)
Indicates whether the current object is equal to another object of the same type.
Public methodGetHashCode
Gets the hash code for this instance of the object which is suitable for use in hashing algorithms and data structures like a hash table.
(Overrides ValueTypeGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIntersect
Computes the intersection between this AFTimeRange and another AFTimeRange.
Public methodStatic memberParse(String, String, IFormatProvider)
Converts the specified local date and time string representations of the start and end times to its AFTimeRange equivalent by using the specified culture-specific formatting information.
Public methodStatic memberParse(String, String, AFTime, IFormatProvider)
Converts the specified local date and time string representations of the start and end times to its AFTimeRange equivalent by using the specified reference time and culture-specific formatting information.
Public methodToString
Returns a String that represents the time range in a format that can be presented to the user.
(Overrides ValueTypeToString.)
Public methodToString(IFormatProvider)
Returns a String that represents the time range using the specified culture-specific information that can be presented to the user.
Public methodToString(String)
Returns a String that represents the time range using the specified format that can be presented to the user.
Public methodToString(String, IFormatProvider)
Returns a String that represents the time range using the specified format and culture-specific information that can be presented to the user.
Public methodStatic memberTryParse(String, String, AFTimeRange)
Converts the specified local date and time string representations of the start and end times to its AFTimeRange equivalent by using the CurrentCulture and returns a value that indicates whether the conversion succeeded.
Public methodStatic memberTryParse(String, String, AFTime, AFTimeRange)
Converts the specified local date and time string representations of the start and end times to its AFTimeRange equivalent by using the specified reference time and returns a value that indicates whether the conversion succeeded.
Public methodStatic memberTryParse(String, String, IFormatProvider, AFTimeRange)
Converts the specified local date and time string representations of the start and end times to its AFTimeRange equivalent by using the specified culture-specific formatting information and returns a value that indicates whether the conversion succeeded.
Public methodStatic memberTryParse(String, String, AFTime, IFormatProvider, AFTimeRange)
Converts the specified local date and time string representations of the start and end times to its AFTimeRange equivalent by using the specified reference time and culture-specific formatting information, and returns a value that indicates whether the conversion succeeded.
Top
Operators
  NameDescription
Public operatorStatic memberEquality
The equality operator (==) compares its operands to determine if they are equal.
Public operatorStatic memberGreaterThan
The greater than relation operator (>) compares its operands to determine which one is greater than the other.
Public operatorStatic memberGreaterThanOrEqual
The greater than or equal relation operator (>=) compares its operands to determine which one is greater than or equal to the other.
Public operatorStatic memberInequality
The inequality operator (!=) compares its operands to determine if they are not equal.
Public operatorStatic memberLessThan
The less than relation operator (<) compares its operands to determine which one is less than the other.
Public operatorStatic memberLessThanOrEqual
The less than or equal relation operator (<=) compares its operands to determine which one is less than or equal to the other.
Top
Fields
  NameDescription
Public fieldStatic memberEmpty
Represents the empty AFTimeRange.
Top
Remarks
A time range can be used as a context when getting values with one of the AFAttribute.GetValue Overload methods. If the StartTime and EndTime properties are equal, then this is the same as only specifying a single time as the context.
Examples
// This example shows how to create a dynamic attribute and obtain
// the values of an attribute over a specified time range.

// Get the Database
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
AFDatabase myDB = myPISystem.Databases.DefaultDatabase;

// Create the Attribute
AFAttribute myAttribute = new AFAttribute(myDB);
myAttribute.Name = "Sinusoid";
myAttribute.Type = typeof(float);
myAttribute.DefaultUOM = myPISystem.UOMDatabase.UOMs["m"];
myAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem);
myAttribute.ConfigString = @"\\%Server%\Sinusoid";

// Set the Time Range
AFTimeRange myTimeRange = new AFTimeRange();
myTimeRange.StartTime = new AFTime(DateTime.UtcNow.AddHours(-1));
myTimeRange.EndTime = AFTime.Now;

// Display each Value of the Attribute during the Time Range
AFValues myValues = myAttribute.GetValues(myTimeRange, 0, null);
Console.WriteLine("Number of values = {0}", myValues.Count);
foreach (AFValue myValue in myValues)
{
    Console.WriteLine("Annotated = {0}", myValue.Annotated);
    Console.WriteLine("IsGood = {0}", myValue.IsGood);
    Console.WriteLine("Questionable = {0}", myValue.Questionable);
    Console.WriteLine("Substituted = {0}", myValue.Substituted);
    Console.WriteLine("TimeStamp = {0}", myValue.Timestamp.LocalTime);
    Console.WriteLine("UOM = {0}", myValue.UOM);
    Console.WriteLine("Value = {0}", myValue.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, 2.5, 2.4
See Also
Enabling Operational Intelligence