@nywqs/scada-engine 1.1.31 → 2.0.1
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/LICENSE +21 -21
- package/README.md +359 -193
- package/dist/index.d.ts +3 -0
- package/dist/scada-engine.css +1 -1
- package/dist/scada-engine.es.js +47932 -40
- package/dist/scada-engine.umd.js +3752 -3843
- package/dist/src/components/canvas/composables/index.d.ts +12 -0
- package/dist/src/components/canvas/composables/useAutoSave.d.ts +9 -0
- package/dist/src/components/canvas/composables/useCanvasScale.d.ts +12 -0
- package/dist/src/components/canvas/composables/useDataSource.d.ts +87 -0
- package/dist/src/components/canvas/composables/useFileOperations.d.ts +37 -0
- package/dist/src/components/canvas/composables/useGraphEvents.d.ts +22 -0
- package/dist/src/components/canvas/composables/useNodeOperations.d.ts +35 -0
- package/dist/src/components/canvas/config/graphConfig.d.ts +64 -0
- package/dist/src/components/canvas/config/pluginConfig.d.ts +5 -0
- package/dist/src/components/canvas/config/scadaEdgeShape.d.ts +14 -0
- package/dist/src/components/canvas/config/scadaEdgeView.d.ts +4 -0
- package/dist/src/components/canvas/types/canvas.d.ts +41 -0
- package/dist/src/components/configurators/BindingCard.d.ts +24 -0
- package/dist/src/components/configurators/ComponentPointSelector.d.ts +16 -0
- package/dist/src/components/{EventCard.d.ts → configurators/EventCard.d.ts} +13 -26
- package/dist/src/components/configurators/MappingConfigurator.d.ts +15 -0
- package/dist/src/components/dialogs/AttributeConfigDialog.d.ts +28 -0
- package/dist/src/components/dialogs/CustomCodeDialog.d.ts +20 -0
- package/dist/src/components/dialogs/DataSourceDialog.d.ts +16 -0
- package/dist/src/components/dialogs/ScadaModal.d.ts +37 -0
- package/dist/src/components/{WorkflowSelectorDialog.d.ts → dialogs/WorkflowSelectorDialog.d.ts} +3 -3
- package/dist/src/components/layout/Footer.d.ts +16 -0
- package/dist/src/components/layout/Header.d.ts +56 -0
- package/dist/src/components/panels/CanvasConfigPanel.d.ts +4 -0
- package/dist/src/components/panels/ComponentLibrary.d.ts +6 -0
- package/dist/src/components/panels/ContextMenu.d.ts +26 -0
- package/dist/src/components/panels/PropertyPanel.d.ts +22 -0
- package/dist/src/components/property-tabs/BasicPropertiesTab.d.ts +37 -0
- package/dist/src/components/property-tabs/DataPropertiesTab.d.ts +14 -0
- package/dist/src/components/property-tabs/EdgePropertiesTab.d.ts +16 -0
- package/dist/src/constants/animation.d.ts +5 -0
- package/dist/src/constants/index.d.ts +3 -0
- package/dist/src/constants/layout.d.ts +16 -0
- package/dist/src/constants/theme.d.ts +17 -0
- package/dist/src/index.d.ts +17 -15
- package/dist/src/main.d.ts +0 -1
- package/dist/src/scada-components/basic/circle.d.ts +0 -1
- package/dist/src/scada-components/basic/rect.d.ts +0 -1
- package/dist/src/scada-components/basic/text.d.ts +0 -1
- package/dist/src/scada-components/canvas/config.d.ts +0 -1
- package/dist/src/scada-components/canvas/manager.d.ts +0 -1
- package/dist/src/scada-components/iot/echarts-gauge/EChartsGauge.d.ts +3 -10
- package/dist/src/scada-components/iot/echarts-gauge/index.d.ts +0 -1
- package/dist/src/scada-components/iot/echarts-line/EChartsLine.d.ts +3 -10
- package/dist/src/scada-components/iot/echarts-line/index.d.ts +0 -1
- package/dist/src/scada-components/iot/index.d.ts +0 -6
- package/dist/src/scada-components/registry.d.ts +0 -1
- package/dist/src/scada-components/svg/core/index.d.ts +7 -0
- package/dist/src/scada-components/svg/core/loader.d.ts +71 -0
- package/dist/src/scada-components/svg/core/parser.d.ts +40 -0
- package/dist/src/scada-components/svg/core/types.d.ts +297 -0
- package/dist/src/scada-components/svg/helpers/demo.d.ts +20 -0
- package/dist/src/scada-components/svg/helpers/index.d.ts +5 -0
- package/dist/src/scada-components/svg/helpers/utils.d.ts +24 -0
- package/dist/src/scada-components/svg/index.d.ts +9 -0
- package/dist/src/scada-components/svg/rendering/SVGRenderer.d.ts +14 -0
- package/dist/src/scada-components/svg/rendering/animationTemplates.d.ts +81 -0
- package/dist/src/scada-components/svg/rendering/index.d.ts +6 -0
- package/dist/src/scada-components/types.d.ts +0 -1
- package/dist/src/types/context-menu.d.ts +13 -0
- package/dist/src/types/model3d.d.ts +106 -0
- package/dist/src/types/zone.d.ts +54 -0
- package/dist/src/utils/animation/index.d.ts +6 -0
- package/dist/src/utils/{canvasConfigWatcher.d.ts → canvas/config-watcher.d.ts} +19 -9
- package/dist/src/utils/{canvasDataHandler.d.ts → canvas/data-handler.d.ts} +0 -29
- package/dist/src/utils/{edgeOperations.d.ts → canvas/edge-operations.d.ts} +6 -3
- package/dist/src/utils/{graphOperations.d.ts → canvas/graph-operations.d.ts} +0 -1
- package/dist/src/utils/canvas/index.d.ts +10 -0
- package/dist/src/utils/{canvasLayerManager.d.ts → canvas/layer-manager.d.ts} +0 -1
- package/dist/src/utils/{nodeOperations.d.ts → canvas/node-operations.d.ts} +0 -1
- package/dist/src/utils/core/index.d.ts +8 -0
- package/dist/src/utils/{dataBindingService.d.ts → data/binding-service.d.ts} +1 -2
- package/dist/src/utils/data/index.d.ts +6 -0
- package/dist/src/utils/{contextMenuManager.d.ts → events/context-menu.d.ts} +1 -2
- package/dist/src/utils/{eventManager.d.ts → events/event-manager.d.ts} +1 -2
- package/dist/src/utils/events/index.d.ts +7 -0
- package/dist/src/utils/index.d.ts +30 -20
- package/dist/src/utils/{dracoLoader.d.ts → integrations/draco-loader.d.ts} +0 -1
- package/dist/src/utils/integrations/index.d.ts +6 -0
- package/dist/src/utils/performance/index.d.ts +6 -0
- package/dist/src/utils/{viewportCulling.d.ts → performance/viewport-culling.d.ts} +0 -1
- package/dist/src/utils/{workerManager.d.ts → performance/worker-manager.d.ts} +1 -0
- package/dist/src/views/Preview.d.ts +4 -0
- package/dist/src/views/workflow/WorkflowDialog.d.ts +10 -30
- package/dist/src/views/workflow/components/AddNodeMenu.d.ts +5 -14
- package/dist/src/views/workflow/components/ElementSelector.d.ts +5 -27
- package/dist/src/views/workflow/components/PropertyPanel.d.ts +8 -15
- package/dist/src/views/workflow/components/node-configs/ClearTimerConfig.d.ts +4 -14
- package/dist/src/views/workflow/components/node-configs/ConditionConfig.d.ts +4 -14
- package/dist/src/views/workflow/components/node-configs/CustomCodeConfig.d.ts +4 -14
- package/dist/src/views/workflow/components/node-configs/GetPropertyConfig.d.ts +4 -14
- package/dist/src/views/workflow/components/node-configs/HttpRequestConfig.d.ts +4 -14
- package/dist/src/views/workflow/components/node-configs/SetPropertyConfig.d.ts +4 -14
- package/dist/src/views/workflow/components/node-configs/TimerConfig.d.ts +4 -14
- package/dist/src/views/workflow/config/nodeConfigRegistry.d.ts +0 -1
- package/dist/src/views/workflow/services/canvasElementService.d.ts +0 -1
- package/package.json +86 -84
- package/dist/Tank3DThree-DYRGEi5G.js +0 -108
- package/dist/draco/gltf/draco_decoder.js +0 -33
- package/dist/draco/gltf/draco_decoder.wasm +0 -0
- package/dist/draco/gltf/draco_encoder.js +0 -33
- package/dist/draco/gltf/draco_wasm_wrapper.js +0 -116
- package/dist/index-Bp0lBzVu.js +0 -45027
- package/dist/src/components/AttributeConfigDialog.d.ts +0 -39
- package/dist/src/components/BasicPropertiesTab.d.ts +0 -51
- package/dist/src/components/BindingCard.d.ts +0 -39
- package/dist/src/components/CanvasArea.d.ts +0 -4
- package/dist/src/components/ComponentLibrary.d.ts +0 -34
- package/dist/src/components/ComponentPointSelector.d.ts +0 -29
- package/dist/src/components/ContextMenu.d.ts +0 -63
- package/dist/src/components/CustomCodeDialog.d.ts +0 -30
- package/dist/src/components/DataPropertiesTab.d.ts +0 -24
- package/dist/src/components/DataSourceDialog.d.ts +0 -26
- package/dist/src/components/EdgePropertiesTab.d.ts +0 -22
- package/dist/src/components/Footer.d.ts +0 -41
- package/dist/src/components/Header.d.ts +0 -73
- package/dist/src/components/MappingConfigurator.d.ts +0 -27
- package/dist/src/components/PropertyPanel.d.ts +0 -45
- package/dist/src/scada-components/iot/industrial-3d/Motor3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d/Pump3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d/PumpGLB.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d/Tank3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d/Valve3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d/index.d.ts +0 -22
- package/dist/src/scada-components/iot/industrial-3d-extended/AlarmLight3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d-extended/Conveyor3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d-extended/Cylinder3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d-extended/TemperatureSensor3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d-extended/index.d.ts +0 -18
- package/dist/src/scada-components/iot/industrial-3d-fluid/Filter3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d-fluid/HeatExchanger3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d-fluid/Pipe3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d-fluid/Tee3D.d.ts +0 -14
- package/dist/src/scada-components/iot/industrial-3d-fluid/index.d.ts +0 -18
- package/dist/src/scada-components/iot/light/Light3D.d.ts +0 -14
- package/dist/src/scada-components/iot/light/index.d.ts +0 -6
- package/dist/src/scada-components/iot/switch/Switch3D.d.ts +0 -14
- package/dist/src/scada-components/iot/switch/index.d.ts +0 -6
- package/dist/src/scada-components/iot/tank-3d-three/Tank3DThree.d.ts +0 -14
- package/dist/src/scada-components/iot/tank-3d-three/index.d.ts +0 -7
- package/dist/src/views/workflow/WorkflowEditor.d.ts +0 -38
- package/dist/src/views/workflow/components/WorkflowToolbar.d.ts +0 -24
- /package/dist/src/{components/CanvasConfigPanel.d.ts → App.d.ts} +0 -0
- /package/dist/src/utils/{animationEngine.d.ts → animation/animation-engine.d.ts} +0 -0
- /package/dist/src/utils/{animationScheduler.d.ts → animation/animation-scheduler.d.ts} +0 -0
- /package/dist/src/utils/{commonUtils.d.ts → core/common.d.ts} +0 -0
- /package/dist/src/utils/{fileUtils.d.ts → core/file.d.ts} +0 -0
- /package/dist/src/utils/{messageUtils.d.ts → core/message.d.ts} +0 -0
- /package/dist/src/utils/{storageUtils.d.ts → core/storage.d.ts} +0 -0
- /package/dist/src/utils/{nodePropertyUtils.d.ts → data/node-property.d.ts} +0 -0
- /package/dist/src/utils/{eventUtils.d.ts → events/event-utils.d.ts} +0 -0
- /package/dist/src/utils/{authCrypto.d.ts → integrations/auth-crypto.d.ts} +0 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 leoncheng
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 leoncheng
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,193 +1,359 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
# @nywqs/scada-engine
|
|
4
|
-
|
|
5
|
-
基于 AntV X6 + Vue 3 的自研 SCADA 组态引擎。旨在为工业物联网(IIoT)提供高性能、可扩展的可视化组态解决方案,支持拖拽式界面设计、实时数据绑定及复杂的流程编排。
|
|
6
|
-
|
|
7
|
-
## 特性
|
|
8
|
-
|
|
9
|
-
- 🛠 **可视化编辑器**:基于 AntV X6 构建的专业级图形编辑能力,支持节点拖拽、连线编排、框选复制等操作。
|
|
10
|
-
- 📦 **丰富组件库**:
|
|
11
|
-
- **基础组件**:矩形、圆形、文本等基础矢量图形。
|
|
12
|
-
- **IoT 组件**:支持 ECharts 图表(仪表盘、折线图)、3D 设备模型(电机、管道、阀门、储罐等)、指示灯、开关等工业控件。
|
|
13
|
-
- 🔗 **多源数据集成**:内置服务层,支持 WebSocket、MQTT、HTTP 请求及 SSE(Server-Sent Events)等多种实时数据接入方式。
|
|
14
|
-
- 🎨 **动画引擎**:内置独立的动画调度器(AnimationScheduler)与动画引擎(AnimationEngine),支持脉冲、闪烁、旋转等节点特效。
|
|
15
|
-
- ⚙️ **流程编排**:内置可视化工作流编辑器(Workflow Editor),支持通过逻辑节点(条件判断、定时器、HTTP 请求、自定义代码)编排复杂业务流程。
|
|
16
|
-
- 🔐 **授权与安全**:基于 ECDSA P-256 + SHA-256 的数字签名授权机制,保障软件使用安全。
|
|
17
|
-
- 🚀 **性能优化**:支持视口裁剪(Viewport Culling)技术,在保证视觉效果的同时优化大数据量场景下的渲染性能。
|
|
18
|
-
|
|
19
|
-
## 安装
|
|
20
|
-
|
|
21
|
-
### 环境要求
|
|
22
|
-
|
|
23
|
-
确保你的项目中已安装以下依赖:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
npm install vue@^3.4.0
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### 安装引擎
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm install @nywqs/scada-engine
|
|
33
|
-
# 或
|
|
34
|
-
pnpm add @nywqs/scada-engine
|
|
35
|
-
# 或
|
|
36
|
-
yarn add @nywqs/scada-engine
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## 快速开始
|
|
40
|
-
|
|
41
|
-
### 1. 全局注册
|
|
42
|
-
|
|
43
|
-
在你的应用入口文件(如 `main.ts`)中引入并注册组件:
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
import { createApp } from 'vue'
|
|
47
|
-
import ScadaEngine from '@nywqs/scada-engine'
|
|
48
|
-
import '@nywqs/scada-engine/dist/scada-engine.css' // 引入样式
|
|
49
|
-
import App from './App.vue'
|
|
50
|
-
|
|
51
|
-
const app = createApp(App)
|
|
52
|
-
app.use(ScadaEngine)
|
|
53
|
-
app.mount('#app')
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### 2. 在组件中使用
|
|
57
|
-
|
|
58
|
-
最核心的组件是 `ScadaCanvas`,它承载了画布编辑器和预览功能。
|
|
59
|
-
|
|
60
|
-
```vue
|
|
61
|
-
<template>
|
|
62
|
-
<div class="scada-container">
|
|
63
|
-
<ScadaCanvas
|
|
64
|
-
ref="canvasRef"
|
|
65
|
-
:auth-code="authCode"
|
|
66
|
-
@node-click="handleNodeClick"
|
|
67
|
-
/>
|
|
68
|
-
</div>
|
|
69
|
-
</template>
|
|
70
|
-
|
|
71
|
-
<script setup lang="ts">
|
|
72
|
-
import { ref } from 'vue'
|
|
73
|
-
import { ScadaCanvas } from '@nywqs/scada-engine'
|
|
74
|
-
|
|
75
|
-
const canvasRef = ref()
|
|
76
|
-
const authCode = '你的授权码' // 商业版本需要
|
|
77
|
-
|
|
78
|
-
const handleNodeClick = (node) => {
|
|
79
|
-
console.log('点击了节点:', node.id)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# @nywqs/scada-engine
|
|
4
|
+
|
|
5
|
+
基于 AntV X6 + Vue 3 的自研 SCADA 组态引擎。旨在为工业物联网(IIoT)提供高性能、可扩展的可视化组态解决方案,支持拖拽式界面设计、实时数据绑定及复杂的流程编排。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- 🛠 **可视化编辑器**:基于 AntV X6 构建的专业级图形编辑能力,支持节点拖拽、连线编排、框选复制等操作。
|
|
10
|
+
- 📦 **丰富组件库**:
|
|
11
|
+
- **基础组件**:矩形、圆形、文本等基础矢量图形。
|
|
12
|
+
- **IoT 组件**:支持 ECharts 图表(仪表盘、折线图)、3D 设备模型(电机、管道、阀门、储罐等)、指示灯、开关等工业控件。
|
|
13
|
+
- 🔗 **多源数据集成**:内置服务层,支持 WebSocket、MQTT、HTTP 请求及 SSE(Server-Sent Events)等多种实时数据接入方式。
|
|
14
|
+
- 🎨 **动画引擎**:内置独立的动画调度器(AnimationScheduler)与动画引擎(AnimationEngine),支持脉冲、闪烁、旋转等节点特效。
|
|
15
|
+
- ⚙️ **流程编排**:内置可视化工作流编辑器(Workflow Editor),支持通过逻辑节点(条件判断、定时器、HTTP 请求、自定义代码)编排复杂业务流程。
|
|
16
|
+
- 🔐 **授权与安全**:基于 ECDSA P-256 + SHA-256 的数字签名授权机制,保障软件使用安全。
|
|
17
|
+
- 🚀 **性能优化**:支持视口裁剪(Viewport Culling)技术,在保证视觉效果的同时优化大数据量场景下的渲染性能。
|
|
18
|
+
|
|
19
|
+
## 安装
|
|
20
|
+
|
|
21
|
+
### 环境要求
|
|
22
|
+
|
|
23
|
+
确保你的项目中已安装以下依赖:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install vue@^3.4.0 @antv/x6@^3.1.6 echarts@^5.5.0 pinia@^2.1.0 @vueuse/core@^10.0.0
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 安装引擎
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install @nywqs/scada-engine
|
|
33
|
+
# 或
|
|
34
|
+
pnpm add @nywqs/scada-engine
|
|
35
|
+
# 或
|
|
36
|
+
yarn add @nywqs/scada-engine
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 快速开始
|
|
40
|
+
|
|
41
|
+
### 1. 全局注册
|
|
42
|
+
|
|
43
|
+
在你的应用入口文件(如 `main.ts`)中引入并注册组件:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { createApp } from 'vue'
|
|
47
|
+
import ScadaEngine from '@nywqs/scada-engine'
|
|
48
|
+
import '@nywqs/scada-engine/dist/scada-engine.css' // 引入样式
|
|
49
|
+
import App from './App.vue'
|
|
50
|
+
|
|
51
|
+
const app = createApp(App)
|
|
52
|
+
app.use(ScadaEngine)
|
|
53
|
+
app.mount('#app')
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 2. 在组件中使用
|
|
57
|
+
|
|
58
|
+
最核心的组件是 `ScadaCanvas`,它承载了画布编辑器和预览功能。
|
|
59
|
+
|
|
60
|
+
```vue
|
|
61
|
+
<template>
|
|
62
|
+
<div class="scada-container" style="width: 100vw; height: 100vh;">
|
|
63
|
+
<ScadaCanvas
|
|
64
|
+
ref="canvasRef"
|
|
65
|
+
:auth-code="authCode"
|
|
66
|
+
@node-click="handleNodeClick"
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script setup lang="ts">
|
|
72
|
+
import { ref, onMounted } from 'vue'
|
|
73
|
+
import { ScadaCanvas } from '@nywqs/scada-engine'
|
|
74
|
+
|
|
75
|
+
const canvasRef = ref()
|
|
76
|
+
const authCode = '你的授权码' // 商业版本需要
|
|
77
|
+
|
|
78
|
+
const handleNodeClick = (node) => {
|
|
79
|
+
console.log('点击了节点:', node.id)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 使用 API 方法
|
|
83
|
+
onMounted(() => {
|
|
84
|
+
// 添加节点
|
|
85
|
+
canvasRef.value?.addNode('rect')
|
|
86
|
+
|
|
87
|
+
// 获取画布数据
|
|
88
|
+
const data = canvasRef.value?.getCanvasData()
|
|
89
|
+
console.log('画布数据:', data)
|
|
90
|
+
})
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<style scoped>
|
|
94
|
+
.scada-container {
|
|
95
|
+
position: relative;
|
|
96
|
+
}
|
|
97
|
+
</style>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 3. 自定义组件注册
|
|
101
|
+
|
|
102
|
+
你可以注册自定义的 SCADA 组件:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { componentRegistry } from '@nywqs/scada-engine'
|
|
106
|
+
|
|
107
|
+
// 注册自定义组件
|
|
108
|
+
componentRegistry.register({
|
|
109
|
+
type: 'custom-sensor',
|
|
110
|
+
name: '自定义传感器',
|
|
111
|
+
category: 'iot',
|
|
112
|
+
icon: '🔌',
|
|
113
|
+
defaultSize: { width: 100, height: 100 },
|
|
114
|
+
props: {
|
|
115
|
+
value: { type: 'number', default: 0 },
|
|
116
|
+
unit: { type: 'string', default: '°C' }
|
|
117
|
+
},
|
|
118
|
+
component: () => import('./components/CustomSensor.vue')
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 4. 数据绑定与实时更新
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { dataSourceManager } from '@nywqs/scada-engine'
|
|
126
|
+
|
|
127
|
+
// 配置 WebSocket 数据源
|
|
128
|
+
await dataSourceManager.addSource({
|
|
129
|
+
id: 'ws-1',
|
|
130
|
+
type: 'websocket',
|
|
131
|
+
url: 'ws://localhost:8080',
|
|
132
|
+
autoConnect: true
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
// 订阅数据更新
|
|
136
|
+
dataSourceManager.subscribe('device_01.temperature', (value) => {
|
|
137
|
+
console.log('温度更新:', value)
|
|
138
|
+
})
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## 目录结构
|
|
142
|
+
|
|
143
|
+
项目采用了清晰的模块划分:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
src/
|
|
147
|
+
├── components/ # 核心 UI 组件
|
|
148
|
+
│ ├── canvas/ # 画布组件
|
|
149
|
+
│ │ ├── ScadaCanvas.vue # 核心画布组件
|
|
150
|
+
│ │ ├── composables/ # 画布组合式 API
|
|
151
|
+
│ │ ├── config/ # 画布配置
|
|
152
|
+
│ │ └── types/ # 画布类型定义
|
|
153
|
+
│ ├── configurators/ # 配置器组件
|
|
154
|
+
│ │ ├── BindingCard.vue # 数据绑定配置
|
|
155
|
+
│ │ ├── EventCard.vue # 事件配置
|
|
156
|
+
│ │ └── ...
|
|
157
|
+
│ ├── dialogs/ # 对话框组件
|
|
158
|
+
│ │ ├── AttributeConfigDialog.vue
|
|
159
|
+
│ │ ├── CustomCodeDialog.vue
|
|
160
|
+
│ │ └── ...
|
|
161
|
+
│ ├── layout/ # 布局组件
|
|
162
|
+
│ │ ├── Header.vue # 顶部工具栏
|
|
163
|
+
│ │ └── Footer.vue # 底部版权栏
|
|
164
|
+
│ ├── panels/ # 面板组件
|
|
165
|
+
│ │ ├── PropertyPanel.vue # 属性面板
|
|
166
|
+
│ │ ├── ComponentLibrary.vue # 组件库面板
|
|
167
|
+
│ │ ├── CanvasConfigPanel.vue # 画布配置面板
|
|
168
|
+
│ │ └── ContextMenu.vue # 右键菜单
|
|
169
|
+
│ └── property-tabs/ # 属性标签页
|
|
170
|
+
│ ├── BasicPropertiesTab.vue
|
|
171
|
+
│ ├── DataPropertiesTab.vue
|
|
172
|
+
│ └── EdgePropertiesTab.vue
|
|
173
|
+
├── scada-components/ # SCADA 组件库
|
|
174
|
+
│ ├── basic/ # 基础图形组件
|
|
175
|
+
│ │ ├── rect.ts # 矩形组件
|
|
176
|
+
│ │ ├── circle.ts # 圆形组件
|
|
177
|
+
│ │ └── text.ts # 文本组件
|
|
178
|
+
│ ├── iot/ # IoT 设备组件
|
|
179
|
+
│ │ ├── echarts-gauge/ # ECharts 仪表盘
|
|
180
|
+
│ │ ├── echarts-line/ # ECharts 折线图
|
|
181
|
+
│ │ └── model3d/ # 3D 设备模型
|
|
182
|
+
│ ├── svg/ # SVG 组件系统
|
|
183
|
+
│ │ ├── core/ # SVG 核心(加载器、解析器)
|
|
184
|
+
│ │ ├── rendering/ # SVG 渲染引擎
|
|
185
|
+
│ │ ├── helpers/ # SVG 辅助工具
|
|
186
|
+
│ │ └── examples/ # SVG 示例组件
|
|
187
|
+
│ ├── canvas/ # 画布配置管理
|
|
188
|
+
│ │ ├── config.ts # 预设配置
|
|
189
|
+
│ │ ├── manager.ts # 配置管理器
|
|
190
|
+
│ │ └── types.ts # 类型定义
|
|
191
|
+
│ ├── registry.ts # 组件注册表
|
|
192
|
+
│ └── types.ts # 组件类型定义
|
|
193
|
+
├── services/ # 数据服务层
|
|
194
|
+
│ ├── dataSourceManager.ts # 数据源管理器
|
|
195
|
+
│ ├── websocketService.ts # WebSocket 服务
|
|
196
|
+
│ ├── mqttService.ts # MQTT 服务
|
|
197
|
+
│ ├── httpService.ts # HTTP 服务
|
|
198
|
+
│ ├── sseService.ts # SSE 服务
|
|
199
|
+
│ └── dataParser.ts # 数据解析器
|
|
200
|
+
├── utils/ # 工具函数与引擎核心
|
|
201
|
+
│ ├── animation/ # 动画系统
|
|
202
|
+
│ │ ├── animation-engine.ts # 动画引擎
|
|
203
|
+
│ │ └── animation-scheduler.ts # 动画调度器
|
|
204
|
+
│ ├── canvas/ # 画布操作工具
|
|
205
|
+
│ │ ├── graph-operations.ts # 画布操作
|
|
206
|
+
│ │ ├── node-operations.ts # 节点操作
|
|
207
|
+
│ │ ├── edge-operations.ts # 连线操作
|
|
208
|
+
│ │ └── layer-manager.ts # 图层管理
|
|
209
|
+
│ ├── core/ # 核心工具
|
|
210
|
+
│ │ ├── common.ts # 通用工具
|
|
211
|
+
│ │ ├── storage.ts # 本地存储
|
|
212
|
+
│ │ ├── file.ts # 文件操作
|
|
213
|
+
│ │ └── message.ts # 消息提示
|
|
214
|
+
│ ├── data/ # 数据处理
|
|
215
|
+
│ │ ├── binding-service.ts # 数据绑定服务
|
|
216
|
+
│ │ └── node-property.ts # 节点属性管理
|
|
217
|
+
│ ├── events/ # 事件系统
|
|
218
|
+
│ │ ├── event-manager.ts # 事件管理器
|
|
219
|
+
│ │ ├── event-utils.ts # 事件工具
|
|
220
|
+
│ │ └── context-menu.ts # 右键菜单
|
|
221
|
+
│ ├── integrations/ # 集成模块
|
|
222
|
+
│ │ ├── auth-crypto.ts # 授权加密
|
|
223
|
+
│ │ └── draco-loader.ts # 3D 模型加载
|
|
224
|
+
│ └── performance/ # 性能优化
|
|
225
|
+
│ ├── viewport-culling.ts # 视口裁剪
|
|
226
|
+
│ └── worker-manager.ts # Worker 管理
|
|
227
|
+
├── views/ # 视图页面
|
|
228
|
+
│ ├── workflow/ # 流程编排模块
|
|
229
|
+
│ │ ├── WorkflowDialog.vue # 流程编辑对话框
|
|
230
|
+
│ │ ├── components/ # 流程组件
|
|
231
|
+
│ │ ├── services/ # 流程服务
|
|
232
|
+
│ │ └── types/ # 流程类型
|
|
233
|
+
│ └── Preview.vue # 预览页面
|
|
234
|
+
├── types/ # 全局类型定义
|
|
235
|
+
│ ├── device.ts # 设备类型
|
|
236
|
+
│ ├── binding.ts # 绑定类型
|
|
237
|
+
│ ├── workflow.ts # 流程类型
|
|
238
|
+
│ └── ...
|
|
239
|
+
├── constants/ # 常量定义
|
|
240
|
+
│ ├── theme.ts # 主题常量
|
|
241
|
+
│ ├── layout.ts # 布局常量
|
|
242
|
+
│ └── animation.ts # 动画常量
|
|
243
|
+
├── workers/ # Web Workers
|
|
244
|
+
│ └── dataProcessor.worker.ts # 数据处理 Worker
|
|
245
|
+
├── styles/ # 全局样式
|
|
246
|
+
│ ├── theme.css # 主题样式
|
|
247
|
+
│ └── components/ # 组件样式
|
|
248
|
+
├── index.ts # 库入口文件
|
|
249
|
+
├── main.ts # 开发入口文件
|
|
250
|
+
└── App.vue # 根组件
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## 核心概念
|
|
254
|
+
|
|
255
|
+
### 画布 (ScadaCanvas)
|
|
256
|
+
|
|
257
|
+
画布是整个系统的核心,提供以下能力:
|
|
258
|
+
- **编辑模式**:用于设计组态画面。
|
|
259
|
+
- **预览模式**:用于运行展示,隐藏编辑 UI。
|
|
260
|
+
- **数据绑定**:支持将设备点位(Point)绑定到组件属性,实时更新显示。
|
|
261
|
+
|
|
262
|
+
### 组件注册系统 (ComponentRegistry)
|
|
263
|
+
|
|
264
|
+
引擎使用了懒加载注册机制来优化性能。
|
|
265
|
+
- 支持按分类(`basic`, `iot`)获取组件列表。
|
|
266
|
+
- 支持动态注册新组件。
|
|
267
|
+
|
|
268
|
+
### 数据服务 (Data Services)
|
|
269
|
+
|
|
270
|
+
引擎不强制绑定特定后端,提供了灵活的数据接入适配器:
|
|
271
|
+
- **WebSocket**:适用于高频实时数据。
|
|
272
|
+
- **MQTT**:适用于物联网消息订阅。
|
|
273
|
+
- **HTTP**:适用于请求-响应式查询。
|
|
274
|
+
- **SSE**:适用于服务器推送事件。
|
|
275
|
+
|
|
276
|
+
### 流程引擎 (Workflow Engine)
|
|
277
|
+
|
|
278
|
+
内置的可视化脚本系统,允许用户在画布上通过图形化节点编写逻辑,无需编写大量代码即可实现:
|
|
279
|
+
- 定时触发任务
|
|
280
|
+
- 条件判断分支
|
|
281
|
+
- HTTP 外部请求
|
|
282
|
+
- 自定义 JavaScript 代码执行
|
|
283
|
+
|
|
284
|
+
## API 参考
|
|
285
|
+
|
|
286
|
+
### ScadaCanvas 方法
|
|
287
|
+
|
|
288
|
+
通过 `ref` 可以直接调用画布的操作方法:
|
|
289
|
+
|
|
290
|
+
| 方法 | 说明 |
|
|
291
|
+
|------|------|
|
|
292
|
+
| **文件操作** | |
|
|
293
|
+
| `save()` | 保存当前画布数据到 LocalStorage |
|
|
294
|
+
| `exportFile()` | 导出当前画布为 JSON 文件 |
|
|
295
|
+
| `importFile()` | 触发文件选择器导入 JSON |
|
|
296
|
+
| **视图操作** | |
|
|
297
|
+
| `preview()` | 跳转到预览页面 |
|
|
298
|
+
| `workflow()` | 打开流程编排弹窗 |
|
|
299
|
+
| **画布操作** | |
|
|
300
|
+
| `zoomIn()` / `zoomOut()` | 放大/缩小画布 |
|
|
301
|
+
| `setZoom(scale)` | 设置画布缩放比例 |
|
|
302
|
+
| `clearAll()` | 清空画布所有元素 |
|
|
303
|
+
| **节点操作** | |
|
|
304
|
+
| `addNode(type)` | 添加指定类型的节点 |
|
|
305
|
+
| `updateNode(data)` | 更新节点数据 |
|
|
306
|
+
| `deleteNode()` | 删除当前选中的节点 |
|
|
307
|
+
| `getSelectedNode()` | 获取当前选中的节点 |
|
|
308
|
+
| `selectNode(nodeId)` | 选中指定节点 |
|
|
309
|
+
| `clearSelection()` | 取消选中 |
|
|
310
|
+
| **数据访问** | |
|
|
311
|
+
| `getGraph()` | 获取 X6 Graph 实例 |
|
|
312
|
+
| `getCanvasData()` | 获取画布完整数据(包含节点、连线和配置) |
|
|
313
|
+
| `loadCanvasData(data)` | 加载画布数据 |
|
|
314
|
+
| `getAllNodes()` | 获取所有节点 |
|
|
315
|
+
| `getNodeById(nodeId)` | 根据 ID 获取节点 |
|
|
316
|
+
| **画布配置** | |
|
|
317
|
+
| `getConfigManager()` | 获取画布配置管理器 |
|
|
318
|
+
| `updateCanvasConfig(config)` | 更新画布配置 |
|
|
319
|
+
| `setCanvasSize(width, height)` | 设置画布大小 |
|
|
320
|
+
| `setBackgroundColor(color)` | 设置背景颜色 |
|
|
321
|
+
| **动画控制** | |
|
|
322
|
+
| `getAnimationEngine()` | 获取动画引擎 |
|
|
323
|
+
|
|
324
|
+
### 数据结构示例
|
|
325
|
+
|
|
326
|
+
`getCanvasData()` 返回的结构大致如下:
|
|
327
|
+
|
|
328
|
+
```json
|
|
329
|
+
{
|
|
330
|
+
"version": "1.0",
|
|
331
|
+
"config": {
|
|
332
|
+
"width": 1920,
|
|
333
|
+
"height": 1080,
|
|
334
|
+
"grid": true
|
|
335
|
+
},
|
|
336
|
+
"cells": [
|
|
337
|
+
{
|
|
338
|
+
"id": "node-1",
|
|
339
|
+
"type": "rect",
|
|
340
|
+
"x": 100,
|
|
341
|
+
"y": 100,
|
|
342
|
+
"label": "电机",
|
|
343
|
+
"data": { "binding": "device_01_status" }
|
|
344
|
+
}
|
|
345
|
+
]
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## 许可证
|
|
350
|
+
|
|
351
|
+
本项目采用 MIT 许可证。内置的组件库和引擎功能可以免费用于学习和非商业项目。
|
|
352
|
+
|
|
353
|
+
**商业授权**:如需将本引擎用于商业产品并隐藏底部版权标识,请联系作者获取数字签名授权。
|
|
354
|
+
|
|
355
|
+
## 作者
|
|
356
|
+
|
|
357
|
+
- **nywqs**
|
|
358
|
+
|
|
359
|
+
如有问题或建议,欢迎提交 Issue 或联系作者。
|