private static double ToDouble(AFValue value) { if (value == null || !value.IsGood || !IsNumericType(value.ValueTypeCode)) { return(double.NaN); } return(value.ValueAsDouble()); }
private static double ToDouble(AFValue value) { if (value == null || !value.IsGood || !IsNumericType(value.ValueTypeCode)) { return(double.NaN); } // https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/M_OSIsoft_AF_Asset_AFValue_ValueAsDouble.htm return(value.ValueAsDouble()); }
private int CompareAFValue(AFValue val1, AFValue val2) { if (val1.ValueTypeCode != val2.ValueTypeCode) { throw new InvalidOperationException("Types of inputs do not match"); } if (val1.ValueTypeCode == TypeCode.Double) { return(val1.ValueAsDouble().CompareTo(val2.ValueAsDouble())); } else if (val1.ValueTypeCode == TypeCode.Single) { return(val1.ValueAsSingle().CompareTo(val2.ValueAsSingle())); } else if (val1.ValueTypeCode == TypeCode.Int32) { return(val1.ValueAsInt32().CompareTo(val2.ValueAsInt32())); } else { throw new InvalidOperationException(string.Format("Cannot compare type {0}", val1.ValueType.Name)); } }