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;
}