Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
* text=auto
*.sh text eol=lf
*.py text eol=lf
*.js text eol=lf
*.cjs text eol=lf
*.html text eol=lf
*.css text eol=lf
*.md text eol=lf
*.yml text eol=lf
*.lock text eol=lf
*.ps1 text eol=crlf
*.cmd text eol=crlf
27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Offline acceptance checks
on:
push:
pull_request:
permissions:
contents: read
jobs:
offline:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python: ['3.10', '3.13']
runs-on: ${{ matrix.os }}
env:
PYTHONIOENCODING: utf-8
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python }}
- run: python -m pip install --require-hashes -r requirements.lock
- run: python validate_config.py
- run: python self_test.py
- run: python -m coverage run --source=inspection,core.protocol_engine,core.transport -m pytest
- run: python -m coverage report --show-missing
- run: python -m compileall -q inspection core web_app.py legacy_web.py
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ __pycache__/

# Generated reports
report/
data/
output/
.coverage
coverage.xml
htmlcov/
.pytest_cache/
.superpowers/

# IDE
.idea/
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

## 3.1 — 2026-10-08

- Add English/Chinese interfaces for the acceptance workbench and compatibility scan page, with browser-language defaults and a remembered preference.
- Translate navigation, forms, status labels, dialogs and operational messages while retaining user-entered data and original evidence.
- Export printable HTML reports in the chosen language; preserve default Chinese exports and unchanged JSON/CSV data.
- Add bilingual browser/API/report regression checks and matching offline release packages.

## 3.0 — 2026-10-07

- Add a configuration-driven acceptance workbench with station/batch/operator metadata, async progress and cooperative cancellation.
- Persist task snapshots, results and events in SQLite; mark unfinished tasks interrupted on restart without hardware replay.
- Keep expected missing devices as failures; separate execution status from inspection verdict.
- Add failed-only retest lineage, scope-aware comparison, HTML/JSON/CSV evidence reports and separate demo/live metrics.
- Add a hardware-independent synthetic demo, local responsive browser assets and a compatibility UI at `/legacy`.
- Assemble fragmented configured active TCP responses; validate Modbus byte counts, quantities and frame identity.
- Add API and protocol regressions, a demo browser workflow, source/artifact dependency provenance and pinned offline CI.

The project owner confirmed the project was tested and is usable. This upgrade's automated checks and release-package validation are recorded in [validation](docs/VALIDATION.md).
74 changes: 46 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,67 @@
# Industrial Device Check
# QLDeviceCheck · Field Acceptance Workbench

[简体中文](README_zh.md) · [Configuration guide](config/CONFIG_GUIDE.md) · [MIT License](LICENSE)
[简体中文](README_zh.md) · [Demo](docs/DEMO.md) · [Architecture](docs/ARCHITECTURE.md) · [API](docs/API.md) · [Validation](docs/VALIDATION.md) · [MIT](LICENSE)

A Linux Web UI for discovering known industrial devices, checking protocol responses, and generating inspection reports. Configuration-driven matching connects serial, network, and PCI interfaces to the equipment being tested.
A local acceptance station for industrial device vendors and system integrators. Turn an expected equipment list into a traceable inspection: record what was tested, preserve protocol evidence, and compare results after repairs.

## Capabilities
![Synthetic demo of the acceptance workbench](docs/screenshots/overview.png)

| Interface | Checks |
## A workflow for delivery and repair

| Field problem | Workbench behavior |
| --- | --- |
| Serial | Modbus RTU read functions 01–04; configured custom requests and response matching |
| Network | Modbus TCP, TCP connectivity, custom TCP/UDP probes |
| PCI | Passive inspection of link state, driver binding, and associated interface nodes |
| A disconnected device disappears from a discovery list | Every selected configured device gets a result; missing devices remain failures. |
| A report cannot be tied to the configuration used | Each task keeps the full configuration snapshot, SHA-256, station/unit ID, batch, operator and timestamps. |
| Rechecking a repair loses the original evidence | Failed-only retests retain their parent task and original snapshot. Comparison shows recovery, regression and scope limits. |
| A demonstration needs field hardware | `--demo` uses an independent synthetic catalog, visibly stamps reports `SIMULATED`, and separates demo/live statistics. |

