private IChannelMetadataRecord ToChannelMetadataRecord(IEtpAdapter etpAdapter, Channel channel, IList <IIndexMetadataRecord> indexMetadata) { var uri = channel.GetUri(); var channelIndex = GetIndexRange(channel); var lastChanged = channel.Citation.LastUpdate.ToUnixTimeMicroseconds().GetValueOrDefault(); var primaryIndex = indexMetadata.FirstOrDefault(); var isTimeIndex = etpAdapter.IsTimeIndex(primaryIndex); var dataObject = etpAdapter.CreateDataObject(); etpAdapter.SetDataObject(dataObject, channel, uri, channel.Mnemonic, 0, lastChanged); var metadata = etpAdapter.CreateChannelMetadata(uri); metadata.DataType = channel.DataType.GetValueOrDefault(EtpDataType.@double).ToString().Replace("@", string.Empty); metadata.Description = channel.Citation != null ? channel.Citation.Description ?? channel.Mnemonic : channel.Mnemonic; metadata.ChannelName = channel.Mnemonic; metadata.Uom = Units.GetUnit(channel.Uom); metadata.MeasureClass = channel.ChannelClass?.Title ?? ObjectTypes.Unknown; metadata.Source = channel.Source ?? ObjectTypes.Unknown; metadata.Uuid = channel.Mnemonic; metadata.DomainObject = dataObject; //metadata.Status = (ChannelStatuses)(int)channel.GrowingStatus.GetValueOrDefault(ChannelStatus.inactive); metadata.StartIndex = primaryIndex == null ? null : channelIndex.Start.IndexToScale(primaryIndex.Scale, isTimeIndex); metadata.EndIndex = primaryIndex == null ? null : channelIndex.End.IndexToScale(primaryIndex.Scale, isTimeIndex); metadata.Indexes = etpAdapter.ToList(indexMetadata); return(metadata); }
/// <summary> /// Determines the data type of the index. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="index">The index.</param> /// <returns><c>true</c> if the index is increasing; otherwise, <c>false</c>.</returns> public static string GetDataType(this IEtpAdapter etpAdapter, IIndexMetadataRecord index) { if (index == null) { return(string.Empty); } return(etpAdapter is Energistics.Etp.v11.Etp11Adapter ? "long" : etpAdapter.IsTimeIndex(index) ? "long" : "double"); }
/// <summary> /// Determines the data type of the index. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="index">The index.</param> /// <returns><c>true</c> if the index is increasing; otherwise, <c>false</c>.</returns> public static string GetDataType(this IEtpAdapter etpAdapter, IIndexMetadataRecord index) { if (index == null) { return(string.Empty); } return(etpAdapter.SupportedVersion == EtpVersion.v11 ? "long" : etpAdapter.IsTimeIndex(index) ? "long" : "double"); }
/// <summary> /// Returns the specified indexValue as an object of the correct type. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="index">The index metadata.</param> /// <param name="indexValue">The index value.</param> /// <returns> /// <c>true</c> if the index is increasing; otherwise, <c>false</c>. /// </returns> public static object GetIndexValue(this IEtpAdapter etpAdapter, IIndexMetadataRecord index, long?indexValue) { if (index == null) { return(string.Empty); } var value = indexValue ?? 0; if (etpAdapter is Energistics.Etp.v11.Etp11Adapter || etpAdapter.IsTimeIndex(index)) { return(value); } return((double)value); }
/// <summary> /// Returns the specified indexValue as an object of the correct type. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="index">The index metadata.</param> /// <param name="indexValue">The index value.</param> /// <returns> /// <c>true</c> if the index is increasing; otherwise, <c>false</c>. /// </returns> public static object GetIndexValue(this IEtpAdapter etpAdapter, IIndexMetadataRecord index, long?indexValue) { if (index == null) { return(string.Empty); } var value = indexValue ?? 0; if (etpAdapter.SupportedVersion == EtpVersion.v11 || etpAdapter.IsTimeIndex(index)) { return(value); } return((double)value); }