예제 #1
0
        /// <summary>
        /// Calculates the index range for a <see cref="ChannelDataReader"/>
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="channelIndex">Index of the channel.</param>
        /// <param name="index">The index.</param>
        private static void CalculateIndexRange(ChannelDataReader reader, ChannelIndexInfo channelIndex, int index)
        {
            _log.DebugFormat("Calculating channel index range for {0}", channelIndex.Mnemonic);

            var range = reader.GetIndexRange(index);

            channelIndex.Start = range.Start.GetValueOrDefault(double.NaN);
            channelIndex.End   = range.End.GetValueOrDefault(double.NaN);
        }
예제 #2
0
        /// <summary>
        /// Adds index data to a <see cref="ChannelDataReader"/> instance
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="mnemonic">The mnemonic.</param>
        /// <param name="unit">The unit.</param>
        /// <param name="increasing">if set to <c>true</c> the data is increasing, otherwise false.</param>
        /// <param name="isTimeIndex">if set to <c>true</c> the index is time, otherwise false.</param>
        /// <returns>The <see cref="ChannelDataReader"/> instance being updated.</returns>
        public static ChannelDataReader WithIndex(this ChannelDataReader reader, string mnemonic, string unit, bool increasing, bool isTimeIndex)
        {
            _log.DebugFormat("Adding channel index to ChannelDataReader for {0}", mnemonic);

            var index = new ChannelIndexInfo()
            {
                Mnemonic    = mnemonic,
                Increasing  = increasing,
                IsTimeIndex = isTimeIndex,
                Unit        = unit
            };

            reader.Indices.Add(index);
            CalculateIndexRange(reader, index, reader.Indices.Count - 1);

            return(reader.Sort());
        }