The intended position is a lightweight Linux field acceptance workflow with local evidence ownership. The project owner has confirmed the project was tested and is usable. See the [design and positioning rationale](docs/superpowers/specs/2026-10-07-field-acceptance-design.md) and [verification records](docs/VALIDATION.md).

## Try the demo

The workflow supports full scans, individual interface scans, and device retests. Reports are generated in HTML, TXT, and JSON. The `via_device` configuration models devices reached through a shared PLC or gateway connection.
For a ready-to-install bundle, download the Windows x64 or Linux x86_64 package from [Releases](https://github.com/KaiserIIII/QLDeviceCheck_Generic_WebUI_Linux/releases). Bundles include offline runtime dependencies. Install CPython 3.10+ first; then double-click `Start-Demo.cmd` on Windows or run `bash run_demo.sh` on Linux. [Release guide](docs/RELEASE.md).

## Run
The workbench and compatibility scan page support **English / 简体中文**. Use the language selector to switch; your preference is remembered on this browser. On first visit, Chinese browser locales select Chinese and other locales select English. HTML reports use the selected interface language. Configured device names, entered metadata and original protocol evidence retain their source text.

Requirements: Linux, Python 3.7+, and permission to access the selected interfaces.
Python **3.10+**. The demo and offline checks also run on Windows.

```bash
bash setup_linux.sh
bash run_web.sh
python -m venv .venv
source .venv/bin/activate
python -m pip install --require-hashes -r requirements-runtime.lock
python web_app.py --demo --data-dir data/demo
```

Open <http://127.0.0.1:8080>.

## Configure and verify
On PowerShell, activate with `.\.venv\Scripts\Activate.ps1`. Open [localhost:8080](http://127.0.0.1:8080), create a **mixed faults** task, inspect its evidence, then retest with **healthy**. [Demo walkthrough](docs/DEMO.md).

Define equipment in [config/device_list.json](config/device_list.json), using [device_list_examples.json](config/device_list_examples.json) and the [configuration guide](config/CONFIG_GUIDE.md).
## Field mode

```bash
python3 validate_config.py
python3 self_test.py
bash setup_linux.sh
bash run_web.sh --config config/device_list.json --data-dir data/live
```

Configuration validation and the internal self-test do not access field devices.
Review the target equipment and custom request bytes before executing a live task. Built-in acceptance rejects write-labelled operations and Modbus functions outside 01–04. PCI checks are passive. Communication checks do not establish electrical performance or complete business functionality.

## Implementation
| Interface | Existing inspection capabilities |
| --- | --- |
| Serial | Modbus RTU reads 01–04; configured custom request/response matching |
| Network | Modbus TCP, TCP connectivity, custom TCP/UDP checks |
| PCI | Link/driver/interface inspection, including configured child devices |

The original scan UI remains at `/legacy` in live mode, sharing the station execution lock. Its reports remain separate from acceptance history. See [configuration](config/CONFIG_GUIDE.md) and [deployment](docs/DEPLOYMENT.md) for operational boundaries.

## Engineering

- [web_app.py](web_app.py): HTTP API, task coordination, and report generation.
- [core/config_manager.py](core/config_manager.py): configuration loading and validation.
- [core/generic_detector.py](core/generic_detector.py): discovery and inspection workflow.
- [core/protocol_engine.py](core/protocol_engine.py): protocol requests and response validation.
- [web/index.html](web/index.html): browser interface.
The new `inspection/` domain, service, store, adapters, HTTP and report modules isolate the browser workflow from the existing protocol core. SQLite persists task state and evidence; restart marks unfinished work interrupted without replaying hardware operations. A single process owns each station database.

## Device access
The browser uses local assets without a CDN or frontend framework. Default binding is `127.0.0.1`; network binding requires `QLDC_ACCESS_TOKEN`. The service includes bounded inputs, Host/Origin checks and escaped exports. It does not include multi-user roles or a TLS terminator.

```bash
python -m pip install --require-hashes -r requirements.lock
python validate_config.py
python self_test.py
python -m pytest -q
```

Built-in Modbus checks use read-only function codes; PCI checks are passive. Custom requests can have different semantics and must be reviewed for the target equipment. Use an isolated test environment before field testing, and keep the Web UI on a trusted network.
[Validation](docs/VALIDATION.md) records tested paths and remaining hardware risks. [Dependencies](docs/DEPENDENCIES.md) records pinned releases, source commits, licenses and artifact hashes. CI covers offline checks on Windows/Linux with Python 3.10/3.13.
74 changes: 46 additions & 28 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,67 @@
# 工业设备检测系统
# QLDeviceCheck · 工控设备验收工作台

[English](README.md) · [配置指南](config/CONFIG_GUIDE.md) · [MIT 许可证](LICENSE)
[English](README.md) · [演示](docs/DEMO.md) · [架构](docs/ARCHITECTURE.md) · [API](docs/API.md) · [验证记录](docs/VALIDATION.md) · [MIT](LICENSE)

面向 Linux 的设备发现与协议连通性检测工具,通过 Web 界面完成扫描、测试和报告生成。系统根据配置匹配串口、网络和 PCI 接口与已知设备,支持按接口、设备或全量执行检查。
面向工控设备厂商和系统集成商的本地验收工位。以应检设备清单为起点,记录本次检查范围、协议证据与交付信息,修复后保留原始记录并比较复测结果。

## 检测能力
![验收工作台合成演示](docs/screenshots/overview.png)

| 接口 | 检查内容 |
## 围绕交付与维修组织功能

| 现场问题 | 工作台的处理方式 |
| --- | --- |
| 串口 | Modbus RTU 只读功能码 01–04;自定义请求与响应匹配 |
| 网络 | Modbus TCP、TCP 连通性、自定义 TCP/UDP 探测 |
| PCI | 被动检查链路状态、驱动绑定及关联接口节点 |
| 设备断开后从扫描列表消失 | 每个选定的配置设备都有结果,缺失设备保留失败记录。 |
| 报告无法对应当时的配置 | 每次任务保存完整配置快照、SHA-256、工位或设备编号、批次、操作者和时间。 |
| 修复后重跑覆盖原有证据 | 失败项复测关联原任务并沿用原配置;比较恢复、退化及覆盖范围。 |
| 演示依赖现场设备 | `--demo` 使用独立合成清单,报告标注 `SIMULATED`,模拟与真实任务分别统计。 |

产品定位是轻量的 Linux 现场验收流程与本地证据管理。项目方已确认项目经过测试、可以使用;[设计文档](docs/superpowers/specs/2026-10-07-field-acceptance-design.md)说明定位依据,[验证记录](docs/VALIDATION.md)记录本次升级的检查结果。

## 体验演示

支持全量扫描、单接口扫描和单设备复测,生成 HTML、TXT、JSON 报告。`via_device` 配置用于表示通过 PLC 或网关共享连接的下级设备。
直接安装可从 [Releases](https://github.com/KaiserIIII/QLDeviceCheck_Generic_WebUI_Linux/releases) 下载 Windows x64 或 Linux x86_64 包,内含离线运行依赖。先安装 CPython 3.10+,Windows 双击 `Start-Demo.cmd`,Linux 运行 `bash run_demo.sh`。[Release 使用说明](docs/RELEASE.md)。

## 运行
工作台和兼容扫描页面支持 **English/简体中文**。使用页面语言选择器切换,浏览器会保存选择;首次访问时按浏览器语言选择中文或英文。HTML 报告按当前界面语言导出,配置设备名称、输入信息和原始协议证据保留原文。

需要 Linux、Python 3.7+ 及对应接口的访问权限。
需要 Python **3.10+**;Windows 也可运行演示及离线测试。

```bash
bash setup_linux.sh
bash run_web.sh
python -m venv .venv
source .venv/bin/activate
python -m pip install --require-hashes -r requirements-runtime.lock
python web_app.py --demo --data-dir data/demo
```

浏览器访问 <http://127.0.0.1:8080>。

## 配置与验证
PowerShell 使用 `.\.venv\Scripts\Activate.ps1` 激活环境。浏览器打开 [localhost:8080](http://127.0.0.1:8080),创建“混合故障”任务、查看报文证据,再选择“全部正常”复测。[完整演示步骤](docs/DEMO.md)。

在 [config/device_list.json](config/device_list.json) 中定义设备,参考 [device_list_examples.json](config/device_list_examples.json) 和 [配置指南](config/CONFIG_GUIDE.md)。
## 现场运行

```bash
python3 validate_config.py
python3 self_test.py
bash setup_linux.sh
bash run_web.sh --config config/device_list.json --data-dir data/live
```

配置校验与内部自测不会访问现场设备。
执行真实任务前审核目标设备及自定义报文。内置验收拒绝标注为写操作的配置及 01–04 以外的 Modbus 功能码,PCI 检查采用被动方式。通信检查结果不代表电气性能或完整业务功能通过。

## 实现
| 接口 | 现有检测能力 |
| --- | --- |
| 串口 | Modbus RTU 只读功能码 01–04;自定义请求与响应匹配 |
| 网络 | Modbus TCP、TCP 连通性、自定义 TCP/UDP 检查 |
| PCI | 链路、驱动、接口节点检查,支持配置下级设备 |

真实模式保留 `/legacy` 原扫描界面,与验收任务共用工位执行锁;其报告单独存放,不计入新验收历史。现场接入参考[配置指南](config/CONFIG_GUIDE.md)和[部署说明](docs/DEPLOYMENT.md)。

## 工程实现

- [web_app.py](web_app.py):HTTP API、检测任务协调与报告生成。
- [core/config_manager.py](core/config_manager.py):配置加载与校验。
- [core/generic_detector.py](core/generic_detector.py):设备发现与检测流程。
- [core/protocol_engine.py](core/protocol_engine.py):协议请求与响应校验。
- [web/index.html](web/index.html):浏览器界面。
新增 `inspection/` 领域、服务、存储、适配器、HTTP 与报告模块,将浏览器验收流程和已有协议核心分开。SQLite 持久化任务与证据;重启后将未完成任务标记为中断,不自动重放硬件操作。每个工位数据库只允许一个服务进程使用。

## 设备访问
前端使用本地资源,无 CDN 或前端框架。默认监听 `127.0.0.1`,网络监听必须设置 `QLDC_ACCESS_TOKEN`;提供输入限制、Host/Origin 校验及导出转义。当前未实现多用户权限和 TLS 终止。

```bash
python -m pip install --require-hashes -r requirements.lock
python validate_config.py
python self_test.py
python -m pytest -q
```

内置 Modbus 检查使用只读功能码,PCI 检查采用被动方式。自定义报文的行为取决于设备协议,使用前应单独审核。现场测试前先在隔离环境验证,并将 Web 界面限制在可信网络内。
[验证记录](docs/VALIDATION.md)列明已测路径与未覆盖的真实硬件风险;[依赖记录](docs/DEPENDENCIES.md)提供固定版本、来源 commit、许可证及制品哈希。CI 在 Windows/Linux、Python 3.10/3.13 运行离线检查。
6 changes: 6 additions & 0 deletions Start-Demo.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
cd /d "%~dp0"
echo QLDeviceCheck demo: http://127.0.0.1:8080
echo Leave this window open while using the workbench. Ctrl+C stops the station.
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0run_demo.ps1" %*
if errorlevel 1 pause
Loading
Loading