made everything modular
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
# app/simulation/modules/abs.py
|
||||
from __future__ import annotations
|
||||
from ..vehicle import Vehicle, Module
|
||||
|
||||
class AbsModule(Module):
|
||||
"""Stub: deceleration limiting if ABS enabled (future: needs braking input)."""
|
||||
def apply(self, v: Vehicle, dt: float) -> None:
|
||||
_abs = bool(v.config.get("vehicle", {}).get("abs", True))
|
||||
if not _abs:
|
||||
return
|
||||
# braking model folgt später
|
@@ -1,6 +1,9 @@
|
||||
# =============================
|
||||
# app/simulation/modules/basic.py
|
||||
# =============================
|
||||
|
||||
from __future__ import annotations
|
||||
from ..vehicle import Vehicle, Module
|
||||
from app.simulation.simulator import Module, Vehicle
|
||||
import bisect
|
||||
|
||||
def _ocv_from_soc(soc: float, table: dict[float, float]) -> float:
|
||||
@@ -17,6 +20,8 @@ def _ocv_from_soc(soc: float, table: dict[float, float]) -> float:
|
||||
return y0 + t*(y1 - y0)
|
||||
|
||||
class BasicModule(Module):
|
||||
PRIO = 10
|
||||
NAME = "basic"
|
||||
"""
|
||||
- Zündungslogik inkl. START→ON nach crank_time_s
|
||||
- Ambient-Temperatur als globale Umweltgröße
|
||||
|
@@ -3,7 +3,7 @@
|
||||
# =============================
|
||||
|
||||
from __future__ import annotations
|
||||
from ..vehicle import Vehicle, Module
|
||||
from app.simulation.simulator import Module, Vehicle
|
||||
import random, math
|
||||
|
||||
# Ein einziger Wahrheitsanker für alle Defaults:
|
||||
@@ -50,6 +50,8 @@ ENGINE_DEFAULTS = {
|
||||
}
|
||||
|
||||
class EngineModule(Module):
|
||||
PRIO = 20
|
||||
NAME = "engine"
|
||||
"""
|
||||
Erweiterte Motormodellierung mit realistischem Jitter & Drive-by-Wire:
|
||||
- OFF/ACC/ON/START Logik, Starten/Abwürgen
|
||||
@@ -310,16 +312,17 @@ class EngineModule(Module):
|
||||
self._rpm_noise *= 0.9
|
||||
|
||||
# --- Klammern & Setzen -----------------------------------------------------
|
||||
rpm = max(0.0, min(rpm, maxr))
|
||||
cool = max(-40.0, min(cool, 120.0))
|
||||
oil = max(-40.0, min(oil, 150.0))
|
||||
rpm = max(0.0, min(rpm, maxr))
|
||||
cool = max(-40.0, min(cool, 120.0))
|
||||
oil = max(-40.0, min(oil, 150.0))
|
||||
oil_p = max(oil_floor_off if not self._running else oil_floor_off, min(8.0, oil_p))
|
||||
|
||||
v.set("rpm", int(rpm))
|
||||
v.set("coolant_temp", round(cool, 1))
|
||||
v.set("oil_temp", round(oil, 1))
|
||||
v.set("oil_pressure", round(oil_p, 2))
|
||||
# WICHTIG: NICHT runden – das macht das Dashboard per fmt
|
||||
v.set("coolant_temp", float(cool))
|
||||
v.set("oil_temp", float(oil))
|
||||
v.set("oil_pressure", float(oil_p))
|
||||
v.set("engine_available_torque_nm", float(avail_torque))
|
||||
v.set("engine_net_torque_nm", float(net_torque))
|
||||
v.set("throttle_pedal_pct", float(pedal))
|
||||
v.set("throttle_plate_pct", float(self._plate_pct))
|
||||
v.set("throttle_plate_pct", float(self._plate_pct))
|
@@ -1,8 +1,13 @@
|
||||
# =============================
|
||||
# app/simulation/modules/gearbox.py
|
||||
# =============================
|
||||
|
||||
from __future__ import annotations
|
||||
from ..vehicle import Vehicle, Module
|
||||
from app.simulation.simulator import Module, Vehicle
|
||||
|
||||
class GearboxModule(Module):
|
||||
PRIO = 30
|
||||
NAME = "gearbox"
|
||||
"""Koppelt Engine-RPM ↔ Wheel-Speed; registriert speed_kmh/gear fürs Dashboard."""
|
||||
def __init__(self):
|
||||
self.speed_tau = 0.3
|
||||
|
Reference in New Issue
Block a user