feat(ui): add DI/DO status page showing 8 inputs and 4 outputs

New read-only content page under 实时数据 → 开入开出 showing the board's
8 opto inputs (DI_A..DI_H, 合/分) and 4 relay outputs (KO6/TRIP/ERT/CLZ,
吸合/释放) as a 12-row list, 8 rows per page, 2 pages.

Data path reuses the existing de-bounced input poll instead of adding a
second hardware reader:

  defaultTask (50 ms) → ioboard_di_snap_publish() → de-bounced snapshot
    → ioboard_di_snap_lookup()  [new registration channel]
    → ui_data_feed_tick() (uiTask, 200 ms)
    → ui_data_rt_t.dio_di_* / dio_do_*

No new critical sections, no new hardware access on the UI path. Outputs
come from the volatile shadow register (a memory read, no lock).

Semantic honesty, recorded in ui_page_di_do.c and README §6:
  · Output state is the software shadow register (ODR mirror), NOT a
    mechanical contact feedback — this platform has no auxiliary contact
    readback path. ioboard_do_read_level() also reads ODR, so comparing
    the two is tautological.
  · IOBOARD_DO_LEVEL_ACTIVE polarity has not been checked against the
    schematic.
  · Input bit order has not been verified by manual shorting. The
    2026-11-16 run read 0x00 eight times because the operator had no time
    to short each channel — the data path itself was fine.
  · Board-level inputs are deliberately kept out of the 33-point telemetry
    bitmap (IEC 104 point-table semantics); the two have no mapping.

Invalid snapshots render "--", never 合/分 or 吸合/释放: painting "no data"
as "all inputs released" would tell the field the inputs are open when we
simply failed to read them.

Board-verified 2026-11-16: page 1 shows 分 on all 8 inputs, page 2 shows
释放 on all 4 outputs, page footer and paging correct. Input bit order
still pending manual shorting.

Also: regenerate ui_font_cn_12 for 吸/释, add golden references for both
pages, align check_menu_rows.py L2 geometry with the now-4-item submenu,
and register the new source file in both the Keil project and CMake.

