Commit Graph

23 Commits

Author SHA1 Message Date
caoqianming 532eeaba42 feat(simulate): chaos task for rem/flt signal testing
When SIMULATE_PLC=true, a background task randomly disrupts rem or flt
signals on equipment (rem=false for 5-15s, flt=true for 3-10s) to
exercise fault detection, comm lock, and recovery logic in the engine.
Uses XorShift64 PRNG with no extra dependencies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 10:11:05 +08:00
caoqianming 08add0d087 refactor(api): embed runtime in unit list/get/detail responses
Remove the standalone GET /api/unit/runtimes endpoint in favour of
embedding runtime directly in existing responses:
- GET /api/unit          → each item now includes `runtime` field
- GET /api/unit/:id      → returns UnitWithRuntime
- GET /api/unit/:id/detail → UnitDetail now includes `runtime`

runtime is null when the engine has not yet initialised the unit.
Frontend loadUnits() reads the embedded runtime field to populate
state.runtimes — one request instead of two.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 09:18:14 +08:00
caoqianming 42cdbbc0cc fix(web): fetch all unit runtimes on page load
Root cause: state.runtimes was empty after refresh because the engine
only pushes UnitRuntimeChanged on state transitions — if the engine
is mid-wait-phase, no push occurs and badges show OFFLINE.

Fix: add GET /api/unit/runtimes batch endpoint (returns all known
runtimes as { unit_id: UnitRuntime }) and call it in parallel with
the unit list fetch inside loadUnits(), so runtime badges are correct
immediately after page load.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 09:11:47 +08:00
caoqianming 757d6f9a3a feat(control): batch start/stop auto control for all enabled units
Backend:
- POST /api/control/unit/batch-start-auto — starts auto on all enabled
  units that are not fault/comm locked and not already running auto
- POST /api/control/unit/batch-stop-auto — stops auto on all units

Frontend (ops view):
- Add "全部启动" / "全部停止" buttons in the unit sidebar header

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 13:05:23 +08:00
caoqianming 2732238be7 feat(api): add GET /api/unit/{id}/detail with nested equipment and points
Returns unit with its equipments, each embedding their bound points.
Uses 2 queries (equipment list + points via ANY) to avoid N+1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 08:37:09 +08:00
caoqianming 622d010cb1 fix(server): add Cache-Control: no-store to static file responses
Prevents browser from caching JS/CSS modules, so frontend changes take
effect immediately on page refresh without needing hard refresh.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 16:57:39 +08:00
caoqianming d2bd567799 feat(main): register control engine routes and start engine 2026-03-24 14:56:19 +08:00
caoqianming 97d2f6ebf8 feat(control): add manual equipment pulse commands 2026-03-24 11:16:50 +08:00
caoqianming 4e3d325437 feat(control): add unit and event foundation 2026-03-24 10:20:23 +08:00
caoqianming 06ace5e67d refactor(app): split services and web modules 2026-03-23 11:31:38 +08:00
caoqianming a691f07e8e feat(web): add API.md drawer preview 2026-03-20 19:00:46 +08:00
caoqianming 920e37f759 feat(web): add inline point chart panel 2026-03-20 10:54:20 +08:00
caoqianming 7e6c7a7e4c feat(reconnect): add retry backoff and manual reconnect 2026-03-17 08:15:54 +08:00
caoqianming 6f215162a3 feat(page): add page table and CRUD handlers 2026-03-11 13:54:14 +08:00
caoqianming efed6aa816 feat: add page 2026-03-11 13:23:05 +08:00
caoqianming 1374abe550 feat(log): add file-based log APIs and switch file logs to JSON 2026-03-09 14:47:19 +08:00
caoqianming ee3ee273b2 refactor: merge set_pool and start_reconnect_task into set_pool_and_start_reconnect_task 2026-03-05 14:01:40 +08:00
caoqianming 0f37c9435e feat: 实现心跳检测和自动重连功能 2026-03-05 13:27:13 +08:00
caoqianming 494cf1d656 优化连接流程:connect_from_source自动处理订阅,简化main.rs 2026-03-05 11:18:30 +08:00
caoqianming a2217a991c 重构ConnectionManager:简化get_session方法,移除pool依赖,重命名new_with_pool为new 2026-03-05 11:13:10 +08:00
caoqianming 5685c33687 优化main.rs日志打印:移除重复日志,使用并发处理source连接和订阅 2026-03-05 11:08:01 +08:00
caoqianming c88a0b2398 修复编译错误和警告: 添加缺失的导入,移除未使用的导入和变量 2026-03-03 13:39:58 +08:00
caoqianming 44f4a794d3 feat: 软件第一个版本 2026-03-03 13:32:05 +08:00