public NormativeAnalysisComponent(AnalysisMetric metric, TestAnalysisComponentField field, double min, double max)
 {
     Metric = metric;
     Field = field;
     Min = min;
     Max = max;
 }
        /// <summary>
        /// Constructs a new instance of the NormativeAnalysis class and gets analysis
        /// data from the database for the specified script ID.
        /// </summary>
        /// <param name="testID">The database ID for the script for which to retrieve a normative analysis.</param>
        public NormativeAnalysis(int scriptID)
        {
            using (IDataReader Reader = ExecuteReader(GetConnection(),
                                                      "GET_NORMATIVE_ANALYSIS",
                                                      CommandBehavior.CloseConnection,
                                                      "@script_id", scriptID))
            {
                while (Reader.Read())
                {
                    AnalysisMetric Metric = (AnalysisMetric)Reader["metric_id"];
                    List <NormativeAnalysisComponent> MetricList;

                    if (!Components.TryGetValue(Metric, out MetricList))
                    {
                        MetricList = new List <NormativeAnalysisComponent>();
                        Components.Add(Metric, MetricList);
                    }

                    MetricList.Add(new NormativeAnalysisComponent(
                                       Metric,
                                       (TestAnalysisComponentField)Reader["metric_field_id"],
                                       (double)Reader["min"],
                                       (double)Reader["max"]));
                }
            }
        }
 public NormativeAnalysisComponent(AnalysisMetric metric, TestAnalysisComponentField field, double min, double max)
 {
     Metric = metric;
     Field  = field;
     Min    = min;
     Max    = max;
 }
Ejemplo n.º 4
0
 public AnalysisComponent this[AnalysisMetric m]
 {
     get
     {
         AnalysisComponent c;
         return(Metrics.TryGetValue(m, out c) ? c : AnalysisComponent.INVALID);
     }
 }
Ejemplo n.º 5
0
 public TestAnalysisComponent(AnalysisMetric metric, int count, double sum, double mean, double stddev, double min, double max)
 {
     Metric = metric;
     Count  = count;
     Sum    = sum;
     Mean   = mean;
     StdDev = stddev;
     Min    = min;
     Max    = max;
 }
        public void ShowAnalysis(AnalysisMetric metric, List<CalibratedInkSample> samples)
        {
            if (samples == null)
                return;
            else if (mComboBox.SelectedItem == null || (AnalysisMetric)mComboBox.SelectedItem != metric)
                mComboBox.SelectedItem = metric;

            _LastSamples = samples;
            mAnalysisPlot.ShowAnalysis(metric, samples);
        }
Ejemplo n.º 7
0
 private void ShowAnalysis(
     AnalysisMetric metric,
     List <double> time,
     List <double> breaks,
     List <double> data,
     int derivative,
     Unit dataUnit)
 {
     Title  = string.Format("{0} vs {1}", metric, "Time");
     YLabel = string.Format("{0} {1}", metric, dataUnit.Label);
     ShowData(metric.ToString(), Color.Black, time.ToArray(), data.ToArray(), derivative);
     ShowBreaks(Color.Black, breaks.ToArray());
 }
        public void ShowAnalysis(AnalysisMetric metric, List <CalibratedInkSample> samples)
        {
            if (samples == null)
            {
                return;
            }
            else if (mComboBox.SelectedItem == null || (AnalysisMetric)mComboBox.SelectedItem != metric)
            {
                mComboBox.SelectedItem = metric;
            }

            _LastSamples = samples;
            mAnalysisPlot.ShowAnalysis(metric, samples);
        }
Ejemplo n.º 9
0
        internal AnalysisComponent(Analyzer.RunningCount r)
        {
            Metric = r.Metric;

            Count = r.Count;
            Sum   = r.Sum;

            Mean   = r.Mean;
            StdDev = r.StdDev;
            Min    = r.Min;
            Max    = r.Max;

            if (!IsValid(Count))
            {
                Count = 0;
            }
            if (!IsValid(Sum))
            {
                Sum = 0;
            }

            if (!IsValid(Mean))
            {
                Mean = 0;
            }
            if (!IsValid(StdDev))
            {
                StdDev = 0;
            }

            if (!IsValid(Min))
            {
                Min = 0;
            }
            if (!IsValid(Max))
            {
                Max = 0;
            }
        }