Reviewed independently; zero blocking findings.
This commit is contained in:
2026-11-16 21:45:08 +08:00
parent bdc6f2f9b8
commit 2b466b85f0
24 changed files with 1012 additions and 300 deletions
+73
View File
@@ -732,6 +732,74 @@ static void snap_faults_accessor_matches_fields(void)
CHECK((edges == 0U) && (fails == 0), "faults accessor on a NULL snapshot yields zeros");
}
/* ---------------------------------------------------------------------------
* 五、注册式共享读口(ioboard_di.c 的 s_di_snap_registered)
*
* 登记表是**进程级全局**且占用后不可注销(产品里整个固件只登记一次),所以本组
* 用例共用同一张表、**按首次登记的先后顺序**执行:先测"空表 → NULL",再登记第一
* 个对象并锁定它,之后的用例只能以它为唯一真相源。新增用例时不要在前面的用例
* 里"先登记一个别的指针",否则后面所有断言都会跟着失败。
*
* 为何值得测:注册表是跨任务(defaultTask 写 / uiTask 读)唯一的耦合点。板端若
* 误接受第二个指针,读者拿到哪一份取决于调度顺序——表现为"开入有时对有时错",
* 而这类错在台架上往往要等两块板/两套时序才复现。这里用纯内存把判据钉死。
* -------------------------------------------------------------------------*/
/* 本组用例共享的两个快照对象。**必须是文件作用域**:注册表记住的是地址,若写成
* 各用例自己的函数内 static,相邻用例拿到的是两个不同地址,"幂等"判据会被
* 误判成"第二个写者被拒绝"(本组首版就是这样红的)。 */
static ioboard_di_snapshot_t s_reg_owner;
static ioboard_di_snapshot_t s_reg_intruder;
/* 未登记就查表 = NULL(不是"随便给一个")。
* 为何值得测:消费者必须能区分"本构建没有开入发布者"与"开入全 0",
* 把 NULL 当 0 上报就是"失败当全 0"那条铁律的翻版。
* 注:本用例必须排在最前——它断言的是空表态。 */
static void reg_lookup_before_any_register_is_null(void)
{
CHECK(ioboard_di_snap_lookup() == NULL, "lookup on an empty registry returns NULL");
CHECK(ioboard_di_snap_register(NULL) == -1, "register(NULL) is rejected with -1");
CHECK(ioboard_di_snap_lookup() == NULL, "a rejected NULL registration leaves the registry empty");
}
/* 首次登记成功,且只存指针(不复制、不改写内容)。 */
static void reg_first_register_stores_the_pointer_verbatim(void)
{
ioboard_di_snap_reset(&s_reg_owner);
(void)ioboard_di_snap_publish(&s_reg_owner, 0xA5U, 1U, 1U);
CHECK(ioboard_di_snap_register(&s_reg_owner) == 0, "first registration succeeds (returns 0)");
CHECK(ioboard_di_snap_lookup() == &s_reg_owner, "lookup returns the very pointer that was registered");
CHECK(s_reg_owner.mask == 0xA5U, "registration does not touch the snapshot contents");
CHECK(s_reg_owner.valid == 1U, "registration does not clear the snapshot validity");
}
/* 重复登记同一指针 = 幂等;换一个指针 = 拒绝并保留首个。
* 为何值得测:这正是"不得形成第二个真相源"的机器判据。若这条被写成"后登记覆盖
* 前者",产品里任一模块误调一次 register 就能把读者悄悄指到另一个对象上。 */
static void reg_second_pointer_is_rejected_and_idempotent(void)
{
const ioboard_di_snapshot_t *fresh;
ioboard_di_snap_reset(&s_reg_owner);
ioboard_di_snap_reset(&s_reg_intruder);
(void)ioboard_di_snap_publish(&s_reg_intruder, 0x3CU, 1U, 1U);
/* 上一个用例已把 &s_reg_owner 登记为唯一写者 */
CHECK(ioboard_di_snap_register(&s_reg_owner) == 0, "re-registering the same pointer is idempotent (0)");
CHECK(ioboard_di_snap_register(&s_reg_intruder) == -1, "registering a different pointer is rejected (-1)");
CHECK(ioboard_di_snap_register(&s_reg_intruder) == -1, "the rejected pointer stays rejected on retry");
CHECK(ioboard_di_snap_lookup() == &s_reg_owner, "the first registration is kept (no second source of truth)");
CHECK(ioboard_di_snap_register(NULL) == -1, "register(NULL) stays rejected after a writer exists");
CHECK(ioboard_di_snap_lookup() == &s_reg_owner, "a rejected NULL registration does not disturb the owner");
/* 读者拿到指针后仍走序号协议:读到的是**登记的那个**对象的一致值 */
fresh = ioboard_di_snap_lookup();
CHECK(fresh != NULL, "lookup yields a non-NULL pointer once registered");
CHECK(fresh == &s_reg_owner, "the pointer handed to readers is the owner's snapshot");
CHECK(s_reg_intruder.mask == 0x3CU, "the rejected pointer's snapshot is left untouched");
}
int main(void)
{
printf("-- ioboard unit tests --\n");
@@ -777,6 +845,11 @@ int main(void)
di_null_inputs_are_safe();
snap_faults_accessor_matches_fields();
/* 五、注册式共享读口(顺序有意义:空表态 → 首个写者锁定,见该节注释) */
reg_lookup_before_any_register_is_null();
reg_first_register_stores_the_pointer_verbatim();
reg_second_pointer_is_rejected_and_idempotent();
printf("=== IO Board Tests: %d/%d PASSED ===\n", s_pass, s_pass + s_fail);
return (s_fail == 0) ? 0 : 1;
}
+37 -10
View File
@@ -58,8 +58,9 @@
* 值区一字不动;解闭锁后重新提交可成功
* TC-UIDATA-020 apply 中途失败(预检与执行不一致的防御分支):如实 ERR_RANGE,
* 已生效的前几项不回滚(prot_set 无回滚接口,谎称整批未写更坏)
* TC-UIDATA-021 v2 帧扩展:UI_DATA_VER == 2、既有字段偏移逐字节见证(只允许尾
* 追加)、cal_block 两种态(未标定/已标定)整帧往返
* TC-UIDATA-021 v2/v3 帧扩展:UI_DATA_VER == 3、既有字段偏移逐字节见证(只允许尾
* 追加)、cal_block 两种态(未标定/已标定)整帧往返、rt 帧 v3
* 尾追加的板级开入开出四字段落在 208..211(既有字段不挪位)
* ── 以下 5 组 = 装置维护通道与时钟换算(道F task-3,
* docs/任务规划/UI补齐.md §2 第 3 行「装置维护 3 页」的地基)──
* TC-UIDATA-022 时钟换算与"无效值拒收":12 条锚点正向换算 + 反函数互逆 +
@@ -867,8 +868,9 @@ static void tc_param_frame_v2(void)
ui_data_par_t src;
ui_data_par_t got;
/* 版本号是页面与写侧唯一对齐凭据;v2 = 尾追加 cal_block */
CHECK(UI_DATA_VER == 2u, "TC-UIDATA-021a contract version is 2");
/* 版本号是页面与写侧唯一对齐凭据;v2 = par 尾追加 cal_block,
* v3 = rt 尾追加板级开入开出四字段(ui_data.h 文件头「追加即升此值」) */
CHECK(UI_DATA_VER == 3u, "TC-UIDATA-021a contract version is 3");
/* v1 布局逐字节见证:字段只允许尾追加,任何插入/重排都会让下面四条红
* (页面按名字取字段,错位是静默的——只有把偏移钉死才照得出来) */
CHECK(offsetof(ui_data_par_t, seq) == 0u, "TC-UIDATA-021b seq offset unchanged");
@@ -880,9 +882,34 @@ static void tc_param_frame_v2(void)
/* 写侧组装缓冲是 rt/par/info 三帧共用的 union(App/app/ui_data_feed.c 的 s_scr):
* rt 恒大于 par,所以给 par 追加字段**不会**连带抬升那块 .bss——加字段之前
* 先确认这条,否则每次尾追加都悄悄多啃一份 RAM(台账只记总量,看不出是谁长的) */
CHECK(sizeof(ui_data_rt_t) == 208u, "TC-UIDATA-021g rt frame is 208 B (union stays put)");
/* rt 帧尺寸(MSVC x64 / ARMCC 实测均 216 B):v3 只是尾追加 4 个 uint8(恰好
* 落在旧尾部填充里,字段偏移 208..211 连续),但**整 struct 由 208 涨到 216**——
* 尾部 char[20] 之后有 4 B 对齐填充,加 4 B 正好把它顶满、再补 4 B 新填充
* (24 B 数组区 → 需要 8 的倍数)。所以 s_scr union 的真实增量是 8 B 而不是 4 B,
* 写侧 .bss 台账按 216 算(这条断言就是"别猜、量出来"的落点) */
CHECK(sizeof(ui_data_rt_t) == 216u, "TC-UIDATA-021g rt frame is 216 B (v3 +8, union follows rt)");
CHECK(sizeof(ui_data_par_t) < sizeof(ui_data_rt_t),
"TC-UIDATA-021h par still smaller than rt (shared scratch unchanged)");
"TC-UIDATA-021h par still smaller than rt (shared scratch follows rt)");
/* v3 布局逐字节见证(rt 帧):只允许尾追加。offsetof 能照出 sizeof 照不出的
* "把字段插进 struct 中间、总长恰好不变"——那正是页面按名字取字段时会静默错位
* 的形态,所以尺寸与偏移两把尺子都要钉 */
CHECK(offsetof(ui_data_rt_t, yx_bits) == 152u,
"TC-UIDATA-021i rt yx_bits offset unchanged (104 point-table bitmaps not moved)");
/* 三张点表位图必须同时移动:只动其中一张 = 点表语义被局部重排(段内静默错位) */
CHECK(offsetof(ui_data_rt_t, yx_valid) == 160u,
"TC-UIDATA-021i2 rt yx_valid offset unchanged (bitmaps move together)");
CHECK(offsetof(ui_data_rt_t, yx_dp) == 168u,
"TC-UIDATA-021i3 rt yx_dp offset unchanged (bitmaps move together)");
CHECK(offsetof(ui_data_rt_t, clock) == 188u,
"TC-UIDATA-021j rt clock offset unchanged (v2 tail field not moved)");
CHECK(offsetof(ui_data_rt_t, dio_di_mask) == 208u,
"TC-UIDATA-021o rt dio_di_mask is the appended tail field (offset 208)");
CHECK(offsetof(ui_data_rt_t, dio_di_valid) == 209u,
"TC-UIDATA-021p rt dio_di_valid offset 209");
CHECK(offsetof(ui_data_rt_t, dio_do_mask) == 210u,
"TC-UIDATA-021q rt dio_do_mask offset 210");
CHECK(offsetof(ui_data_rt_t, dio_do_valid) == 211u,
"TC-UIDATA-021r rt dio_do_valid offset 211");
/* 闭锁态:1 = 未标定(写侧按 UA/UN/IA 三路 VALID 现算,本层只存真值) */
ui_data_init();
@@ -890,24 +917,24 @@ static void tc_param_frame_v2(void)
src.valid = 1u;
src.locked = 0u;
src.cal_block = 1u;
CHECK(ui_data_publish_par(&src) == 0, "TC-UIDATA-021g publish blocked frame");
CHECK(ui_data_publish_par(&src) == 0, "TC-UIDATA-021k publish blocked frame");
(void)memset(&got, 0, sizeof(got));
CHECK((ui_data_par(&got) == 0) && (got.cal_block == 1u) && (got.locked == 0u),
"TC-UIDATA-021h cal_block=1 roundtrip, distinct from locked");
"TC-UIDATA-021l cal_block=1 roundtrip, distinct from locked");
/* 解卡态:写侧填 0 后覆盖发布(同一份存储不会粘住旧值) */
src.cal_block = 0u;
(void)ui_data_publish_par(&src);
(void)memset(&got, 0xAA, sizeof(got));
CHECK((ui_data_par(&got) == 0) && (got.cal_block == 0u),
"TC-UIDATA-021i cal_block=0 roundtrip (no stale block flag)");
"TC-UIDATA-021m cal_block=0 roundtrip (no stale block flag)");
/* 写侧默认值纪律:调用方清零后不填本字段 = 0(未闭锁),首帧不会假报徽标 */
(void)memset(&src, 0, sizeof(src));
src.valid = 1u;
(void)ui_data_publish_par(&src);
(void)ui_data_par(&got);
CHECK(got.cal_block == 0u, "TC-UIDATA-021j zero-initialized frame means not blocked");
CHECK(got.cal_block == 0u, "TC-UIDATA-021n zero-initialized frame means not blocked");
}
/* ============ 装置维护写通道与时钟换算(道F task-3,UI 补齐 §2 第 3 行)============ */