feat(demo): 深/浅双主题 + 单位体系 + 界面细节修正

- 新增浅色主题(deep 调色板 + 白色弧内文字),右上角 ☀/☾ 两段式开关切换;6 张 2K 示例图(深浅 × 圆周/条形/设置)
- 单位体系:时间 ms/s/min、相位 °/%、显示精度与换算表;工具栏单位下拉 + 右栏'工艺单位与精度'卡片 + 工艺设置面板
- 修正界面细节:按钮图标与文字重叠(添加动作/编辑/帮助/新建/层级操作/编辑操作)、顺序规则卡片文字被卡片下边裁切、跨循环片段在浅色下过淡、设置面板下拉箭头与单位文字重叠
- 浅色主题下环带加深、阴影减淡、选中描边改为深色,保证对比度
- docs/README 同步更新
This commit is contained in:
2026-09-17 23:34:58 +08:00
parent c2c5f0c47d
commit b876ef2129
15 changed files with 524 additions and 174 deletions
+25 -8
View File
@@ -3,21 +3,38 @@
面向 **PLC 流程节拍设计 / 相位角设计** 的桌面设计软件(Flutter Desktop)。 面向 **PLC 流程节拍设计 / 相位角设计** 的桌面设计软件(Flutter Desktop)。
- **两种视图,一份数据**:条形节拍(甘特 / 流程图 + 依赖箭头) ⇄ 圆周节拍(同心圆相位图,12 点钟起始,一圈 = 一个循环,每新增一个动作在最外层加一层) - **两种视图,一份数据**:条形节拍(甘特 / 流程图 + 依赖箭头) ⇄ 圆周节拍(同心圆相位图,12 点钟起始,一圈 = 一个循环,每新增一个动作在最外层加一层)
- **顺序一目了然**:绿色实线箭头 = FS 严格顺序(完成后启动),琥珀虚线 = SS 并行重叠(可提前启动),关键路径带 ★
- **专业单位体系**:时间 `ms / s / min`、相位 `° / %`、显示精度可配,工艺设置面板统一管理
- **响应快**:自研 Canvas 渲染,双层缓存 + 脏区重绘 + 空间索引,1000 动作仍保持 60 fps - **响应快**:自研 Canvas 渲染,双层缓存 + 脏区重绘 + 空间索引,1000 动作仍保持 60 fps
- **深色 / 浅色双主题**:右上角 ☀ / ☾ 一键切换,语义颜色不变,导出 SVG 与屏幕一致
- **导出 SVG**:矢量、分层、带语义 `id` / `data-*` 元数据,可直接进工艺卡与 MES - **导出 SVG**:矢量、分层、带语义 `id` / `data-*` 元数据,可直接进工艺卡与 MES
## 设计预览(2560 × 1440) ## 设计预览(2560 × 1440)
| 圆周节拍视图 | 条形节拍视图 | **圆周节拍视图**(同心圆 · 12 点钟起始 · 顺序箭头)
| 深色主题 | 浅色主题 |
| --- | --- | | --- | --- |
| ![圆周节拍](demo/circular-timing.png) | ![条形节拍](demo/bar-timing.png) | | ![圆周节拍·深色](demo/circular-timing.png) | ![圆周节拍·浅色](demo/circular-timing-light.png) |
**条形节拍视图**(甘特 / 流程图 · 依赖箭头)
| 深色主题 | 浅色主题 |
| --- | --- |
| ![条形节拍·深色](demo/bar-timing.png) | ![条形节拍·浅色](demo/bar-timing-light.png) |
**工艺设置**(单位与精度 / 循环与相位 / 换算表 / 编辑辅助)
| 深色主题 | 浅色主题 |
| --- | --- |
| ![工艺设置·深色](demo/unit-settings.png) | ![工艺设置·浅色](demo/unit-settings-light.png) |
## 目录 ## 目录
| 路径 | 说明 | | 路径 | 说明 |
| --- | --- | | --- | --- |
| [`docs/DESIGN.md`](docs/DESIGN.md) | 完整设计文档:需求、技术选型、数据模型、布局算法、SVG 导出、里程碑、风险 | | [`docs/DESIGN.md`](docs/DESIGN.md) | 完整设计文档:需求、技术选型、数据模型、单位体系、布局算法、SVG 导出、配色规范、里程碑、风险 |
| `demo/*.svg` | 设计示例图源文件(矢量,可直接编辑) | | `demo/*.svg` | 设计示例图源文件(矢量,可直接编辑,含深/浅两套) |
| `demo/*.png` | 2K(2560×1440)预览图 | | `demo/*.png` | 2K(2560×1440)预览图 |
| `tools/demo-gen.mjs` | 示例图生成脚本(Node,输出 SVG) | | `tools/demo-gen.mjs` | 示例图生成脚本(Node,输出 SVG) |
@@ -27,15 +44,15 @@
node tools/demo-gen.mjs node tools/demo-gen.mjs
``` ```
生成 `demo/circular-timing.svg` 与 `demo/bar-timing.svg`;用任意浏览器/Inkscape 可导出 2K PNG。 生成 6 个 SVG(深色 / 浅色 × 圆周 / 条形 / 设置),用任意浏览器或 Inkscape 可导出 2K PNG。
## 技术栈 ## 技术栈
Flutter 3.29+(Desktop) · CustomPainter 自绘 · Riverpod · 不可变模型 + Command 撤销栈 · 纯 Dart 几何算法 · 自研 SVG 序列化器 · JSON(`.seq.json`)持久化 Flutter 3.29+(Desktop) · CustomPainter 自绘 · Riverpod · 不可变模型 + Command 撤销栈 · 纯 Dart 几何算法 · 自研 SVG 序列化器 · JSON(`.seq.json`)持久化 · 主题 Token 化(深浅双主题)
## 路线图 ## 路线图
- [ ] M1 数据模型 + JSON 存取 + 条形视图(渲染 / 缩放 / 平移) - [ ] M1 数据模型 + 单位体系 + JSON 存取 + 条形视图(渲染 / 缩放 / 平移)
- [ ] M2 圆周视图 + 双视图切换动画 + 拖拽吸附 + 属性面板 + 撤销重做 - [ ] M2 圆周视图 + 双视图切换动画 + 拖拽吸附 + 属性面板 + 撤销重做
- [ ] M3 SVG / PNG 导出 + 依赖编辑 + 关键路径与统计 + Golden 测试 - [ ] M3 SVG / PNG 导出 + 依赖编辑 + 关键路径与统计 + 深浅主题 + Golden 测试
- [ ] M4 PLC 点位对接(OPC UA / 三菱 MC / Modbus)+ 工艺卡 PDF + 自动节拍优化 - [ ] M4 PLC 点位对接(OPC UA / 三菱 MC / Modbus)+ 工艺卡 PDF + 自动节拍优化
Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 KiB

After

Width:  |  Height:  |  Size: 429 KiB

+1 -1
View File
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 603 KiB

After

Width:  |  Height:  |  Size: 615 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 131 KiB

