/// <remarks/> public static TsDaPropertyID GetPropertyID(int input) { FieldInfo[] fields = typeof(TsDaProperty).GetFields(BindingFlags.Static | BindingFlags.Public); foreach (FieldInfo field in fields) { TsDaPropertyID property = (TsDaPropertyID)field.GetValue(typeof(TsDaPropertyID)); if (input == property.Code) { return(property); } } return(new TsDaPropertyID(input)); }
/// <summary> /// Converts the property value to a type supported by COM-DA interface. /// </summary> internal static object MarshalPropertyValue(TsDaPropertyID propertyID, object input) { if (input == null) { return(null); } try { if (propertyID == TsDaProperty.DATATYPE) { return((short)Technosoftware.DaAeHdaClient.Com.Interop.GetType((Type)input)); } if (propertyID == TsDaProperty.ACCESSRIGHTS) { switch ((TsDaAccessRights)input) { case TsDaAccessRights.Readable: return(OpcRcw.Da.Constants.OPC_READABLE); case TsDaAccessRights.Writable: return(OpcRcw.Da.Constants.OPC_WRITEABLE); case TsDaAccessRights.ReadWritable: return(OpcRcw.Da.Constants.OPC_READABLE | OpcRcw.Da.Constants.OPC_WRITEABLE); } return(null); } if (propertyID == TsDaProperty.EUTYPE) { switch ((TsDaEuType)input) { case TsDaEuType.NoEnum: return(OpcRcw.Da.OPCEUTYPE.OPC_NOENUM); case TsDaEuType.Analog: return(OpcRcw.Da.OPCEUTYPE.OPC_ANALOG); case TsDaEuType.Enumerated: return(OpcRcw.Da.OPCEUTYPE.OPC_ENUMERATED); } return(null); } if (propertyID == TsDaProperty.QUALITY) { return(((TsCDaQuality)input).GetCode()); } // convert local time in property to UTC time for the COM DA interface. if (propertyID == TsDaProperty.TIMESTAMP) { if (input.GetType() == typeof(DateTime)) { DateTime dateTime = (DateTime)input; if (dateTime != DateTime.MinValue) { return(dateTime.ToUniversalTime()); } return(dateTime); } } } catch { } return(input); }
/// <summary> /// Converts the property value to a type supported by the unified interface. /// </summary> internal static object UnmarshalPropertyValue(TsDaPropertyID propertyID, object input) { if (input == null) { return(null); } try { if (propertyID == TsDaProperty.DATATYPE) { return(Technosoftware.DaAeHdaClient.Com.Interop.GetType((VarEnum)System.Convert.ToUInt16(input))); } if (propertyID == TsDaProperty.ACCESSRIGHTS) { switch (System.Convert.ToInt32(input)) { case OpcRcw.Da.Constants.OPC_READABLE: return(TsDaAccessRights.Readable); case OpcRcw.Da.Constants.OPC_WRITEABLE: return(TsDaAccessRights.Writable); case OpcRcw.Da.Constants.OPC_READABLE | OpcRcw.Da.Constants.OPC_WRITEABLE: { return(TsDaAccessRights.ReadWritable); } } return(null); } if (propertyID == TsDaProperty.EUTYPE) { switch ((OpcRcw.Da.OPCEUTYPE)input) { case OpcRcw.Da.OPCEUTYPE.OPC_NOENUM: return(TsDaEuType.NoEnum); case OpcRcw.Da.OPCEUTYPE.OPC_ANALOG: return(TsDaEuType.Analog); case OpcRcw.Da.OPCEUTYPE.OPC_ENUMERATED: return(TsDaEuType.Enumerated); } return(null); } if (propertyID == TsDaProperty.QUALITY) { return(new TsCDaQuality(System.Convert.ToInt16(input))); } // convert UTC time in property to local time for the unified DA interface. if (propertyID == TsDaProperty.TIMESTAMP) { if (input.GetType() == typeof(DateTime)) { DateTime dateTime = (DateTime)input; if (dateTime != DateTime.MinValue) { return(dateTime.ToLocalTime()); } return(dateTime); } } } catch { } return(input); }
protected static TsCDaItemProperty GetProperty(TsCDaBrowseElement element, TsDaPropertyID propertyId) { return element.Properties.FirstOrDefault(x => x.ID == propertyId); }