EU Data Act: fix soc (#31259)
This commit is contained in:
parent
5c53a70849
commit
37e96867ab
4 changed files with 8013 additions and 45 deletions
8003
vehicle/vw/eudataact/datadictionary.json
Normal file
8003
vehicle/vw/eudataact/datadictionary.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -186,44 +186,22 @@ func TestSocFreshestField(t *testing.T) {
|
|||
|
||||
// first datasets carry both SoC fields at 57, the high-priority field winning
|
||||
deliver([]point{
|
||||
{Name: FieldBatteryStateReportSoc, Value: "57"},
|
||||
{Name: FieldHvBatteryLevelValue, Value: "57.0"},
|
||||
{Name: FieldSoc, Value: "57"},
|
||||
})
|
||||
deliver([]point{
|
||||
{Name: FieldBatteryStateReportSoc, Value: "57"},
|
||||
{Name: FieldHvBatteryLevelValue, Value: "57.0"},
|
||||
{Name: FieldSoc, Value: "57"},
|
||||
})
|
||||
|
||||
// later datasets only refresh the fallback field as the car charges
|
||||
for _, v := range []string{"58.0", "59.0", "61.0"} {
|
||||
deliver([]point{{Name: FieldHvBatteryLevelValue, Value: v}})
|
||||
// later datasets only refresh the lower-priority field as the car charges
|
||||
for _, v := range []string{"58", "59", "61"} {
|
||||
deliver([]point{{Name: FieldSoc, Value: v}})
|
||||
}
|
||||
|
||||
soc, err := testProvider(data).Soc()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 61.0, soc, "the still-updating fallback wins over the stale high-priority field")
|
||||
}
|
||||
|
||||
// TestSocHvBatteryLevelValid reproduces #31084: battery_level_HV.value (74) is
|
||||
// preferred over ambiguous battery_state_report.soc (45) only when state is VALID.
|
||||
func TestSocHvBatteryLevelValid(t *testing.T) {
|
||||
raw := []dataPoint{
|
||||
{DataFieldName: FieldBatteryStateReportSoc, Value: "74"},
|
||||
{DataFieldName: FieldBatteryStateReportSoc, Value: "45"},
|
||||
{DataFieldName: FieldBatteryStateReportSoc, Value: "45"},
|
||||
{DataFieldName: FieldHvBatteryLevelValue, Value: "74.0"},
|
||||
}
|
||||
|
||||
// without a VALID flag the ambiguous battery_state_report.soc still wins (45)
|
||||
soc, err := testProvider(points(raw)).Soc()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 45.0, soc, "prior behaviour kept when HV level is not flagged valid")
|
||||
|
||||
// with battery_level_HV.state VALID, battery_level_HV.value (74) is preferred
|
||||
valid := append(raw, dataPoint{DataFieldName: FieldHvBatteryLevelState, Value: hvBatteryLevelValid})
|
||||
soc, err = testProvider(points(valid)).Soc()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 74.0, soc, "battery_level_HV.value wins when flagged VALID")
|
||||
assert.Equal(t, 61.0, soc, "the still-updating field wins over the stale higher-priority field")
|
||||
}
|
||||
|
||||
// TestPoints guards that a data point with a generic field name ("value") is
|
||||
|
|
|
|||
|
|
@ -81,14 +81,7 @@ func (v *Provider) Soc() (float64, error) {
|
|||
return 0, err
|
||||
}
|
||||
|
||||
// use battery_level_HV.value when its state reports valid
|
||||
if s := lookup(data, FieldHvBatteryLevelState); s != nil && s.Value == hvBatteryLevelValid {
|
||||
if p := lookup(data, FieldHvBatteryLevelValue); p != nil {
|
||||
return strconv.ParseFloat(p.Value, 64)
|
||||
}
|
||||
}
|
||||
|
||||
if p := lookup(data, FieldBatteryStateReportSoc, FieldSoc, FieldHvSoc, FieldHvBatteryLevelValue); p != nil {
|
||||
if p := lookup(data, FieldHvBatteryLevelValue, FieldSoc, FieldHvSoc); p != nil {
|
||||
return strconv.ParseFloat(p.Value, 64)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,11 +119,9 @@ const (
|
|||
FieldPlugState = "plug_state"
|
||||
|
||||
// soc
|
||||
FieldBatteryStateReportSoc = "battery_state_report.soc"
|
||||
FieldSoc = "state_of_charge"
|
||||
FieldHvSoc = "hv_soc"
|
||||
FieldHvBatteryLevelValue = "battery_level_HV.value"
|
||||
FieldHvBatteryLevelState = "battery_level_HV.state"
|
||||
FieldSoc = "state_of_charge"
|
||||
FieldHvSoc = "hv_soc"
|
||||
FieldHvBatteryLevelValue = "battery_level_HV.value"
|
||||
|
||||
// target soc
|
||||
FieldTargetSoc = "settings.target_soc"
|
||||
|
|
@ -142,10 +140,6 @@ const (
|
|||
FieldRemainingTime = "remaining_charging_time"
|
||||
)
|
||||
|
||||
// hvBatteryLevelValid is the battery_level_HV.state value that marks
|
||||
// battery_level_HV.value as a trustworthy SoC reading
|
||||
const hvBatteryLevelValid = "VALID"
|
||||
|
||||
// contentDatasets returns the content datasets, sorted oldest to newest. The
|
||||
// portal emits "..._no_content_found.zip" placeholders while the vehicle is
|
||||
// asleep; those are skipped.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue