Conversation
japsuu
left a comment
There was a problem hiding this comment.
All pending tasks need to be completed before the PR can be merged to master
| using GNSSStatus.Utils; | ||
| using YamlDotNet.Serialization; |
There was a problem hiding this comment.
Do not leave unused using statements
| //public readonly List<string> RoverFixCache = new(); | ||
| //public readonly List<string> RoverSatInUseCache = new(); | ||
| //public readonly List<GGAData.FixType> FixTypesCache = new(); |
There was a problem hiding this comment.
(RSPEC-125) Sections of code should not be commented out.
Commented-out code distracts the focus from the actual executed code. It creates a noise that increases maintenance code. And because it is never executed, it quickly becomes out of date and invalid.
Commented-out code should be deleted and can be retrieved from source control history if required.
| double roverXAverage = RoverXCache.Count > 0 ? RoverXCache.Average() : 0; | ||
| double roverYAverage = RoverYCache.Count > 0 ? RoverYCache.Average() : 0; | ||
| double roverZAverage = RoverZCache.Count > 0 ? RoverZCache.Average() : 0; | ||
| */ |
There was a problem hiding this comment.
(RSPEC-125) Sections of code should not be commented out.
| { | ||
| JsonPayloadBuilder builder = new(); | ||
|
|
||
| /* |
There was a problem hiding this comment.
(RSPEC-125) Sections of code should not be commented out.
| double deltaYMedian = DeltaYCache[medianIndex]; | ||
| double deltaXy = Math.Sqrt(deltaXMedian * deltaXMedian + deltaYMedian * deltaYMedian); | ||
| string roverUtCTime = RoverUtcTimeCache[medianIndex]; | ||
| GGAData.FixType roverFixType = RoverFixTypeCache[medianIndex]; |
There was a problem hiding this comment.
FixTypes are no longer based on the worst in measure interval.
| var indexedNumbers = list | ||
| .Select((value, index) => new { Value = value, Index = index }) | ||
| .OrderBy(x => x.Value) | ||
| .ToArray(); |
There was a problem hiding this comment.
Allocates >3 IEnumerables, not ok in embedded systems
| public (int, int) CalculateMedianIndex<T>(List<T> list) | ||
| { | ||
| // Luo kopio alkuperäisestä listasta ja liitä siihen alkuperäiset indeksit | ||
| var indexedNumbers = list |
There was a problem hiding this comment.
Prefer strong types where possible (maintainability)
| var indexedNumbers = list | ||
| .Select((value, index) => new { Value = value, Index = index }) | ||
| .OrderBy(x => x.Value) | ||
| .ToArray(); | ||
|
|
||
| int count = indexedNumbers.Length; | ||
|
|
||
| if (count % 2 == 0) | ||
| { | ||
| // Jos määrä on parillinen, laske kahden keskimmäisen luvun indeksit | ||
| int mid1Index = indexedNumbers[count / 2 - 1].Index; | ||
| int mid2Index = indexedNumbers[count / 2].Index; | ||
| return (mid1Index, mid2Index); | ||
| } | ||
| else | ||
| { | ||
| // Jos määrä on pariton, valitse keskimmäisen luvun indeksi | ||
| int medianIndex = indexedNumbers[count / 2].Index; | ||
| return (medianIndex, -1); // -1 tarkoittaa, että vain yksi mediaani löytyy | ||
| } |
There was a problem hiding this comment.
Does not work as expected, and returns incorrect indices for generic types that do not implement IComparable.
| public readonly List<string> RoverUtcTimeCache = new(); | ||
| public readonly List<GGAData.FixType> RoverFixTypeCache = new(); | ||
| public readonly List<int> RoverSatInUseCache = new(); | ||
| public readonly List<float> RoverPDopCache = new(); | ||
| public readonly List<float> RoverVDopCache = new(); | ||
| public readonly List<float> RoverHDopCache = new(); | ||
| public readonly List<float> RoverErrorLatitudeCache = new(); | ||
| public readonly List<float> RoverErrorLongitudeCache = new(); | ||
| public readonly List<float> RoverErrorAltitudeCache = new(); | ||
| public readonly List<double> RoverBaselineCache = new(); |
There was a problem hiding this comment.
No need to prefix everything with "rover"
| public readonly List<double> DeltaZCache = new(); | ||
| public readonly List<double> DeltaXCache = new(); | ||
| public readonly List<double> DeltaYCache = new(); | ||
| public readonly List<double> DeltaZCache = new(); | ||
| public readonly List<double> RoverXCache = new(); | ||
| public readonly List<double> RoverYCache = new(); | ||
| public readonly List<double> RoverZCache = new(); | ||
| public readonly List<GGAData.FixType> FixTypesCache = new(); | ||
| public readonly List<string> RoverUtcTimeCache = new(); | ||
| public readonly List<GGAData.FixType> RoverFixTypeCache = new(); | ||
| public readonly List<int> RoverSatInUseCache = new(); | ||
| public readonly List<float> RoverPDopCache = new(); | ||
| public readonly List<float> RoverVDopCache = new(); | ||
| public readonly List<float> RoverHDopCache = new(); | ||
| public readonly List<float> RoverErrorLatitudeCache = new(); | ||
| public readonly List<float> RoverErrorLongitudeCache = new(); | ||
| public readonly List<float> RoverErrorAltitudeCache = new(); | ||
| public readonly List<double> RoverBaselineCache = new(); |
There was a problem hiding this comment.
If everything needs to be averaged/median calculated, wrap in struct member (GGA, GSA, GST...) field setters. It's not maintainable to store everything publicly accessible here.
No description provided.