Ejemplo n.º 10
0
        private void ShowOtherAnalysis(
            AnalysisMetric metric,
            List <double> t,
            List <double> b,
            List <double> x,
            List <double> y,
            List <double> p)
        {
            List <double> Temp;

            switch (metric)
            {
            case AnalysisMetric.Time:
                ShowAnalysis(metric, t, b, t, 0, StandardUnits.Time);
                break;

            case AnalysisMetric.TimeDelta:
                Temp = new List <double>(t.Count);
                for (int i = 1; i < t.Count; i++)
                {
                    Temp.Add(t[i] - t[i - 1]);
                }
                Temp.Add(0);

                ShowAnalysis(metric, t, b, Temp, 0, StandardUnits.Time);
                break;

            case AnalysisMetric.Distance:
                Temp = new List <double>(t.Count);
                Temp.Add(0);       //use the pressure array as a temp
                for (int i = 1; i < t.Count; i++)
                {
                    Temp.Add(Temp[Temp.Count - 1] + new Analyzer.Vector2(x[i] - x[i - 1], y[i] - y[i - 1]).Norm());
                }

                ShowAnalysis(metric, t, b, Temp, 0, StandardUnits.Distance);
                break;
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Accesses a specific analysis component in this instance.
 /// </summary>
 /// <param name="value">The metric to get the analysis for.</param>
 /// <returns>The analysis result for the given metric.</returns>
 public TestAnalysisComponent this[AnalysisMetric value] {
     get { return(Components[value]); }
 }
 /// <summary>
 /// Accesses a specific analysis component in this instance.
 /// </summary>
 /// <param name="value">The metric to get the analysis for.</param>
 /// <returns>The analysis result for the given metric.</returns>
 public List<NormativeAnalysisComponent> this[AnalysisMetric value]
 {
     get { return Components[value]; }
 }
 /// <summary>
 /// Accesses a specific analysis component in this instance.
 /// </summary>
 /// <param name="value">The metric to get the analysis for.</param>
 /// <returns>The analysis result for the given metric.</returns>
 public List <NormativeAnalysisComponent> this[AnalysisMetric value] {
     get { return(Components[value]); }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Shows an analysis.
        /// </summary>
        /// <param name="metric">The metric to show.</param>
        /// <param name="t">The time data.</param>
        /// <param name="b">The timestamps where there is a gap in the data.</param>
        /// <param name="x">The x-coord data.</param>
        /// <param name="y">The y-coord data.</param>
        /// <param name="p">The pressure data.</param>
        public void ShowAnalysis(
            AnalysisMetric metric,
            List <CalibratedInkSample> samples)
        {
            Clear();

            if (samples.Count == 0)
            {
                return;
            }

            List <double> t = new List <double>(samples.Count),
                          x = new List <double>(samples.Count),
                          y = new List <double>(samples.Count),
                          p = new List <double>(samples.Count),
                          b = new List <double>();

            foreach (CalibratedInkSample s in samples)
            {
                if (s.IsInvalid())
                {
                    b.Add(s.Time);
                }
                else
                {
                    t.Add(s.Time);
                    x.Add(s.X);
                    y.Add(s.Y);
                    p.Add(s.Pressure);
                }
            }

            switch (metric)
            {
            //CARTESIAN PLOTS
            case AnalysisMetric.X:
                ShowAnalysis(metric, t, b, x, 0, StandardUnits.Distance);
                break;

            case AnalysisMetric.Y:
                ShowAnalysis(metric, t, b, y, 0, StandardUnits.Distance);
                break;

            case AnalysisMetric.Pressure:
                ShowAnalysis(metric, t, b, p, 0, StandardUnits.Pressure);
                break;

            case AnalysisMetric.VelocityX:
                ShowAnalysis(metric, t, b, x, 1, StandardUnits.Distance.TimeDerivative(1));
                break;

            case AnalysisMetric.VelocityY:
                ShowAnalysis(metric, t, b, y, 1, StandardUnits.Distance.TimeDerivative(1));
                break;

            case AnalysisMetric.MassFlux:
                ShowAnalysis(metric, t, b, p, 1, StandardUnits.Pressure.TimeDerivative(1));
                break;

            case AnalysisMetric.AccelerationX:
                ShowAnalysis(metric, t, b, x, 2, StandardUnits.Distance.TimeDerivative(2));
                break;

            case AnalysisMetric.AccelerationY:
                ShowAnalysis(metric, t, b, y, 2, StandardUnits.Distance.TimeDerivative(2));
                break;

            //POLAR PLOTS
            case AnalysisMetric.Rho:
            case AnalysisMetric.Theta:
            case AnalysisMetric.VelocityRho:
            case AnalysisMetric.VelocityTheta:
            case AnalysisMetric.VelocityTangent:
            case AnalysisMetric.AccelerationRho:
            case AnalysisMetric.AccelerationTheta:
            case AnalysisMetric.AccelerationTangent:
                ShowPolarAnalysis(metric, t, b, x, y, p);
                break;

            case AnalysisMetric.Time:
            case AnalysisMetric.TimeDelta:
            case AnalysisMetric.Distance:
                ShowOtherAnalysis(metric, t, b, x, y, p);
                break;

            case AnalysisMetric.Deviation:
            case AnalysisMetric.InnerDeviation:
            case AnalysisMetric.OuterDeviation:
            case AnalysisMetric.Invalid:
                throw new NotSupportedException();

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 15
0
        private void ShowPolarAnalysis(
            AnalysisMetric metric,
            List <double> t,
            List <double> b,
            List <double> x,
            List <double> y,
            List <double> p)
        {
            Analyzer.RunningCount XCounter = new Analyzer.RunningCount(AnalysisMetric.Invalid),
                                  YCounter = new Analyzer.RunningCount(AnalysisMetric.Invalid);

            for (int i = 0; i < t.Count; i++)
            {
                XCounter.Add(x[i]);
                YCounter.Add(y[i]);
            }

            double XMean = XCounter.Mean,
                   YMean = YCounter.Mean;

            List <double> Rho    = new List <double>(t.Count),
                          Theta  = new List <double>(t.Count),
                          VelTan = new List <double>(t.Count);

            for (int i = 0; i < t.Count; i++)
            {
                double XCentered = x[i] - XMean,
                       YCentered = y[i] - YMean;

                Theta.Add(Math.Atan(YCentered / XCentered));
                Rho.Add(new Analyzer.Vector2(XCentered, YCentered).Norm());
                VelTan.Add(Theta[i] * Rho[i]);
            }

            switch (metric)
            {
            case AnalysisMetric.Rho:
                ShowAnalysis(metric, t, b, Rho, 0, StandardUnits.Distance);
                break;

            case AnalysisMetric.Theta:
                ShowAnalysis(metric, t, b, Theta, 0, StandardUnits.Angle);
                break;

            case AnalysisMetric.VelocityRho:
                ShowAnalysis(metric, t, b, Rho, 1, StandardUnits.Distance.TimeDerivative(1));
                break;

            case AnalysisMetric.VelocityTheta:
                ShowAnalysis(metric, t, b, Theta, 1, StandardUnits.Angle.TimeDerivative(1));
                break;

            case AnalysisMetric.VelocityTangent:
                ShowAnalysis(metric, t, b, VelTan, 0, StandardUnits.Distance.TimeDerivative(1));
                break;

            case AnalysisMetric.AccelerationRho:
                ShowAnalysis(metric, t, b, Rho, 2, StandardUnits.Distance.TimeDerivative(2));
                break;

            case AnalysisMetric.AccelerationTheta:
                ShowAnalysis(metric, t, b, Theta, 2, StandardUnits.Angle.TimeDerivative(2));
                break;

            case AnalysisMetric.AccelerationTangent:
                ShowAnalysis(metric, t, b, VelTan, 1, StandardUnits.Distance.TimeDerivative(2));
                break;

            default:
                throw new NotSupportedException();
            }
        }
Ejemplo n.º 16
0
 private RunningCount this[AnalysisMetric m] {
     get { return(Counters[(int)m]); }
 }
Ejemplo n.º 17
0
 public RunningCount(AnalysisMetric m)
 {
     Metric = m;
     Clear();
 }
Ejemplo n.º 18
0
 private RunningCount this[AnalysisMetric m]
 {
     get { return Counters[(int)m]; }
 }