@jnrs/lingshu-smart 2.2.28 → 2.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +29 -16
- package/README.md +30 -6
- package/dist/components/index.js +4 -4
- package/dist/{index-tpebqVjC.js → index-xyCXB0RY.js} +1569 -1543
- package/dist/index.js +4 -3
- package/dist/ui/models/Rgv.d.ts +2 -2
- package/dist/utils/index.d.ts +8 -0
- package/package.json +2 -2
package/AGENTS.md
CHANGED
|
@@ -74,7 +74,7 @@ const handleExit = () => {
|
|
|
74
74
|
import { ref, computed, onMounted } from 'vue'
|
|
75
75
|
import type { ICase, ILayer, ILayerOperating, InteractiveUi } from '@/types'
|
|
76
76
|
import { EnumModel } from '@/types'
|
|
77
|
-
import { transRuntimeToPixel } from '@/utils'
|
|
77
|
+
import { transRuntimeToPixel, transPercentToPixel } from '@/utils'
|
|
78
78
|
import LingshuSmartPreview from '@/components/preview/index.vue'
|
|
79
79
|
|
|
80
80
|
const lingshuSmartPreviewRef = ref()
|
|
@@ -305,7 +305,7 @@ operating({
|
|
|
305
305
|
color: payload.status === 2 ? 'green' : '#424242',
|
|
306
306
|
blinking: payload.status === 2
|
|
307
307
|
},
|
|
308
|
-
x:
|
|
308
|
+
x: transPercentToPixel(payload.x, 2, 'width') // 沿轨道移动时需转换
|
|
309
309
|
})
|
|
310
310
|
```
|
|
311
311
|
|
|
@@ -320,7 +320,7 @@ operating({
|
|
|
320
320
|
color: payload.status === 2 ? 'green' : '#424242',
|
|
321
321
|
blinking: payload.status === 2
|
|
322
322
|
},
|
|
323
|
-
x:
|
|
323
|
+
x: transPercentToPixel(payload.x, 2, 'width'),
|
|
324
324
|
j1: payload.j1, // 一级关节角度(度)
|
|
325
325
|
currentFixture: payload.currentFixture // EnumResourceType.PALLET | TOOL
|
|
326
326
|
})
|
|
@@ -337,7 +337,7 @@ operating({
|
|
|
337
337
|
color: payload.status === 0 ? '#f30' : '#424242'
|
|
338
338
|
},
|
|
339
339
|
currentFixture: payload.currentFixture,
|
|
340
|
-
x:
|
|
340
|
+
x: transPercentToPixel(payload.x, 2, 'width'),
|
|
341
341
|
j1: payload.j1,
|
|
342
342
|
j2: payload.j2
|
|
343
343
|
})
|
|
@@ -392,10 +392,10 @@ operating({
|
|
|
392
392
|
id: payload.id,
|
|
393
393
|
rawData: payload,
|
|
394
394
|
light: { color: payload.lightColor, blinking: payload.blinking },
|
|
395
|
-
x:
|
|
395
|
+
x: transPercentToPixel(payload.x, 2, 'width'),
|
|
396
396
|
j1: payload.j1, // 旋转角度
|
|
397
|
-
forkXY: payload.forkXY, //
|
|
398
|
-
forkZ: payload.forkZ // 货叉升降比例 0
|
|
397
|
+
forkXY: payload.forkXY, // 货叉进出移动比例 [−1,1]
|
|
398
|
+
forkZ: payload.forkZ // 货叉升降比例 [0,1]
|
|
399
399
|
})
|
|
400
400
|
```
|
|
401
401
|
|
|
@@ -423,6 +423,18 @@ const pixelX = transRuntimeToPixel(payload.x, 1, 'width')
|
|
|
423
423
|
const pixelY = transRuntimeToPixel(payload.y, 1, 'height')
|
|
424
424
|
```
|
|
425
425
|
|
|
426
|
+
### 百分比转换为像素数值
|
|
427
|
+
|
|
428
|
+
后端推送的 `x` / `y` 通常为**百分比数值**(范围通常为[-1,1]),画布使用**像素坐标**。转换公式:
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
import { transPercentToPixel } from '@jnrs/lingshu-smart'
|
|
432
|
+
|
|
433
|
+
// 宽方向:pixel = percentVal * scene.width
|
|
434
|
+
const pixelX = transPercentToPixel(payload.x, 2, 'width')
|
|
435
|
+
const pixelY = transPercentToPixel(payload.y, 1, 'height')
|
|
436
|
+
```
|
|
437
|
+
|
|
426
438
|
**前提:** 方案 `IScene` 中需配置 `runtime_width` / `runtime_height`。该函数读取 `useEditorStore().scene`,预览页需确保场景数据已加载。
|
|
427
439
|
|
|
428
440
|
### WebSocket 接入示例
|
|
@@ -559,14 +571,14 @@ type ILayerOperating =
|
|
|
559
571
|
|
|
560
572
|
#### IRGVOperating
|
|
561
573
|
|
|
562
|
-
| 属性 | 类型 | 说明
|
|
563
|
-
| ---------- | -------------------- |
|
|
564
|
-
| `light` | `ILightOperating` | 双灯同步更新
|
|
565
|
-
| `x` | `number` | 沿轨道位移(像素) |
|
|
566
|
-
| `j1` | `number` | 车体旋转角度(度)
|
|
567
|
-
| `forkXY` | `number` |
|
|
568
|
-
| `forkZ` | `number` | 货叉升降比例 0
|
|
569
|
-
| `resource` | `IResourceOperating` | 托盘/刀具工位槽
|
|
574
|
+
| 属性 | 类型 | 说明 |
|
|
575
|
+
| ---------- | -------------------- | ------------------------- |
|
|
576
|
+
| `light` | `ILightOperating` | 双灯同步更新 |
|
|
577
|
+
| `x` | `number` | 沿轨道位移(像素)[0,1] |
|
|
578
|
+
| `j1` | `number` | 车体旋转角度(度)[0,360] |
|
|
579
|
+
| `forkXY` | `number` | 货叉进出移动比例 [−1,1] |
|
|
580
|
+
| `forkZ` | `number` | 货叉升降比例 [0,1] |
|
|
581
|
+
| `resource` | `IResourceOperating` | 托盘/刀具工位槽 |
|
|
570
582
|
|
|
571
583
|
#### IRailOperating
|
|
572
584
|
|
|
@@ -666,6 +678,7 @@ type ILayerOperating =
|
|
|
666
678
|
| `transPercentAndPixel(val, size, precision?, getPercent?)` | 百分比 ↔ 像素 |
|
|
667
679
|
| `transFraction(val, size)` | 百分比转小数 |
|
|
668
680
|
| `transRuntimeToPixel(val, precision?, type?)` | 运行时坐标 → 像素(依赖 scene.runtime_width/height) |
|
|
681
|
+
| `transPercentToPixel(val, precision?, type?)` | 百分比数值 → 像素(依赖 scene.width/height) |
|
|
669
682
|
|
|
670
683
|
---
|
|
671
684
|
|
|
@@ -673,7 +686,7 @@ type ILayerOperating =
|
|
|
673
686
|
|
|
674
687
|
1. **编辑器 vs 预览:** 编辑模式配置 `EditorActions`;预览模式配置 `PreviewActions` + `onMessage` → `operating`
|
|
675
688
|
2. **ID 匹配:** `operating` 的 `id` 必须与方案图层 `rawData.id` 一致,否则静默失败(在前端层面该值即为编辑器组件中业务数据配置中必填项 id 的值,需根据后端预先提供的设备 id 在编辑器中进行配置)
|
|
676
|
-
3. **坐标系:** 轨道类设备的 `x` 通常需 `
|
|
689
|
+
3. **坐标系:** 轨道类设备的 `x` 通常需 `transPercentToPixel` 转换;`IRailOperating.x` 直接使用像素
|
|
677
690
|
4. **资源消息:** `Resource` 类型不对应独立图层,通过目标设备的 `resource` 字段操作工位槽
|
|
678
691
|
5. **引擎生命周期:** 组件卸载时自动 `destroyContainer`;手动集成需自行销毁
|
|
679
692
|
6. **类型安全:** 所有 API 均导出 TypeScript 类型,推荐 `import type { ILayerOperating, EnumModel } from '@jnrs/lingshu-smart'`
|
package/README.md
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## ✨ 介绍
|
|
4
4
|
|
|
5
|
-
巨能前端 2D
|
|
5
|
+
巨能前端 2D 数字孪生库,灵枢智造。基于 LeaferJS 引擎构建,提供完整的 2D 数字孪生解决方案。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
### 核心功能
|
|
8
|
+
|
|
9
|
+
| 功能 | 说明 |
|
|
10
|
+
| ---------- | ------------------------------------------------------------ |
|
|
11
|
+
| 编辑器模式 | `LingshuSmartEditor` — 方案可视化编辑,支持拖拽布局、设备配置、图层管理、方案保存/预览 |
|
|
12
|
+
| 运行看板 | `LingshuSmartPreview` — 方案运行看板,支持 WebSocket 实时驱动设备动画、交互事件(点击/拖拽/右键菜单) |
|
|
13
|
+
| 设备模型 | 机床、机器人(单关节/双关节)、RGV、装载站、打标机、清洗机、轨道拖链、资源库等 |
|
|
14
|
+
| 设备运转 | 灯光、进度条、入口动画、工位槽资源增删、坐标/角度/货叉控制 |
|
|
15
|
+
| 坐标转换 | `transRuntimeToPixel` / `transPercentToPixel` — 物理坐标与像素坐标互转 |
|
|
9
16
|
|
|
10
17
|
## 💻 技术栈
|
|
11
18
|
|
|
12
|
-
TypeScript、Vue3 生态、
|
|
19
|
+
TypeScript、Vue3 生态、LeaferJS
|
|
13
20
|
|
|
14
21
|
## 🧩 安装教程
|
|
15
22
|
|
|
@@ -20,8 +27,25 @@ pnpm add @jnrs/lingshu-smart
|
|
|
20
27
|
## 🔍 使用示例
|
|
21
28
|
|
|
22
29
|
```typescript
|
|
23
|
-
import type { ILayerOperating } from '@jnrs/lingshu-smart'
|
|
30
|
+
import type { ILayerOperating, ILayer, ICase } from '@jnrs/lingshu-smart'
|
|
24
31
|
import { LingshuSmartPreview, LingshuSmartEditor } from '@jnrs/lingshu-smart/components'
|
|
32
|
+
import { transRuntimeToPixel, transPercentToPixel } from '@jnrs/lingshu-smart'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 编辑器模式
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<LingshuSmartEditor :actions="{ loadCases, saveCases, handlePreview, handleExit }" />
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 运行看板模式
|
|
42
|
+
|
|
43
|
+
```vue
|
|
44
|
+
<LingshuSmartPreview
|
|
45
|
+
ref="previewRef"
|
|
46
|
+
:case-uuid="currentCaseId"
|
|
47
|
+
:actions="{ loadCases, onTap, onMenuTap, onDragEnd }"
|
|
48
|
+
/>
|
|
25
49
|
```
|
|
26
50
|
|
|
27
|
-
详细文档请查看
|
|
51
|
+
详细文档请查看 [AGENTS.md](./AGENTS.md)
|