Esempio n. 1
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 list.Add( sample );
 }
Esempio n. 2
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)list[0] ).Time.ToOADate();
         case SampleType.VelocityAvg:
             double timeDiff = sample.Time.ToOADate() - ( (Sample)list[0] ).Time.ToOADate();
             if ( timeDiff <= 0 )
                 return PointPair.Missing;
             else
                 return ( sample.Position - ( (Sample)list[0] ).Position ) / timeDiff;
         case SampleType.VelocityInst:
             return sample.Velocity;
         default:
             return PointPair.Missing;
     }
 }
Esempio n. 3
0
        private void CreateGraph_SamplePointListDemo( ZedGraphControl z1 )
        {
            GraphPane myPane = z1.GraphPane;

            myPane.Title.Text = "Demonstration of SamplePointList";
            myPane.XAxis.Title.Text = "Time since start, days";
            myPane.YAxis.Title.Text = "Postion (meters) or\nAverage Velocity (meters/day)";
            myPane.Chart.Fill = new Fill( Color.White, Color.FromArgb( 230, 230, 255 ), 45.0f );

            SamplePointList spl = new SamplePointList();

            // Calculate sample data _points
            // starting position & velocity
            double d0 = 15.0;		// m
            double v0 = 5.2;		// m/d
            double acc = 11.5;	// m/d/d
            for ( int i = 0; i < 10; i++ )
            {
                Sample sample = new Sample();

                // Samples are one day apart
                sample.Time = new DateTime( 2006, 3, i + 1 );
                // velocity in meters per day
                sample.Velocity = v0 + acc * i;
                sample.Position = acc * i * i / 2.0 + v0 * i + d0;
                spl.Add( sample );
            }

            // Create the first curve as Position vs delta time
            spl.XType = SampleType.TimeDiff;
            spl.YType = SampleType.Position;
            LineItem curve = myPane.AddCurve( "Position", spl, Color.Green, SymbolType.Diamond );
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Line.Width = 2.0f;

            // create the second curve as Average Velocity vs delta time
            SamplePointList spl2 = new SamplePointList( spl );
            spl2.YType = SampleType.VelocityAvg;
            LineItem curve2 = myPane.AddCurve( "Average Velocity", spl2, Color.Blue, SymbolType.Circle );
            curve2.Symbol.Fill = new Fill( Color.White );
            curve2.Line.Width = 2.0f;
        }