Add color configuration and extra signals to vehicle frames

This commit is contained in:
2026-07-23 13:26:37 +02:00
parent be7cf9cb6a
commit 0eac7a571f
3 changed files with 35 additions and 7 deletions
+1 -1
View File
@@ -437,7 +437,7 @@ def render_vehicles(vehicle):
for sig in frame_def.signals:
unit_str = f" ({sig.unit})" if sig.unit else ""
title = f"{frame_def.can_id} - {sig.name}{unit_str}"
fig = vehicle_module.plot_signal(decoded, sig.name, title=title)
fig = vehicle_module.plot_signal(decoded, sig.name, title=title, color=frame_def.color)
card = dbc.Card([
dbc.CardBody([
+3 -2
View File
@@ -23,6 +23,7 @@ class SignalDef:
class FrameDef:
can_id: str
description: str = ""
color: str = "#377eb8"
signals: List[SignalDef] = field(default_factory=list)
def normalize_id(can_id: str) -> str:
@@ -92,7 +93,7 @@ def decode_dataframe(df: pd.DataFrame, can_id: str, decoder_rules: dict) -> pd.D
return out
def plot_signal(df: pd.DataFrame, signal_name: str, title: str, height: int = 280) -> go.Figure:
def plot_signal(df: pd.DataFrame, signal_name: str, title: str, color: str = "#377eb8", height: int = 280) -> go.Figure:
fig = go.Figure()
if df.empty or signal_name not in df.columns:
@@ -109,7 +110,7 @@ def plot_signal(df: pd.DataFrame, signal_name: str, title: str, height: int = 28
x=df["Timestamp"],
y=df[signal_name],
mode="lines",
line=dict(width=2, color="#377eb8"),
line=dict(width=2, color=color),
name=signal_name,
hovertemplate=f"<b>{signal_name}</b><br>Time: %{{x}}<br>Value: %{{y:.2f}}<extra></extra>",
))
+31 -4
View File
@@ -10,6 +10,7 @@ DECODER_RULES = {
normalize_id("0x011F"): FrameDef(
can_id="0x011F",
description="Engine ECM Main Broadcast",
color="#e41a1c",
signals=[
SignalDef(
name="Engine",
@@ -25,15 +26,41 @@ DECODER_RULES = {
name="Pressure / Load",
bit_start=16,
bit_length=16,
factor=1.0,
offset=0.0,
factor=0.05,
offset=0,
is_signed=False,
byte_order="little",
unit="raw",
unit="%",
),
],
),
normalize_id("0x0CFF3300"): FrameDef(
can_id="0x0CFF3300",
description="Engine temperature block",
color="#0080fe",
signals=[
SignalDef(
name="Engine coolant temp",
bit_start=8,
bit_length=8,
factor=1,
offset=0.0,
is_signed=False,
byte_order="big",
unit="",
),
SignalDef(
name="Engine oil temp",
bit_start=40,
bit_length=8,
factor=1,
offset=0.0,
is_signed=False,
byte_order="big",
unit="",
),
],
),
}
def decode_dataframe(df, can_id):