Files
obdash/obdcore/__init__.py
T
justin f3f0bf2a77 Make app vehicle-agnostic: JSON vehicle profiles + menu bar
Vehicle data is now DATA, not code. PIDs/scaling/DTCs/presets live in
profiles/*.json; the app loads them at runtime, so it works across vehicles
and others can contribute profiles (open source).

Core:
- obdcore/formula.py: safe AST evaluator for scaling formulas (A/B/... byte
  vars, Torque/FORScan convention). Only arithmetic/bitwise + min/max/abs/
  round/int/float; names/attrs/arbitrary calls rejected at load -> a community
  profile CANNOT execute code.
- obdcore/profile.py: load/save/list profiles; compiles each formula into a
  decode callable. registry.py now profile-backed (PidRegistry/DtcDatabase
  take a Profile); hardcoded Ford table removed.
- store.py: clear()/snapshot()/export_csv() for capture management.

Profiles:
- profiles/ford-6.0-powerstroke.json (27 PIDs, verified formulas, DTCs)
- profiles/generic-obd2.json (standard SAE Mode-01 base, any vehicle)
- profiles/README.md (schema + formula language + contributing)

GUI:
- Menu bar: File (new/record/export/replay capture, quit), Profile (switch/
  load/import/reload/edit-JSON/export, live profile list), View (Graph/Table
  views, gauges P2, toggle PID dock, normalize, light/dark theme), Help
  (about/confidence legend/profile info).
- PID browser + presets rebuild on profile switch; added Table view; raw-JSON
  profile editor dialog (validates schema+formulas before saving).

Tests: profiles load+compile, formula sandbox rejects hostile input, decoders
still match real truck bytes, crank/derived/dead-PID/replay -- all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016yT89n4zR4qbrySoSiEyZs
2026-06-30 14:34:33 -04:00

30 lines
1.3 KiB
Python

"""obdcore -- headless, vehicle-agnostic OBD-II acquisition core.
Vehicle data (PIDs, scaling, DTCs, presets) lives in JSON profiles under
profiles/ -- loaded at runtime, not hardcoded -- so the app works across
vehicles and others can contribute profiles.
formula.py safe A/B/... scaling-formula evaluator (no code execution)
profile.py load/save/list vehicle profiles (JSON)
registry.py PidRegistry / DtcDatabase model + lookups
link.py ElmLink ELM327 serial transport (+ MockLink in mock.py)
scheduler.py PollScheduler prioritized polling engine
store.py TimeSeriesStore ring buffers + record/replay
See ARCHITECTURE.md and profiles/README.md.
"""
from .registry import PidRegistry, DtcDatabase, Pid, Dtc
from .profile import (Profile, load_profile, save_profile, list_profiles,
profiles_dir, default_profile_path, load_default)
from .formula import compile_formula, FormulaError
from .store import TimeSeriesStore, CsvRecorder, replay_csv, export_csv
from .scheduler import PollScheduler
__all__ = [
"PidRegistry", "DtcDatabase", "Pid", "Dtc",
"Profile", "load_profile", "save_profile", "list_profiles",
"profiles_dir", "default_profile_path", "load_default",
"compile_formula", "FormulaError",
"TimeSeriesStore", "CsvRecorder", "replay_csv", "export_csv", "PollScheduler",
]