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:
@@ -6,6 +6,9 @@
|
||||
* 读引脚在 App/util/ioboard_di.c 的 .c 部分(本 .c 就是那一半,属于同一模块的
|
||||
* 可测部分);本头文件**不 include** HAL / FreeRTOS / ioboard.h / main.h,
|
||||
* 可被主机侧 MSVC 单测直接编译。
|
||||
* 跨任务共享:快照对象归写者(defaultTask)私有,读者经下方的
|
||||
* ioboard_di_snap_register / ioboard_di_snap_lookup 拿指针,仍用同一套
|
||||
* 序号协议(ioboard_di_snap_read)读——不引入第二份副本、不引入锁。
|
||||
*
|
||||
* 为什么去抖不放进 ioboard.c:BSP 只回答"让硬件动起来并如实汇报",去抖与
|
||||
* 失败语义是上报层的事;而且 ioboard.c 依赖 HAL/FreeRTOS,主机侧编不过。
|
||||
@@ -160,6 +163,59 @@ void ioboard_di_snap_reset(ioboard_di_snapshot_t *s);
|
||||
/* 诊断副本:不保证一致性,仅供自检/串口打印 */
|
||||
void ioboard_di_snap_copy(const ioboard_di_snapshot_t *s, ioboard_di_snapshot_t *out);
|
||||
|
||||
/* ======================== 注册式共享读口 ======================== */
|
||||
|
||||
/*
|
||||
* 为什么要有这一对函数:快照对象是写者(defaultTask)的文件作用域静态变量,
|
||||
* 作用域外拿不到地址。让读者自己 include 写者的私有状态 = 打开第二个写者入口;
|
||||
* 让读者 copy 一份 = 造出第二份随时间漂移的真相。所以中间只放"登记一个地址",
|
||||
* 读者拿走指针后**仍走 ioboard_di_snap_read() 的同一套序号协议**(不是第二个读者实现)。
|
||||
* 在此之前 ioboard_di_snap_read() 在本仓没有任何调用方(它只被主机侧单测覆盖),
|
||||
* 本对函数就是它"跨任务可用"的接线:读者 = App/app/ui_data_feed.c(uiTask 上下文),
|
||||
* 写者 = defaultTask(登记点 = default_task_di_publish_register)。
|
||||
* 为什么注册表放在本纯逻辑层:它就是一个指针 + 单写者判据,零 HAL / 零 FreeRTOS;
|
||||
* 放进来才能在主机侧单测里直接验证"拒绝第二个写者",而不必上板。
|
||||
*/
|
||||
|
||||
/*
|
||||
* 函数功能:写者登记它的快照对象(产品里 = defaultTask 的 s_di_snap)
|
||||
* 入口参数:s - 由本登记者独占写入的快照对象(s == 0 = 参数非法)
|
||||
* 返回值:0 - 成功(首次登记成功,或重复登记的**正是同一个**指针:幂等)
|
||||
* -1 - 参数非法(s == 0),或已被**另一个**指针占用(保留首个,拒绝后来的)
|
||||
* 限定条件:写在登记成功之后**才开始**发布,不得先发布再登记(见函数说明第二段)
|
||||
* 函数说明:
|
||||
* 一、只存指针:不复制、不初始化、不改写快照内容——快照的初始态由写者自己
|
||||
* (ioboard_di_snap_reset 或静态零初始化)负责,本函数不代劳。否则登记时刻
|
||||
* 就是一个"把写者正在发布的快照清零"的竞态点。
|
||||
* 二、单写者:占用后第一个指针就是唯一真相源。第二个不同指针 = 返回 -1 并保留首个;
|
||||
* 重复登记同一指针 = 幂等返回 0。为什么换写者也不行:指针一变,读者拿到的
|
||||
* 旧指针生命周期无法保证,且两个快照对象同时存在正是本函数要禁掉的局面
|
||||
* (换写者需要先下线旧写者,本平台没有这种用法,故不提供注销)。
|
||||
* 三、登记表本身是编译期零初始化的文件作用域静态,**没有"初始化"步骤**:
|
||||
* 于是不存在"谁必须先跑一遍初始化"的启动顺序依赖,本函数也是幂等的。
|
||||
* 是否可用在任务启动之前:可以(注册表零初始化、本就用于 app_main_init 阶段的
|
||||
* 提前登记),但届时还没有读者——本仓的登记点在写者自己的任务启动段:
|
||||
* default_task_func 里调 default_task_di_publish_register(),先于首次
|
||||
* default_task_di_poll() 发布。
|
||||
* 四、注册表置 volatile:读者(uiTask / 任意上下文)与写者(defaultTask)跨任务
|
||||
* 通过它传地址,编译器不得把"看起来没变"的读缓存起来。指针本身的赋值在 M4 上
|
||||
* 是单条 32 位存储,读者不会看到半个地址;"读到非 0 之后指针不再变化"由上面
|
||||
* 的不可变约束保证,所以读者侧既不用关中断也不用再校验一次。
|
||||
*/
|
||||
int ioboard_di_snap_register(const ioboard_di_snapshot_t *s);
|
||||
|
||||
/*
|
||||
* 函数功能:读者取已登记的快照对象
|
||||
* 入口参数:无
|
||||
* 返回值:已登记的快照指针;未登记(或登记被拒绝且从未成功过)= NULL
|
||||
* 限定条件:任意上下文(任务 / 中断 / 启动段)、无锁、不阻塞、不关中断
|
||||
* 函数说明:拿到指针后必须自己调 ioboard_di_snap_read() 取一致值,**不要**直接读
|
||||
* s->mask —— 直接读会不带序号校验,拿到写者写到一半的字段。
|
||||
* 返回 NULL 表示"本构建没有开入发布者"(如 TEST_SUITE_STORAGE),
|
||||
* 消费者应把它当作"无数据源",不是"开入全 0"。
|
||||
*/
|
||||
const ioboard_di_snapshot_t *ioboard_di_snap_lookup(void);
|
||||
|
||||
/*
|
||||
* 函数功能:读"有效 → 失效 下降沿"累计次数与"连续失败拍数"
|
||||
* 入口参数:s - 快照对象
|
||||
|
||||
Reference in New Issue
Block a user