public static Type GetNETDataType(this TDMChannelDataTypes ddcDataType) { switch (ddcDataType) { case TDMChannelDataTypes.DDC_Double: return(typeof(double)); case TDMChannelDataTypes.DDC_Float: return(typeof(float)); case TDMChannelDataTypes.DDC_Int16: return(typeof(Int16)); case TDMChannelDataTypes.DDC_Int32: return(typeof(Int32)); case TDMChannelDataTypes.DDC_String: return(typeof(string)); case TDMChannelDataTypes.DDC_Timestamp: return(typeof(DateTime)); case TDMChannelDataTypes.DDC_UInt8: return(typeof(Byte)); } throw new NotImplementedException("Unsupported DataType"); }
/// <summary> /// returns the matching channel content type. /// returns <see cref="CommonChannelDataTypes.DIAdemFileSpecific"/> if no DIAdem common type is stored in this channel /// </summary> /// <param name="dataTypes">type to be mapped</param> /// <returns></returns> public static CommonChannelDataTypes ToCommonChannelDataType(this TDMChannelDataTypes dataTypes) { switch (dataTypes) { case TDMChannelDataTypes.DDC_Int16: return(CommonChannelDataTypes.Int16); case TDMChannelDataTypes.DDC_Int32: return(CommonChannelDataTypes.Int32); case TDMChannelDataTypes.DDC_Float: return(CommonChannelDataTypes.Single); case TDMChannelDataTypes.DDC_Double: return(CommonChannelDataTypes.Double); case TDMChannelDataTypes.DDC_String: return(CommonChannelDataTypes.String); default: return(CommonChannelDataTypes.DIAdemFileSpecific); } }
internal static object GetPropertyData <THandl>(THandl h, string propertyName, TDMChannelDataTypes dataType) where THandl : Handle { //if (typeof(TVal) != dataType.GetNETDataType()) // throw new InvalidCastException($"Type {typeof(TVal).ToString()} was provided but type {dataType.GetNETDataType()} was expected. Provide a matching parameter to parameter{nameof(dataType)}."); switch (dataType) { case TDMChannelDataTypes.DDC_Double: return(GetDoubleValue(h, propertyName)); case TDMChannelDataTypes.DDC_Float: return(GetFloatValue(h, propertyName)); case TDMChannelDataTypes.DDC_Int16: return(GetInt16Value(h, propertyName)); case TDMChannelDataTypes.DDC_Int32: return(GetInt32Value(h, propertyName)); case TDMChannelDataTypes.DDC_String: return(GetStringValue(h, propertyName)); case TDMChannelDataTypes.DDC_Timestamp: return(GetDateTimeValue(h, propertyName)); case TDMChannelDataTypes.DDC_UInt8: return(GetUInt8Value(h, propertyName)); } throw new NotImplementedException("DataType not supported."); }