Skip to content

Commit 4815c9e

Browse files
authored
rename bidi to bidi_charging_enabled (#2665)
1 parent 91fb000 commit 4815c9e

4 files changed

Lines changed: 25 additions & 12 deletions

File tree

packages/control/ev/charge_template.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def _calc_remaining_time(self,
421421
control_parameter_phases: int,
422422
soc_request_interval_offset: int,
423423
bidi_state: BidiState) -> SelectedPlan:
424-
bidi = BidiState.BIDI_CAPABLE and plan.bidi
424+
bidi = BidiState.BIDI_CAPABLE and plan.bidi_charging_enabled
425425
if bidi:
426426
duration, missing_amount = self._calculate_duration(
427427
plan, soc, ev_template.data.battery_capacity,
@@ -553,14 +553,14 @@ def scheduled_charging_calc_current(self,
553553
if limit.selected == "soc" and soc >= limit.soc_limit and soc >= limit.soc_scheduled:
554554
message = self.SCHEDULED_CHARGING_REACHED_LIMIT_SOC
555555
elif limit.selected == "soc" and limit.soc_scheduled <= soc < limit.soc_limit:
556-
if plan.bidi and bidi_state == BidiState.BIDI_CAPABLE:
556+
if plan.bidi_charging_enabled and bidi_state == BidiState.BIDI_CAPABLE:
557557
message = self.SCHEDULED_CHARGING_BIDI
558558
current = min_current
559559
submode = "bidi_charging"
560560
phases = control_parameter_phases
561561
else:
562562
message = self.SCHEDULED_CHARGING_REACHED_SCHEDULED_SOC
563-
if plan.bidi and bidi_state != BidiState.BIDI_CAPABLE:
563+
if plan.bidi_charging_enabled and bidi_state != BidiState.BIDI_CAPABLE:
564564
message += bidi_state.value
565565
current = min_current
566566
submode = "pv_charging"

packages/control/ev/charge_template_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,24 +166,24 @@ def test_calc_remaining_time(phases_to_use,
166166

167167

168168
@pytest.mark.parametrize(
169-
"selected, phases, bidi, expected_duration, expected_missing_amount",
169+
"selected, phases, bidi_charging_enabled, expected_duration, expected_missing_amount",
170170
[
171171
pytest.param("soc", 1, False, 10062.111801242236, 9000, id="soc, one phase"),
172172
pytest.param("amount", 2, False, 447.2049689440994, 800, id="amount, two phases"),
173173
pytest.param("soc", 2, True, 3240.0, 9000, id="bidi"),
174174
])
175175
def test_calculate_duration(selected: str,
176176
phases: int,
177-
bidi: bool,
177+
bidi_charging_enabled: bool,
178178
expected_duration: float,
179179
expected_missing_amount: float):
180180
# setup
181181
ct = ChargeTemplate()
182-
plan = ScheduledChargingPlan(bidi=bidi)
182+
plan = ScheduledChargingPlan(bidi_charging_enabled=bidi_charging_enabled)
183183
plan.limit.selected = selected
184184
# execution
185185
duration, missing_amount = ct._calculate_duration(
186-
plan, 60, 45000, 200, phases, ChargingType.AC.value, EvTemplate(), bidi)
186+
plan, 60, 45000, 200, phases, ChargingType.AC.value, EvTemplate(), bidi_charging_enabled)
187187

188188
# evaluation
189189
assert duration == expected_duration
@@ -226,7 +226,7 @@ def test_scheduled_charging_recent_plan(end_time_mock,
226226

227227

228228
@pytest.mark.parametrize(
229-
"plan_data, soc, used_amount, selected, bidi, expected",
229+
"plan_data, soc, used_amount, selected, bidi_charging_enabled, expected",
230230
[
231231
pytest.param(None, 0, 0, "none", False, (0, "stop",
232232
ChargeTemplate.SCHEDULED_CHARGING_NO_DATE_PENDING, 3), id="no date pending"),
@@ -262,13 +262,13 @@ def test_scheduled_charging_calc_current(plan_data: SelectedPlan,
262262
soc: int,
263263
used_amount: float,
264264
selected: str,
265-
bidi: bool,
265+
bidi_charging_enabled: bool,
266266
expected: Tuple[float, str, str, int]):
267267
# setup
268268
ct = ChargeTemplate()
269269
plan = ScheduledChargingPlan(active=True, id=0)
270270
plan.limit.selected = selected
271-
plan.bidi = bidi
271+
plan.bidi_charging_enabled = bidi_charging_enabled
272272
# json verwandelt Keys in strings
273273
ct.data.chargemode.scheduled_charging.plans = [plan]
274274
if plan_data:

packages/helpermodules/abstract_plans.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class TimeframePlan(PlanBase):
7777

7878
@dataclass
7979
class ScheduledChargingPlan(PlanBase):
80-
bidi: bool = False
80+
bidi_charging_enabled: bool = False
8181
bidi_power: int = 10000
8282
current: int = 14
8383
dc_current: float = 145

packages/helpermodules/update_config.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
class UpdateConfig:
5959

60-
DATASTORE_VERSION = 92
60+
DATASTORE_VERSION = 93
6161

6262
valid_topic = [
6363
"^openWB/bat/config/bat_control_permitted$",
@@ -2412,3 +2412,16 @@ def upgrade(topic: str, payload) -> Optional[dict]:
24122412
return {topic: payload}
24132413
self._loop_all_received_topics(upgrade)
24142414
self.__update_topic("openWB/system/datastore_version", 92)
2415+
2416+
def upgrade_datastore_92(self) -> None:
2417+
def upgrade(topic: str, payload) -> Optional[dict]:
2418+
if re.search("openWB/vehicle/template/charge_template/[0-9]+$", topic) is not None:
2419+
payload = decode_payload(payload)
2420+
for plan in payload["chargemode"]["scheduled_charging"]["plans"]:
2421+
if "bidi" in plan:
2422+
bidi_charging_enabled = plan["bidi"]
2423+
plan.pop("bidi")
2424+
plan.update({"bidi_charging_enabled": bidi_charging_enabled})
2425+
return {topic: payload}
2426+
self._loop_all_received_topics(upgrade)
2427+
self.__update_topic("openWB/system/datastore_version", 93)

0 commit comments

Comments
 (0)