Skip to content

device-agent(C# 本机设备服务) ​

路径:packages/device-agent
包名:@xichen-full-stack/device-agent

本机仪器设备控制服务(ASP.NET Core Minimal API,默认 http://127.0.0.1:19721)。
由 产品端 Desktop 与 调试端 instrument-devtool 共用,经 @xichen-full-stack/instrument 调用。

架构 ​

text
desktop / instrument-devtool
        ↓
  instrument (TS)
        ↓
  DeviceAgent.Host → DeviceManager → Driver
        ├── StageDriver (stage-1) → Motion / Camera Backend
        └── SampleFlowDriver (sample-flow-1) → CAN 整机协议
  • 调试层:connect / commands — 单步 motion / imaging / SampleFlow
  • 任务层:jobs + SSE — 扫片等长任务
  • 工作流:POST /api/v1/workflows/instrument-reset — SampleFlow ↔ Stage 整机复位握手

能力标签 ​

generic · motion · imaging · scan · io(见 DeviceDescriptor.capabilities)

Job API 摘要 ​

方法路径
POST/api/v1/jobs
POST/api/v1/jobs/{id}/control
GET/api/v1/jobs/{id}/artifacts
GET/api/v1/jobs/events(SSE)

控制动作:Start / Pause / Resume / Abort

另有:/api/v1/system/*(串口、Backend、诊断)、/api/v1/recipes,见仓库 device-agent/README.md。

motion / imaging 命令 ​

类别command关键 params
motionhome—
motionmovex/y/z/inject 或 axis + position
motionread-position—
imagingsnapexposureMs?, cameraId?
imagingset-exposureexposureMs, cameraId?
ioread-di / read-do / write-dochannel, value?

设备 ​

ID驱动说明
stage-1stage台架;DeviceAgent:Stage 配置 Motion/Camera Backend
sample-flow-1sample-flow全自动阅片机;DeviceAgent:SampleFlow(串口/CAN)

start-normal、reset 等整机命令只能发到 sample-flow 设备。

联调(推荐) ​

bash
# 调试框架:自动拉起 Agent,无需 admin/后端
pnpm instrument-devtool:dev

或分步:

bash
pnpm device-agent:dev
pnpm instrument-devtool:dev

产品壳内验证(需登录):

bash
pnpm device-agent:dev
$env:DEVICE_AGENT_AUTO_START="true"
pnpm --filter desktop dev

相关文档 ​

Xichen Full Stack 内部文档