Пример #1
0
        /// <summary>
        /// Get the specified data type from the specified sample
        /// </summary>
        /// <param name="sample">
        /// The sample instance of interest
        /// </param>
        /// <param name="type">
        /// The data type to be extracted from the sample
        /// </param>
        /// <returns>
        /// A double value representing the requested data
        /// </returns>
        public double GetValue(Sample sample, SampleType type)
        {
            switch (type)
            {
                case SampleType.Position:
                    return sample.Position;
                case SampleType.Time:
                    return sample.Time.ToOADate();
                case SampleType.TimeDiff:
                    return sample.Time.ToOADate() - ((Sample)this.list[0]).Time.ToOADate();
                case SampleType.VelocityAvg:
                    double timeDiff = sample.Time.ToOADate() - ((Sample)this.list[0]).Time.ToOADate();
                    if (timeDiff <= 0)
                    {
                        return PointPairBase.Missing;
                    }

                    return (sample.Position - ((Sample)this.list[0]).Position) / timeDiff;
                case SampleType.VelocityInst:
                    return sample.Velocity;
                default:
                    return PointPairBase.Missing;
            }
        }
Пример #2
0
 /// <summary>
 /// Append a sample to the collection
 /// </summary>
 /// <param name="sample">
 /// The sample to append
 /// </param>
 /// <returns>
 /// The ordinal position at which the sample was added
 /// </returns>
 public int Add(Sample sample)
 {
     return this.list.Add(sample);
 }