diff --git a/demo/bar-timing.png b/demo/bar-timing.png index 96061e3..8332371 100644 Binary files a/demo/bar-timing.png and b/demo/bar-timing.png differ diff --git a/demo/bar-timing.svg b/demo/bar-timing.svg index d794b22..7107116 100644 --- a/demo/bar-timing.svg +++ b/demo/bar-timing.svg @@ -1 +1 @@ -条形节拍视图(甘特 / 流程图 · 依赖箭头)时间轴与相位角双刻度联动;箭头表示动作间关联(FS 完成-启动 / SS 起始-起始);跨循环动作自动拆分并标注上料相位夹紧相位加工相位检测相位下料相位0°060°400120°800180°1200240°1600300°2000360°2400ms相位角循环开始 0° / 0 ms循环结束 360° / 2400 ms1A1 上料ST1 · 气缸 Y12A2 定位夹紧ST1 · 夹爪 M13A3 伺服下压ST2 · 伺服 Z 轴4A4 超声波焊接ST2 · 超声发生器5A5 保压冷却ST2 · 延时 T16A6 视觉检测ST3 · 相机 CAM17A7 分选下料ST3 · 气缸 Y28A8 清洁吹气ST3 · 电磁阀 V3上料467 msΔ70°定位夹紧400 msΔ60°伺服下压567 msΔ85°超声波焊接633 msΔ95°保压冷却300 msΔ45°视觉检测300 msΔ45°分选下料 167msΔ25°↩ 跨循环延续 25°清洁吹气 300msΔ45°SS +55°FSFSFSFSSS +35°SS +5°节拍统计循环周期2400 ms / 360°动作数量8(3 工位)关键路径A1 → A2 → A3 → A4 → A6 → A7最大并行度3 个动作同时执行(185°–190°)相位覆盖率100%(0°–360° 无空档 > 15°)瓶颈工位ST2 加工相位 105°–320°(215°)预估节拍2.400 s / 件 · 1500 件/小时圆周节拍预览(实时联动)360°1 循环 = 2400 ms12 点钟起始 · 顺时针 · 每层一环项目装装配线节拍设计装配线节拍.seq.json · v1.2循环 2.400 s = 360°动作 8 · 依赖 7动作 / 工位泳道1上料A1 · ST1 · 气缸 Y10° – 70°467 ms2定位夹紧A2 · ST1 · 夹爪 M155° – 115°400 ms3伺服下压A3 · ST2 · 伺服 Z 轴105° – 190°567 ms4超声波焊接A4 · ST2 · 超声发生器185° – 280°633 ms5保压冷却A5 · ST2 · 延时 T1275° – 320°300 ms6视觉检测A6 · ST3 · 相机 CAM1300° – 345°300 ms7分选下料A7 · ST3 · 气缸 Y2335° – 360°167 ms8清洁吹气A8 · ST3 · 电磁阀 V3340° – 360°300 ms视图模式条形节拍(甘特)圆周节拍(同心)显示选项时间轴 / 相位双刻度依赖箭头 FS / SS跨循环片段标记相位分区色带工位负载 / 相位占用ST1 上料 · 夹紧115° · 31.9%ST2 压装 · 焊接215° · 59.7%ST3 检测 · 下料85° · 23.6%操作提示拖拽动作块平移相位 · 拖端点改持续角Ctrl+滚轮缩放 · 双击空白新建动作关键路径A1 → A2 → A3 → A4 → A6 → A7累计 2400 ms(占满整圈,无空档)属性 · 选中动作A8清洁吹气ST3 · 电磁阀 V3 · 跨循环跨圈开始时刻2267 ms340.0°结束时刻2567 ms385.0° → 25.0°持续时间300 ms45.0°循环归属当前圈 + 下一圈跨圈片段依赖A7 → SS +5°起始-起始相位归属下料相位335°–360°/0°–25°时间 / 角度联动1° = 6.667 ms角度与时间线性映射,双向同步依赖关系(7)上料 → 定位夹紧SS +55°定位夹紧 → 伺服下压FS伺服下压 → 超声波焊接FS超声波焊接 → 保压冷却FS超声波焊接 → 视觉检测FS视觉检测 → 分选下料SS +35°分选下料 → 清洁吹气SS +5°导出SVG(矢量 · 可编辑 · 打印级)PNG / PDF / 工艺卡时序图设计器Sequence Diagram Studio新建打开保存撤销 ↶重做 ↷条形节拍圆周节拍导出 SVG导出 PNG− 100% +适应窗口文件: 装配线节拍.seq.json循环周期 2400 ms相位 360°动作 8依赖 7工位 3时间轴 0–2400 ms吸附 5°就绪● 已保存 \ No newline at end of file +条形节拍视图(甘特 / 流程图 · 依赖箭头)时间轴与相位角双刻度联动;箭头表示动作间关联(绿色实线 FS 严格顺序 / 琥珀虚线 SS 并行重叠);跨循环动作自动拆分并标注上料相位夹紧相位加工相位检测相位下料相位0°060°400120°800180°1200240°1600300°2000360°2400ms相位角循环开始 0° / 0 ms循环结束 360° / 2400 ms1① A1 上料ST1 · 气缸 Y12② A2 定位夹紧ST1 · 夹爪 M13③ A3 伺服下压ST2 · 伺服 Z 轴4④ A4 超声波焊接ST2 · 超声发生器5⑤ A5 保压冷却ST2 · 延时 T16⑥ A6 视觉检测ST3 · 相机 CAM17⑦ A7 分选下料ST3 · 气缸 Y28⑧ A8 清洁吹气ST3 · 电磁阀 V3上料467 msΔ70°定位夹紧400 msΔ60°伺服下压567 msΔ85°超声波焊接633 msΔ95°保压冷却300 msΔ45°视觉检测300 msΔ45°分选下料 167msΔ25°↩ 跨循环延续 25°清洁吹气 300msΔ45°SS +55°★FS 顺序★FS 顺序★FS 顺序FS 顺序★SS +35°★SS +5°节拍统计循环周期2400 ms / 360°动作数量8(3 工位)关键路径①→②→③→④→⑥→⑦最大并行度3 个动作同时执行(185°–190°)相位覆盖率100%(0°–360° 无空档 > 15°)瓶颈工位ST2 加工相位 105°–320°(215°)预估节拍2.400 s / 件 · 1500 件/小时编辑工具添加动作编辑复制删除对齐?帮助圆周节拍预览(实时联动)360°1 循环 = 2400 ms12 点钟起始 · 顺时针 · 每层一环项目装装配线节拍设计装配线节拍.seq.json · v1.2循环 2.400 s = 360°动作 8 · 依赖 7动作 / 工位泳道新建1上料A1 · ST1 · 气缸 Y10° – 70°467 ms2定位夹紧A2 · ST1 · 夹爪 M155° – 115°400 ms3伺服下压A3 · ST2 · 伺服 Z 轴105° – 190°567 ms4超声波焊接A4 · ST2 · 超声发生器185° – 280°633 ms5保压冷却A5 · ST2 · 延时 T1275° – 320°300 ms6视觉检测A6 · ST3 · 相机 CAM1300° – 345°300 ms7分选下料A7 · ST3 · 气缸 Y2335° – 360°167 ms8清洁吹气A8 · ST3 · 电磁阀 V3340° – 360°300 ms视图模式条形节拍(甘特)圆周节拍(同心)显示选项时间轴 / 相位双刻度依赖箭头 FS / SS跨循环片段标记相位分区色带工位负载 / 相位占用ST1 上料 · 夹紧115° · 31.9%ST2 压装 · 焊接215° · 59.7%ST3 检测 · 下料85° · 23.6%操作提示拖拽动作块平移相位 · 拖端点改持续角Shift+拖拽改层 · Ctrl+滚轮缩放双击空白新建动作 · F1 打开帮助属性 · 选中动作A8⑧ 清洁吹气ST3 · 电磁阀 V3 · 跨循环跨圈开始时刻2267 ms340.0°结束时刻2567 ms385.0° → 25.0°持续时间300 ms45.0°循环归属当前圈 + 下一圈跨圈片段顺序约束⑦ → ⑧ SS +5°起始-起始(可并行)相位归属下料相位335°–360°/0°–25°时间 / 角度联动1° = 6.667 ms角度与时间线性映射,双向同步编辑操作添加动作编辑复制删除依赖关系(7)上料 → 定位夹紧SS +55°定位夹紧 → 伺服下压FS 顺序伺服下压 → 超声波焊接FS 顺序超声波焊接 → 保压冷却FS 顺序超声波焊接 → 视觉检测FS 顺序视觉检测 → 分选下料SS +35°分选下料 → 清洁吹气SS +5°导出SVG(矢量 · 可编辑 · 打印级)PNG / PDF / 工艺卡?帮助 · 快捷键拖拽 = 平移相位 拖端点 = 改时长端点拖出连线 = 建依赖 F1 = 帮助中心Ctrl+滚轮 = 缩放 Ctrl+Z = 撤销时序图设计器Sequence Diagram Studio新建打开保存撤销 ↶重做 ↷添加动作编辑条形节拍圆周节拍导出 SVG导出 PNG− 100% +适应窗口重置视图文件:装配线节拍.seq.json已保存?帮助循环周期 2400 ms相位 360°动作 8依赖 7工位 3时间轴 0–2400 ms吸附 5°就绪F1 帮助 · Ctrl+Z 撤销 · Ctrl+S 保存 \ No newline at end of file diff --git a/demo/circular-timing.png b/demo/circular-timing.png index 9aa98b6..c7622df 100644 Binary files a/demo/circular-timing.png and b/demo/circular-timing.png differ diff --git a/demo/circular-timing.svg b/demo/circular-timing.svg index 8cf585b..ba8d4f1 100644 --- a/demo/circular-timing.svg +++ b/demo/circular-timing.svg @@ -1 +1 @@ -圆周节拍视图(同心圆 · 12 点钟起始 · 顺时针)每增加一个动作,在最外层新增一圈;每圈设置起始角与持续角,1 圈 = 1 循环 = 2400 ms0°30°60°90°120°150°180°210°240°270°300°330°A1 上料0°–70°A2 定位夹紧55°–115°A3 伺服下压105°–190°A4 超声波焊接185°–280°A5 保压冷却275°–320°A6 视觉检测300°–345°A7 分选下料335°–360°A8 清洁吹气340°–360°0° 起点 · 12 点钟方向顺时针 CW图层 / 相位图例A1 上料L1 · r=100 · 0°–70° · 467 msA2 定位夹紧L2 · r=150 · 55°–115° · 400 msA3 伺服下压L3 · r=200 · 105°–190° · 567 msA4 超声波焊接L4 · r=250 · 185°–280° · 633 msA5 保压冷却L5 · r=300 · 275°–320° · 300 msA6 视觉检测L6 · r=350 · 300°–345° · 300 msA7 分选下料L7 · r=400 · 335°–360° · 167 msA8 清洁吹气L8 · r=450 · 340°–360° · 300 ms选中动作A3 伺服下压起始角 105.0°结束角 190.0°持续角 85.0°Δ = 567 ms · 层 L3 · ST2条形节拍预览(实时联动)0 ms1200 ms2400 ms项目装装配线节拍设计装配线节拍.seq.json · v1.2循环 2.400 s = 360°动作 8 · 依赖 7动作列表(按层 L1→L8)1上料A1 · ST1 · 气缸 Y1L1 r=100467 ms2定位夹紧A2 · ST1 · 夹爪 M1L2 r=150400 ms3伺服下压A3 · ST2 · 伺服 Z 轴L3 r=200567 ms4超声波焊接A4 · ST2 · 超声发生器L4 r=250633 ms5保压冷却A5 · ST2 · 延时 T1L5 r=300300 ms6视觉检测A6 · ST3 · 相机 CAM1L6 r=350300 ms7分选下料A7 · ST3 · 气缸 Y2L7 r=400167 ms8清洁吹气A8 · ST3 · 电磁阀 V3L8 r=450300 ms视图模式条形节拍(甘特)圆周节拍(同心)显示选项相位角刻度环依赖连线层半径标注跨循环高亮工位负载 / 相位占用ST1 上料 · 夹紧115° · 31.9%ST2 压装 · 焊接215° · 59.7%ST3 检测 · 下料85° · 23.6%操作提示拖拽动作块平移相位 · 拖端点改持续角Ctrl+滚轮缩放 · 双击空白新建动作关键路径A1 → A2 → A3 → A4 → A6 → A7累计 2400 ms(占满整圈,无空档)属性 · 选中动作A3伺服下压ST2 · 伺服 Z 轴 · 层 L3选中起始角105.0°12 点钟起顺时针结束角190.0°持续角85.0°= 567 ms所在层L3半径 200 px依赖A2 → FS完成-启动相位归属加工相位105°–190°角度编辑起始角105°持续角85°层级操作新增外层 L9重排 / 合并层规则新增动作默认置于最外层同心圆,角度可吸附到 1°,自动检测相位重叠。依赖连线A2 定位夹紧→ A3 完成-启动 FSA3 伺服下压→ A4 完成-启动 FSA3 伺服下压→ A6 起始-起始 SS +195°时序图设计器Sequence Diagram Studio新建打开保存撤销 ↶重做 ↷条形节拍圆周节拍导出 SVG导出 PNG− 100% +适应窗口文件: 装配线节拍.seq.json循环周期 2400 ms相位 360°动作 8层数 L1–L8同心圆 8半径步距 50 px吸附 1°就绪● 已保存 \ No newline at end of file +圆周节拍视图(同心圆 · 12 点钟起始 · 顺时针)同心圆环 = 动作层;箭头 = 执行顺序(绿色实线 FS 严格顺序,琥珀虚线 SS 并行重叠);1 圈 = 1 循环 = 2400 msL1L2L3L4L5L6L7L8① A1 上料0°–70°② A2 定位夹紧55°–115°③ A3 伺服下压105°–190°④ A4 超声波焊接185°–280°⑤ A5 保压冷却275°–320°⑥ A6 视觉检测300°–345°⑦ A7 分选下料335°–360°⑧ A8 清洁吹气340°–360°①→② SS+55°★②→③ FS★③→④ FS★④→⑤ FS④→⑥ FS★⑥→⑦ SS+35°★⑦→⑧ SS+5°0° 起点 · 12 点钟方向顺时针 CW0°30°60°90°120°150°180°210°240°270°300°330°图层 / 相位图例① A1 上料L1 · r=100 · 0°–70° · 467 ms② A2 定位夹紧L2 · r=150 · 55°–115° · 400 ms③ A3 伺服下压L3 · r=200 · 105°–190° · 567 ms④ A4 超声波焊接L4 · r=250 · 185°–280° · 633 ms⑤ A5 保压冷却L5 · r=300 · 275°–320° · 300 ms⑥ A6 视觉检测L6 · r=350 · 300°–345° · 300 ms⑦ A7 分选下料L7 · r=400 · 335°–360° · 167 ms⑧ A8 清洁吹气L8 · r=450 · 340°–360° · 300 ms选中动作③ A3 伺服下压起始角 105.0°结束角 190.0°持续角 85.0°Δ = 567 ms · 层 L3 · ST2执行顺序 / 依赖类型FS 严格顺序(完成后启动)SS 并行重叠(可提前启动)★关键路径(累计最长链)条形节拍预览(实时联动)0 ms1200 ms2400 ms添加编辑复制删除层+层−对齐?帮助项目装装配线节拍设计装配线节拍.seq.json · v1.2循环 2.400 s = 360°动作 8 · 依赖 7动作列表(按层 L1→L8)新建1上料A1 · ST1 · 气缸 Y1L1 r=100467 ms2定位夹紧A2 · ST1 · 夹爪 M1L2 r=150400 ms3伺服下压A3 · ST2 · 伺服 Z 轴L3 r=200567 ms4超声波焊接A4 · ST2 · 超声发生器L4 r=250633 ms5保压冷却A5 · ST2 · 延时 T1L5 r=300300 ms6视觉检测A6 · ST3 · 相机 CAM1L6 r=350300 ms7分选下料A7 · ST3 · 气缸 Y2L7 r=400167 ms8清洁吹气A8 · ST3 · 电磁阀 V3L8 r=450300 ms视图模式条形节拍(甘特)圆周节拍(同心)显示选项同心圆环背景顺序箭头(FS / SS)层半径标注跨循环高亮工位负载 / 相位占用ST1 上料 · 夹紧115° · 31.9%ST2 压装 · 焊接215° · 59.7%ST3 检测 · 下料85° · 23.6%操作提示拖拽动作块平移相位 · 拖端点改持续角Shift+拖拽改层 · Ctrl+滚轮缩放双击空白新建动作 · F1 打开帮助属性 · 选中动作A3③ 伺服下压ST2 · 伺服 Z 轴 · 层 L3选中起始角105.0°12 点钟起顺时针结束角190.0°持续角85.0°= 567 ms所在层L3半径 200 px顺序约束② → ③ FS严格顺序(完成后启动)相位归属加工相位105°–190°角度编辑起始角105°持续角85°层 / 编辑操作新增外层 L9重排 / 合并层复制动作删除动作对齐相位顺序规则新增动作默认置于最外层同心圆,箭头方向 = 执行顺序,绿色实线为严格顺序,琥珀虚线为可并行重叠。依赖连线② 定位夹紧→ ③ 完成-启动 FS③ 伺服下压→ ④ 完成-启动 FS③ 伺服下压→ ⑥ 起始-起始 SS⑥ 视觉检测→ ⑦ 起始-起始 SS?帮助 · 快捷键拖拽 = 平移相位 拖端点 = 改持续角Shift+拖 = 改层 F1 = 帮助中心Ctrl+Z / Ctrl+Y = 撤销 / 重做时序图设计器Sequence Diagram Studio新建打开保存撤销 ↶重做 ↷添加动作编辑条形节拍圆周节拍导出 SVG导出 PNG− 100% +适应窗口重置视图文件:装配线节拍.seq.json已保存?帮助循环周期 2400 ms相位 360°动作 8层数 L1–L8同心圆 8半径步距 50 px吸附 1°就绪F1 帮助 · Ctrl+Z 撤销 · Ctrl+S 保存 \ No newline at end of file diff --git a/docs/DESIGN.md b/docs/DESIGN.md index e7b9382..ae43dcd 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -262,14 +262,34 @@ P(cx, cy, r, θ) = ( cx + r·cos(θ−90°), cy + r·sin(θ−90°) ) **半径自适应**:`needed = R0 + maxLayer × pitch + TH`; 若 `needed > R_available`,依次降级:① `pitch` 压缩至下限 26 px → ② 外圈刻度环内移 → ③ 进入"双环模式"(每 2 层换一个圆心偏移)。 +**同心圆环背景**:每一层绘制为一条"环形带"(`circle` + `stroke-width = TH` + 交替底色), +再在 `r ± TH/2` 处描 1 px 边线,形成一圈一圈可见的轨道; +环内以空闲角度标注 `L1…Ln`(自动避开该层动作所占角度),保证层数一目了然。 + +**依赖箭头(表达严格顺序)**:箭头是圆周视图的第二语义层,规则如下: + +1. 路径为"径向出 → 环间通道走角 → 径向入"的三段式,通道半径取源/目标环的**半径中值**(恰好落在两环之间的空隙); +2. **箭头落点停在目标环的近侧边缘**(由内向外时停在 `rB − TH/2 − 4`,由外向内时停在 `rB + TH/2 + 4`), + 箭头方向 = **行进方向**,指向目标弧段的起始端 —— 一眼看出"下一步从哪开始"; +3. 颜色/线型即语义:**绿色实线 = FS 严格顺序**(前动作完成后才允许启动),**琥珀虚线 = SS 并行重叠**(可提前启动); +4. 跨越 2 层以上的依赖(如 ④→⑥)自动改走**外圈专用通道**(`r = Rmax + 26`),避免穿过中间层的圆环; +5. 标签盒(`③→④ FS` / `⑥→⑦ SS+35°`)**最后绘制并压在最上层**,并随弧线切向旋转(自动翻转保持文字正向), + 因此永远不会被圆环或弧段遮挡; +6. 关键路径上的依赖额外加同色辉光与 `★` 角标。 + ### 6.2 条形节拍布局(甘特 + 流程图) 1. **泳道分行**:按 `Station.order` 排序;同工位内动作按 `startAngle` 排序,若与已有行区间重叠则新开子行(贪心区间着色); 2. **X 映射**:`x(θ) = X0 + θ/360 × (X1 − X0)`;上轴 `ms` 刻度与下轴 `°` 刻度共用同一映射; -3. **依赖路由**: - - FS:`source.end → target.start`;SS:`source.start → target.start`;FF / SF 同理; - - 折线路径 `M s → (s.x + jog) → (t.y) → (t.x − arrow)`,`jog` 按冲突通道递增(`+16 + k×14`),避免多条线重叠; - - 跨行时在 `jog` 处加虚线辅助线,标签盒(`FS` / `SS +5°`)统一放在目标条左上角上方 46 px 处; +3. **依赖路由**(正交折线,绝不穿过任何动作条): + - 出口:FS 从源条**右端**、SS 从源条**左端**,从条的下边缘垂直引出(相邻行直接落到行间隙); + - 相邻行(`|Δrow| = 1`):`出口 ↓ 行间隙 → 横走到 target.start 上方 → 垂直扎入目标条上边缘`, + 箭头方向向下(`ty − 17` 处收尾),横走段位于两行之间的空隙带 `ty − 27`; + - 跨行(`|Δrow| ≥ 2`):先在源条下方间隙横走,再走**垂直车道** + `lane = max(sx, tx, 中间行最大右边界) + 28 + k×16`(保证不与中间行动作条相交), + 到目标行上方间隙后横走到位,再垂直扎入; + - 标签盒(`FS 顺序` / `SS +55°`)压在横走段中点、不透明底色"断开"线条,关键路径加 `★` 角标; + - 颜色语义与圆周视图一致:绿色实线 FS(严格顺序)、琥珀虚线 SS(并行重叠); 4. **跨循环**:拆成 `[θ0, 360]` 与 `[0, θ1−360]` 两段,第二段以虚线 + 左边界标记 + `↩ 跨循环延续` 文本渲染; 5. **关键路径(CPM)**:按依赖图做拓扑排序,计算每个动作的最早/最晚开始,`slack = 0` 的链路即关键路径,加粗高亮; 6. **相位分区色带**:由用户或预设模板定义的 `Phase{name, θ0, θ1, color}` 列表,绘制在时间轴上方。 diff --git a/tools/demo-gen.mjs b/tools/demo-gen.mjs index 741db3f..b34ef2a 100644 --- a/tools/demo-gen.mjs +++ b/tools/demo-gen.mjs @@ -12,8 +12,10 @@ const C = { bg: '#0b1018', canvas: '#0e1520', panel: '#121a28', panel2: '#0f1723', line: '#1f2c40', line2: '#2a3a52', text: '#e8eefc', sub: '#8ea0bd', dim: '#5c6f8c', accent: '#4cc9f0', accent2: '#7c5cff', ok: '#34d399', warn: '#ffd166', danger: '#ff6b6b', + fs: '#4ade80', ss: '#ffd166', crit: '#4cc9f0', }; const PAL = ['#4cc9f0', '#7bd88f', '#ffd166', '#ff8a5c', '#f472b6', '#a78bfa', '#38bdf8', '#34d399']; +const SEQ = ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩']; const CYCLE_MS = 2400; const ACTIONS = [ @@ -26,16 +28,16 @@ const ACTIONS = [ { id: 'A7', name: '分选下料', a0: 335, a1: 360, station: 'ST3', driver: '气缸 Y2' }, { id: 'A8', name: '清洁吹气', a0: 340, a1: 385, station: 'ST3', driver: '电磁阀 V3' }, ]; -ACTIONS.forEach((a, i) => { a.color = PAL[i]; a.ring = i; }); +ACTIONS.forEach((a, i) => { a.color = PAL[i]; a.ring = i; a.step = i + 1; }); const DEPS = [ - { from: 'A1', to: 'A2', type: 'SS', off: 55 }, - { from: 'A2', to: 'A3', type: 'FS', off: 0 }, - { from: 'A3', to: 'A4', type: 'FS', off: 0 }, - { from: 'A4', to: 'A5', type: 'FS', off: 0 }, - { from: 'A4', to: 'A6', type: 'FS', off: 0 }, - { from: 'A6', to: 'A7', type: 'SS', off: 35 }, - { from: 'A7', to: 'A8', type: 'SS', off: 5 }, + { from: 'A1', to: 'A2', type: 'SS', off: 55, critical: true }, + { from: 'A2', to: 'A3', type: 'FS', off: 0, critical: true }, + { from: 'A3', to: 'A4', type: 'FS', off: 0, critical: true }, + { from: 'A4', to: 'A5', type: 'FS', off: 0, critical: false }, + { from: 'A4', to: 'A6', type: 'FS', off: 0, critical: true }, + { from: 'A6', to: 'A7', type: 'SS', off: 35, critical: true }, + { from: 'A7', to: 'A8', type: 'SS', off: 5, critical: false }, ]; const byId = (id) => ACTIONS.find((a) => a.id === id); @@ -102,47 +104,110 @@ function ringArcs(cx, cy, r, a0, a1) { return [arcPath(cx, cy, r, a0, 360), arcPath(cx, cy, r, 0, a1 - 360)]; } +function arrowHead(tx, ty, dx, dy, col, size = 12) { + const len = Math.hypot(dx, dy) || 1; + const ux = dx / len, uy = dy / len; + const bx = tx - ux * size, by = ty - uy * size; + const px = -uy * size * 0.5, py = ux * size * 0.5; + 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) { + const c = x + 24, m = y + 24; + switch (name) { + 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' }); + case 'edit': + return path(`M ${c - 9} ${m + 9} l 2 -6 l 12 -12 l 4 4 l -12 12 z`, { fill: col }) + + path(`M ${c + 6} ${m - 10} l 4 4`, { stroke: col, sw: 2 }); + case 'copy': + 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 }); + case 'del': + 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 - 3, m - 11, c + 3, m - 11, { stroke: col, sw: 1.8, cap: 'round' }) + + line(c - 3, m - 1, c - 3, m + 6, { stroke: col, sw: 1.5 }) + + line(c + 3, m - 1, c + 3, m + 6, { stroke: col, sw: 1.5 }); + case 'up': + return path(`M ${c - 9} ${m + 5} L ${c} ${m - 6} L ${c + 9} ${m + 5}`, { stroke: col, sw: 2.4, cap: 'round' }); + case 'down': + return path(`M ${c - 9} ${m - 5} L ${c} ${m + 6} L ${c + 9} ${m - 5}`, { stroke: col, sw: 2.4, cap: 'round' }); + case 'align': + return line(c - 10, m - 7, c + 10, m - 7, { stroke: col, sw: 2.2, cap: 'round' }) + + line(c - 4, m, c + 10, m, { stroke: col, sw: 2.2, cap: 'round' }) + + line(c - 10, m + 7, c + 4, m + 7, { stroke: col, sw: 2.2, cap: 'round' }); + case 'help': + return circle(c, m, 10, { stroke: col, sw: 1.8 }) + + txt(c, m + 1, '?', { size: 13, anchor: 'middle', fill: col, weight: 700 }); + case 'ruler': + return rect(c - 10, m - 6, 20, 12, { rx: 2, stroke: col, sw: 1.6 }) + + line(c - 5, m - 6, c - 5, m - 1, { stroke: col, sw: 1.4 }) + + line(c, m - 6, c, m - 2, { stroke: col, sw: 1.4 }) + + line(c + 5, m - 6, c + 5, m - 1, { stroke: col, sw: 1.4 }); + default: + return ''; + } +} + +function btn(x, w, label, o = {}) { + const { kind = 'ghost', iconName = null, h = 36, y = 14, size = 14.5 } = o; + const S = { + ghost: { fill: C.panel, stroke: C.line2, col: C.text }, + primary: { fill: C.accent2, stroke: C.accent2, col: '#ffffff' }, + add: { fill: C.ok, stroke: C.ok, col: '#04170e' }, + toggle: { fill: C.accent, stroke: C.accent, col: '#04170e' }, + }[kind]; + let s = rect(x, y, w, h, { rx: 9, fill: S.fill, stroke: S.stroke, sw: 1 }); + if (iconName) { + s += icon(x + 4, y + (h - 48) / 2, iconName, S.col); + s += txt(x + 34, y + h / 2 + 1, label, { size, fill: S.col, weight: kind === 'ghost' ? 400 : 600 }); + } else { + s += txt(x + w / 2, y + h / 2 + 1, label, { size, anchor: 'middle', fill: S.col, weight: kind === 'ghost' ? 400 : 600 }); + } + return s; +} + function chrome(mode) { - const segY = 14, segH = 36; - const segX = 1120, segW = 400, half = segW / 2; + const segX = 962, segW = 340, half = segW / 2, segY = 14, segH = 36; const activeBar = mode === 'bar'; const seg = (x, w, label, active) => rect(x, segY, w, segH, { rx: 10, fill: active ? C.accent : 'transparent', opacity: active ? 0.16 : 1 }) + (active ? rect(x, segY, w, segH, { rx: 10, stroke: C.accent, sw: 1.4 }) : '') + txt(x + w / 2, segY + segH / 2 + 1, label, { size: 15, anchor: 'middle', weight: active ? 600 : 400, fill: active ? C.accent : C.sub }); - const btn = (x, w, label, kind = 'ghost') => { - const fill = kind === 'primary' ? C.accent2 : C.panel; - const stroke = kind === 'primary' ? C.accent2 : C.line2; - const col = kind === 'primary' ? '#ffffff' : C.text; - return rect(x, segY, w, segH, { rx: 9, fill, stroke, sw: 1 }) - + txt(x + w / 2, segY + segH / 2 + 1, label, { size: 14.5, anchor: 'middle', fill: col }); - }; - let s = ''; s += rect(0, 0, W, 64, { fill: '#0f1622' }); 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, stroke: C.accent, sw: 1.2 }); s += path(`M 32 38 L 39 26 L 46 38`, { stroke: C.accent, sw: 2, cap: 'round' }); - s += txt(64, 32, '时序图设计器', { size: 17, weight: 700, ls: 1 }); - s += txt(178, 33, 'Sequence Diagram Studio', { size: 12.5, fill: C.dim }); - s += txt(24, 54, '', { size: 11 }); + s += txt(64, 31, '时序图设计器', { size: 17, weight: 700, ls: 1 }); + s += txt(170, 33, 'Sequence Diagram Studio', { size: 11.5, fill: C.dim }); - s += btn(430, 76, '新建'); - s += btn(514, 76, '打开'); - s += btn(598, 76, '保存'); - s += btn(682, 86, '撤销 ↶'); - s += btn(776, 86, '重做 ↷'); + s += btn(320, 68, '新建'); + s += btn(394, 68, '打开'); + s += btn(468, 68, '保存'); + s += btn(552, 74, '撤销 ↶'); + s += btn(632, 74, '重做 ↷'); + s += btn(722, 132, '添加动作', { kind: 'add', iconName: 'add', size: 14.5 }); + s += btn(862, 80, '编辑', { kind: 'toggle', iconName: 'edit', size: 14.5 }); s += rect(segX, segY, segW, segH, { rx: 11, fill: C.panel, stroke: C.line2, sw: 1 }); s += seg(segX + 4, half - 8, '条形节拍', activeBar); s += seg(segX + half + 4, half - 8, '圆周节拍', !activeBar); - s += btn(1900, 110, '导出 SVG', 'primary'); - s += btn(2020, 110, '导出 PNG'); - s += btn(2140, 96, '− 100% +'); - s += btn(2246, 96, '适应窗口'); - s += btn(2352, 184, '文件: 装配线节拍.seq.json'); + s += btn(1330, 106, '导出 SVG', { kind: 'primary' }); + s += btn(1444, 106, '导出 PNG'); + s += btn(1568, 104, '− 100% +'); + s += btn(1680, 104, '适应窗口'); + s += btn(1796, 80, '重置视图'); + + s += rect(1890, 14, 550, 36, { rx: 9, fill: C.panel, stroke: C.line2, sw: 1 }); + s += txt(1908, 33, '文件:装配线节拍.seq.json', { size: 13.5, fill: C.sub }); + s += circle(2300, 32, 4, { fill: C.ok }); + s += txt(2314, 33, '已保存', { size: 13, fill: C.ok }); + + s += btn(2456, 80, '帮助', { iconName: 'help', size: 14 }); const sbY = H - 36; s += rect(0, sbY, W, 36, { fill: '#0f1622' }); @@ -155,7 +220,30 @@ function chrome(mode) { s += txt(x, sbY + 19, it, { size: 13, fill: i === items.length - 1 ? C.ok : C.sub }); x += it.length * 12 + 46; }); - s += txt(W - 24, sbY + 19, '● 已保存', { size: 13, fill: C.ok, anchor: 'end' }); + s += txt(W - 24, sbY + 19, 'F1 帮助 · Ctrl+Z 撤销 · Ctrl+S 保存', { size: 12.5, fill: C.dim, anchor: 'end' }); + return s; +} + +function floatToolbar() { + const x = 2076, y = 236, w = 48, h = 48, gap = 6; + const items = [ + ['add', '添加', 'add'], + ['edit', '编辑', 'toggle'], + ['copy', '复制', 'ghost'], + ['del', '删除', 'ghost'], + ['up', '层+', 'ghost'], + ['down', '层−', 'ghost'], + ['align', '对齐', 'ghost'], + ['help', '帮助', 'ghost'], + ]; + 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) => { + 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]; + 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 += txt(x + w / 2, by + h - 8, label, { size: 10.5, anchor: 'middle', fill: S.col, weight: 600 }); + }); return s; } @@ -173,7 +261,10 @@ function leftPanel(mode, selected) { s += txt(32, 196, '循环 2.400 s = 360°', { size: 12.5, fill: C.accent }); s += txt(232, 196, '动作 8 · 依赖 7', { size: 12.5, fill: C.sub }); - s += txt(24, 252, 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 += icon(296, 220, 'add', '#04170e'); + s += txt(344, 245, '新建', { size: 12.5, anchor: 'middle', fill: '#04170e', weight: 700 }); const rowH = 50, gap = 6, y1 = 268; ACTIONS.forEach((a, i) => { @@ -184,8 +275,10 @@ function leftPanel(mode, selected) { s += txt(38, y + 26, String(i + 1), { size: 12, anchor: 'middle', fill: '#0b1018', 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 + 36, `${a.id} · ${a.station} · ${a.driver}`, { size: 11.5, fill: C.dim }); - s += txt(352, 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(352, y + 36, `${deg2ms(a.a1 - a.a0)} ms`, { size: 11.5, anchor: 'end', 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 + 36, `${deg2ms(a.a1 - a.a0)} ms`, { 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 += icon(317, y + 1, 'edit', sel ? C.accent : C.dim); }); const yb = y1 + 8 * (rowH + gap) + 14; @@ -199,7 +292,7 @@ function leftPanel(mode, selected) { s += txt(24, yb + 92, '显示选项', { size: 13, fill: C.dim, ls: 2 }); const opts = mode === 'bar' ? ['时间轴 / 相位双刻度', '依赖箭头 FS / SS', '跨循环片段标记', '相位分区色带'] - : ['相位角刻度环', '依赖连线', '层半径标注', '跨循环高亮']; + : ['同心圆环背景', '顺序箭头(FS / SS)', '层半径标注', '跨循环高亮']; opts.forEach((o, i) => { const y = yb + 112 + i * 28; s += rect(20, y, 16, 16, { rx: 4, fill: C.accent, opacity: 0.22 }); @@ -218,16 +311,11 @@ function leftPanel(mode, selected) { s += rect(24, y + 12, (332 * deg) / 360, 8, { rx: 4, fill: col }); }); const ynote = yload + 26 + 3 * 36 + 22; - s += rect(16, ynote, 348, 78, { rx: 10, fill: '#131d2e', stroke: C.line, sw: 1 }); + s += rect(16, ynote, 348, 96, { rx: 10, fill: '#131d2e', stroke: C.line, sw: 1 }); 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 + 62, 'Ctrl+滚轮缩放 · 双击空白新建动作', { size: 11.5, fill: C.sub }); - - const ycp = ynote + 96; - s += txt(24, ycp, '关键路径', { size: 13, fill: C.dim, ls: 2 }); - s += rect(16, ycp + 14, 348, 62, { rx: 10, fill: C.panel2, stroke: C.line, sw: 1 }); - s += txt(32, ycp + 38, 'A1 → A2 → A3 → A4 → A6 → A7', { size: 13, fill: '#cfd9ea', weight: 600 }); - s += txt(32, ycp + 60, '累计 2400 ms(占满整圈,无空档)', { size: 11.5, fill: C.dim }); + s += txt(32, ynote + 62, 'Shift+拖拽改层 · Ctrl+滚轮缩放', { size: 11.5, fill: C.sub }); + s += txt(32, ynote + 80, '双击空白新建动作 · F1 打开帮助', { size: 11.5, fill: C.sub }); return s; } @@ -241,7 +329,7 @@ function rightPanelCircular() { 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 += txt(lx + 29, 144, 'A3', { size: 11.5, anchor: 'middle', fill: '#0b1018', 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 += 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 }); @@ -251,12 +339,12 @@ function rightPanelCircular() { ['结束角', '190.0°', ''], ['持续角', '85.0°', `= ${deg2ms(85)} ms`], ['所在层', 'L3', '半径 200 px'], - ['依赖', 'A2 → FS', '完成-启动'], + ['顺序约束', '② → ③ FS', '严格顺序(完成后启动)'], ['相位归属', '加工相位', '105°–190°'], ]; let y = 196; fields.forEach(([k, v, note], i) => { - if (i % 2 === 0) s += rect(lx, y - 6, rx - lx, 36, { rx: 8, fill: i % 4 === 0 ? C.panel2 : 'transparent', opacity: 0.7 }); + if (i % 2 === 0) s += rect(lx, y - 6, rx - lx, 36, { rx: 8, fill: C.panel2, opacity: 0.7 }); s += txt(lx + 10, y + 12, k, { size: 13.5, fill: C.sub }); s += txt(rx - 10, y + 12, v, { size: 14, anchor: 'end', weight: 600 }); if (note) s += txt(rx - 10, y + 30, note, { size: 11, anchor: 'end', fill: C.dim }); @@ -277,26 +365,52 @@ function rightPanelCircular() { }); y += 4; - s += txt(lx, y, '层级操作', { size: 13, fill: C.dim, ls: 2 }); + s += txt(lx, y, '层 / 编辑操作', { size: 13, fill: C.dim, ls: 2 }); y += 18; - s += rect(lx, y, 168, 40, { rx: 9, fill: C.accent2, opacity: 0.9 }); - s += txt(lx + 84, y + 20, '新增外层 L9', { size: 13.5, anchor: 'middle', weight: 600 }); + s += rect(lx, y, 168, 40, { rx: 9, fill: C.accent2, opacity: 0.92 }); + s += icon(lx + 6, y - 4, 'add', '#ffffff'); + s += txt(lx + 36, 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 += txt(lx + 264, y + 20, '重排 / 合并层', { size: 13.5, anchor: 'middle', fill: C.sub }); + s += icon(lx + 186, y - 4, 'up', C.sub); + s += txt(lx + 216, y + 20, '重排 / 合并层', { size: 13.5, fill: C.sub }); + y += 50; + const eds = [['copy', '复制动作'], ['del', '删除动作'], ['align', '对齐相位']]; + eds.forEach(([ic, label], i) => { + const bx = lx + i * 117; + 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 += txt(bx + 26, y + 20, label, { size: 12.5, fill: C.sub }); + }); y += 62; - s += rect(lx, y, rx - lx, 66, { rx: 10, fill: '#131d2e', stroke: C.line, sw: 1 }); - s += txt(lx + 14, y + 22, '规则', { size: 12, fill: C.warn, weight: 700 }); - s += txt(lx + 14, y + 44, '新增动作默认置于最外层同心圆,', { size: 12, fill: C.sub }); - s += txt(lx + 14, y + 60, '角度可吸附到 1°,自动检测相位重叠。', { size: 12, fill: C.sub }); - s += txt(lx, H - 96, '依赖连线', { size: 13, fill: C.dim, ls: 2 }); - const dl = [['A2 定位夹紧', '→ A3 完成-启动 FS', C.ok], ['A3 伺服下压', '→ A4 完成-启动 FS', C.ok], ['A3 伺服下压', '→ A6 起始-起始 SS +195°', C.warn]]; + s += rect(lx, y, rx - lx, 84, { rx: 10, fill: '#131d2e', stroke: C.line, sw: 1 }); + s += txt(lx + 14, y + 22, '顺序规则', { size: 12, fill: C.warn, weight: 700 }); + s += txt(lx + 14, y + 44, '新增动作默认置于最外层同心圆,', { size: 12, fill: C.sub }); + s += txt(lx + 14, y + 62, '箭头方向 = 执行顺序,绿色实线为严格', { size: 12, fill: C.sub }); + s += txt(lx + 14, y + 78, '顺序,琥珀虚线为可并行重叠。', { size: 12, fill: C.sub }); + y += 104; + + s += txt(lx, y, '依赖连线', { size: 13, fill: C.dim, ls: 2 }); + const dl = [ + ['② 定位夹紧', '→ ③ 完成-启动 FS', C.fs], + ['③ 伺服下压', '→ ④ 完成-启动 FS', C.fs], + ['③ 伺服下压', '→ ⑥ 起始-起始 SS', C.ss], + ['⑥ 视觉检测', '→ ⑦ 起始-起始 SS', C.ss], + ]; dl.forEach(([a, b, col], i) => { - const yy = H - 76 + i * 26; + const yy = y + 24 + i * 26; s += circle(lx + 5, yy, 4, { fill: col }); s += txt(lx + 18, yy, a, { size: 12.5, fill: C.sub }); s += txt(rx, yy, b, { size: 12.5, anchor: 'end', fill: C.dim }); }); + 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 += icon(lx + 8, y - 2, 'help', C.accent); + s += txt(lx + 44, 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 + 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 }); return s; } @@ -310,7 +424,7 @@ function rightPanelBar() { 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 += txt(lx + 29, 144, 'A8', { size: 11.5, anchor: 'middle', fill: '#0b1018', 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 += 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 }); @@ -320,7 +434,7 @@ function rightPanelBar() { ['结束时刻', '2567 ms', '385.0° → 25.0°'], ['持续时间', '300 ms', '45.0°'], ['循环归属', '当前圈 + 下一圈', '跨圈片段'], - ['依赖', 'A7 → SS +5°', '起始-起始'], + ['顺序约束', '⑦ → ⑧ SS +5°', '起始-起始(可并行)'], ['相位归属', '下料相位', '335°–360°/0°–25°'], ]; let y = 196; @@ -340,39 +454,172 @@ function rightPanelBar() { 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 }); + y += 16; + const eds = [['add', '添加动作', 'add'], ['edit', '编辑', 'toggle'], ['copy', '复制', 'ghost'], ['del', '删除', 'ghost']]; + eds.forEach(([ic, label, kind], i) => { + 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]; + 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 += txt(bx + 40, y + 44, label, { size: 11.5, anchor: 'middle', fill: S.col, weight: 600 }); + }); + y += 76; + s += txt(lx, y, '依赖关系(7)', { size: 13, fill: C.dim, ls: 2 }); y += 16; DEPS.forEach((d, i) => { const yy = y + i * 27; - const col = d.type === 'FS' ? C.ok : C.warn; + const col = d.type === 'FS' ? C.fs : C.ss; s += rect(lx, yy, rx - lx, 22, { rx: 6, fill: i % 2 ? 'transparent' : C.panel2, opacity: 0.6 }); s += circle(lx + 9, yy + 11, 4, { fill: col }); s += txt(lx + 20, yy + 11, `${byId(d.from).name} → ${byId(d.to).name}`, { size: 12.5, fill: C.sub }); - s += txt(rx - 10, yy + 11, d.type === 'FS' ? 'FS' : `SS +${d.off}°`, { size: 12, anchor: 'end', fill: col, weight: 600 }); + s += txt(rx - 10, yy + 11, d.type === 'FS' ? 'FS 顺序' : `SS +${d.off}°`, { size: 12, anchor: 'end', fill: col, weight: 600 }); }); + y = y + DEPS.length * 27 + 22; - y = y + 7 * 27 + 22; s += txt(lx, y, '导出', { size: 13, fill: C.dim, ls: 2 }); y += 16; s += rect(lx, y, rx - lx, 44, { rx: 10, fill: C.panel2, stroke: C.line2, sw: 1 }); s += txt(lx + 14, y + 22, 'SVG(矢量 · 可编辑 · 打印级)', { size: 13, fill: C.sub }); s += rect(lx, y + 54, rx - lx, 44, { rx: 10, fill: C.panel2, stroke: C.line2, sw: 1 }); s += txt(lx + 14, y + 76, 'PNG / PDF / 工艺卡', { size: 13, fill: C.sub }); + y += 118; + + 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 += txt(lx + 44, 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 + 64, '端点拖出连线 = 建依赖 F1 = 帮助中心', { size: 11.5, fill: C.sub }); + s += txt(lx + 14, y + 82, 'Ctrl+滚轮 = 缩放 Ctrl+Z = 撤销', { size: 11.5, fill: C.sub }); return s; } +const R0 = 100, PITCH = 50, TH = 34; +const RMAX = R0 + (ACTIONS.length - 1) * PITCH + TH / 2; +const RTICK = RMAX + 42; +const RLAB = RMAX + 76; + +function depGeometry(cx, cy, dep) { + const A = byId(dep.from), B = byId(dep.to); + const rA = R0 + A.ring * PITCH, rB = R0 + B.ring * PITCH; + const aEnd = Math.min(A.a1, 360); + const aStart = B.a0; + const skip = Math.abs(A.ring - B.ring) > 1; + const rC = skip ? RMAX + 26 : (rA + rB) / 2; + const cw = aStart >= aEnd; + const large = Math.abs(aStart - aEnd) > 180 ? 1 : 0; + const [x0, y0] = pt(cx, cy, rA, aEnd); + const [x1, y1] = pt(cx, cy, rC, aEnd); + const [x2, y2] = pt(cx, cy, rC, aStart); + const rTip = rC < rB ? rB - TH / 2 - 4 : rB + TH / 2 + 4; + const [x3, y3] = pt(cx, cy, rTip, aStart); + const d = `M ${x0.toFixed(2)} ${y0.toFixed(2)} L ${x1.toFixed(2)} ${y1.toFixed(2)} ` + + `A ${rC} ${rC} 0 ${large} ${cw ? 1 : 0} ${x2.toFixed(2)} ${y2.toFixed(2)} ` + + `L ${x3.toFixed(2)} ${y3.toFixed(2)}`; + const theta = (aEnd + aStart) / 2; + const span = Math.abs(aStart - aEnd); + const rChip = skip ? rC : (span < 30 ? rB + TH / 2 + 10 : rC); + const [mx, my] = pt(cx, cy, rChip, theta); + let phi = ((theta + 180) % 360) - 180; + if (phi > 90) phi -= 180; + if (phi < -90) phi += 180; + return { d, tip: [x3, y3], dir: [x3 - x2, y3 - y2], mid: [mx, my], phi, skip }; +} + +function group(transform, inner) { + return `${inner}`; +} + function circularView() { const cx = 1180, cy = 790; - const R0 = 100, PITCH = 50, TH = 34; let s = ''; s += txt(420, 108, '圆周节拍视图(同心圆 · 12 点钟起始 · 顺时针)', { size: 20, weight: 600 }); - s += txt(420, 134, '每增加一个动作,在最外层新增一圈;每圈设置起始角与持续角,1 圈 = 1 循环 = 2400 ms', { size: 13, fill: C.dim }); + s += txt(420, 134, '同心圆环 = 动作层;箭头 = 执行顺序(绿色实线 FS 严格顺序,琥珀虚线 SS 并行重叠);1 圈 = 1 循环 = 2400 ms', { size: 13, fill: C.dim }); - const RMAX = R0 + (ACTIONS.length - 1) * PITCH + TH / 2; - const RTICK = RMAX + 42, RLAB = RMAX + 76; + s += circle(cx, cy, RTICK - 14, { fill: '#0c1320', 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 - 14, { fill: '#0c1320', stroke: C.line, sw: 1 }); + for (let i = 0; i < ACTIONS.length; i++) { + const r = R0 + i * PITCH; + s += circle(cx, cy, r, { stroke: i % 2 ? '#121a28' : '#18222f', sw: TH }); + } + s += circle(cx, cy, R0 - TH / 2, { fill: '#0c1320', stroke: '#233350', sw: 1 }); + for (let i = 0; i < ACTIONS.length; i++) { + const r = R0 + i * PITCH; + s += circle(cx, cy, r - TH / 2, { stroke: '#26374f', sw: 1 }); + s += circle(cx, cy, r + TH / 2, { stroke: '#26374f', sw: 1 }); + } + + [0, 90, 180, 270].forEach((d) => { + const [x1, y1] = pt(cx, cy, 46, d); + const [x2, y2] = pt(cx, cy, RTICK - 16, d); + s += line(x1, y1, x2, y2, { stroke: C.line2, sw: 1, dash: '4 8', opacity: 0.8 }); + }); + + ACTIONS.forEach((a, i) => { + const r = R0 + i * PITCH; + 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 [lx, ly] = pt(cx, cy, r, free); + s += txt(lx, ly, `L${i + 1}`, { size: 11, anchor: 'middle', fill: '#42597a', weight: 700 }); + }); + + const chips = []; + DEPS.forEach((dep) => { + const g = depGeometry(cx, cy, dep); + const A = byId(dep.from), B = byId(dep.to); + const col = dep.type === 'FS' ? C.fs : C.ss; + if (dep.critical) s += path(g.d, { stroke: col, sw: 10, opacity: 0.2 }); + s += path(g.d, { stroke: col, sw: dep.critical ? 3.2 : (dep.type === 'FS' ? 2.4 : 2), dash: dep.type === 'FS' ? null : '7 5' }); + 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 cw2 = label.length * 6.6 + 20; + let inner = rect(-cw2 / 2, -9, cw2, 18, { rx: 6, fill: '#0b1018', stroke: col, sw: 1.1 }); + inner += txt(0, 0.5, label, { size: 10.5, anchor: 'middle', fill: col, weight: 600 }); + if (dep.critical) { + 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 }); + } + chips.push(group(`rotate(${g.phi.toFixed(1)} ${g.mid[0].toFixed(1)} ${g.mid[1].toFixed(1)})`, inner)); + }); + + ACTIONS.forEach((a, i) => { + const r = R0 + i * PITCH; + const isSel = a.id === 'A3'; + const wrap = a.a1 > 360; + 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' }); + segs.forEach((d, k) => { + const isTail = wrap && k === 1; + s += path(d, { stroke: a.color, sw: TH, cap: wrap ? 'butt' : 'round', opacity: isTail ? 0.5 : 1 }); + if (isTail) s += path(d, { stroke: a.color, sw: TH, cap: 'butt', dash: '6 6', opacity: 0.95 }); + }); + if (isSel) { + s += path(segs.join(' '), { stroke: '#ffffff', 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' }); + } + + const mid = (a.a0 + a.a1) / 2; + const [mx, my] = pt(cx, cy, r, mid); + 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 ? 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 += chips.join(''); + + s += path(`M ${cx} ${cy - RTICK - 26} l -11 -18 l 22 0 z`, { fill: C.accent }); + s += txt(cx, cy - RTICK - 58, '0° 起点 · 12 点钟方向', { size: 14, anchor: 'middle', fill: C.accent, weight: 600 }); + + s += path(arcPath(cx, cy, RMAX + 30, 20, 70), { stroke: C.accent2, sw: 2.4, cap: 'round' }); + const [ahx, ahy] = pt(cx, cy, RMAX + 30, 74); + const [ahx2, ahy2] = pt(cx, cy, RMAX + 44, 68); + const [ahx3, ahy3] = pt(cx, cy, RMAX + 22, 66); + s += path(`M ${ahx} ${ahy} L ${ahx2} ${ahy2} L ${ahx3} ${ahy3} z`, { fill: C.accent2 }); + const [rtx, rty] = pt(cx, cy, RMAX + 62, 45); + s += txt(rtx, rty, '顺时针 CW', { size: 13.5, anchor: 'middle', fill: C.accent2, weight: 600 }); for (let d = 0; d < 360; d += 5) { const major = d % 30 === 0; @@ -385,55 +632,6 @@ function circularView() { s += txt(tx, ty, `${d}°`, { size: 13, anchor: 'middle', fill: d % 90 === 0 ? C.accent : C.sub, weight: d % 90 === 0 ? 700 : 400 }); } } - [0, 90, 180, 270].forEach((d) => { - const [x1, y1] = pt(cx, cy, 60, d); - const [x2, y2] = pt(cx, cy, RTICK + 24, d); - s += line(x1, y1, x2, y2, { stroke: C.line2, sw: 1, dash: '4 8', opacity: 0.7 }); - }); - - for (let i = 0; i < ACTIONS.length; i++) { - s += circle(cx, cy, R0 + i * PITCH, { stroke: C.line, sw: 1, dash: '3 7', opacity: 0.75 }); - } - - ACTIONS.forEach((a, i) => { - const r = R0 + i * PITCH; - const isSel = a.id === 'A3'; - const wrap = a.a1 > 360; - const segs = ringArcs(cx, cy, r, a.a0, a.a1); - s += path(segs.join(' '), { stroke: '#000000', sw: TH + 10, opacity: 0.35, cap: wrap ? 'butt' : 'round' }); - segs.forEach((d, k) => { - const isTail = wrap && k === 1; - s += path(d, { - stroke: a.color, sw: TH, cap: wrap ? 'butt' : 'round', - opacity: isTail ? 0.55 : 1, - }); - if (isTail) s += path(d, { stroke: a.color, sw: TH, cap: 'butt', dash: '6 6', opacity: 0.9 }); - }); - if (isSel) { - s += path(segs.join(' '), { stroke: '#ffffff', 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' }); - } - - const mid = (a.a0 + a.a1) / 2; - const [mx, my] = pt(cx, cy, r, mid); - const short = (a.a1 - a.a0) < 40; - s += txt(mx, my - (short ? 5 : 7), `${a.id} ${a.name}`, { size: short ? 11.5 : 14.5, anchor: 'middle', fill: '#0a0f18', 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 }); - }); - - const [sx, sy] = pt(cx, cy, RTICK + 20, 0); - s += path(`M ${cx} ${cy - RTICK - 26} l -11 -18 l 22 0 z`, { fill: C.accent }); - s += txt(cx, cy - RTICK - 58, '0° 起点 · 12 点钟方向', { size: 14, anchor: 'middle', fill: C.accent, weight: 600 }); - - const [rax0, ray0] = pt(cx, cy, RMAX + 30, 20); - const [rax1, ray1] = pt(cx, cy, RMAX + 30, 70); - s += path(arcPath(cx, cy, RMAX + 30, 20, 70), { stroke: C.accent2, sw: 2.4, cap: 'round' }); - const [ahx, ahy] = pt(cx, cy, RMAX + 30, 74); - const [ahx2, ahy2] = pt(cx, cy, RMAX + 44, 68); - const [ahx3, ahy3] = pt(cx, cy, RMAX + 22, 66); - s += path(`M ${ahx} ${ahy} L ${ahx2} ${ahy2} L ${ahx3} ${ahy3} z`, { fill: C.accent2 }); - const [rtx, rty] = pt(cx, cy, RMAX + 62, 45); - s += txt(rtx, rty, '顺时针 CW', { size: 13.5, anchor: 'middle', fill: C.accent2, weight: 600 }); const a3 = byId('A3'); const r3 = R0 + a3.ring * PITCH; @@ -450,19 +648,33 @@ function circularView() { ACTIONS.forEach((a, i) => { const yy = ly + 8 + i * 46; s += rect(lx, yy - 9, 16, 16, { rx: 5, fill: a.color }); - s += txt(lx + 26, yy, `${a.id} ${a.name}`, { size: 13.5, fill: '#cfd9ea' }); + s += txt(lx + 26, yy, `${SEQ[i]} ${a.id} ${a.name}`, { size: 13.5, fill: '#cfd9ea' }); 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 }); }); 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 += 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 + 100, '结束角 190.0°', { size: 12, fill: C.sub }); s += txt(lx, ry0 + 122, '持续角 85.0°', { size: 12, fill: C.sub }); s += txt(lx, ry0 + 146, `Δ = ${deg2ms(85)} ms · 层 L3 · ST2`, { size: 12, fill: C.accent, weight: 600 }); + 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 += txt(lx, dy0 + 24, '执行顺序 / 依赖类型', { size: 13, weight: 600, fill: C.sub }); + s += line(lx, dy0 + 48, lx + 34, dy0 + 48, { stroke: C.fs, sw: 2.4 }); + s += arrowHead(lx + 40, dy0 + 48, 1, 0, C.fs, 10); + s += txt(lx + 46, dy0 + 48, 'FS 严格顺序(完成后启动)', { size: 11.5, fill: C.sub }); + s += line(lx, dy0 + 74, lx + 34, dy0 + 74, { stroke: C.ss, sw: 2, dash: '7 5' }); + s += arrowHead(lx + 40, dy0 + 74, 1, 0, C.ss, 10); + 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 += 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 + 54, dy0 + 100, '关键路径(累计最长链)', { size: 11.5, fill: C.sub }); + const mx0 = 1790, my0 = 1160; s += rect(mx0 - 16, my0 - 34, 340, 214, { rx: 14, fill: C.panel2, stroke: C.line, sw: 1, opacity: 0.96 }); s += txt(mx0, my0 - 14, '条形节拍预览(实时联动)', { size: 13.5, weight: 600, fill: C.sub }); @@ -478,6 +690,8 @@ function circularView() { s += txt(bx0, by0 + 8 * (rh + 3) + 20, '0 ms', { 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, by0 + 8 * (rh + 3) + 20, '2400 ms', { size: 11, anchor: 'end', fill: C.dim }); + + s += floatToolbar(); return s; } @@ -489,7 +703,7 @@ function barView() { let s = ''; s += txt(420, 108, '条形节拍视图(甘特 / 流程图 · 依赖箭头)', { size: 20, weight: 600 }); - s += txt(420, 134, '时间轴与相位角双刻度联动;箭头表示动作间关联(FS 完成-启动 / SS 起始-起始);跨循环动作自动拆分并标注', { size: 13, fill: C.dim }); + s += txt(420, 134, '时间轴与相位角双刻度联动;箭头表示动作间关联(绿色实线 FS 严格顺序 / 琥珀虚线 SS 并行重叠);跨循环动作自动拆分并标注', { size: 13, fill: C.dim }); const phases = [ ['上料相位', 0, 70, '#4cc9f0'], @@ -498,14 +712,12 @@ function barView() { ['检测相位', 300, 345, '#a78bfa'], ['下料相位', 335, 385, '#f472b6'], ]; - phases.forEach(([name, a0, a1]) => { + phases.forEach(([name, a0, a1, col]) => { const x = px(a0), w = Math.max(px(Math.min(a1, 360)) - x, 2); - s += rect(x, 152, w, 34, { rx: 6, fill: name.startsWith('下料') ? '#f472b6' : phases.find((p) => p[0] === name)[3], opacity: 0.24 }); - s += rect(x, 152, w, 34, { rx: 6, stroke: phases.find((p) => p[0] === name)[3], sw: 1, opacity: 0.8 }); - if (w > 60) s += txt(x + w / 2, 169, name, { size: 12.5, anchor: 'middle', fill: phases.find((p) => p[0] === name)[3], weight: 600 }); - if (a1 > 360) { - s += rect(X0, 152, px(a1 - 360) - X0, 34, { rx: 6, fill: '#f472b6', opacity: 0.16, dash: '5 5' }); - } + s += rect(x, 152, w, 34, { rx: 6, fill: col, opacity: 0.24 }); + s += rect(x, 152, w, 34, { rx: 6, stroke: col, sw: 1, opacity: 0.8 }); + if (w > 60) s += txt(x + w / 2, 169, name, { size: 12.5, anchor: 'middle', fill: col, weight: 600 }); + if (a1 > 360) s += rect(X0, 152, px(a1 - 360) - X0, 34, { rx: 6, fill: col, opacity: 0.16, dash: '5 5' }); }); s += line(X0, 196, X1, 196, { stroke: C.line2, sw: 1 }); @@ -523,15 +735,15 @@ function barView() { 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 += txt(px(0) + 8, 250 + 8, '循环开始 0° / 0 ms', { size: 12, fill: C.ok }); - s += txt(px(360) - 8, 250 + 8, '循环结束 360° / 2400 ms', { size: 12, anchor: 'end', fill: C.warn }); + s += txt(px(0) + 8, 258, '循环开始 0° / 0 ms', { size: 12, fill: C.ok }); + s += txt(px(360) - 8, 258, '循环结束 360° / 2400 ms', { size: 12, anchor: 'end', fill: C.warn }); ACTIONS.forEach((a, 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(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(460, y + 6, `${a.id} ${a.name}`, { size: 14.5, 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 += line(X0, y + 33, X1, y + 33, { stroke: C.line, sw: 1, dash: '2 6', opacity: 0.5 }); }); @@ -560,30 +772,49 @@ function barView() { s += txt(px(360) + 14, y + BAR_H / 2, `Δ${fmt(a.a1 - a.a0, 0)}°`, { size: 12, fill: C.dim }); }); - const marker = (id, atEnd) => { - const a = byId(id); - const i = ACTIONS.indexOf(a); - const y = rowY(i) + BAR_H / 2; - const x = px(atEnd ? Math.min(a.a1, 360) : a.a0); - return [x, y]; - }; + const barSpan = (a) => [px(a.a0), px(Math.min(a.a1, 360))]; DEPS.forEach((d, k) => { - const a = byId(d.from), b = byId(d.to); - const ia = ACTIONS.indexOf(a), ib = ACTIONS.indexOf(b); - const fromEnd = d.type === 'FS'; - const [sx, sy] = marker(d.from, fromEnd); - const [tx, ty] = marker(d.to, false); - const col = d.type === 'FS' ? C.ok : C.warn; - const jx = sx + 16 + (k % 3) * 14; - const pathD = `M ${sx} ${sy} L ${jx} ${sy} L ${jx} ${ty} L ${tx - 12} ${ty}`; - s += path(pathD, { stroke: col, sw: 1.6, dash: '5 4', opacity: 0.9 }); - s += path(`M ${tx - 12} ${ty} l -9 -5.5 l 0 11 z`, { fill: col }); - const mx = tx - 46; - s += rect(mx - 34, ty - 46, 68, 18, { rx: 5, fill: '#0b1018', stroke: col, sw: 0.8 }); - s += txt(mx, ty - 37, d.type === 'FS' ? 'FS' : `SS +${d.off}°`, { size: 10.5, anchor: 'middle', fill: col, weight: 600 }); - if (Math.abs(ia - ib) > 1) { - s += line(jx, sy, jx, ty, { stroke: col, sw: 1.2, opacity: 0.35, dash: '3 5' }); + const A = byId(d.from), B = byId(d.to); + const ia = ACTIONS.indexOf(A), ib = ACTIONS.indexOf(B); + const sy = rowY(ia) + BAR_H / 2; + const ty = rowY(ib) + BAR_H / 2; + const sx = d.type === 'FS' ? px(Math.min(A.a1, 360)) : px(A.a0); + const ex = d.type === 'FS' ? sx - 9 : sx + 9; + const tx = px(B.a0) + 14; + const dir = ty > sy ? 1 : -1; + const col = d.type === 'FS' ? C.fs : C.ss; + const gapY = ty - dir * 27; + const tipY = ty - dir * 17; + let pathD, chipX, chipY; + if (Math.abs(ib - ia) <= 1) { + pathD = `M ${ex} ${sy + dir * 17} L ${ex} ${gapY} L ${tx} ${gapY} L ${tx} ${tipY - dir * 14}`; + chipX = (ex + tx) / 2; + chipY = gapY; + } else { + let maxRight = 0, minLeft = 1e9; + for (let r = Math.min(ia, ib) + 1; r < Math.max(ia, ib); r++) { + const [b0, b1] = barSpan(ACTIONS[r]); + maxRight = Math.max(maxRight, b1); + minLeft = Math.min(minLeft, b0); + } + let lane = Math.max(sx, tx, maxRight) + 28 + (k % 3) * 16; + if (lane > X1 - 16) lane = Math.min(sx, tx, minLeft) - 28 - (k % 3) * 16; + const srcGapY = sy + dir * 33; + pathD = `M ${ex} ${sy + dir * 17} L ${ex} ${srcGapY} L ${lane} ${srcGapY} L ${lane} ${gapY} L ${tx} ${gapY} L ${tx} ${tipY - dir * 14}`; + chipX = (lane + tx) / 2; + chipY = gapY; + } + if (d.critical) s += path(pathD, { stroke: col, sw: 9, opacity: 0.18 }); + s += path(pathD, { stroke: col, sw: d.critical ? 2.2 : 1.7, dash: d.type === 'FS' ? null : '6 4', opacity: 0.95 }); + s += arrowHead(tx, tipY, 0, dir, col, 13); + const label = d.type === 'FS' ? 'FS 顺序' : `SS +${d.off}°`; + 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 += txt(chipX, chipY + 0.5, label, { size: 10.5, anchor: 'middle', fill: col, weight: 600 }); + if (d.critical) { + 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 }); } }); @@ -592,7 +823,7 @@ function barView() { const stats = [ ['循环周期', '2400 ms / 360°'], ['动作数量', '8(3 工位)'], - ['关键路径', 'A1 → A2 → A3 → A4 → A6 → A7'], + ['关键路径', '①→②→③→④→⑥→⑦'], ['最大并行度', '3 个动作同时执行(185°–190°)'], ['相位覆盖率', '100%(0°–360° 无空档 > 15°)'], ['瓶颈工位', 'ST2 加工相位 105°–320°(215°)'], @@ -605,13 +836,25 @@ function barView() { if (i < stats.length - 1) s += line(444, y + 15, 1036, y + 15, { stroke: C.line, sw: 1, opacity: 0.6 }); }); - const cx = 1890, cy = 1120, R0 = 40, PITCH = 18, PW = 10; - const outer = R0 + 7 * PITCH; + s += rect(420, 1190, 640, 140, { rx: 14, fill: C.panel2, stroke: C.line, sw: 1, opacity: 0.96 }); + s += txt(444, 1222, '编辑工具', { size: 15, weight: 600, fill: C.sub }); + const tools = [['add', '添加动作', 'add'], ['edit', '编辑', 'toggle'], ['copy', '复制', 'ghost'], ['del', '删除', 'ghost'], ['align', '对齐', 'ghost'], ['help', '帮助', 'ghost']]; + tools.forEach(([ic, label, kind], i) => { + 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]; + 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 += txt(bx + 46, 1300, label, { size: 12, anchor: 'middle', fill: S.col, weight: 600 }); + }); + + const cx = 1890, cy = 1120, r0 = 40, pitch = 18, PW = 10; + 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 += txt(1664, 892, '圆周节拍预览(实时联动)', { size: 15, weight: 600, fill: C.sub }); s += circle(cx, cy, outer + PW + 14, { fill: '#0c1320', stroke: C.line, sw: 1 }); 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 }); const segs = ringArcs(cx, cy, r, a.a0, a.a1); segs.forEach((d, k) => { const tail = a.a1 > 360 && k === 1;