From 246fb772c5bf7dd6a85143fadebece3b4d9f1e04 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 1 Sep 2020 02:18:41 -0700 Subject: Add constants class and separate classes into regions --- grapher/Models/Calculations/AccelCalculator.cs | 28 +++++++++++++++++--------- grapher/Models/Calculations/AccelChartData.cs | 12 +++++++++++ grapher/Models/Calculations/AccelData.cs | 10 +++++++++ 3 files changed, 41 insertions(+), 9 deletions(-) (limited to 'grapher/Models/Calculations') diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 102de8d..0f0a60a 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -1,4 +1,5 @@ -using grapher.Models.Serialized; +using grapher.Constants; +using grapher.Models.Serialized; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -11,11 +12,7 @@ namespace grapher.Models.Calculations { public class AccelCalculator { - public const int DefaultDPI = 1200; - public const int DefaultPollRate = 1000; - public const int Resolution = 100; - public const double MaxMultiplier = 85; - public const double XYToCombinedRatio = 1.3; + #region Structs public struct MagnitudeData { @@ -24,6 +21,9 @@ namespace grapher.Models.Calculations public int y; } + #endregion Structs + + #region Constructors public AccelCalculator(Field dpi, Field pollRate) { @@ -31,6 +31,10 @@ namespace grapher.Models.Calculations PollRate = pollRate; } + #endregion Constructors + + #region Properties + public ReadOnlyCollection MagnitudesCombined { get; private set; } public ReadOnlyCollection MagnitudesX { get; private set; } @@ -47,6 +51,10 @@ namespace grapher.Models.Calculations private int Increment { get; set; } + #endregion Fields + + #region Methods + public void Calculate(AccelData data, ManagedAccel accel, DriverSettings settings) { ScaleByMouseSettings(); @@ -171,12 +179,14 @@ namespace grapher.Models.Calculations public void ScaleByMouseSettings() { var dpiPollFactor = DPI.Data / PollRate.Data; - CombinedMaxVelocity = dpiPollFactor * MaxMultiplier; - Increment = (int) Math.Floor(CombinedMaxVelocity / Resolution); - XYMaxVelocity = CombinedMaxVelocity * 1.5; + CombinedMaxVelocity = dpiPollFactor * AccelGUIConstants.MaxMultiplier; + Increment = (int) Math.Floor(CombinedMaxVelocity / AccelGUIConstants.Resolution); + XYMaxVelocity = CombinedMaxVelocity * AccelGUIConstants.XYToCombinedRatio; MagnitudesCombined = GetMagnitudes(); MagnitudesX = GetMagnitudesX(); MagnitudesY = GetMagnitudesY(); } + + #endregion Methods } } diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index 20142a7..6b29f16 100644 --- a/grapher/Models/Calculations/AccelChartData.cs +++ b/grapher/Models/Calculations/AccelChartData.cs @@ -8,6 +8,8 @@ namespace grapher.Models.Calculations { public class AccelChartData { + #region Constructors + public AccelChartData() { AccelPoints = new SortedDictionary(); @@ -17,6 +19,10 @@ namespace grapher.Models.Calculations OutVelocityToPoints = new Dictionary(); } + #endregion Constructors + + #region Properties + public SortedDictionary AccelPoints { get; } public SortedDictionary VelocityPoints { get; } @@ -27,6 +33,10 @@ namespace grapher.Models.Calculations public Dictionary OutVelocityToPoints { get; } + #endregion Properties + + #region Methods + public void Clear() { AccelPoints.Clear(); @@ -57,5 +67,7 @@ namespace grapher.Models.Calculations return values; } } + + #endregion Methods } } diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs index 683c67e..3e1f987 100644 --- a/grapher/Models/Calculations/AccelData.cs +++ b/grapher/Models/Calculations/AccelData.cs @@ -10,6 +10,7 @@ namespace grapher.Models.Calculations { public class AccelData { + #region Constructors public AccelData( EstimatedPoints combined, @@ -25,6 +26,10 @@ namespace grapher.Models.Calculations EstimatedY = y; } + #endregion Constructors + + #region Properties + public AccelChartData Combined { get; } public AccelChartData X { get; } @@ -37,6 +42,10 @@ namespace grapher.Models.Calculations private EstimatedPoints EstimatedY { get; } + #endregion Properties + + #region Methods + public void Clear() { Combined.Clear(); @@ -70,5 +79,6 @@ namespace grapher.Models.Calculations EstimatedY.Gain.Set(inYVelocity, yGain); } + #endregion Methods } } -- cgit v1.2.3 From 4aa2f3ed741dcbd39233e125a34cac8163267d8d Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 1 Sep 2020 02:39:09 -0700 Subject: Move constants to central class --- grapher/Models/Calculations/AccelCalculator.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'grapher/Models/Calculations') diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 0f0a60a..4e44902 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -1,5 +1,4 @@ -using grapher.Constants; -using grapher.Models.Serialized; +using grapher.Models.Serialized; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -179,9 +178,9 @@ namespace grapher.Models.Calculations public void ScaleByMouseSettings() { var dpiPollFactor = DPI.Data / PollRate.Data; - CombinedMaxVelocity = dpiPollFactor * AccelGUIConstants.MaxMultiplier; - Increment = (int) Math.Floor(CombinedMaxVelocity / AccelGUIConstants.Resolution); - XYMaxVelocity = CombinedMaxVelocity * AccelGUIConstants.XYToCombinedRatio; + CombinedMaxVelocity = dpiPollFactor * Constants.MaxMultiplier; + Increment = (int)Math.Floor(CombinedMaxVelocity / Constants.Resolution); + XYMaxVelocity = CombinedMaxVelocity * Constants.XYToCombinedRatio; MagnitudesCombined = GetMagnitudes(); MagnitudesX = GetMagnitudesX(); MagnitudesY = GetMagnitudesY(); -- cgit v1.2.3 From 9502dcf7608475857b1487375997d20a9d29622e Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 8 Sep 2020 01:26:22 -0700 Subject: Remove and sort usings en masse --- grapher/Models/Calculations/AccelCalculator.cs | 3 --- grapher/Models/Calculations/AccelChartData.cs | 2 -- grapher/Models/Calculations/AccelData.cs | 5 ----- 3 files changed, 10 deletions(-) (limited to 'grapher/Models/Calculations') diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index 4e44902..092a7aa 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -3,9 +3,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; namespace grapher.Models.Calculations { diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index 6b29f16..8c0c8ea 100644 --- a/grapher/Models/Calculations/AccelChartData.cs +++ b/grapher/Models/Calculations/AccelChartData.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace grapher.Models.Calculations { diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs index 3e1f987..eef4d01 100644 --- a/grapher/Models/Calculations/AccelData.cs +++ b/grapher/Models/Calculations/AccelData.cs @@ -1,10 +1,5 @@ using grapher.Models.Charts; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static grapher.AccelCharts; namespace grapher.Models.Calculations { -- cgit v1.2.3