Skip to content

Convert raw values to physical values - #50

Merged
Nakakiyo092 merged 3 commits into
mainfrom
feature/conversion-rule
Jun 19, 2026
Merged

Convert raw values to physical values#50
Nakakiyo092 merged 3 commits into
mainfrom
feature/conversion-rule

Conversation

@Nakakiyo092

Copy link
Copy Markdown
Owner

Close #11

Nakakiyo092 and others added 3 commits June 19, 2026 18:00
reader.py previously appended only a Raw value column. Add a Physical
value column derived from the format/*.csv conversion rules.

Conversion order per signal:
  1. Look up the (possibly multi-byte) aggregated raw value in the
     Value table column. On hit, emit the matched label.
  2. Otherwise apply the Conversion column:
     - linear formula  E=N, E=N+K, E=N*K, E=N*K+K (and -K variants)
     - Ascii           printable byte -> char, else 0xHH
     - Not defined / N/A / empty -> leave the cell empty

Multi-byte signals follow the existing "Subsequent byte" marker on
continuation rows. The leading row carries the formula and value table;
the reader counts the contiguous Subsequent byte rows to determine
width and aggregates the bytes in big-endian (Motorola) order. Byte
order is fixed in the tool, not encoded per signal, per automotive
convention.

CSV format changes:
- Value table entries are now separated by `;` instead of `,` and have
  no whitespace around `:`. Example: `0xFE:Invalid;0xFF:N/A`. This
  eliminates the embedded-comma quoting that complicated machine
  parsing and survives copy/paste between editors.

format/README.md documents the new conventions (Value table syntax,
Conversion column verbs, multi-byte representation, byte order).

test/test_conversion.py exercises _parse_value_table, _parse_linear,
and _convert against every form found in format/*.csv (24 cases) plus
the integrated value-table-then-formula precedence (3 cases).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The format CSVs had one row per DID using `N/A` in the Conversion column
to mean "no formula". Replace those with `Not defined` so the column has
a single canonical verb for that case.

Drop the redundant `N/A` handling in _convert (since the spec now
disallows it) and the corresponding unit test. Update format/README.md
to remove the confusing whole-cell-N/A note and the `Not defined or N/A`
bullet.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Each docstring states what the test asserts. Several inline comments
that simply restated the intent are removed; the docstring now carries
that information. Inline comments are kept only where they spell out a
non-obvious arithmetic step (e.g., 200 * 0.1 - 300 = -280).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Nakakiyo092
Nakakiyo092 merged commit 6c43bd3 into main Jun 19, 2026
13 checks passed
@Nakakiyo092
Nakakiyo092 deleted the feature/conversion-rule branch June 19, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add function to convert raw data to physical data

1 participant