Ejemplo n.º 1
0
        /// <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");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines whether the specified index is time.
        /// </summary>
        /// <param name="etpAdapter">The ETP adapter.</param>
        /// <param name="index">The index.</param>
        /// <returns><c>true</c> if the index is time-based; otherwise, <c>false</c>.</returns>
        public static bool IsTimeIndex(this IEtpAdapter etpAdapter, IIndexMetadataRecord index)
        {
            if (index == null)
            {
                return(false);
            }

            return(etpAdapter is Energistics.Etp.v11.Etp11Adapter
                ? index.IndexKind == (int)Energistics.Etp.v11.Datatypes.ChannelData.ChannelIndexTypes.Time
                : index.IndexKind == (int)Energistics.Etp.v12.Datatypes.ChannelData.ChannelIndexKinds.Time);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines whether the specified index is increasing.
        /// </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 bool IsIncreasing(this IEtpAdapter etpAdapter, IIndexMetadataRecord index)
        {
            if (index == null)
            {
                return(false);
            }

            return(etpAdapter is Energistics.Etp.v11.Etp11Adapter
                ? index.Direction == (int)Energistics.Etp.v11.Datatypes.ChannelData.IndexDirections.Increasing
                : index.Direction == (int)Energistics.Etp.v12.Datatypes.ChannelData.IndexDirections.Increasing);
        }
Ejemplo n.º 4
0
        /// <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");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Determines whether the specified index is time.
        /// </summary>
        /// <param name="etpAdapter">The ETP adapter.</param>
        /// <param name="index">The index.</param>
        /// <returns><c>true</c> if the index is time-based; otherwise, <c>false</c>.</returns>
        public static bool IsTimeIndex(this IEtpAdapter etpAdapter, IIndexMetadataRecord index)
        {
            if (index == null)
            {
                return(false);
            }

            return(etpAdapter.SupportedVersion == EtpVersion.v11
                ? index.IndexKind == (int)Energistics.Etp.v11.Datatypes.ChannelData.ChannelIndexTypes.Time
                : index.IndexKind == (int)Energistics.Etp.v12.Datatypes.ChannelData.ChannelIndexKind.Time);
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        /// <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);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Converts a logCurveInfo to a channel metadata record.
        /// </summary>
        /// <param name="etpAdapter">The ETP adapter.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="curve">The curve.</param>
        /// <param name="indexMetadata">The index metadata.</param>
        /// <returns></returns>
        protected override IChannelMetadataRecord ToChannelMetadataRecord(IEtpAdapter etpAdapter, Log entity, LogCurveInfo curve, IIndexMetadataRecord indexMetadata)
        {
            var uri          = curve.GetUri(entity);
            var isTimeLog    = IsTimeLog(entity, true);
            var curveIndexes = GetCurrentIndexRange(entity);
            var unixTime     = entity.CommonData.DateTimeLastChange.ToUnixTimeMicroseconds();

            var dataObject = etpAdapter.CreateDataObject();

            etpAdapter.SetDataObject(dataObject, curve, uri, curve.Mnemonic, 0, unixTime.GetValueOrDefault());

            var metadata = etpAdapter.CreateChannelMetadata(uri);

            metadata.DataType     = curve.TypeLogData.GetValueOrDefault(LogDataType.@double).ToString().Replace("@", string.Empty);
            metadata.Description  = curve.CurveDescription ?? curve.Mnemonic;
            metadata.ChannelName  = curve.Mnemonic;
            metadata.Uom          = Units.GetUnit(curve.Unit);
            metadata.MeasureClass = curve.ClassWitsml?.Name ?? ObjectTypes.Unknown;
            metadata.Source       = curve.DataSource ?? ObjectTypes.Unknown;
            metadata.DomainObject = dataObject;
            metadata.Status       = etpAdapter.GetChannelStatus(entity.ObjectGrowing.GetValueOrDefault());
            metadata.StartIndex   = curveIndexes[curve.Mnemonic].Start.IndexToScale(indexMetadata.Scale, isTimeLog);
            metadata.EndIndex     = curveIndexes[curve.Mnemonic].End.IndexToScale(indexMetadata.Scale, isTimeLog);
            metadata.Indexes      = etpAdapter.ToList(new List <IIndexMetadataRecord> {
                indexMetadata
            });

            return(metadata);
        }
Ejemplo n.º 9
0
        private IChannelMetadataRecord ToChannelMetadataRecord(IEtpAdapter etpAdapter, Trajectory entity, IIndexMetadataRecord indexMetadata)
        {
            var uri         = entity.GetUri();
            var lastChanged = entity.Citation.LastUpdate.ToUnixTimeMicroseconds().GetValueOrDefault();

            var dataObject = etpAdapter.CreateDataObject();

            etpAdapter.SetDataObject(dataObject, entity, uri, entity.Citation.Title, 0, lastChanged);

            var metadata = etpAdapter.CreateChannelMetadata(uri);

            metadata.DataType     = [email protected]();
            metadata.Description  = entity.Citation.Description ?? entity.Citation.Title;
            metadata.ChannelName  = entity.Citation.Title;
            metadata.Uom          = Units.GetUnit(entity.MDMin?.Uom.ToString());
            metadata.MeasureClass = ObjectTypes.Unknown;
            metadata.Source       = ObjectTypes.Unknown;
            metadata.Uuid         = entity.Uuid;
            metadata.DomainObject = dataObject;
            metadata.Status       = etpAdapter.GetChannelStatus(entity.GrowingStatus == ChannelStatus.active);
            metadata.StartIndex   = entity.MDMin?.Value.IndexToScale(indexMetadata.Scale);
            metadata.EndIndex     = entity.MDMax?.Value.IndexToScale(indexMetadata.Scale);
            metadata.Indexes      = etpAdapter.ToList(new List <IIndexMetadataRecord> {
                indexMetadata
            });

            return(metadata);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Determines if the specified index metadata is time-based.
 /// </summary>
 /// <param name="index">The index metadata.</param>
 /// <returns><c>true</c> if the index is time-based; otherwise, <c>false</c>.</returns>
 public bool IsTimeIndex(IIndexMetadataRecord index)
 {
     return(index?.IndexKind == (int)ChannelIndexKind.Time);
 }
Ejemplo n.º 11
0
        public IChannelMetadataRecord ToChannelMetadataRecord(IChannelMetadataRecord channelMetadata, IIndexMetadataRecord indexMetadata)
        {
            var uri = GetChannelUri(channelMetadata.ChannelName);

            var channel = new ChannelMetadataRecord
            {
                ChannelUri   = uri,
                ContentType  = uri.ContentType,
                ChannelId    = channelMetadata.ChannelId,
                ChannelName  = channelMetadata.ChannelName,
                Uom          = channelMetadata.Uom,
                MeasureClass = channelMetadata.MeasureClass,
                DataType     = channelMetadata.DataType,
                Description  = channelMetadata.Description,
                Uuid         = channelMetadata.Uuid,
                Status       = (ChannelStatuses)channelMetadata.Status,
                Source       = channelMetadata.Source,
                Indexes      = new[] { indexMetadata }
                .OfType <IndexMetadataRecord>()
                .ToList(),
                CustomData = new Dictionary <string, DataValue>()
            };

            return(channel);
        }