made everything modular

This commit is contained in:
2025-09-05 01:03:14 +02:00
parent 268dc201bf
commit 0276a3fb3c
21 changed files with 788 additions and 692 deletions

View File

@@ -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))