Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/modules/common/configurable_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ def __init__(self,
vehicle: int,
calc_while_charging: bool = False,
general_config: Optional[GeneralVehicleConfig] = None,
calculated_soc_state: Optional[CalculatedSocState] = None) -> None:
calculated_soc_state: Optional[CalculatedSocState] = None,
initializer: Callable = lambda: None) -> None:
self.__component_updater = component_updater
self.vehicle_config = vehicle_config
self.calculated_soc_state = calculated_soc_state
self.__initializer = initializer
if calculated_soc_state is None:
self.calculated_soc_state = CalculatedSocState()
else:
Expand All @@ -52,12 +54,17 @@ def __init__(self,
self.store = store.get_car_value_store(self.vehicle)
self.fault_state = FaultState(ComponentInfo(self.vehicle, self.vehicle_config.name, "vehicle"))

try:
self.__initializer()
except Exception:
log.exception(f"Initialisierung von Fahrzeug {self.vehicle_config.name} fehlgeschlagen")

def update(self, vehicle_update_data: VehicleUpdateData):
log.debug(f"Vehicle Instance {type(self.vehicle_config)}")
log.debug(f"Calculated SoC-State {self.calculated_soc_state}")
log.debug(f"Vehicle Update Data {vehicle_update_data}")
log.debug(f"General Config {self.general_config}")
with SingleComponentUpdateContext(self.fault_state):
with SingleComponentUpdateContext(self.fault_state, self.__initializer):

source = self._get_carstate_source(vehicle_update_data)
if source == SocSource.NO_UPDATE:
Expand Down