summaryrefslogtreecommitdiff
path: root/grapher/Models
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-21 00:08:19 -0700
committerJacob Palecki <[email protected]>2020-09-21 00:08:19 -0700
commitba642cd8c8e63ec3778fa17ecbcd7964074aaba1 (patch)
treebb7baaf0e076b64538b7d408cec47045c63a3a8a /grapher/Models
parentAttempt to get separate x/y working (diff)
downloadrawaccel-ba642cd8c8e63ec3778fa17ecbcd7964074aaba1.tar.xz
rawaccel-ba642cd8c8e63ec3778fa17ecbcd7964074aaba1.zip
separate x/y mostly works
Diffstat (limited to 'grapher/Models')
-rw-r--r--grapher/Models/AccelGUI.cs2
-rw-r--r--grapher/Models/Calculations/AccelCalculator.cs8
-rw-r--r--grapher/Models/Calculations/AccelChartData.cs4
-rw-r--r--grapher/Models/Calculations/AccelData.cs16
-rw-r--r--grapher/Models/Charts/AccelCharts.cs1
-rw-r--r--grapher/Models/Charts/ChartState/ChartState.cs10
-rw-r--r--grapher/Models/Charts/ChartState/XYOneGraphState.cs18
-rw-r--r--grapher/Models/Charts/ChartXY.cs26
8 files changed, 59 insertions, 26 deletions
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index 5567be3..95d0c25 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -96,8 +96,8 @@ namespace grapher
public void RefreshOnRead()
{
- UpdateGraph();
UpdateShownActiveValues();
+ UpdateGraph();
}
public void UpdateGraph()
diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs
index 35fee2d..a140c90 100644
--- a/grapher/Models/Calculations/AccelCalculator.cs
+++ b/grapher/Models/Calculations/AccelCalculator.cs
@@ -110,9 +110,9 @@ namespace grapher.Models.Calculations
var ratio = magnitudeDatum.magnitude > 0 ? magnitudeWithoutSens / magnitudeDatum.magnitude : 1;
- if (!data.Combined.AccelPoints.ContainsKey(magnitudeDatum.magnitude))
+ if (!data.Combined.VelocityPoints.ContainsKey(magnitudeDatum.magnitude))
{
- data.Combined.AccelPoints.Add(magnitudeDatum.magnitude, ratio);
+ data.Combined.VelocityPoints.Add(magnitudeDatum.magnitude, magnitudeWithoutSens);
}
var xRatio = settings.sensitivity.x * ratio;
@@ -158,8 +158,8 @@ namespace grapher.Models.Calculations
}
lastInputMagnitude = magnitudeDatum.magnitude;
- lastOutputMagnitudeX = xOutDiff;
- lastOutputMagnitudeY = yOutDiff;
+ lastOutputMagnitudeX = xOut;
+ lastOutputMagnitudeY = yOut;
}
data.Combined.OrderedVelocityPointsList.AddRange(data.Combined.VelocityPoints.Values.ToList());
diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs
index c943643..907eb0e 100644
--- a/grapher/Models/Calculations/AccelChartData.cs
+++ b/grapher/Models/Calculations/AccelChartData.cs
@@ -63,7 +63,7 @@ namespace grapher.Models.Calculations
public (double, double, double) ValuesAtIndex(int index)
{
- return (VelocityPoints.ElementAt(index).Value, AccelPoints.ElementAt(index).Value, GainPoints.ElementAt(index).Value);
+ return (AccelPoints.ElementAt(index).Value, VelocityPoints.ElementAt(index).Value, GainPoints.ElementAt(index).Value);
}
public int GetVelocityIndex(double outVelocityValue)
@@ -75,6 +75,8 @@ namespace grapher.Models.Calculations
velIdx = ~velIdx;
}
+ velIdx = Math.Min(velIdx, VelocityPoints.Count - 1);
+
return velIdx;
}
diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs
index 894774b..0fe7a3c 100644
--- a/grapher/Models/Calculations/AccelData.cs
+++ b/grapher/Models/Calculations/AccelData.cs
@@ -1,6 +1,8 @@
using grapher.Models.Charts;
+using grapher.Models.Serialized;
using System;
using System.Collections.Generic;
+using System.Linq;
namespace grapher.Models.Calculations
{
@@ -20,6 +22,8 @@ namespace grapher.Models.Calculations
Estimated = combined;
EstimatedX = x;
EstimatedY = y;
+
+ OutVelocityToPoints = new Dictionary<double, (double, double, double, double, double, double, double)>();
}
#endregion Constructors
@@ -49,6 +53,7 @@ namespace grapher.Models.Calculations
Combined.Clear();
X.Clear();
Y.Clear();
+ OutVelocityToPoints.Clear();
}
public void CalculateDots(int x, int y, double timeInMs)
@@ -77,9 +82,10 @@ namespace grapher.Models.Calculations
EstimatedY.Gain.Set(inYVelocity, yGain);
}
- public void CalculateDotsCombinedDiffSens(int x, int y, double timeInMs)
+ public void CalculateDotsCombinedDiffSens(int x, int y, double timeInMs, DriverSettings settings)
{
- var outVelocity = AccelCalculator.Velocity(x, y, timeInMs);
+ (var xStripped, var yStripped) = AccelCalculator.StripSens(x, y, settings.sensitivity.x, settings.sensitivity.y);
+ var outVelocity = AccelCalculator.Velocity(xStripped, yStripped, timeInMs);
if (OutVelocityToPoints.TryGetValue(outVelocity, out var points))
{
@@ -93,9 +99,9 @@ namespace grapher.Models.Calculations
else
{
var index = Combined.GetVelocityIndex(outVelocity);
- var inVelocity = Combined.VelocityPoints[index];
- var xPoints = X.FindPointValuesFromOut(outVelocity);
- var yPoints = Y.FindPointValuesFromOut(outVelocity);
+ var inVelocity = Combined.VelocityPoints.ElementAt(index).Value;
+ var xPoints = X.ValuesAtIndex(index);
+ var yPoints = Y.ValuesAtIndex(index);
OutVelocityToPoints.Add(outVelocity, (inVelocity, xPoints.Item1, xPoints.Item2, xPoints.Item3, yPoints.Item1, yPoints.Item2, yPoints.Item3));
EstimatedX.Sensitivity.Set(inVelocity, xPoints.Item1);
EstimatedX.Velocity.Set(inVelocity, xPoints.Item2);
diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs
index 657ae89..d22ab78 100644
--- a/grapher/Models/Charts/AccelCharts.cs
+++ b/grapher/Models/Charts/AccelCharts.cs
@@ -98,6 +98,7 @@ namespace grapher
private ChartStateManager ChartStateManager { get; }
+
#endregion Properties
#region Methods
diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs
index a219cc4..ea67e83 100644
--- a/grapher/Models/Charts/ChartState/ChartState.cs
+++ b/grapher/Models/Charts/ChartState/ChartState.cs
@@ -23,6 +23,7 @@ namespace grapher.Models.Charts.ChartState
GainChart = gainChart;
Data = accelData;
Calculator = calculator;
+ TwoDotsPerGraph = false;
}
public ChartXY SensitivityChart { get; }
@@ -37,6 +38,8 @@ namespace grapher.Models.Charts.ChartState
public virtual DriverSettings Settings { get; set; }
+ internal bool TwoDotsPerGraph { get; set; }
+
public abstract void MakeDots(int x, int y, double timeInMs);
public abstract void Bind();
@@ -44,6 +47,7 @@ namespace grapher.Models.Charts.ChartState
public abstract void Activate();
public abstract void Calculate(ManagedAccel accel, DriverSettings settings);
+
public virtual void SetUpCalculate(DriverSettings settings)
{
Data.Clear();
@@ -52,9 +56,9 @@ namespace grapher.Models.Charts.ChartState
public void DrawLastMovement()
{
- SensitivityChart.DrawLastMovementValue();
- VelocityChart.DrawLastMovementValue();
- GainChart.DrawLastMovementValue();
+ SensitivityChart.DrawLastMovementValue(TwoDotsPerGraph);
+ VelocityChart.DrawLastMovementValue(TwoDotsPerGraph);
+ GainChart.DrawLastMovementValue(TwoDotsPerGraph);
}
public void SetWidened()
diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs
index c1153c1..bbc0c28 100644
--- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs
+++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs
@@ -17,25 +17,27 @@ namespace grapher.Models.Charts.ChartState
gainChart,
accelData,
accelCalculator)
- { }
+ {
+ TwoDotsPerGraph = true;
+ }
public override void Activate()
{
- SensitivityChart.SetSeparate();
- VelocityChart.SetSeparate();
- GainChart.SetSeparate();
+ SensitivityChart.SetCombined();
+ VelocityChart.SetCombined();
+ GainChart.SetCombined();
}
public override void MakeDots(int x, int y, double timeInMs)
{
- Data.CalculateDotsCombinedDiffSens(x, y, timeInMs);
+ Data.CalculateDotsCombinedDiffSens(x, y, timeInMs, Settings);
}
public override void Bind()
{
- SensitivityChart.BindXY(Data.X.AccelPoints, Data.Y.AccelPoints);
- VelocityChart.BindXY(Data.X.VelocityPoints, Data.Y.VelocityPoints);
- GainChart.BindXY(Data.X.GainPoints, Data.Y.GainPoints);
+ SensitivityChart.BindXYCombined(Data.X.AccelPoints, Data.Y.AccelPoints);
+ VelocityChart.BindXYCombined(Data.X.VelocityPoints, Data.Y.VelocityPoints);
+ GainChart.BindXYCombined(Data.X.GainPoints, Data.Y.GainPoints);
}
public override void Calculate(ManagedAccel accel, DriverSettings settings)
diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs
index 1360409..fdd0258 100644
--- a/grapher/Models/Charts/ChartXY.cs
+++ b/grapher/Models/Charts/ChartXY.cs
@@ -117,12 +117,17 @@ namespace grapher
chart.Titles[0].Font = new System.Drawing.Font(chart.Titles[0].Font.Name, 9.0f, System.Drawing.FontStyle.Italic);
}
- public static void DrawPoint(Chart chart, PointData point)
+ public static void DrawPoint(Chart chart, PointData pointOne, PointData pointTwo = null)
{
if (chart.Visible)
{
- point.Get(out var x, out var y);
+ pointOne.Get(out var x, out var y);
chart.Series[1].Points.DataBindXY(x, y);
+ if (pointTwo != null)
+ {
+ pointTwo.Get(out x, out y);
+ chart.Series[3].Points.DataBindXY(x, y);
+ }
chart.Update();
}
}
@@ -134,11 +139,18 @@ namespace grapher
YPointData = y;
}
- public void DrawLastMovementValue()
+ public void DrawLastMovementValue(bool twoDotsPerGraph = false)
{
if(Combined)
{
- DrawPoint(ChartX, CombinedPointData);
+ if (twoDotsPerGraph)
+ {
+ DrawPoint(ChartX, XPointData, YPointData);
+ }
+ else
+ {
+ DrawPoint(ChartX, CombinedPointData);
+ }
}
else
{
@@ -164,6 +176,12 @@ namespace grapher
ChartY.Series[0].Points.DataBindXY(dataY.Keys, dataY.Values);
}
+ public void BindXYCombined(IDictionary dataX, IDictionary dataY)
+ {
+ ChartX.Series[0].Points.DataBindXY(dataX.Keys, dataX.Values);
+ ChartX.Series[2].Points.DataBindXY(dataY.Keys, dataY.Values);
+ }
+
public void SetCombined()
{
if (!Combined)