Exemple #1
0
        // Shamelessly copy pasted from XDAWaveFormDataParser
        ChannelMetadata ConvertToChannelMetadata(ParsedChannel parsedChannel)
        {
            ChannelMetadata channelRecord = new ChannelMetadata
            {
                Name = parsedChannel.Name,

                // Remove these assumptions at a later stage
                IsDigital  = false,
                SignalType = GSF.Units.EE.SignalType.ALOG
            };

            return(channelRecord);
        }
Exemple #2
0
        private ParsedChannel MakeParsedChannel(ChannelInstance channel)
        {
            // Get the time series and value series for the given channel
            SeriesInstance timeSeries   = channel.SeriesInstances.Single(series => series.Definition.ValueTypeID == SeriesValueType.Time);
            SeriesInstance valuesSeries = channel.SeriesInstances.Single(series => series.Definition.ValueTypeID == SeriesValueType.Val);

            // Set up parsed channel to be returned
            ParsedChannel parsedChannel = new ParsedChannel()
            {
                Name    = channel.Definition.ChannelName,
                YValues = valuesSeries.OriginalValues
            };

            if (timeSeries.Definition.QuantityUnits == QuantityUnits.Seconds)
            {
                // If time series is in seconds from start time of the observation record,
                // TimeValues must be calculated by adding values to start time
                parsedChannel.TimeValues = timeSeries.OriginalValues
                                           .Select(Convert.ToDouble)
                                           .Select(seconds => (long)(seconds * TimeSpan.TicksPerSecond))
                                           .Select(TimeSpan.FromTicks)
                                           .Select(timeSpan => channel.ObservationRecord.StartTime + timeSpan)
                                           .ToList();

                parsedChannel.XValues = timeSeries.OriginalValues;
            }
            else if (timeSeries.Definition.QuantityUnits == QuantityUnits.Timestamp)
            {
                // If time series is a collection of absolute time, seconds from start time
                // must be calculated by subtracting the start time of the observation record
                parsedChannel.TimeValues = timeSeries.OriginalValues.Cast <DateTime>().ToList();

                parsedChannel.XValues = timeSeries.OriginalValues
                                        .Cast <DateTime>()
                                        .Select(time => time - channel.ObservationRecord.StartTime)
                                        .Select(timeSpan => timeSpan.TotalSeconds)
                                        .Cast <object>()
                                        .ToList();
            }

            return(parsedChannel);
        }
Exemple #3
0
        // Shamelessly copy pasted from the XDAWaveFormDataParser
        // Thanks other Stephen
        private ParsedChannel MakeParsedChannel(CommaSeparatedEventReport report, Channel <double> channel)
        {
            List <DateTime> timeSamples = report.AnalogSection.TimeChannel.Samples.ToList();

            List <object> xValues = timeSamples
                                    .Select(time => time - timeSamples[0])
                                    .Select(timeSpan => timeSpan.TotalSeconds)
                                    .Cast <object>()
                                    .ToList();

            ParsedChannel parsedChannel = new ParsedChannel()
            {
                Name       = string.Format("({0}) {1}", report.Command, channel.Name),
                TimeValues = timeSamples,
                XValues    = xValues,
                YValues    = channel.Samples.Cast <object>().ToList()
            };

            return(parsedChannel);
        }
        private ParsedChannel MakeParsedChannel(CommaSeparatedEventReport report, Channel<double> channel)
        {
            List<DateTime> timeSamples = report.AnalogSection.TimeChannel.Samples.ToList();

            List<object> xValues = timeSamples
                .Select(time => time - timeSamples[0])
                .Select(timeSpan => timeSpan.TotalSeconds)
                .Cast<object>()
                .ToList();

            ParsedChannel parsedChannel = new ParsedChannel()
            {
                Name = string.Format("({0}) {1}", report.Command, channel.Name),
                TimeValues = timeSamples,
                XValues = xValues,
                YValues = channel.Samples.Cast<object>().ToList()
            };

            return parsedChannel;
        }
        private ParsedChannel MakeParsedChannel(ChannelInstance channel)
        {
            // Get the time series and value series for the given channel
            SeriesInstance timeSeries = channel.SeriesInstances.Single(series => series.Definition.ValueTypeID == SeriesValueType.Time);
            SeriesInstance valuesSeries = channel.SeriesInstances.Single(series => series.Definition.ValueTypeID == SeriesValueType.Val);

            // Set up parsed channel to be returned
            ParsedChannel parsedChannel = new ParsedChannel()
            {
                Name = channel.Definition.ChannelName,
                YValues = valuesSeries.OriginalValues
            };

            if (timeSeries.Definition.QuantityUnits == QuantityUnits.Seconds)
            {
                // If time series is in seconds from start time of the observation record,
                // TimeValues must be calculated by adding values to start time
                parsedChannel.TimeValues = timeSeries.OriginalValues
                    .Select(Convert.ToDouble)
                    .Select(seconds => (long)(seconds * TimeSpan.TicksPerSecond))
                    .Select(TimeSpan.FromTicks)
                    .Select(timeSpan => channel.ObservationRecord.StartTime + timeSpan)
                    .ToList();

                parsedChannel.XValues = timeSeries.OriginalValues;
            }
            else if (timeSeries.Definition.QuantityUnits == QuantityUnits.Timestamp)
            {
                // If time series is a collection of absolute time, seconds from start time
                // must be calculated by subtracting the start time of the observation record
                parsedChannel.TimeValues = timeSeries.OriginalValues.Cast<DateTime>().ToList();

                parsedChannel.XValues = timeSeries.OriginalValues
                    .Cast<DateTime>()
                    .Select(time => time - channel.ObservationRecord.StartTime)
                    .Select(timeSpan => timeSpan.TotalSeconds)
                    .Cast<object>()
                    .ToList();
            }

            return parsedChannel;
        }