summaryrefslogtreecommitdiff
path: root/grapher/Models/Calculations/Data/AccelDataCombined.cs
blob: 025a344a548bd6c020fec6fb0eb7cc7566289848 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using grapher.Models.Charts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace grapher.Models.Calculations.Data
{
    public class AccelDataCombined : IAccelData
    {
        public AccelDataCombined(EstimatedPoints points, AccelCalculator calculator)
        {
            X = new AccelChartData();
            Points = points;
            Calculator = calculator;
        }

        public AccelChartData X { get; }

        public AccelChartData Y { get => X; }

        private EstimatedPoints Points { get; }

        private AccelCalculator Calculator { get; }

        public void CalculateDots(double x, double y, double timeInMs)
        {
            var outVelocity = AccelCalculator.Velocity(x, y, timeInMs);

            (var inCombVel, var combSens, var combGain) = X.FindPointValuesFromOut(outVelocity);
            Points.Velocity.Set(inCombVel, outVelocity);
            Points.Sensitivity.Set(inCombVel, combSens);
            Points.Gain.Set(inCombVel, combGain);

        }

        public void Clear()
        {
            X.Clear();
        }

        public void CreateGraphData(ManagedAccel accel, Profile settings)
        {
            Clear();
            Calculator.Calculate(X, accel, settings.sensitivity, Calculator.SimulatedInputCombined);
        }
    }
}