+108 -19
View File
@@ -192,14 +192,63 @@ angle(deg) = ms / cycleMs × 360 ms = angle / 360 × cycleMs
- 修改 `cycleMs` 时,可选择"保持角度"(动作角度不变,实际时间整体缩放)或"保持时间"(反算新角度)——默认前者; - 修改 `cycleMs` 时,可选择"保持角度"(动作角度不变,实际时间整体缩放)或"保持时间"(反算新角度)——默认前者;
- 这样两视图切换只是**换一个 Layout 投影**,不产生任何数据转换与精度损失。 - 这样两视图切换只是**换一个 Layout 投影**,不产生任何数据转换与精度损失。
### 5.3 文件格式示例(`.seq.json`) ### 5.3 单位与精度体系(专业化设置)
工艺节拍的时间量级差异极大:伺服点位可能是 **50 ms**,装配压装是 **秒级**,热处理/固化则是 **分钟级**。
因此单位必须是**可配置的工程属性**,而不是写死的常量。
**核心原则:模型只存"毫秒(double)+ 角度(double)",单位只是显示/输入偏好。**
```
time = angle / 360 × cycleMs (内部恒为 ms,不做任何舍入)
angle = time / cycleMs × 360
```
| 设置项 | 取值 | 默认 | 说明 |
| --- | --- | --- | --- |
| `timeUnit` | `ms` / `s` / `min` | `s` | 时间轴、时长、统计、导出文本的显示单位 |
| `phaseUnit` | `deg`(°) / `percent`(%) | `deg` | 相位显示单位,PLC 工程师常用 % |
| `precision` | `auto` / 0 / 1 / 2 / 3 / 4 位 | `auto` | 仅影响显示;`auto` = 保证 ~1 ms 分辨率(ms→0 位、s→3 位、min→4 位) |
| `snapAngle` | 1° / 5° / 15° / 自定义 | 1° | 角度吸附步长 |
| `snapTime` | 10 ms / 0.1 s / 1 s / 自定义 | 0.1 s | 时间吸附步长(秒级工艺更顺手) |
| `cycleInputPolicy` | 保持角度 / 保持时间 | 保持角度 | 改循环时长时的联动策略 |
**单位感知的格式化**(同一套函数同时供 Canvas 与 SVG 导出使用,保证所见即所得):
| 函数 | 作用 | 示例 |
| --- | --- | --- |
| `tfmt(ms)` | 按当前时间单位格式化 | `0.467 s` / `467 ms` / `0.0078 min` |
| `tfmtAuto(ms)` | 按量级自动选单位,用于换算提示 | `1° = 6.7 ms`、`1 圈 = 2.400 s` |
| `pfmt(deg)` | 按当前相位单位格式化 | `105.0°` / `29.17%` |
**输入解析**:文本框接受 `700ms`、`0.7s`、`0.7`(跟随当前单位)、`29.17%`、`105°`,
统一由 `parseDuration()` / `parsePhase()` 转回内部 ms / deg;非法输入即时标红且不写入模型。
**典型工艺预设**(新建项目时可选,避免每次手配):
| 工艺类型 | 典型周期 | 推荐时间单位 | 推荐相位单位 |
| --- | --- | --- | --- |
| 高速点位 / 伺服贴装 | 50 – 500 ms | `ms` | ° |
| 装配 / 压装 / 焊接 | 0.5 – 10 s | `s` | ° 或 % |
| 包装 / 灌装 / 分选 | 1 – 30 s | `s` | % |
| 热处理 / 固化 / 长周期 | 5 – 120 min | `min` | % |
> 变更 `timeUnit` 不改变任何模型数值,只重算显示;变更 `cycleMs` 时默认"保持角度"(动作相位不变,实际时间整体缩放),
> 也可切换为"保持时间"(反算新角度),两种策略都要在状态栏给出提示。
### 5.4 文件格式示例(`.seq.json`)
```json ```json
{ {
"schema": "seqdiagram/1.2", "schema": "seqdiagram/1.2",
"project": { "project": {
"name": "装配线节拍设计", "name": "装配线节拍设计",
"cycle": { "durationMs": 2400, "unit": "deg", "startAngle": 0, "direction": "cw", "origin": "12o", "snapDeg": 1 }, "units": {
"timeUnit": "s", "phaseUnit": "deg", "precision": "auto",
"snapAngle": 1, "snapTime": 0.1, "cycleInputPolicy": "keepAngle",
"preset": "assembly"
},
"cycle": { "durationMs": 2400, "startAngle": 0, "direction": "cw", "origin": "12o" },
"stations": [ "stations": [
{ "id": "ST1", "name": "上料工位", "order": 0, "color": "#4cc9f0" }, { "id": "ST1", "name": "上料工位", "order": 0, "color": "#4cc9f0" },
{ "id": "ST2", "name": "压装工位", "order": 1, "color": "#ffd166" }, { "id": "ST2", "name": "压装工位", "order": 1, "color": "#ffd166" },
@@ -321,7 +370,19 @@ Model (单一数据源)
| 空格 + 拖拽 | 平移画布;`Ctrl`+滚轮缩放 | | 空格 + 拖拽 | 平移画布;`Ctrl`+滚轮缩放 |
| 从端点拖出连线 | 建立依赖,落点自动判定 FS/SS,弹窗确认 offset | | 从端点拖出连线 | 建立依赖,落点自动判定 FS/SS,弹窗确认 offset |
| 右键动作 | 上下文菜单:改层、改色、复制、设为关键路径起点、删除 | | 右键动作 | 上下文菜单:改层、改色、复制、设为关键路径起点、删除 |
| 相位游标 | 拖动时两视图同步显示当前角度与对应 ms | | 相位游标 | 拖动时两视图同步显示当前相位与对应时间(按当前单位) |
| 单位下拉(工具栏) | 一键切换 `ms / s / min`,全界面即时换算,模型数值不变 |
| `⚙ 工艺设置`(F2) | 打开设置面板:单位与精度 / 循环与相位 / 编辑辅助 / 显示 / 导出 / 快捷键 |
**工艺设置面板**(见 `demo/unit-settings.png`):
- **时间单位**:`ms` / `s`(推荐)/ `min` 三张卡片,附适用场景与实时换算示例(如 `467 ms → 0.467 s`);
- **相位单位**:`°` / `%` 切换,示例 `105.0° ⇄ 29.17%`;
- **显示精度**:自动 / 0–4 位,附实时预览串 `2.400 s · 105.0° · 29.17% · 0.700 s`;
- **循环与相位**:循环时长(带单位下拉)、起始相位与位置(12 点钟 / 3 点钟)、旋转方向(CW / CCW)、圈数显示;
- **时间 ↔ 相位换算表**:列出 0°/90°/180°/270°/360° 对应的秒数与百分比,方便工艺员核对;
- **编辑辅助**:角度吸附、时间吸附、网格显示/吸附、跨圈自动拆分;
- 底部 `恢复默认 / 取消 / 应用 / 确定`,设置项立即生效并写入 `.seq.json`。
--- ---
@@ -360,7 +421,33 @@ Model (单一数据源)
--- ---
## 9. 目录结构 ## 9. 视觉与主题(配色规范)
软件提供**深色 / 浅色两套配色**,右上角一个两段式开关(☀ / ☾)随时切换,快捷键 `F3`。
| 主题 | 适用场景 | 画布 | 强调色 |
| --- | --- | --- | --- |
| 深色(默认) | 车间大屏、长时间盯图、与 PLC 编程软件并列 | `#0e1520 → #0a0f18` 渐变 + 点阵网格 | `#4cc9f0` |
| 浅色 | 投影评审、打印工艺卡、办公室环境 | `#ffffff → #f5f8fc` 渐变 + 点阵网格 | `#0284c7` |
**设计要点**
1. **语义颜色两套主题一致**:FS 严格顺序 = 绿、SS 并行重叠 = 琥珀、关键路径 = ★ + 辉光、选中 = 强调色;
换主题不改变任何语义,只改变明暗;
2. **对比度**:深色主题用亮色调色板 + 深色文字压在弧/条上;浅色主题换用**深色调色板** + 白色文字,
两种主题下弧内文字对比度均 ≥ 4.5:1;
3. **全部颜色走 token**(`ThemeTokens`:bg / panel / line / text / accent / fs / ss / ring / chip / shadow…),
Canvas 绘制与 SVG 导出共用同一份 token,导出时按当前主题输出,保证"屏幕所见 = 导出所得";
4. **主题属于用户偏好**,写入应用设置而非 `.seq.json` —— 同一个项目文件在两种主题下打开都不失真;
5. 同心圆环背景、网格点、阴影在浅色主题下单独调过:环带加深(`#e8eff8 / #dbe5f1`)、
阴影透明度由 0.32 降到 0.16,避免浅色下发灰。
> 预览:`demo/circular-timing.png`(深色) / `demo/circular-timing-light.png`(浅色)、
> `demo/bar-timing.png` / `demo/bar-timing-light.png`、`demo/unit-settings.png` / `demo/unit-settings-light.png`
---
## 10. 目录结构
``` ```
sequence-diagram/ sequence-diagram/
@@ -382,7 +469,7 @@ sequence-diagram/
--- ---
## 10. 里程碑 ## 11. 里程碑
| 阶段 | 周期 | 交付 | | 阶段 | 周期 | 交付 |
| --- | --- | --- | | --- | --- | --- |
@@ -393,7 +480,7 @@ sequence-diagram/
--- ---
## 11. 风险与对策 ## 12. 风险与对策
| 风险 | 影响 | 对策 | | 风险 | 影响 | 对策 |
| --- | --- | --- | | --- | --- | --- |
@@ -406,26 +493,28 @@ sequence-diagram/
--- ---
## 12. 附录:示例 PLC 流程数据(demo 图所用) ## 13. 附录:示例 PLC 流程数据(demo 图所用)
循环 2400 ms = 360°,8 个动作,3 个工位,7 条依赖: 循环 2400 ms = 360° = 100%,8 个动作,3 个工位,7 条依赖(单位设置:时间 `s`、相位 `°`、精度 `auto`):
| ID | 动作 | 工位 | 驱动 | 起始角 | 持续角 | 时间 | 层 | 依赖 | | ID | 动作 | 工位 | 驱动 | 起始相位 | 持续相位 | 起始时间 | 持续时间 | 层 | 依赖 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| A1 | 上料 | ST1 | 气缸 Y1 | 0° | 70° | 467 ms | L1 | — | | A1 | 上料 | ST1 | 气缸 Y1 | 0° (0%) | 70° (19.4%) | 0.000 s | 0.467 s | L1 | — |
| A2 | 定位夹紧 | ST1 | 夹爪 M1 | 55° | 60° | 400 ms | L2 | A1 SS +55° | | A2 | 定位夹紧 | ST1 | 夹爪 M1 | 55° (15.3%) | 60° (16.7%) | 0.367 s | 0.400 s | L2 | A1 SS +55° |
| A3 | 伺服下压 | ST2 | 伺服 Z 轴 | 105° | 85° | 567 ms | L3 | A2 FS | | A3 | 伺服下压 | ST2 | 伺服 Z 轴 | 105° (29.2%) | 85° (23.6%) | 0.700 s | 0.567 s | L3 | A2 FS |
| A4 | 超声波焊接 | ST2 | 超声发生器 | 185° | 95° | 633 ms | L4 | A3 FS | | A4 | 超声波焊接 | ST2 | 超声发生器 | 185° (51.4%) | 95° (26.4%) | 1.233 s | 0.633 s | L4 | A3 FS |
| A5 | 保压冷却 | ST2 | 延时 T1 | 275° | 45° | 300 ms | L5 | A4 FS | | A5 | 保压冷却 | ST2 | 延时 T1 | 275° (76.4%) | 45° (12.5%) | 1.833 s | 0.300 s | L5 | A4 FS |
| A6 | 视觉检测 | ST3 | 相机 CAM1 | 300° | 45° | 300 ms | L6 | A4 FS | | A6 | 视觉检测 | ST3 | 相机 CAM1 | 300° (83.3%) | 45° (12.5%) | 2.000 s | 0.300 s | L6 | A4 FS |
| A7 | 分选下料 | ST3 | 气缸 Y2 | 335° | 25° | 167 ms | L7 | A6 SS +35° | | A7 | 分选下料 | ST3 | 气缸 Y2 | 335° (93.1%) | 25° (6.9%) | 2.233 s | 0.167 s | L7 | A6 SS +35° |
| A8 | 清洁吹气 | ST3 | 电磁阀 V3 | 340° | 45° | 300 ms | L8 | A7 SS +5°(跨循环至 25°) | | A8 | 清洁吹气 | ST3 | 电磁阀 V3 | 340° (94.4%) | 45° (12.5%) | 2.267 s | 0.300 s | L8 | A7 SS +5°(跨循环至 25°) |
- 关键路径:`A1 → A2 → A3 → A4 → A6 → A7` - 关键路径:`A1 → A2 → A3 → A4 → A6 → A7`
- 最大并行度:3(185°–190° 区间) - 最大并行度:3(185°–190° 区间)
- 瓶颈工位:ST2,加工相位 105°–320°(215°) - 瓶颈工位:ST2,加工相位 105°–320°(215°)
- 预估节拍:2.400 s / 件 ≈ 1500 件/小时 - 预估产能:1500 件/小时(节拍 2.400 s)
![圆周节拍](../demo/circular-timing.png) ![圆周节拍](../demo/circular-timing.png)
![条形节拍](../demo/bar-timing.png) ![条形节拍](../demo/bar-timing.png)
![工艺设置(单位与精度)](../demo/unit-settings.png)
+385 -145
View File
@@ -8,15 +8,78 @@ mkdirSync(OUT, { recursive: true });
const W = 2560, H = 1440; const W = 2560, H = 1440;
const FONT = "'Microsoft YaHei','Segoe UI',sans-serif"; const FONT = "'Microsoft YaHei','Segoe UI',sans-serif";
const C = { const THEMES = {
bg: '#0b1018', canvas: '#0e1520', panel: '#121a28', panel2: '#0f1723', dark: {
line: '#1f2c40', line2: '#2a3a52', text: '#e8eefc', sub: '#8ea0bd', dim: '#5c6f8c', bg: '#0b1018', canvas1: '#0e1520', canvas2: '#0a0f18', chrome: '#0f1622',
accent: '#4cc9f0', accent2: '#7c5cff', ok: '#34d399', warn: '#ffd166', danger: '#ff6b6b', panel: '#121a28', panel2: '#0f1723', dialog: '#101827', navBg: '#0d1522',
fs: '#4ade80', ss: '#ffd166', crit: '#4cc9f0', line: '#1f2c40', line2: '#2a3a52',
text: '#e8eefc', text2: '#cfd9ea', sub: '#8ea0bd', dim: '#5c6f8c',
accent: '#4cc9f0', accent2: '#7c5cff', ok: '#34d399', warn: '#ffd166', danger: '#ff6b6b',
fs: '#4ade80', ss: '#ffd166', crit: '#4cc9f0',
chip: '#0b1018', dial: '#0c1320', arcText: '#0a0f18', onAccent: '#04121b', tailOp: 0.45,
ringA: '#18222f', ringB: '#121a28', ringEdge: '#26374f', ringLabel: '#42597a',
info: '#131d2e', track: '#1b2740', sel: '#182437', activeCard: '#14233a',
grid: '#1c2940', shadow: '#000000', shadowOp: 0.32, selOutline: '#ffffff',
overlay: '#04080f', overlayOp: 0.74,
pal: ['#4cc9f0', '#7bd88f', '#ffd166', '#ff8a5c', '#f472b6', '#a78bfa', '#38bdf8', '#34d399'],
},
light: {
bg: '#eaeff6', canvas1: '#ffffff', canvas2: '#f5f8fc', chrome: '#ffffff',
panel: '#ffffff', panel2: '#f6f9fc', dialog: '#ffffff', navBg: '#f3f7fb',
line: '#e4eaf3', line2: '#c9d6e5',
text: '#1b2740', text2: '#334155', sub: '#4a5a72', dim: '#8fa0b8',
accent: '#0284c7', accent2: '#7c3aed', ok: '#059669', warn: '#c2740a', danger: '#dc2626',
fs: '#15803d', ss: '#b45309', crit: '#0284c7',
chip: '#ffffff', dial: '#eef3f9', arcText: '#ffffff', onAccent: '#ffffff', tailOp: 0.55,
ringA: '#e8eff8', ringB: '#dbe5f1', ringEdge: '#c2d2e4', ringLabel: '#8fa3bc',
info: '#f3f7fb', track: '#dfe8f2', sel: '#dcefff', activeCard: '#dcefff',
grid: '#d6e0ec', shadow: '#7c8fa6', shadowOp: 0.16, selOutline: '#0f172a',
overlay: '#0f172a', overlayOp: 0.45,
pal: ['#0284c7', '#16a34a', '#c2740a', '#ea580c', '#db2777', '#7c3aed', '#0891b2', '#059669'],
},
}; };
const PAL = ['#4cc9f0', '#7bd88f', '#ffd166', '#ff8a5c', '#f472b6', '#a78bfa', '#38bdf8', '#34d399']; /* __THEMES_END__ */
let T = THEMES.dark;
let C = T;
let PAL = T.pal;
let THEME = 'dark';
function setTheme(name) {
THEME = name;
T = THEMES[name];
C = T;
PAL = T.pal;
}
const SEQ = ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩']; const SEQ = ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩'];
const UNIT = { time: 's', phase: 'deg', precision: 'auto' };
const TIME_DIV = { ms: 1, s: 1000, min: 60000 };
const TIME_DEC = { ms: 0, s: 3, min: 4 };
function tval(ms) {
return ms / TIME_DIV[UNIT.time];
}
function tfmt(ms, dec) {
const d = dec ?? (UNIT.precision === 'auto' ? TIME_DEC[UNIT.time] : UNIT.precision);
return `${tval(ms).toFixed(d)} ${UNIT.time}`;
}
function tvalStr(ms, dec = 1) {
return tval(ms).toFixed(dec);
}
function tfmtAuto(ms) {
if (ms < 100) return `${ms.toFixed(1)} ms`;
if (ms < 1000) return `${Math.round(ms)} ms`;
if (ms < 60000) return `${(ms / 1000).toFixed(ms < 10000 ? 3 : 2)} s`;
return `${(ms / 60000).toFixed(3)} min`;
}
function pfmt(deg, dec = 1) {
return UNIT.phase === '%' ? `${(deg / 3.6).toFixed(2)}%` : `${fmt(deg, dec)}°`;
}
const CYCLE_MS = 2400; const CYCLE_MS = 2400;
const ACTIONS = [ const ACTIONS = [
{ id: 'A1', name: '上料', a0: 0, a1: 70, station: 'ST1', driver: '气缸 Y1' }, { id: 'A1', name: '上料', a0: 0, a1: 70, station: 'ST1', driver: '气缸 Y1' },
@@ -112,8 +175,8 @@ function arrowHead(tx, ty, dx, dy, col, size = 12) {
return path(`M ${tx.toFixed(2)} ${ty.toFixed(2)} L ${(bx + px).toFixed(2)} ${(by + py).toFixed(2)} L ${(bx - px).toFixed(2)} ${(by - py).toFixed(2)} z`, { fill: col }); return path(`M ${tx.toFixed(2)} ${ty.toFixed(2)} L ${(bx + px).toFixed(2)} ${(by + py).toFixed(2)} L ${(bx - px).toFixed(2)} ${(by - py).toFixed(2)} z`, { fill: col });
} }
function icon(x, y, name, col) { function iconAt(cx, cy, name, col) {
const c = x + 24, m = y + 24; const c = cx, m = cy;
switch (name) { switch (name) {
case 'add': case 'add':
return line(c - 9, m, c + 9, m, { stroke: col, sw: 2.4, cap: 'round' }) + line(c, m - 9, c, m + 9, { stroke: col, sw: 2.4, cap: 'round' }); return line(c - 9, m, c + 9, m, { stroke: col, sw: 2.4, cap: 'round' }) + line(c, m - 9, c, m + 9, { stroke: col, sw: 2.4, cap: 'round' });
@@ -122,7 +185,7 @@ function icon(x, y, name, col) {
+ path(`M ${c + 6} ${m - 10} l 4 4`, { stroke: col, sw: 2 }); + path(`M ${c + 6} ${m - 10} l 4 4`, { stroke: col, sw: 2 });
case 'copy': case 'copy':
return rect(c - 8, m - 10, 12, 14, { rx: 3, stroke: col, sw: 1.8 }) return rect(c - 8, m - 10, 12, 14, { rx: 3, stroke: col, sw: 1.8 })
+ rect(c - 3, m - 5, 12, 14, { rx: 3, fill: '#121a28', stroke: col, sw: 1.8 }); + rect(c - 3, m - 5, 12, 14, { rx: 3, fill: T.ringB, stroke: col, sw: 1.8 });
case 'del': case 'del':
return rect(c - 8, m - 5, 16, 14, { rx: 2.5, stroke: col, sw: 1.8 }) return rect(c - 8, m - 5, 16, 14, { rx: 2.5, stroke: col, sw: 1.8 })
+ line(c - 10, m - 8, c + 10, m - 8, { stroke: col, sw: 1.8, cap: 'round' }) + line(c - 10, m - 8, c + 10, m - 8, { stroke: col, sw: 1.8, cap: 'round' })
@@ -150,24 +213,57 @@ function icon(x, y, name, col) {
} }
} }
function sunIcon(cx, cy, col) {
let s = circle(cx, cy, 5.6, { fill: col });
for (let i = 0; i < 8; i++) {
const a = (i * 45 * Math.PI) / 180;
s += line(cx + Math.cos(a) * 8.6, cy + Math.sin(a) * 8.6, cx + Math.cos(a) * 11.6, cy + Math.sin(a) * 11.6, { stroke: col, sw: 1.8, cap: 'round' });
}
return s;
}
function moonIcon(cx, cy, col) {
return path(`M ${cx + 3.4} ${cy - 9.6} A 9.8 9.8 0 1 0 ${cx + 3.4} ${cy + 9.6} A 7.6 7.6 0 1 1 ${cx + 3.4} ${cy - 9.6} z`, { fill: col });
}
function btn(x, w, label, o = {}) { function btn(x, w, label, o = {}) {
const { kind = 'ghost', iconName = null, h = 36, y = 14, size = 14.5 } = o; const { kind = 'ghost', iconName = null, h = 36, y = 14, size = 14.5 } = o;
const S = { const S = {
ghost: { fill: C.panel, stroke: C.line2, col: C.text }, ghost: { fill: C.panel, stroke: C.line2, col: C.text },
primary: { fill: C.accent2, stroke: C.accent2, col: '#ffffff' }, primary: { fill: C.accent2, stroke: C.accent2, col: '#ffffff' },
add: { fill: C.ok, stroke: C.ok, col: '#04170e' }, add: { fill: C.ok, stroke: C.ok, col: T.onAccent },
toggle: { fill: C.accent, stroke: C.accent, col: '#04170e' }, toggle: { fill: C.accent, stroke: C.accent, col: T.onAccent },
}[kind]; }[kind];
let s = rect(x, y, w, h, { rx: 9, fill: S.fill, stroke: S.stroke, sw: 1 }); let s = rect(x, y, w, h, { rx: 9, fill: S.fill, stroke: S.stroke, sw: 1 });
if (iconName) { if (iconName) {
s += icon(x + 4, y + (h - 48) / 2, iconName, S.col); s += iconAt(x + 21, y + h / 2, iconName, S.col);
s += txt(x + 34, y + h / 2 + 1, label, { size, fill: S.col, weight: kind === 'ghost' ? 400 : 600 }); s += txt(x + 40, y + h / 2 + 1, label, { size, fill: S.col, weight: kind === 'ghost' ? 400 : 600 });
} else { } else {
s += txt(x + w / 2, y + h / 2 + 1, label, { size, anchor: 'middle', fill: S.col, weight: kind === 'ghost' ? 400 : 600 }); s += txt(x + w / 2, y + h / 2 + 1, label, { size, anchor: 'middle', fill: S.col, weight: kind === 'ghost' ? 400 : 600 });
} }
return s; return s;
} }
function segBtn(x, y, w, h, label, active) {
return rect(x, y, w, h, { rx: 8, fill: active ? C.accent : C.panel, opacity: active ? 0.18 : 1, stroke: active ? C.accent : C.line2, sw: 1 })
+ txt(x + w / 2, y + h / 2 + 1, label, { size: 12.5, anchor: 'middle', fill: active ? C.accent : C.sub, weight: active ? 600 : 400 });
}
function unitCard(x, y, w) {
const h = 158;
let s = rect(x, y, w, h, { rx: 12, fill: C.panel2, stroke: C.line, sw: 1 });
s += txt(x + 14, y + 24, '工艺单位与精度', { size: 13, fill: C.dim, ls: 2 });
s += txt(x + w - 14, y + 24, '⚙ 设置…', { size: 12.5, anchor: 'end', fill: C.accent });
const bw = 60;
s += txt(x + 14, y + 58, '时间单位', { size: 12.5, fill: C.sub });
['ms', 's', 'min'].forEach((u, i) => { s += segBtn(x + 100 + i * (bw + 6), y + 42, bw, 32, u, u === UNIT.time); });
s += txt(x + 14, y + 104, '相位单位', { size: 12.5, fill: C.sub });
['°', '%'].forEach((u, i) => { s += segBtn(x + 100 + i * (bw + 6), y + 88, bw, 32, u, u === UNIT.phase); });
s += line(x + 14, y + 131, x + w - 14, y + 131, { stroke: C.line, sw: 1 });
s += txt(x + 14, y + 146, `1° = ${tfmtAuto(CYCLE_MS / 360)} 1% = ${tfmtAuto(CYCLE_MS / 100)} 1 圈 = ${tfmt(CYCLE_MS)}`, { size: 11, fill: C.dim });
return { svg: s, h };
}
function chrome(mode) { function chrome(mode) {
const segX = 962, segW = 340, half = segW / 2, segY = 14, segH = 36; const segX = 962, segW = 340, half = segW / 2, segY = 14, segH = 36;
const activeBar = mode === 'bar'; const activeBar = mode === 'bar';
@@ -176,7 +272,7 @@ function chrome(mode) {
+ txt(x + w / 2, segY + segH / 2 + 1, label, { size: 15, anchor: 'middle', weight: active ? 600 : 400, fill: active ? C.accent : C.sub }); + txt(x + w / 2, segY + segH / 2 + 1, label, { size: 15, anchor: 'middle', weight: active ? 600 : 400, fill: active ? C.accent : C.sub });
let s = ''; let s = '';
s += rect(0, 0, W, 64, { fill: '#0f1622' }); s += rect(0, 0, W, 64, { fill: T.chrome });
s += line(0, 63.5, W, 63.5, { stroke: C.line2, sw: 1 }); s += line(0, 63.5, W, 63.5, { stroke: C.line2, sw: 1 });
s += rect(24, 17, 30, 30, { rx: 9, fill: C.accent, opacity: 0.18 }); s += rect(24, 17, 30, 30, { rx: 9, fill: C.accent, opacity: 0.18 });
s += rect(24, 17, 30, 30, { rx: 9, stroke: C.accent, sw: 1.2 }); s += rect(24, 17, 30, 30, { rx: 9, stroke: C.accent, sw: 1.2 });
@@ -198,23 +294,37 @@ function chrome(mode) {
s += btn(1330, 106, '导出 SVG', { kind: 'primary' }); s += btn(1330, 106, '导出 SVG', { kind: 'primary' });
s += btn(1444, 106, '导出 PNG'); s += btn(1444, 106, '导出 PNG');
s += btn(1568, 104, '− 100% +'); s += btn(1568, 96, '− 100% +');
s += btn(1680, 104, '适应窗口'); s += btn(1672, 96, '适应窗口');
s += btn(1796, 80, '重置视图'); s += btn(1776, 84, '重置视图');
s += rect(1890, 14, 550, 36, { rx: 9, fill: C.panel, stroke: C.line2, sw: 1 }); s += rect(1868, 14, 96, 36, { rx: 9, fill: C.panel, stroke: C.accent, sw: 1.2 });
s += txt(1908, 33, '文件:装配线节拍.seq.json', { size: 13.5, fill: C.sub }); s += txt(1884, 33, '单位', { size: 12.5, fill: C.dim });
s += circle(2300, 32, 4, { fill: C.ok }); s += txt(1916, 33, UNIT.time, { size: 14, weight: 700, fill: C.accent });
s += txt(2314, 33, '已保存', { size: 13, fill: C.ok }); s += path(`M 1938 28 l 5 6 l 5 -6`, { stroke: C.accent, sw: 1.6, cap: 'round' });
s += btn(2456, 80, '帮助', { iconName: 'help', size: 14 }); s += rect(1980, 14, 380, 36, { rx: 9, fill: C.panel, stroke: C.line2, sw: 1 });
s += txt(1998, 33, '文件:装配线节拍.seq.json', { size: 13.5, fill: C.sub });
s += circle(2200, 32, 4, { fill: C.ok });
s += txt(2214, 33, '已保存', { size: 13, fill: C.ok });
s += btn(2372, 76, '帮助', { iconName: 'help', size: 14 });
const lightOn = THEME === 'light';
s += rect(2454, 14, 84, 36, { rx: 10, fill: C.panel, stroke: C.line2, sw: 1 });
s += rect(2458, 18, 36, 28, { rx: 8, fill: lightOn ? C.accent : 'transparent', opacity: lightOn ? 0.18 : 1 });
if (lightOn) s += rect(2458, 18, 36, 28, { rx: 8, stroke: C.accent, sw: 1.2 });
s += sunIcon(2476, 32, lightOn ? C.accent : C.dim);
s += rect(2498, 18, 36, 28, { rx: 8, fill: !lightOn ? C.accent : 'transparent', opacity: !lightOn ? 0.18 : 1 });
if (!lightOn) s += rect(2498, 18, 36, 28, { rx: 8, stroke: C.accent, sw: 1.2 });
s += moonIcon(2516, 32, !lightOn ? C.accent : C.dim);
const sbY = H - 36; const sbY = H - 36;
s += rect(0, sbY, W, 36, { fill: '#0f1622' }); s += rect(0, sbY, W, 36, { fill: T.chrome });
s += line(0, sbY + 0.5, W, sbY + 0.5, { stroke: C.line2, sw: 1 }); s += line(0, sbY + 0.5, W, sbY + 0.5, { stroke: C.line2, sw: 1 });
const items = mode === 'bar' const items = mode === 'bar'
? ['循环周期 2400 ms', '相位 360°', '动作 8', '依赖 7', '工位 3', '时间轴 0–2400 ms', '吸附 5°', '就绪'] ? [`循环周期 ${tfmt(CYCLE_MS)}`, '相位 360° = 100%', '动作 8', '依赖 7', '工位 3', `时间轴 0–${tfmt(CYCLE_MS)}`, `1° = ${tfmtAuto(CYCLE_MS / 360)}`, '就绪']
: ['循环周期 2400 ms', '相位 360°', '动作 8', '层数 L1–L8', '同心圆 8', '半径步距 50 px', '吸附 1°', '就绪']; : [`循环周期 ${tfmt(CYCLE_MS)}`, '相位 360° = 100%', '动作 8', '层数 L1–L8', '同心圆 8', `单位 ${UNIT.time} / ${UNIT.phase}`, `1° = ${tfmtAuto(CYCLE_MS / 360)}`, '就绪'];
let x = 24; let x = 24;
items.forEach((it, i) => { items.forEach((it, i) => {
s += txt(x, sbY + 19, it, { size: 13, fill: i === items.length - 1 ? C.ok : C.sub }); s += txt(x, sbY + 19, it, { size: 13, fill: i === items.length - 1 ? C.ok : C.sub });
@@ -239,9 +349,9 @@ function floatToolbar() {
let s = rect(x - 6, y - 6, w + 12, items.length * (h + gap) + 6, { rx: 14, fill: C.panel, stroke: C.line2, sw: 1, opacity: 0.96 }); let s = rect(x - 6, y - 6, w + 12, items.length * (h + gap) + 6, { rx: 14, fill: C.panel, stroke: C.line2, sw: 1, opacity: 0.96 });
items.forEach(([ic, label, kind], i) => { items.forEach(([ic, label, kind], i) => {
const by = y + i * (h + gap); const by = y + i * (h + gap);
const S = { add: { fill: C.ok, col: '#04170e' }, toggle: { fill: C.accent, col: '#04170e' }, ghost: { fill: C.panel2, col: C.sub } }[kind]; const S = { add: { fill: C.ok, col: T.onAccent }, toggle: { fill: C.accent, col: T.onAccent }, ghost: { fill: C.panel2, col: C.sub } }[kind];
s += rect(x, by, w, h, { rx: 10, fill: S.fill, stroke: kind === 'ghost' ? C.line : S.fill, sw: 1 }); s += rect(x, by, w, h, { rx: 10, fill: S.fill, stroke: kind === 'ghost' ? C.line : S.fill, sw: 1 });
s += icon(x - 4, by - 8, ic, S.col); s += iconAt(x + 24, by + 15, ic, S.col);
s += txt(x + w / 2, by + h - 8, label, { size: 10.5, anchor: 'middle', fill: S.col, weight: 600 }); s += txt(x + w / 2, by + h - 8, label, { size: 10.5, anchor: 'middle', fill: S.col, weight: 600 });
}); });
return s; return s;
@@ -258,27 +368,27 @@ function leftPanel(mode, selected) {
s += txt(49, 146, '装', { size: 15, anchor: 'middle', fill: C.accent2, weight: 700 }); s += txt(49, 146, '装', { size: 15, anchor: 'middle', fill: C.accent2, weight: 700 });
s += txt(78, 138, '装配线节拍设计', { size: 15.5, weight: 600 }); s += txt(78, 138, '装配线节拍设计', { size: 15.5, weight: 600 });
s += txt(78, 160, '装配线节拍.seq.json · v1.2', { size: 12, fill: C.dim }); s += txt(78, 160, '装配线节拍.seq.json · v1.2', { size: 12, fill: C.dim });
s += txt(32, 196, '循环 2.400 s = 360°', { size: 12.5, fill: C.accent }); s += txt(32, 196, `循环 ${tfmt(CYCLE_MS)} = 360° = 100%`, { size: 12.5, fill: C.accent });
s += txt(232, 196, '动作 8 · 依赖 7', { size: 12.5, fill: C.sub }); s += txt(232, 196, '动作 8 · 依赖 7', { size: 12.5, fill: C.sub });
s += txt(24, 246, mode === 'bar' ? '动作 / 工位泳道' : '动作列表(按层 L1→L8)', { size: 13, fill: C.dim, ls: 2 }); s += txt(24, 246, mode === 'bar' ? '动作 / 工位泳道' : '动作列表(按层 L1→L8)', { size: 13, fill: C.dim, ls: 2 });
s += rect(300, 232, 64, 26, { rx: 8, fill: C.ok, opacity: 0.92 }); s += rect(286, 230, 78, 30, { rx: 9, fill: C.ok, opacity: 0.92 });
s += icon(296, 220, 'add', '#04170e'); s += iconAt(308, 245, 'add', T.onAccent);
s += txt(344, 245, '新建', { size: 12.5, anchor: 'middle', fill: '#04170e', weight: 700 }); s += txt(342, 245, '新建', { size: 12.5, anchor: 'middle', fill: T.onAccent, weight: 700 });
const rowH = 50, gap = 6, y1 = 268; const rowH = 50, gap = 6, y1 = 268;
ACTIONS.forEach((a, i) => { ACTIONS.forEach((a, i) => {
const y = y1 + i * (rowH + gap); const y = y1 + i * (rowH + gap);
const sel = a.id === selected; const sel = a.id === selected;
s += rect(16, y, 348, rowH, { rx: 10, fill: sel ? '#182437' : C.panel2, stroke: sel ? C.accent : C.line, sw: sel ? 1.4 : 1 }); s += rect(16, y, 348, rowH, { rx: 10, fill: sel ? T.sel : C.panel2, stroke: sel ? C.accent : C.line, sw: sel ? 1.4 : 1 });
s += rect(28, y + 15, 20, 20, { rx: 6, fill: a.color, opacity: 0.9 }); s += rect(28, y + 15, 20, 20, { rx: 6, fill: a.color, opacity: 0.9 });
s += txt(38, y + 26, String(i + 1), { size: 12, anchor: 'middle', fill: '#0b1018', weight: 700 }); s += txt(38, y + 26, String(i + 1), { size: 12, anchor: 'middle', fill: T.chip, weight: 700 });
s += txt(58, y + 18, a.name, { size: 14.5, weight: sel ? 600 : 400, fill: sel ? C.text : '#cfd9ea' }); s += txt(58, y + 18, a.name, { size: 14.5, weight: sel ? 600 : 400, fill: sel ? C.text : T.text2 });
s += txt(58, y + 36, `${a.id} · ${a.station} · ${a.driver}`, { size: 11.5, fill: C.dim }); s += txt(58, y + 36, `${a.id} · ${a.station} · ${a.driver}`, { size: 11.5, fill: C.dim });
s += txt(316, y + 18, mode === 'bar' ? `${fmt(a.a0, 0)}° – ${fmt(Math.min(a.a1, 360), 0)}°` : `L${i + 1} r=${100 + i * 50}`, { size: 12, anchor: 'end', fill: C.sub }); s += txt(316, y + 18, mode === 'bar' ? `${pfmt(a.a0, 0)} – ${pfmt(Math.min(a.a1, 360), 0)}` : `L${i + 1} r=${100 + i * 50}`, { size: 12, anchor: 'end', fill: C.sub });
s += txt(316, y + 36, `${deg2ms(a.a1 - a.a0)} ms`, { size: 11.5, anchor: 'end', fill: C.dim }); s += txt(316, y + 36, tfmt(deg2ms(a.a1 - a.a0)), { size: 11.5, anchor: 'end', fill: C.dim });
s += rect(324, y + 13, 30, 24, { rx: 7, fill: 'transparent', stroke: C.line2, sw: 1 }); s += rect(324, y + 13, 30, 24, { rx: 7, fill: 'transparent', stroke: C.line2, sw: 1 });
s += icon(317, y + 1, 'edit', sel ? C.accent : C.dim); s += iconAt(341, y + 25, 'edit', sel ? C.accent : C.dim);
}); });
const yb = y1 + 8 * (rowH + gap) + 14; const yb = y1 + 8 * (rowH + gap) + 14;
@@ -307,11 +417,11 @@ function leftPanel(mode, selected) {
const y = yload + 26 + i * 36; const y = yload + 26 + i * 36;
s += txt(24, y, k, { size: 12.5, fill: C.sub }); s += txt(24, y, k, { size: 12.5, fill: C.sub });
s += txt(356, y, `${deg}° · ${((deg / 3.6)).toFixed(1)}%`, { size: 12, anchor: 'end', fill: col, weight: 600 }); s += txt(356, y, `${deg}° · ${((deg / 3.6)).toFixed(1)}%`, { size: 12, anchor: 'end', fill: col, weight: 600 });
s += rect(24, y + 12, 332, 8, { rx: 4, fill: '#1b2740' }); s += rect(24, y + 12, 332, 8, { rx: 4, fill: T.track });
s += rect(24, y + 12, (332 * deg) / 360, 8, { rx: 4, fill: col }); s += rect(24, y + 12, (332 * deg) / 360, 8, { rx: 4, fill: col });
}); });
const ynote = yload + 26 + 3 * 36 + 22; const ynote = yload + 26 + 3 * 36 + 22;
s += rect(16, ynote, 348, 96, { rx: 10, fill: '#131d2e', stroke: C.line, sw: 1 }); s += rect(16, ynote, 348, 96, { rx: 10, fill: T.info, stroke: C.line, sw: 1 });
s += txt(32, ynote + 22, '操作提示', { size: 12, fill: C.warn, weight: 700 }); s += txt(32, ynote + 22, '操作提示', { size: 12, fill: C.warn, weight: 700 });
s += txt(32, ynote + 44, '拖拽动作块平移相位 · 拖端点改持续角', { size: 11.5, fill: C.sub }); s += txt(32, ynote + 44, '拖拽动作块平移相位 · 拖端点改持续角', { size: 11.5, fill: C.sub });
s += txt(32, ynote + 62, 'Shift+拖拽改层 · Ctrl+滚轮缩放', { size: 11.5, fill: C.sub }); s += txt(32, ynote + 62, 'Shift+拖拽改层 · Ctrl+滚轮缩放', { size: 11.5, fill: C.sub });
@@ -328,16 +438,16 @@ function rightPanelCircular() {
s += txt(lx, 96, '属性 · 选中动作', { size: 13, fill: C.dim, ls: 2 }); s += txt(lx, 96, '属性 · 选中动作', { size: 13, fill: C.dim, ls: 2 });
s += rect(lx, 112, rx - lx, 62, { rx: 12, fill: C.panel2, stroke: C.line, sw: 1 }); s += rect(lx, 112, rx - lx, 62, { rx: 12, fill: C.panel2, stroke: C.line, sw: 1 });
s += rect(lx + 14, 128, 30, 30, { rx: 8, fill: byId('A3').color, opacity: 0.9 }); s += rect(lx + 14, 128, 30, 30, { rx: 8, fill: byId('A3').color, opacity: 0.9 });
s += txt(lx + 29, 144, 'A3', { size: 11.5, anchor: 'middle', fill: '#0b1018', weight: 700 }); s += txt(lx + 29, 144, 'A3', { size: 11.5, anchor: 'middle', fill: T.chip, weight: 700 });
s += txt(lx + 56, 136, '③ 伺服下压', { size: 16, weight: 600 }); s += txt(lx + 56, 136, '③ 伺服下压', { size: 16, weight: 600 });
s += txt(lx + 56, 158, 'ST2 · 伺服 Z 轴 · 层 L3', { size: 12, fill: C.dim }); s += txt(lx + 56, 158, 'ST2 · 伺服 Z 轴 · 层 L3', { size: 12, fill: C.dim });
s += rect(rx - 74, 126, 60, 34, { rx: 8, fill: C.accent, opacity: 0.14, stroke: C.accent, sw: 1 }); s += rect(rx - 74, 126, 60, 34, { rx: 8, fill: C.accent, opacity: 0.14, stroke: C.accent, sw: 1 });
s += txt(rx - 44, 143, '选中', { size: 12.5, anchor: 'middle', fill: C.accent }); s += txt(rx - 44, 143, '选中', { size: 12.5, anchor: 'middle', fill: C.accent });
const fields = [ const fields = [
['起始角', '105.0°', '12 点钟起顺时针'], ['起始相位', pfmt(105), `${tfmt(deg2ms(105))} · 12 点钟起顺时针`],
['结束角', '190.0°', ''], ['结束相位', pfmt(190), tfmt(deg2ms(190))],
['持续角', '85.0°', `= ${deg2ms(85)} ms`], ['持续相位', pfmt(85), `${tfmt(deg2ms(85))} · 占循环 23.61%`],
['所在层', 'L3', '半径 200 px'], ['所在层', 'L3', '半径 200 px'],
['顺序约束', '② → ③ FS', '严格顺序(完成后启动)'], ['顺序约束', '② → ③ FS', '严格顺序(完成后启动)'],
['相位归属', '加工相位', '105°–190°'], ['相位归属', '加工相位', '105°–190°'],
@@ -358,37 +468,38 @@ function rightPanelCircular() {
sliders.forEach(([k, p, v]) => { sliders.forEach(([k, p, v]) => {
s += txt(lx, y, k, { size: 13, fill: C.sub }); s += txt(lx, y, k, { size: 13, fill: C.sub });
s += txt(rx, y, v, { size: 13, anchor: 'end', fill: C.accent, weight: 600 }); s += txt(rx, y, v, { size: 13, anchor: 'end', fill: C.accent, weight: 600 });
s += rect(lx, y + 16, rx - lx, 8, { rx: 4, fill: '#1b2740' }); s += rect(lx, y + 16, rx - lx, 8, { rx: 4, fill: T.track });
s += rect(lx, y + 16, (rx - lx) * p, 8, { rx: 4, fill: C.accent }); s += rect(lx, y + 16, (rx - lx) * p, 8, { rx: 4, fill: C.accent });
s += circle(lx + (rx - lx) * p, y + 20, 9, { fill: '#0b1018', stroke: C.accent, sw: 2.5 }); s += circle(lx + (rx - lx) * p, y + 20, 9, { fill: T.chip, stroke: C.accent, sw: 2.5 });
y += 56; y += 56;
}); });
y += 4; y += 4;
const uc = unitCard(lx, 590, rx - lx);
s += uc.svg;
y = 590 + uc.h + 24;
s += txt(lx, y, '层 / 编辑操作', { size: 13, fill: C.dim, ls: 2 }); s += txt(lx, y, '层 / 编辑操作', { size: 13, fill: C.dim, ls: 2 });
y += 18; y += 18;
s += rect(lx, y, 168, 40, { rx: 9, fill: C.accent2, opacity: 0.92 }); s += rect(lx, y, 168, 40, { rx: 9, fill: C.accent2, opacity: 0.92 });
s += icon(lx + 6, y - 4, 'add', '#ffffff'); s += iconAt(lx + 26, y + 20, 'add', '#ffffff');
s += txt(lx + 36, y + 20, '新增外层 L9', { size: 13.5, weight: 600, fill: '#ffffff' }); s += txt(lx + 46, y + 20, '新增外层 L9', { size: 13.5, weight: 600, fill: '#ffffff' });
s += rect(lx + 180, y, 168, 40, { rx: 9, fill: C.panel2, stroke: C.line2, sw: 1 }); s += rect(lx + 180, y, 168, 40, { rx: 9, fill: C.panel2, stroke: C.line2, sw: 1 });
s += icon(lx + 186, y - 4, 'up', C.sub); s += iconAt(lx + 206, y + 20, 'up', C.sub);
s += txt(lx + 216, y + 20, '重排 / 合并层', { size: 13.5, fill: C.sub }); s += txt(lx + 226, y + 20, '重排 / 合并层', { size: 13.5, fill: C.sub });
y += 50; y += 50;
const eds = [['copy', '复制动作'], ['del', '删除动作'], ['align', '对齐相位']]; const eds = [['copy', '复制动作'], ['del', '删除动作'], ['align', '对齐相位']];
eds.forEach(([ic, label], i) => { eds.forEach(([ic, label], i) => {
const bx = lx + i * 117; const bx = lx + i * 117;
s += rect(bx, y, 105, 40, { rx: 9, fill: C.panel2, stroke: C.line2, sw: 1 }); s += rect(bx, y, 105, 40, { rx: 9, fill: C.panel2, stroke: C.line2, sw: 1 });
s += icon(bx - 8, y - 4, ic, C.sub); s += iconAt(bx + 20, y + 20, ic, C.sub);
s += txt(bx + 26, y + 20, label, { size: 12.5, fill: C.sub }); s += txt(bx + 40, y + 20, label, { size: 12.5, fill: C.sub });
}); });
y += 62; y += 62;
s += rect(lx, y, rx - lx, 84, { rx: 10, fill: '#131d2e', stroke: C.line, sw: 1 }); s += rect(lx, y, rx - lx, 58, { rx: 10, fill: T.info, stroke: C.line, sw: 1 });
s += txt(lx + 14, y + 22, '顺序规则', { size: 12, fill: C.warn, weight: 700 }); s += txt(lx + 14, y + 22, '新增动作置于最外层;箭头方向即执行顺序', { size: 11.5, fill: C.sub });
s += txt(lx + 14, y + 44, '新增动作默认置于最外层同心圆,', { size: 12, fill: C.sub }); s += txt(lx + 14, y + 40, '绿实线 FS 严格顺序 · 琥珀虚线 SS 并行重叠', { size: 11.5, fill: C.sub });
s += txt(lx + 14, y + 62, '箭头方向 = 执行顺序,绿色实线为严格', { size: 12, fill: C.sub }); y += 78;
s += txt(lx + 14, y + 78, '顺序,琥珀虚线为可并行重叠。', { size: 12, fill: C.sub });
y += 104;
s += txt(lx, y, '依赖连线', { size: 13, fill: C.dim, ls: 2 }); s += txt(lx, y, '依赖连线', { size: 13, fill: C.dim, ls: 2 });
const dl = [ const dl = [
@@ -406,10 +517,10 @@ function rightPanelCircular() {
y = y + 24 + dl.length * 26 + 16; y = y + 24 + dl.length * 26 + 16;
s += rect(lx, y, rx - lx, 92, { rx: 10, fill: C.panel2, stroke: C.line, sw: 1 }); s += rect(lx, y, rx - lx, 92, { rx: 10, fill: C.panel2, stroke: C.line, sw: 1 });
s += icon(lx + 8, y - 2, 'help', C.accent); s += iconAt(lx + 32, y + 22, 'help', C.accent);
s += txt(lx + 44, y + 22, '帮助 · 快捷键', { size: 13, weight: 600, fill: C.accent }); s += txt(lx + 52, y + 22, '帮助 · 快捷键', { size: 13, weight: 600, fill: C.accent });
s += txt(lx + 14, y + 46, '拖拽 = 平移相位 拖端点 = 改持续角', { size: 11.5, fill: C.sub }); s += txt(lx + 14, y + 46, '拖拽 = 平移相位 · 拖端点 = 改持续角', { size: 11.5, fill: C.sub });
s += txt(lx + 14, y + 64, 'Shift+拖 = 改层 F1 = 帮助中心', { size: 11.5, fill: C.sub }); s += txt(lx + 14, y + 64, 'Shift+拖 = 改层 · F1 = 帮助中心', { size: 11.5, fill: C.sub });
s += txt(lx + 14, y + 82, 'Ctrl+Z / Ctrl+Y = 撤销 / 重做', { size: 11.5, fill: C.sub }); s += txt(lx + 14, y + 82, 'Ctrl+Z / Ctrl+Y = 撤销 / 重做', { size: 11.5, fill: C.sub });
return s; return s;
} }
@@ -423,16 +534,16 @@ function rightPanelBar() {
s += txt(lx, 96, '属性 · 选中动作', { size: 13, fill: C.dim, ls: 2 }); s += txt(lx, 96, '属性 · 选中动作', { size: 13, fill: C.dim, ls: 2 });
s += rect(lx, 112, rx - lx, 62, { rx: 12, fill: C.panel2, stroke: C.line, sw: 1 }); s += rect(lx, 112, rx - lx, 62, { rx: 12, fill: C.panel2, stroke: C.line, sw: 1 });
s += rect(lx + 14, 128, 30, 30, { rx: 8, fill: byId('A8').color, opacity: 0.9 }); s += rect(lx + 14, 128, 30, 30, { rx: 8, fill: byId('A8').color, opacity: 0.9 });
s += txt(lx + 29, 144, 'A8', { size: 11.5, anchor: 'middle', fill: '#0b1018', weight: 700 }); s += txt(lx + 29, 144, 'A8', { size: 11.5, anchor: 'middle', fill: T.chip, weight: 700 });
s += txt(lx + 56, 136, '⑧ 清洁吹气', { size: 16, weight: 600 }); s += txt(lx + 56, 136, '⑧ 清洁吹气', { size: 16, weight: 600 });
s += txt(lx + 56, 158, 'ST3 · 电磁阀 V3 · 跨循环', { size: 12, fill: C.dim }); s += txt(lx + 56, 158, 'ST3 · 电磁阀 V3 · 跨循环', { size: 12, fill: C.dim });
s += rect(rx - 74, 126, 60, 34, { rx: 8, fill: C.warn, opacity: 0.14, stroke: C.warn, sw: 1 }); s += rect(rx - 74, 126, 60, 34, { rx: 8, fill: C.warn, opacity: 0.14, stroke: C.warn, sw: 1 });
s += txt(rx - 44, 143, '跨圈', { size: 12.5, anchor: 'middle', fill: C.warn }); s += txt(rx - 44, 143, '跨圈', { size: 12.5, anchor: 'middle', fill: C.warn });
const fields = [ const fields = [
['开始时刻', '2267 ms', '340.0°'], ['开始时刻', tfmt(2267), pfmt(340)],
['结束时刻', '2567 ms', '385.0° → 25.0°'], ['结束时刻', tfmt(2567), `385.0° → 25.0°`],
['持续时间', '300 ms', '45.0°'], ['持续时间', tfmt(300), pfmt(45)],
['循环归属', '当前圈 + 下一圈', '跨圈片段'], ['循环归属', '当前圈 + 下一圈', '跨圈片段'],
['顺序约束', '⑦ → ⑧ SS +5°', '起始-起始(可并行)'], ['顺序约束', '⑦ → ⑧ SS +5°', '起始-起始(可并行)'],
['相位归属', '下料相位', '335°–360°/0°–25°'], ['相位归属', '下料相位', '335°–360°/0°–25°'],
@@ -447,21 +558,18 @@ function rightPanelBar() {
}); });
y += 8; y += 8;
s += txt(lx, y, '时间 / 角度联动', { size: 13, fill: C.dim, ls: 2 }); const uc = unitCard(lx, y, rx - lx);
y += 20; s += uc.svg;
s += rect(lx, y, rx - lx, 54, { rx: 10, fill: '#131d2e', stroke: C.line, sw: 1 }); y += uc.h + 26;
s += txt(lx + 14, y + 20, '1° = 6.667 ms', { size: 13.5, fill: C.accent, weight: 600 });
s += txt(lx + 14, y + 40, '角度与时间线性映射,双向同步', { size: 11.5, fill: C.dim });
y += 74;
s += txt(lx, y, '编辑操作', { size: 13, fill: C.dim, ls: 2 }); s += txt(lx, y, '编辑操作', { size: 13, fill: C.dim, ls: 2 });
y += 16; y += 16;
const eds = [['add', '添加动作', 'add'], ['edit', '编辑', 'toggle'], ['copy', '复制', 'ghost'], ['del', '删除', 'ghost']]; const eds = [['add', '添加动作', 'add'], ['edit', '编辑', 'toggle'], ['copy', '复制', 'ghost'], ['del', '删除', 'ghost']];
eds.forEach(([ic, label, kind], i) => { eds.forEach(([ic, label, kind], i) => {
const bx = lx + i * 88; const bx = lx + i * 88;
const S = { add: { fill: C.ok, col: '#04170e' }, toggle: { fill: C.accent, col: '#04170e' }, ghost: { fill: C.panel2, col: C.sub } }[kind]; const S = { add: { fill: C.ok, col: T.onAccent }, toggle: { fill: C.accent, col: T.onAccent }, ghost: { fill: C.panel2, col: C.sub } }[kind];
s += rect(bx, y, 80, 56, { rx: 9, fill: S.fill, stroke: kind === 'ghost' ? C.line2 : S.fill, sw: 1 }); s += rect(bx, y, 80, 56, { rx: 9, fill: S.fill, stroke: kind === 'ghost' ? C.line2 : S.fill, sw: 1 });
s += icon(bx + 16, y - 4, ic, S.col); s += iconAt(bx + 40, y + 18, ic, S.col);
s += txt(bx + 40, y + 44, label, { size: 11.5, anchor: 'middle', fill: S.col, weight: 600 }); s += txt(bx + 40, y + 44, label, { size: 11.5, anchor: 'middle', fill: S.col, weight: 600 });
}); });
y += 76; y += 76;
@@ -487,11 +595,11 @@ function rightPanelBar() {
y += 118; y += 118;
s += rect(lx, y, rx - lx, 92, { rx: 10, fill: C.panel2, stroke: C.line, sw: 1 }); s += rect(lx, y, rx - lx, 92, { rx: 10, fill: C.panel2, stroke: C.line, sw: 1 });
s += icon(lx + 8, y - 2, 'help', C.accent); s += iconAt(lx + 32, y + 22, 'help', C.accent);
s += txt(lx + 44, y + 22, '帮助 · 快捷键', { size: 13, weight: 600, fill: C.accent }); s += txt(lx + 52, y + 22, '帮助 · 快捷键', { size: 13, weight: 600, fill: C.accent });
s += txt(lx + 14, y + 46, '拖拽 = 平移相位 拖端点 = 改时长', { size: 11.5, fill: C.sub }); s += txt(lx + 14, y + 46, '拖拽 = 平移相位 · 拖端点 = 改时长', { size: 11.5, fill: C.sub });
s += txt(lx + 14, y + 64, '端点拖出连线 = 建依赖 F1 = 帮助中心', { size: 11.5, fill: C.sub }); s += txt(lx + 14, y + 64, '端点拖出连线 = 建依赖 · F1 = 帮助中心', { size: 11.5, fill: C.sub });
s += txt(lx + 14, y + 82, 'Ctrl+滚轮 = 缩放 Ctrl+Z = 撤销', { size: 11.5, fill: C.sub }); s += txt(lx + 14, y + 82, 'Ctrl+滚轮 = 缩放 · Ctrl+Z = 撤销', { size: 11.5, fill: C.sub });
return s; return s;
} }
@@ -536,20 +644,20 @@ function circularView() {
let s = ''; let s = '';
s += txt(420, 108, '圆周节拍视图(同心圆 · 12 点钟起始 · 顺时针)', { size: 20, weight: 600 }); s += txt(420, 108, '圆周节拍视图(同心圆 · 12 点钟起始 · 顺时针)', { size: 20, weight: 600 });
s += txt(420, 134, '同心圆环 = 动作层;箭头 = 执行顺序(绿色实线 FS 严格顺序,琥珀虚线 SS 并行重叠);1 圈 = 1 循环 = 2400 ms', { size: 13, fill: C.dim }); s += txt(420, 134, `同心圆环 = 动作层;箭头 = 执行顺序(绿色实线 FS 严格顺序,琥珀虚线 SS 并行重叠);1 圈 = 1 循环 = ${tfmt(CYCLE_MS)} = 360° = 100%`, { size: 13, fill: C.dim });
s += circle(cx, cy, RTICK - 14, { fill: '#0c1320', stroke: C.line2, sw: 1.2 }); s += circle(cx, cy, RTICK - 14, { fill: T.dial, stroke: C.line2, sw: 1.2 });
s += circle(cx, cy, RTICK - 20, { stroke: C.line, sw: 1, dash: '2 6' }); s += circle(cx, cy, RTICK - 20, { stroke: C.line, sw: 1, dash: '2 6' });
for (let i = 0; i < ACTIONS.length; i++) { for (let i = 0; i < ACTIONS.length; i++) {
const r = R0 + i * PITCH; const r = R0 + i * PITCH;
s += circle(cx, cy, r, { stroke: i % 2 ? '#121a28' : '#18222f', sw: TH }); s += circle(cx, cy, r, { stroke: i % 2 ? T.ringB : T.ringA, sw: TH });
} }
s += circle(cx, cy, R0 - TH / 2, { fill: '#0c1320', stroke: '#233350', sw: 1 }); s += circle(cx, cy, R0 - TH / 2, { fill: T.dial, stroke: T.ringEdge, sw: 1 });
for (let i = 0; i < ACTIONS.length; i++) { for (let i = 0; i < ACTIONS.length; i++) {
const r = R0 + i * PITCH; const r = R0 + i * PITCH;
s += circle(cx, cy, r - TH / 2, { stroke: '#26374f', sw: 1 }); s += circle(cx, cy, r - TH / 2, { stroke: T.ringEdge, sw: 1 });
s += circle(cx, cy, r + TH / 2, { stroke: '#26374f', sw: 1 }); s += circle(cx, cy, r + TH / 2, { stroke: T.ringEdge, sw: 1 });
} }
[0, 90, 180, 270].forEach((d) => { [0, 90, 180, 270].forEach((d) => {
@@ -563,7 +671,7 @@ function circularView() {
const cands = [270, 278, 262, 286, 254, 294, 246, 302, 238, 310]; const cands = [270, 278, 262, 286, 254, 294, 246, 302, 238, 310];
const free = cands.find((c) => c < a.a0 || c > Math.min(a.a1, 360)) ?? 270; const free = cands.find((c) => c < a.a0 || c > Math.min(a.a1, 360)) ?? 270;
const [lx, ly] = pt(cx, cy, r, free); const [lx, ly] = pt(cx, cy, r, free);
s += txt(lx, ly, `L${i + 1}`, { size: 11, anchor: 'middle', fill: '#42597a', weight: 700 }); s += txt(lx, ly, `L${i + 1}`, { size: 11, anchor: 'middle', fill: T.ringLabel, weight: 700 });
}); });
const chips = []; const chips = [];
@@ -576,11 +684,11 @@ function circularView() {
s += arrowHead(g.tip[0], g.tip[1], g.dir[0], g.dir[1], col, 14); s += arrowHead(g.tip[0], g.tip[1], g.dir[0], g.dir[1], col, 14);
const label = `${SEQ[A.step - 1]}→${SEQ[B.step - 1]} ${dep.type === 'FS' ? 'FS' : `SS+${dep.off}°`}`; const label = `${SEQ[A.step - 1]}→${SEQ[B.step - 1]} ${dep.type === 'FS' ? 'FS' : `SS+${dep.off}°`}`;
const cw2 = label.length * 6.6 + 20; const cw2 = label.length * 6.6 + 20;
let inner = rect(-cw2 / 2, -9, cw2, 18, { rx: 6, fill: '#0b1018', stroke: col, sw: 1.1 }); let inner = rect(-cw2 / 2, -9, cw2, 18, { rx: 6, fill: T.chip, stroke: col, sw: 1.1 });
inner += txt(0, 0.5, label, { size: 10.5, anchor: 'middle', fill: col, weight: 600 }); inner += txt(0, 0.5, label, { size: 10.5, anchor: 'middle', fill: col, weight: 600 });
if (dep.critical) { if (dep.critical) {
inner += circle(-cw2 / 2 - 12, 0, 8, { fill: C.crit }); inner += circle(-cw2 / 2 - 12, 0, 8, { fill: C.crit });
inner += txt(-cw2 / 2 - 12, 0.5, '★', { size: 9.5, anchor: 'middle', fill: '#04121b', weight: 700 }); inner += txt(-cw2 / 2 - 12, 0.5, '★', { size: 9.5, anchor: 'middle', fill: T.onAccent, weight: 700 });
} }
chips.push(group(`rotate(${g.phi.toFixed(1)} ${g.mid[0].toFixed(1)} ${g.mid[1].toFixed(1)})`, inner)); chips.push(group(`rotate(${g.phi.toFixed(1)} ${g.mid[0].toFixed(1)} ${g.mid[1].toFixed(1)})`, inner));
}); });
@@ -590,22 +698,22 @@ function circularView() {
const isSel = a.id === 'A3'; const isSel = a.id === 'A3';
const wrap = a.a1 > 360; const wrap = a.a1 > 360;
const segs = ringArcs(cx, cy, r, a.a0, a.a1); const segs = ringArcs(cx, cy, r, a.a0, a.a1);
s += path(segs.join(' '), { stroke: '#000000', sw: TH + 8, opacity: 0.32, cap: wrap ? 'butt' : 'round' }); s += path(segs.join(' '), { stroke: T.shadow, sw: TH + 8, opacity: T.shadowOp, cap: wrap ? 'butt' : 'round' });
segs.forEach((d, k) => { segs.forEach((d, k) => {
const isTail = wrap && k === 1; const isTail = wrap && k === 1;
s += path(d, { stroke: a.color, sw: TH, cap: wrap ? 'butt' : 'round', opacity: isTail ? 0.5 : 1 }); s += path(d, { stroke: a.color, sw: TH, cap: wrap ? 'butt' : 'round', opacity: isTail ? T.tailOp : 1 });
if (isTail) s += path(d, { stroke: a.color, sw: TH, cap: 'butt', dash: '6 6', opacity: 0.95 }); if (isTail) s += path(d, { stroke: a.color, sw: TH, cap: 'butt', dash: '6 6', opacity: 0.95 });
}); });
if (isSel) { if (isSel) {
s += path(segs.join(' '), { stroke: '#ffffff', sw: 1.6, opacity: 0.9 }); s += path(segs.join(' '), { stroke: T.selOutline, sw: 1.6, opacity: 0.9 });
s += path(arcPath(cx, cy, r + TH / 2 + 12, a.a0, a.a1), { stroke: C.accent, sw: 1.6, dash: '6 5' }); s += path(arcPath(cx, cy, r + TH / 2 + 12, a.a0, a.a1), { stroke: C.accent, sw: 1.6, dash: '6 5' });
} }
const mid = (a.a0 + a.a1) / 2; const mid = (a.a0 + a.a1) / 2;
const [mx, my] = pt(cx, cy, r, mid); const [mx, my] = pt(cx, cy, r, mid);
const short = (a.a1 - a.a0) < 40; const short = (a.a1 - a.a0) < 40;
s += txt(mx, my - (short ? 5 : 7), `${SEQ[i]} ${a.id} ${a.name}`, { size: short ? 11 : 14, anchor: 'middle', fill: '#0a0f18', weight: 700 }); s += txt(mx, my - (short ? 5 : 7), `${SEQ[i]} ${a.id} ${a.name}`, { size: short ? 11 : 14, anchor: 'middle', fill: T.arcText, weight: 700 });
s += txt(mx, my + (short ? 10 : 12), `${fmt(a.a0, 0)}°–${fmt(Math.min(a.a1, 360), 0)}°`, { size: short ? 10 : 11.5, anchor: 'middle', fill: '#0a0f18', opacity: 0.85 }); s += txt(mx, my + (short ? 10 : 12), `${fmt(a.a0, 0)}°–${fmt(Math.min(a.a1, 360), 0)}°`, { size: short ? 10 : 11.5, anchor: 'middle', fill: T.arcText, opacity: 0.85 });
}); });
s += chips.join(''); s += chips.join('');
@@ -648,18 +756,18 @@ function circularView() {
ACTIONS.forEach((a, i) => { ACTIONS.forEach((a, i) => {
const yy = ly + 8 + i * 46; const yy = ly + 8 + i * 46;
s += rect(lx, yy - 9, 16, 16, { rx: 5, fill: a.color }); s += rect(lx, yy - 9, 16, 16, { rx: 5, fill: a.color });
s += txt(lx + 26, yy, `${SEQ[i]} ${a.id} ${a.name}`, { size: 13.5, fill: '#cfd9ea' }); s += txt(lx + 26, yy, `${SEQ[i]} ${a.id} ${a.name}`, { size: 13.5, fill: T.text2 });
s += txt(lx + 26, yy + 18, `L${i + 1} · r=${R0 + i * PITCH} · ${a.a0}°–${Math.min(a.a1, 360)}° · ${deg2ms(a.a1 - a.a0)} ms`, { size: 10.5, fill: C.dim }); s += txt(lx + 26, yy + 18, `L${i + 1} · r=${R0 + i * PITCH} · ${a.a0}°–${Math.min(a.a1, 360)}° · ${tfmt(deg2ms(a.a1 - a.a0))}`, { size: 10.5, fill: C.dim });
}); });
const ry0 = ly + 8 + 8 * 46 + 16; const ry0 = ly + 8 + 8 * 46 + 16;
s += rect(lx - 16, ry0, 250, 168, { rx: 14, fill: '#0b1018', stroke: C.accent, sw: 1.2, opacity: 0.96 }); s += rect(lx - 16, ry0, 250, 168, { rx: 14, fill: T.chip, stroke: C.accent, sw: 1.2, opacity: 0.96 });
s += txt(lx, ry0 + 26, '选中动作', { size: 12, fill: C.accent, weight: 700, ls: 1 }); s += txt(lx, ry0 + 26, '选中动作', { size: 12, fill: C.accent, weight: 700, ls: 1 });
s += txt(lx, ry0 + 52, '③ A3 伺服下压', { size: 15, weight: 700 }); s += txt(lx, ry0 + 52, '③ A3 伺服下压', { size: 15, weight: 700 });
s += txt(lx, ry0 + 78, '起始角 105.0°', { size: 12, fill: C.sub }); s += txt(lx, ry0 + 78, `起始相位 ${pfmt(105)}`, { size: 12, fill: C.sub });
s += txt(lx, ry0 + 100, '结束角 190.0°', { size: 12, fill: C.sub }); s += txt(lx, ry0 + 100, `结束相位 ${pfmt(190)}`, { size: 12, fill: C.sub });
s += txt(lx, ry0 + 122, '持续角 85.0°', { size: 12, fill: C.sub }); s += txt(lx, ry0 + 122, `持续相位 ${pfmt(85)}`, { size: 12, fill: C.sub });
s += txt(lx, ry0 + 146, `Δ = ${deg2ms(85)} ms · 层 L3 · ST2`, { size: 12, fill: C.accent, weight: 600 }); s += txt(lx, ry0 + 146, `Δ = ${tfmt(deg2ms(85))} · 层 L3 · ST2`, { size: 12, fill: C.accent, weight: 600 });
const dy0 = ry0 + 186; const dy0 = ry0 + 186;
s += rect(lx - 16, dy0, 250, 132, { rx: 14, fill: C.panel2, stroke: C.line, sw: 1, opacity: 0.96 }); s += rect(lx - 16, dy0, 250, 132, { rx: 14, fill: C.panel2, stroke: C.line, sw: 1, opacity: 0.96 });
@@ -672,7 +780,7 @@ function circularView() {
s += txt(lx + 46, dy0 + 74, 'SS 并行重叠(可提前启动)', { size: 11.5, fill: C.sub }); s += txt(lx + 46, dy0 + 74, 'SS 并行重叠(可提前启动)', { size: 11.5, fill: C.sub });
s += line(lx, dy0 + 100, lx + 34, dy0 + 100, { stroke: C.fs, sw: 3.2 }); s += line(lx, dy0 + 100, lx + 34, dy0 + 100, { stroke: C.fs, sw: 3.2 });
s += circle(lx + 40, dy0 + 100, 7.5, { fill: C.crit }); s += circle(lx + 40, dy0 + 100, 7.5, { fill: C.crit });
s += txt(lx + 40, dy0 + 100.5, '★', { size: 9, anchor: 'middle', fill: '#04121b', weight: 700 }); s += txt(lx + 40, dy0 + 100.5, '★', { size: 9, anchor: 'middle', fill: T.onAccent, weight: 700 });
s += txt(lx + 54, dy0 + 100, '关键路径(累计最长链)', { size: 11.5, fill: C.sub }); s += txt(lx + 54, dy0 + 100, '关键路径(累计最长链)', { size: 11.5, fill: C.sub });
const mx0 = 1790, my0 = 1160; const mx0 = 1790, my0 = 1160;
@@ -684,12 +792,12 @@ function circularView() {
const x1 = bx0 + (a.a0 / 360) * bw; const x1 = bx0 + (a.a0 / 360) * bw;
const x2 = bx0 + (Math.min(a.a1, 360) / 360) * bw; const x2 = bx0 + (Math.min(a.a1, 360) / 360) * bw;
s += rect(x1, y, Math.max(x2 - x1, 2), rh - 4, { rx: 3, fill: a.color, opacity: 0.9 }); s += rect(x1, y, Math.max(x2 - x1, 2), rh - 4, { rx: 3, fill: a.color, opacity: 0.9 });
if (a.a1 > 360) s += rect(bx0, y, ((a.a1 - 360) / 360) * bw, rh - 4, { rx: 3, fill: a.color, opacity: 0.5, dash: '3 3' }); if (a.a1 > 360) s += rect(bx0, y, ((a.a1 - 360) / 360) * bw, rh - 4, { rx: 3, fill: a.color, opacity: T.tailOp, dash: '3 3' });
}); });
s += line(bx0, by0 + 8 * (rh + 3) + 4, bx0 + bw, by0 + 8 * (rh + 3) + 4, { stroke: C.line2, sw: 1 }); s += line(bx0, by0 + 8 * (rh + 3) + 4, bx0 + bw, by0 + 8 * (rh + 3) + 4, { stroke: C.line2, sw: 1 });
s += txt(bx0, by0 + 8 * (rh + 3) + 20, '0 ms', { size: 11, fill: C.dim }); s += txt(bx0, by0 + 8 * (rh + 3) + 20, `0.0 ${UNIT.time}`, { size: 11, fill: C.dim });
s += txt(bx0 + bw / 2, by0 + 8 * (rh + 3) + 20, '1200 ms', { size: 11, anchor: 'middle', fill: C.dim }); s += txt(bx0 + bw / 2, by0 + 8 * (rh + 3) + 20, tfmt(CYCLE_MS / 2), { size: 11, anchor: 'middle', fill: C.dim });
s += txt(bx0 + bw, by0 + 8 * (rh + 3) + 20, '2400 ms', { size: 11, anchor: 'end', fill: C.dim }); s += txt(bx0 + bw, by0 + 8 * (rh + 3) + 20, tfmt(CYCLE_MS), { size: 11, anchor: 'end', fill: C.dim });
s += floatToolbar(); s += floatToolbar();
return s; return s;
@@ -706,11 +814,11 @@ function barView() {
s += txt(420, 134, '时间轴与相位角双刻度联动;箭头表示动作间关联(绿色实线 FS 严格顺序 / 琥珀虚线 SS 并行重叠);跨循环动作自动拆分并标注', { size: 13, fill: C.dim }); s += txt(420, 134, '时间轴与相位角双刻度联动;箭头表示动作间关联(绿色实线 FS 严格顺序 / 琥珀虚线 SS 并行重叠);跨循环动作自动拆分并标注', { size: 13, fill: C.dim });
const phases = [ const phases = [
['上料相位', 0, 70, '#4cc9f0'], ['上料相位', 0, 70, PAL[0]],
['夹紧相位', 55, 115, '#7bd88f'], ['夹紧相位', 55, 115, PAL[1]],
['加工相位', 105, 320, '#ffd166'], ['加工相位', 105, 320, PAL[2]],
['检测相位', 300, 345, '#a78bfa'], ['检测相位', 300, 345, PAL[5]],
['下料相位', 335, 385, '#f472b6'], ['下料相位', 335, 385, PAL[4]],
]; ];
phases.forEach(([name, a0, a1, col]) => { phases.forEach(([name, a0, a1, col]) => {
const x = px(a0), w = Math.max(px(Math.min(a1, 360)) - x, 2); const x = px(a0), w = Math.max(px(Math.min(a1, 360)) - x, 2);
@@ -725,24 +833,24 @@ function barView() {
const x = px(d); const x = px(d);
const major = d % 30 === 0; const major = d % 30 === 0;
s += line(x, 196, x, major ? 224 : 210, { stroke: major ? C.line2 : C.line, sw: 1 }); s += line(x, 196, x, major ? 224 : 210, { stroke: major ? C.line2 : C.line, sw: 1 });
if (d % 60 === 0) s += txt(x, 238, `${d}°`, { size: 12, anchor: 'middle', fill: C.accent }); if (d % 60 === 0) s += txt(x, 238, pfmt(d, 0), { size: 12, anchor: 'middle', fill: C.accent });
if (d % 60 === 0) s += txt(x, 214, `${deg2ms(d)}`, { size: 11, anchor: 'middle', fill: C.dim }); if (d % 60 === 0) s += txt(x, 214, tvalStr(d), { size: 11, anchor: 'middle', fill: C.dim });
} }
s += txt(X0 - 16, 214, 'ms', { size: 11.5, anchor: 'end', fill: C.dim }); s += txt(X0 - 16, 214, `时间 / ${UNIT.time}`, { size: 11.5, anchor: 'end', fill: C.dim });
s += txt(X0 - 16, 238, '相位角', { size: 11.5, anchor: 'end', fill: C.accent }); s += txt(X0 - 16, 238, `相位 / ${UNIT.phase}`, { size: 11.5, anchor: 'end', fill: C.accent });
[0, 360].forEach((d) => { [0, 360].forEach((d) => {
const x = px(d); const x = px(d);
s += line(x, 196, x, rowY(7) + 66, { stroke: d === 0 ? C.ok : C.warn, sw: 1.4, dash: '6 6', opacity: 0.7 }); s += line(x, 196, x, rowY(7) + 66, { stroke: d === 0 ? C.ok : C.warn, sw: 1.4, dash: '6 6', opacity: 0.7 });
}); });
s += txt(px(0) + 8, 258, '循环开始 0° / 0 ms', { size: 12, fill: C.ok }); s += txt(px(0) + 8, 258, `循环开始 0° / 0.0 ${UNIT.time}`, { size: 12, fill: C.ok });
s += txt(px(360) - 8, 258, '循环结束 360° / 2400 ms', { size: 12, anchor: 'end', fill: C.warn }); s += txt(px(360) - 8, 258, `循环结束 360° / ${tfmt(CYCLE_MS)}`, { size: 12, anchor: 'end', fill: C.warn });
ACTIONS.forEach((a, i) => { ACTIONS.forEach((a, i) => {
const y = rowY(i); const y = rowY(i);
s += rect(420, y - 8, 250, 50, { rx: 10, fill: i % 2 ? 'transparent' : C.panel2, opacity: 0.6 }); s += rect(420, y - 8, 250, 50, { rx: 10, fill: i % 2 ? 'transparent' : C.panel2, opacity: 0.6 });
s += rect(432, y + 5, 18, 18, { rx: 5, fill: a.color }); s += rect(432, y + 5, 18, 18, { rx: 5, fill: a.color });
s += txt(441, y + 14, `${i + 1}`, { size: 11, anchor: 'middle', fill: '#0b1018', weight: 700 }); s += txt(441, y + 14, `${i + 1}`, { size: 11, anchor: 'middle', fill: T.chip, weight: 700 });
s += txt(460, y + 6, `${SEQ[i]} ${a.id} ${a.name}`, { size: 14, weight: 600 }); s += txt(460, y + 6, `${SEQ[i]} ${a.id} ${a.name}`, { size: 14, weight: 600 });
s += txt(460, y + 26, `${a.station} · ${a.driver}`, { size: 11.5, fill: C.dim }); s += txt(460, y + 26, `${a.station} · ${a.driver}`, { size: 11.5, fill: C.dim });
s += line(X0, y + 33, X1, y + 33, { stroke: C.line, sw: 1, dash: '2 6', opacity: 0.5 }); s += line(X0, y + 33, X1, y + 33, { stroke: C.line, sw: 1, dash: '2 6', opacity: 0.5 });
@@ -753,21 +861,21 @@ function barView() {
const x1 = px(a.a0), x2 = px(Math.min(a.a1, 360)); const x1 = px(a.a0), x2 = px(Math.min(a.a1, 360));
const w = Math.max(x2 - x1, 4); const w = Math.max(x2 - x1, 4);
s += rect(x1, y, w, BAR_H, { rx: 8, fill: a.color, opacity: 0.92 }); s += rect(x1, y, w, BAR_H, { rx: 8, fill: a.color, opacity: 0.92 });
s += rect(x1, y, w, BAR_H, { rx: 8, stroke: '#ffffff', sw: 1, opacity: a.id === 'A8' ? 0.9 : 0.25 }); s += rect(x1, y, w, BAR_H, { rx: 8, stroke: T.selOutline, sw: 1, opacity: a.id === 'A8' ? 0.9 : 0.25 });
if (a.a1 > 360) { if (a.a1 > 360) {
const wx = px(a.a1 - 360) - X0; const wx = px(a.a1 - 360) - X0;
s += rect(X0, y, wx, BAR_H, { rx: 8, fill: a.color, opacity: 0.45, dash: '6 5' }); s += rect(X0, y, wx, BAR_H, { rx: 8, fill: a.color, opacity: T.tailOp, dash: '6 5' });
s += path(`M ${X0 + 3} ${y + 6} L ${X0 + 3} ${y + BAR_H - 6}`, { stroke: '#ffffff', sw: 2, opacity: 0.8 }); s += path(`M ${X0 + 3} ${y + 6} L ${X0 + 3} ${y + BAR_H - 6}`, { stroke: T.selOutline, sw: 2, opacity: 0.8 });
s += txt(X0 + wx + 10, y + BAR_H / 2, '↩ 跨循环延续 25°', { size: 11.5, fill: C.warn }); s += txt(X0 + wx + 10, y + BAR_H / 2, '↩ 跨循环延续 25°', { size: 11.5, fill: C.warn });
} }
const inside = w > 150; const inside = w > 150;
if (inside) { if (inside) {
s += txt(x1 + 12, y + 13, `${a.name}`, { size: 13.5, fill: '#0a0f18', weight: 700 }); s += txt(x1 + 12, y + 13, `${a.name}`, { size: 13.5, fill: T.arcText, weight: 700 });
s += txt(x1 + 12, y + 26, `${deg2ms(a.a1 - a.a0)} ms`, { size: 11, fill: '#0a0f18', opacity: 0.8 }); s += txt(x1 + 12, y + 26, tfmt(deg2ms(a.a1 - a.a0)), { size: 11, fill: T.arcText, opacity: 0.8 });
} else if (x2 + 150 > X1) { } else if (x2 + 160 > X1) {
s += txt(x1 - 10, y + BAR_H / 2, `${a.name} ${deg2ms(a.a1 - a.a0)}ms`, { size: 12.5, fill: a.color, weight: 600, anchor: 'end' }); s += txt(x1 - 10, y + BAR_H / 2, `${a.name} ${tfmt(deg2ms(a.a1 - a.a0))}`, { size: 12.5, fill: a.color, weight: 600, anchor: 'end' });
} else { } else {
s += txt(x2 + 10, y + BAR_H / 2, `${a.name} ${deg2ms(a.a1 - a.a0)}ms`, { size: 12.5, fill: a.color, weight: 600 }); s += txt(x2 + 10, y + BAR_H / 2, `${a.name} ${tfmt(deg2ms(a.a1 - a.a0))}`, { size: 12.5, fill: a.color, weight: 600 });
} }
s += txt(px(360) + 14, y + BAR_H / 2, `Δ${fmt(a.a1 - a.a0, 0)}°`, { size: 12, fill: C.dim }); s += txt(px(360) + 14, y + BAR_H / 2, `Δ${fmt(a.a1 - a.a0, 0)}°`, { size: 12, fill: C.dim });
}); });
@@ -810,29 +918,29 @@ function barView() {
s += arrowHead(tx, tipY, 0, dir, col, 13); s += arrowHead(tx, tipY, 0, dir, col, 13);
const label = d.type === 'FS' ? 'FS 顺序' : `SS +${d.off}°`; const label = d.type === 'FS' ? 'FS 顺序' : `SS +${d.off}°`;
const cw2 = label.length * 6.8 + 20; const cw2 = label.length * 6.8 + 20;
s += rect(chipX - cw2 / 2, chipY - 9, cw2, 18, { rx: 6, fill: '#0b1018', stroke: col, sw: 1 }); s += rect(chipX - cw2 / 2, chipY - 9, cw2, 18, { rx: 6, fill: T.chip, stroke: col, sw: 1 });
s += txt(chipX, chipY + 0.5, label, { size: 10.5, anchor: 'middle', fill: col, weight: 600 }); s += txt(chipX, chipY + 0.5, label, { size: 10.5, anchor: 'middle', fill: col, weight: 600 });
if (d.critical) { if (d.critical) {
s += circle(chipX - cw2 / 2 - 12, chipY, 8, { fill: C.crit }); s += circle(chipX - cw2 / 2 - 12, chipY, 8, { fill: C.crit });
s += txt(chipX - cw2 / 2 - 12, chipY + 0.5, '★', { size: 9.5, anchor: 'middle', fill: '#04121b', weight: 700 }); s += txt(chipX - cw2 / 2 - 12, chipY + 0.5, '★', { size: 9.5, anchor: 'middle', fill: T.onAccent, weight: 700 });
} }
}); });
s += rect(420, 860, 640, 300, { rx: 14, fill: C.panel2, stroke: C.line, sw: 1, opacity: 0.96 }); s += rect(420, 860, 640, 300, { rx: 14, fill: C.panel2, stroke: C.line, sw: 1, opacity: 0.96 });
s += txt(444, 892, '节拍统计', { size: 15, weight: 600, fill: C.sub }); s += txt(444, 892, '节拍统计', { size: 15, weight: 600, fill: C.sub });
const stats = [ const stats = [
['循环周期', '2400 ms / 360°'], ['循环周期', `${tfmt(CYCLE_MS)} / 360° / 100%`],
['动作数量', '8(3 工位)'], ['动作数量', '8(3 工位)'],
['关键路径', '①→②→③→④→⑥→⑦'], ['关键路径', '①→②→③→④→⑥→⑦'],
['最大并行度', '3 个动作同时执行(185°–190°)'], ['最大并行度', '3 个动作同时执行(185°–190°)'],
['相位覆盖率', '100%(0°–360° 无空档 > 15°)'], ['相位覆盖率', '100%(0°–360° 无空档 > 15°)'],
['瓶颈工位', 'ST2 加工相位 105°–320°(215°)'], ['瓶颈工位', 'ST2 加工相位 105°–320°(215°)'],
['预估节拍', '2.400 s / 件 · 1500 件/小时'], ['预估产能', `${(3600 / (CYCLE_MS / 1000)).toFixed(0)} 件/小时(节拍 ${tfmt(CYCLE_MS)})`],
]; ];
stats.forEach(([k, v], i) => { stats.forEach(([k, v], i) => {
const y = 926 + i * 32; const y = 926 + i * 32;
s += txt(444, y, k, { size: 13, fill: C.dim }); s += txt(444, y, k, { size: 13, fill: C.dim });
s += txt(1036, y, v, { size: 13, anchor: 'end', fill: '#cfd9ea', weight: 600 }); s += txt(1036, y, v, { size: 13, anchor: 'end', fill: T.text2, weight: 600 });
if (i < stats.length - 1) s += line(444, y + 15, 1036, y + 15, { stroke: C.line, sw: 1, opacity: 0.6 }); if (i < stats.length - 1) s += line(444, y + 15, 1036, y + 15, { stroke: C.line, sw: 1, opacity: 0.6 });
}); });
@@ -841,9 +949,9 @@ function barView() {
const tools = [['add', '添加动作', 'add'], ['edit', '编辑', 'toggle'], ['copy', '复制', 'ghost'], ['del', '删除', 'ghost'], ['align', '对齐', 'ghost'], ['help', '帮助', 'ghost']]; const tools = [['add', '添加动作', 'add'], ['edit', '编辑', 'toggle'], ['copy', '复制', 'ghost'], ['del', '删除', 'ghost'], ['align', '对齐', 'ghost'], ['help', '帮助', 'ghost']];
tools.forEach(([ic, label, kind], i) => { tools.forEach(([ic, label, kind], i) => {
const bx = 444 + i * 102; const bx = 444 + i * 102;
const S = { add: { fill: C.ok, col: '#04170e' }, toggle: { fill: C.accent, col: '#04170e' }, ghost: { fill: C.panel, col: C.sub } }[kind]; const S = { add: { fill: C.ok, col: T.onAccent }, toggle: { fill: C.accent, col: T.onAccent }, ghost: { fill: C.panel, col: C.sub } }[kind];
s += rect(bx, 1246, 92, 66, { rx: 10, fill: S.fill, stroke: kind === 'ghost' ? C.line2 : S.fill, sw: 1 }); s += rect(bx, 1246, 92, 66, { rx: 10, fill: S.fill, stroke: kind === 'ghost' ? C.line2 : S.fill, sw: 1 });
s += icon(bx + 22, 1246 + 4, ic, S.col); s += iconAt(bx + 46, 1272, ic, S.col);
s += txt(bx + 46, 1300, label, { size: 12, anchor: 'middle', fill: S.col, weight: 600 }); s += txt(bx + 46, 1300, label, { size: 12, anchor: 'middle', fill: S.col, weight: 600 });
}); });
@@ -851,41 +959,173 @@ function barView() {
const outer = r0 + 7 * pitch; const outer = r0 + 7 * pitch;
s += rect(1640, 860, 500, 480, { rx: 14, fill: C.panel2, stroke: C.line, sw: 1, opacity: 0.96 }); s += rect(1640, 860, 500, 480, { rx: 14, fill: C.panel2, stroke: C.line, sw: 1, opacity: 0.96 });
s += txt(1664, 892, '圆周节拍预览(实时联动)', { size: 15, weight: 600, fill: C.sub }); s += txt(1664, 892, '圆周节拍预览(实时联动)', { size: 15, weight: 600, fill: C.sub });
s += circle(cx, cy, outer + PW + 14, { fill: '#0c1320', stroke: C.line, sw: 1 }); s += circle(cx, cy, outer + PW + 14, { fill: T.dial, stroke: C.line, sw: 1 });
ACTIONS.forEach((a, i) => { ACTIONS.forEach((a, i) => {
const r = r0 + i * pitch; const r = r0 + i * pitch;
s += circle(cx, cy, r, { stroke: i % 2 ? '#121a28' : '#18222f', sw: PW }); s += circle(cx, cy, r, { stroke: i % 2 ? T.ringB : T.ringA, sw: PW });
const segs = ringArcs(cx, cy, r, a.a0, a.a1); const segs = ringArcs(cx, cy, r, a.a0, a.a1);
segs.forEach((d, k) => { segs.forEach((d, k) => {
const tail = a.a1 > 360 && k === 1; const tail = a.a1 > 360 && k === 1;
s += path(d, { stroke: a.color, sw: PW, cap: a.a1 > 360 ? 'butt' : 'round', opacity: tail ? 0.45 : 0.95 }); s += path(d, { stroke: a.color, sw: PW, cap: a.a1 > 360 ? 'butt' : 'round', opacity: tail ? T.tailOp : 0.95 });
}); });
}); });
s += path(`M ${cx} ${cy - outer - PW - 22} l -8 -13 l 16 0 z`, { fill: C.accent }); s += path(`M ${cx} ${cy - outer - PW - 22} l -8 -13 l 16 0 z`, { fill: C.accent });
s += txt(cx, cy - 6, '360°', { size: 15, anchor: 'middle', fill: C.sub, weight: 600 }); s += txt(cx, cy - 6, '360°', { size: 15, anchor: 'middle', fill: C.sub, weight: 600 });
s += txt(cx, cy + 16, '1 循环 = 2400 ms', { size: 11.5, anchor: 'middle', fill: C.dim }); s += txt(cx, cy + 16, `1 循环 = ${tfmt(CYCLE_MS)}`, { size: 11.5, anchor: 'middle', fill: C.dim });
s += txt(1664, 1322, '12 点钟起始 · 顺时针 · 每层一环', { size: 12, fill: C.dim }); s += txt(1664, 1322, '12 点钟起始 · 顺时针 · 每层一环', { size: 12, fill: C.dim });
return s; return s;
} }
function build(mode) { function settingsDialog() {
const dx = 660, dy = 268, dw = 1240, dh = 900;
const cx0 = dx + 232, cw = dw - 232 - 32;
let s = rect(0, 64, W, H - 64 - 36, { fill: T.overlay, opacity: 0.74 });
s += rect(dx, dy, dw, dh, { rx: 18, fill: T.dialog, stroke: C.line2, sw: 1.2 });
s += line(dx, dy + 64, dx + dw, dy + 64, { stroke: C.line, sw: 1 });
s += txt(dx + 32, dy + 33, '工艺设置', { size: 19, weight: 700 });
s += txt(dx + 140, dy + 34, '装配线节拍.seq.json · 循环 2.400 s · 8 动作 · 3 工位', { size: 12.5, fill: C.dim });
s += circle(dx + dw - 36, dy + 32, 14, { stroke: C.line2, sw: 1 });
s += txt(dx + dw - 36, dy + 33, '✕', { size: 13, anchor: 'middle', fill: C.sub });
s += rect(dx, dy + 64, 200, dh - 140, { fill: T.navBg });
const nav = ['单位与精度', '循环与相位', '编辑辅助', '显示', '导出', '快捷键'];
nav.forEach((t, i) => {
const y = dy + 96 + i * 52;
const active = i === 0;
if (active) s += rect(dx + 12, y - 20, 176, 44, { rx: 10, fill: C.accent, opacity: 0.14 });
if (active) s += rect(dx + 12, y - 20, 4, 44, { rx: 2, fill: C.accent });
s += txt(dx + 32, y + 2, t, { size: 14, fill: active ? C.accent : C.sub, weight: active ? 600 : 400 });
});
let y = dy + 100;
s += txt(cx0, y, '时间单位', { size: 14.5, weight: 600 });
s += txt(cx0 + 86, y, '决定时间轴 / 时长 / 统计的显示单位,内部统一以毫秒存储,换算无损', { size: 11.5, fill: C.dim });
y += 24;
const cards = [
['ms', '毫秒', '高速动作 · 伺服点位 · 快速检测', '0.467 s → 467 ms'],
['s', '秒(推荐)', '装配 / 压装 / 焊接等多数产线节拍', '467 ms → 0.467 s'],
['min', '分钟', '热处理 · 固化 · 长周期工艺', '0.467 s → 0.0078 min'],
];
cards.forEach(([u, name, desc, ex], i) => {
const x = cx0 + i * 320;
const active = u === UNIT.time;
s += rect(x, y, 300, 100, { rx: 12, fill: active ? T.activeCard : C.panel2, stroke: active ? C.accent : C.line, sw: active ? 1.6 : 1 });
s += circle(x + 24, y + 30, 9, { fill: active ? C.accent : 'none', stroke: active ? C.accent : C.line2, sw: 1.6 });
if (active) s += path(`M ${x + 19} ${y + 30} l 4 4 l 6 -9`, { stroke: T.onAccent, sw: 2, cap: 'round' });
s += txt(x + 42, y + 30, `${u} ${name}`, { size: 14, weight: 600, fill: active ? C.text : C.sub });
s += txt(x + 24, y + 58, desc, { size: 11.5, fill: C.dim });
s += txt(x + 24, y + 80, ex, { size: 11.5, fill: active ? C.accent : C.dim });
});
y += 132;
s += txt(cx0, y, '相位单位', { size: 14.5, weight: 600 });
s += txt(cx0 + 86, y, 'PLC 工程师常用百分比描述相位,导出时按当前单位输出', { size: 11.5, fill: C.dim });
s += txt(cx0 + 640, y, '显示精度', { size: 14.5, weight: 600 });
s += txt(cx0 + 726, y, '自动 = 保证 1 ms 分辨率', { size: 11.5, fill: C.dim });
y += 24;
[['°', '角度', '0 – 360°'], ['%', '百分比', '0 – 100%']].forEach(([u, name, desc], i) => {
const x = cx0 + i * 320;
const active = u === UNIT.phase;
s += rect(x, y, 300, 84, { rx: 12, fill: active ? T.activeCard : C.panel2, stroke: active ? C.accent : C.line, sw: active ? 1.6 : 1 });
s += circle(x + 24, y + 28, 9, { fill: active ? C.accent : 'none', stroke: active ? C.accent : C.line2, sw: 1.6 });
if (active) s += path(`M ${x + 19} ${y + 28} l 4 4 l 6 -9`, { stroke: T.onAccent, sw: 2, cap: 'round' });
s += txt(x + 42, y + 28, `${u} ${name}`, { size: 14, weight: 600, fill: active ? C.text : C.sub });
s += txt(x + 24, y + 56, `取值范围 ${desc} · 例:105.0° ⇄ 29.17%`, { size: 11.5, fill: C.dim });
});
['自动', '0', '1', '2', '3', '4'].forEach((p, i) => {
const bw = 52;
s += segBtn(cx0 + 640 + i * (bw + 4), y + 4, bw, 34, p, p === '自动');
});
s += rect(cx0 + 640, y + 48, 336, 36, { rx: 9, fill: T.chip, stroke: C.line, sw: 1 });
s += txt(cx0 + 654, y + 66, `2.400 s · 105.0° · 29.17% · 0.700 s`, { size: 12.5, fill: C.accent });
y += 116;
s += txt(cx0, y, '循环与相位', { size: 14.5, weight: 600 });
y += 22;
const ctrl = (x, w, label, value, unit) => {
let r = txt(x, y - 6, label, { size: 11.5, fill: C.dim });
r += rect(x, y + 8, w, 42, { rx: 10, fill: C.panel2, stroke: C.line2, sw: 1 });
r += txt(x + 14, y + 29, value, { size: 14, fill: C.text, weight: 600 });
if (unit) r += txt(x + w - 42, y + 29, unit, { size: 13, anchor: 'end', fill: C.sub });
r += path(`M ${x + w - 26} ${y + 24} l 5 6 l 5 -6`, { stroke: C.sub, sw: 1.5, cap: 'round' });
return r;
};
s += ctrl(cx0, 220, '循环时长(1 圈)', '2.400', UNIT.time);
s += ctrl(cx0 + 244, 220, '起始相位 / 位置', '0.0° (12 点钟)');
s += ctrl(cx0 + 488, 220, '旋转方向', '顺时针 CW');
s += ctrl(cx0 + 732, 244, '圈数 / 循环显示', '1 圈 = 1 循环');
y += 78;
s += txt(cx0, y, '时间 ↔ 相位 换算', { size: 14.5, weight: 600 });
s += txt(cx0 + 176, y, `当前:1° = ${tfmtAuto(CYCLE_MS / 360)},1% = ${tfmtAuto(CYCLE_MS / 100)},双向实时联动`, { size: 11.5, fill: C.dim });
y += 22;
const cols = [cx0, cx0 + 220, cx0 + 440, cx0 + 660];
s += rect(cx0, y, cw, 34, { rx: 8, fill: T.navBg });
['相位角', '时间', '百分比', '说明'].forEach((t, i) => { s += txt(cols[i] + 14, y + 18, t, { size: 12.5, fill: C.dim, weight: 600 }); });
const rows = [
['0°', '0.000 s', '0.00%', '循环起点(12 点钟方向)'],
['90°', '0.600 s', '25.00%', '四分之一圈 · 常用于上料完成'],
['180°', '1.200 s', '50.00%', '半圈 · 加工中位'],
['270°', '1.800 s', '75.00%', '四分之三圈 · 常用于下料前'],
['360°', '2.400 s', '100.00%', '循环终点,与 0° 重合'],
];
rows.forEach((r, i) => {
const ry = y + 34 + i * 30;
if (i % 2 === 0) s += rect(cx0, ry, cw, 30, { rx: 6, fill: C.panel2, opacity: 0.6 });
r.forEach((t, j) => { s += txt(cols[j] + 14, ry + 16, t, { size: 12.5, fill: j === 0 ? C.accent : C.sub, weight: j === 0 ? 600 : 400 }); });
});
y += 34 + rows.length * 30 + 22;
s += txt(cx0, y, '编辑辅助', { size: 14.5, weight: 600 });
s += txt(cx0 + 86, y, '吸附步长可按时长设置,便于秒级工艺快速对齐', { size: 11.5, fill: C.dim });
y += 22;
s += txt(cx0, y + 16, '角度吸附', { size: 12.5, fill: C.sub });
['1°', '5°', '15°'].forEach((t, i) => { s += segBtn(cx0 + 90 + i * 66, y, 60, 34, t, i === 0); });
s += txt(cx0 + 300, y + 16, '时间吸附', { size: 12.5, fill: C.sub });
['10 ms', '0.1 s', '1 s'].forEach((t, i) => { s += segBtn(cx0 + 390 + i * 76, y, 70, 34, t, i === 1); });
s += txt(cx0 + 630, y + 16, '网格', { size: 12.5, fill: C.sub });
s += segBtn(cx0 + 676, y, 84, 34, '显示网格', true);
s += segBtn(cx0 + 768, y, 84, 34, '吸附网格', true);
s += segBtn(cx0 + 860, y, 116, 34, '跨圈自动拆分', true);
s += line(dx, dy + dh - 76, dx + dw, dy + dh - 76, { stroke: C.line, sw: 1 });
s += rect(cx0, dy + dh - 54, 132, 40, { rx: 9, fill: 'transparent', stroke: C.line2, sw: 1 });
s += txt(cx0 + 66, dy + dh - 34, '恢复默认', { size: 13, anchor: 'middle', fill: C.sub });
s += rect(cx0 + cw - 380, dy + dh - 54, 116, 40, { rx: 9, fill: C.panel2, stroke: C.line2, sw: 1 });
s += txt(cx0 + cw - 322, dy + dh - 34, '取消', { size: 13.5, anchor: 'middle', fill: C.text });
s += rect(cx0 + cw - 250, dy + dh - 54, 116, 40, { rx: 9, fill: C.panel2, stroke: C.accent, sw: 1.2 });
s += txt(cx0 + cw - 192, dy + dh - 34, '应用', { size: 13.5, anchor: 'middle', fill: C.accent });
s += rect(cx0 + cw - 120, dy + dh - 54, 120, 40, { rx: 9, fill: C.accent2, stroke: C.accent2, sw: 1 });
s += txt(cx0 + cw - 60, dy + dh - 34, '确定', { size: 13.5, anchor: 'middle', fill: '#ffffff', weight: 600 });
return s;
}
function build(mode, theme = 'dark') {
setTheme(theme);
const grid = `<defs><pattern id="grid" width="32" height="32" patternUnits="userSpaceOnUse">` const grid = `<defs><pattern id="grid" width="32" height="32" patternUnits="userSpaceOnUse">`
+ `<circle cx="1" cy="1" r="1" fill="#1c2940"/></pattern>` + `<circle cx="1" cy="1" r="1" fill="${T.grid}"/></pattern>`
+ `<linearGradient id="canvasGrad" x1="0" y1="0" x2="0" y2="1">` + `<linearGradient id="canvasGrad" x1="0" y1="0" x2="0" y2="1">`
+ `<stop offset="0" stop-color="#0e1520"/><stop offset="1" stop-color="#0a0f18"/></linearGradient></defs>`; + `<stop offset="0" stop-color="${T.canvas1}"/><stop offset="1" stop-color="${T.canvas2}"/></linearGradient></defs>`;
let s = `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">`; let s = `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">`;
s += grid; s += grid;
s += rect(0, 0, W, H, { fill: C.bg }); s += rect(0, 0, W, H, { fill: C.bg });
s += rect(380, 64, W - 380 - 420, H - 64 - 36, { fill: 'url(#canvasGrad)' }); s += rect(380, 64, W - 380 - 420, H - 64 - 36, { fill: 'url(#canvasGrad)' });
s += rect(380, 64, W - 380 - 420, H - 64 - 36, { fill: 'url(#grid)' }); s += rect(380, 64, W - 380 - 420, H - 64 - 36, { fill: 'url(#grid)' });
s += mode === 'bar' ? barView() : circularView(); const settings = mode === 'settings';
s += leftPanel(mode, mode === 'bar' ? 'A8' : 'A3'); const view = settings ? 'circular' : mode;
s += mode === 'bar' ? rightPanelBar() : rightPanelCircular(); s += view === 'bar' ? barView() : circularView();
s += chrome(mode); s += leftPanel(view, view === 'bar' ? 'A8' : 'A3');
s += view === 'bar' ? rightPanelBar() : rightPanelCircular();
s += chrome(view);
if (settings) s += settingsDialog();
s += '</svg>'; s += '</svg>';
return s; return s;
} }
writeFileSync(join(OUT, 'circular-timing.svg'), build('circular'), 'utf8'); for (const theme of ['dark', 'light']) {
writeFileSync(join(OUT, 'bar-timing.svg'), build('bar'), 'utf8'); const suffix = theme === 'dark' ? '' : `-${theme}`;
console.log('generated:', join(OUT, 'circular-timing.svg'), join(OUT, 'bar-timing.svg')); writeFileSync(join(OUT, `circular-timing${suffix}.svg`), build('circular', theme), 'utf8');
writeFileSync(join(OUT, `bar-timing${suffix}.svg`), build('bar', theme), 'utf8');
writeFileSync(join(OUT, `unit-settings${suffix}.svg`), build('settings', theme), 'utf8');
}
console.log('generated 6 svg (dark + light)');