Simple软件架构
概述 / Overview
Simple 是 MDCS 的车队层,分为两部分: SimpleCore(核心算法库 —— 交管、寻路、包络、可达性、调度内核), SimpleComposer(基于 SimpleCore 的 UI 壳 + 插件宿主)。
Simple is the fleet layer of MDCS, split in two parts: SimpleCore (the algorithm library — traffic control, pathfinding, envelopes, reachability, scheduling kernel) and SimpleComposer (a UI shell + plugin host built on top of SimpleCore).
SimpleCore
完全独立的 .NET 库(`D:\src\Simple\SimpleCore\`),可被任何应用引用。它定义了:
A standalone .NET library at `D:\src\Simple\SimpleCore\`, embeddable in any application. It defines:
| 模块 / Module | 用途 / Use |
|---|---|
| `AbstractCar` (`PropType\AbstractCar.cs:346`) | 调度可见的车的最小契约 / minimal contract for a scheduled vehicle |
| `AGVInterface` (`BasicProps\AGVInterface.cs`) | 任务脚本(TopazScript)调用的车 API / car API called by mission scripts |
| `DPSPlanner` | DPS 多车死锁规划 / DPS multi-car deadlock-free planner |
| `Envelope` | 车体包络 + 站点占用判定 / envelope + site-occupancy logic |
| `Reachability` | 可达性状态机 / reachability state machine — see 可达性状态编程 |
| `FlowFieldPlanner` | 流场规划 / flow-field planner |
| `NetworkFlowBizPlanner` | 基于网络流的业务规划器 / network-flow business planner |
| `World` | 地图(站点 + 路径段 + 区域)/ map (sites + path segments + zones) |
| `TopazEngine` | 任务脚本解释器 / mission-script interpreter |
SimpleCore 不依赖 Windows、UI、SimpleComposer、Clumsy 或 Medulla —— 可在 Linux 工控机上单独跑。 SimpleCore depends on none of Windows, UI, SimpleComposer, Clumsy or Medulla — it runs standalone on Linux IPCs.
SimpleComposer
基于 SimpleCore 的 标准车队管理 UI,位于 `D:\src\Simple\SimpleComposer\`。它提供:
The standard fleet-management UI built on SimpleCore. It provides:
- CAD 工具 / CAD tool — 见 开发手册 - CAD工具
- 车型插件接口 / car-type plugin interface — `Car` 与 `ClumsyCar` 子类化点
- 任务脚本编辑器 / mission-script editor
- 实时监控面板 / live monitoring panel — 包络、锁、车辆状态
- 仿真 / simulation — 整套调度算法可在不接真车的情况下跑
`SimpleComposer.RCS.Car` (`D:\src\Simple\SimpleComposer\RCS\Car.cs:33`) 是车的 Composer 端基类,封装 SimpleCore 的 `AbstractCar` 加上 UI 字段、地图坐标转换、可视化属性。`ClumsyCar` (`D:\src\Simple\SimpleComposer\RCS\ClumsyCar.cs:34`) 是它的子类,专为跑 MDCS 车载的车设计;自评估车(PLC / 磁条 / 二维码)则直接继承 `Car` 并实现 nested `AGV : AGVInterface`。
`SimpleComposer.RCS.Car` is the Composer-side base — `AbstractCar` + UI fields + coordinate transforms + render props. `ClumsyCar` extends it for vehicles running MDCS on-board. Self-evaluating cars subclass `Car` directly with a nested `AGV : AGVInterface`.
数据流 / Data flow
业务系统 (WMS / ERP) → SimpleComposer 任务接收
│
▼
SimpleComposer 任务编排 (CarProgram)
│
▼
SegmentPlan.Compile → TopazScript
│
▼
Car.actualSendScript(script)
├─ ClumsyCar: HTTP POST 到车载 → TopazEngine on-board
└─ 自评估车: 本地 SelfEvaluating(agv, script) → 厂商命令
│
▼ (周期心跳)
Car.keepAlive() ← 车体上报 (x, y, th, siteId, ...)
算法层次 / Algorithm layering
| 层 / Layer | 关切 / Concern | 内核 / Engine |
|---|---|---|
| 业务规划 / Business | 哪台车做哪个任务 | `NetworkFlowBizPlanner` |
| 路径规划 / Pathfinding | 当前任务沿哪条路径 | A* / 流场(流场规划)+ 启发器 |
| 交管 / Traffic control | 多车并存如何避碰 | DPS(DPS算法) |
| 可达性 / Reachability | 当前状态下哪些路径有效 | 状态机(可达性状态编程) |
| 包络 / Envelope | 车体当前占用哪些站点 | 几何 + Reachability 联动 |
插件类型 / Plugin types
SimpleComposer 支持三类插件: SimpleComposer supports three plugin classes:
- 车型插件 / Car-type — 派生 `ClumsyCar` 或 `Car`,加 `[CarType]` 属性。新车上线主用。
- 业务插件 / Business — 派生 `BusinessLogic`,定义自定义任务类型、字段、动作。
- CAD 工具插件 / CAD-tool — 派生 `CADToolPlugin`,给 CAD 画布加自定义可视化与编辑工具。
详见 使用手册 - Simple:从使用到开发 和 如何基于SimpleCore核心库进行调度系统开发。
关键决策 / Key design choices
- SimpleCore 与 SimpleComposer 解耦 —— SimpleCore 是纯算法库;SimpleComposer 可被替换。
- TopazScript 中间表达 —— 任务脚本而不是 RPC,让 ClumsyCar 与自评估车共用同一编译产物。
- DPS 预先规划交管 —— 牺牲灵活性换 可证明的无死锁;动态场景多时切流场。
- 可达性是状态机而不是布尔 —— 同一物理车在 带载 / 不带载 / 高位 / 电量低等状态下走不同路径。