Files
lingniu-vehicle-ingest/protocol-gb32960
lingniu-dev dd8f75e0da refactor(gb32960/model): nest InfoBlock by <protocol+version>.<dataType>
Restructure InfoBlock from a flat sealed interface into three nested
sealed interfaces grouped by protocol and version, so every record's
fully-qualified name follows the rule InfoBlock.<protocolVersion>.<dataType>
and the type system enforces strict separation between version variants.

New shape:

  InfoBlock (sealed)
  ├── Gb32960V2016 (sealed)
  │   ├── Vehicle           (20 B, has accel/brake pedal)
  │   ├── DriveMotor        (rpm offset 20000, torque 2 B)
  │   ├── FuelCell          (with N x 1B probe temps)
  │   ├── Engine            (5 B fixed)
  │   ├── Position          (9 B, no coord system)
  │   ├── Extreme           (14 B, 2016-only)
  │   ├── Alarm             (typeCode 0x07, no general alarm levels)
  │   ├── Voltage           (0x08 storage voltage)
  │   └── Temperature       (0x09 storage temperature)
  ├── Gb32960V2025 (sealed)
  │   ├── Vehicle           (18 B, no pedal fields)
  │   ├── DriveMotor        (rpm offset 32000, torque 4 B)
  │   ├── FuelCell          (no current/voltage, no probe list)
  │   ├── Engine            (5 B fixed, identical layout to V2016 but
  │                          duplicated to keep version separation strict)
  │   ├── Position          (10 B, with coordSystem byte)
  │   ├── Alarm             (typeCode 0x06, with generalAlarmLevels)
  │   ├── MinParallelVoltage (0x07 in V2025)
  │   ├── BatteryTemperature (0x08 in V2025)
  │   ├── FuelCellStack     (0x30)
  │   ├── SuperCapacitor    (0x31)
  │   └── SuperCapacitorExtreme (0x32)
  ├── GuangdongFc (sealed)
  │   ├── Stack             (0x30, vendor variant — different field order
  │                          and adds max/min/avg single-cell voltage stats)
  │   ├── Auxiliary         (0x31, air compressor / hydrogen pump / PTC)
  │   ├── DcDc              (0x32 fixed 9 B)
  │   ├── AirConditioner    (0x33 fixed 5 B)
  │   ├── VehicleInfo       (0x34 fixed 7 B)
  │   └── DemoExtension     (0x80 demo extension)
  └── Raw

Even types that share an identical field list (Engine, the two
DriveMotor.Motor inner records, Vehicle when ignoring pedals) are
deliberately duplicated rather than shared, per the rule "数据类型严格按
版本拆分". This lets consumers branch on instanceof / pattern-match
without losing track of which protocol version produced the data.

Knock-on changes (mechanical for the most part):

- All 16 standard parsers (v2016/, v2025/) updated to instantiate the
  matching nested record; e.g.
    new InfoBlock.Vehicle(...)
  becomes
    new InfoBlock.Gb32960V2016.Vehicle(...).
- The 6 Guangdong vendor parsers now return InfoBlock.GuangdongFc.* records
  (previously InfoBlock.GdFcXxx flat records).
- Position/Alarm record pairs split: Position no longer carries a nullable
  coordSystem field (V2025 has its own record with coordSystem; V2016
  has neither), and Alarm no longer carries the protocolVersion tag —
  the nested type already encodes the version.
- Gb32960EventMapper grew three small private "view" records
  (VehicleView, PositionView, AlarmView) plus extract* helpers that try
  V2016 first then fall back to V2025, so downstream payload assembly
  still sees a single uniform view.
- Test files updated to reference the new fully-qualified names.

InfoBlockType enum is left untouched: it is the logical type tag, and
both DriveMotor variants still report InfoBlockType.DRIVE_MOTOR even
though they live under different sealed parents — the *structural*
separation is what matters.

All 30 tests pass (18 existing + 8 selector + 4 vendor parser).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 16:52:57 +08:00
..