Report per phase measurements for correct phase #154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If/when a device registers PhaseSpecific measurements only for one specific phase (or registers them for all phases but only provides measurements for one of them), MeasurementPhaseSpecificDataForFilter() returns a []float64 containing only 1 value with no way for the API user to know for which phase the measurement was meant. This is an issue in e.g. ma/mpc's PowerPerPhase which would then return an array with less than 3 members and callers would then not know to which phase the measurement corresponds.
This PR changes the return type of MeasurementPhaseSpecificDataForFilter to always contain one entry per phase so that for a device which only reports data on phase B, it would return []float64{0, 10, 0} instead of []float64{10}. The advantage of this approach is that it doesn't change the return type of MeasurementPhaseSpecificDataForFilter or any of its callers, the downside is that callers can't (easily) distinguish devices that are reporting 0 for a phase and devices that aren't reporting a phase at all. The alternative would be to change the return type from []float64 to map[ElectricalConnectionPhaseNameType]float64 and then going through all the callers to make them use/return that as well.
I'm not particular to either approach so I picked the one that changed the surface API less.