scada-engine 1.0.0
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 -0
- package/README.md +193 -0
- package/dist/draco/gltf/draco_decoder.js +33 -0
- package/dist/draco/gltf/draco_decoder.wasm +0 -0
- package/dist/draco/gltf/draco_encoder.js +33 -0
- package/dist/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/dist/index.d.ts +3 -0
- package/dist/scada-engine.css +1 -0
- package/dist/scada-engine.es.js +22936 -0
- package/dist/scada-engine.umd.js +1356 -0
- package/dist/src/features/canvas/components/CanvasArea.d.ts +4 -0
- package/dist/src/features/canvas/components/CanvasConfigPanel.d.ts +2 -0
- package/dist/src/features/canvas/index.d.ts +9 -0
- package/dist/src/features/canvas/managers/configWatcher.d.ts +49 -0
- package/dist/src/features/canvas/managers/dataHandler.d.ts +70 -0
- package/dist/src/features/canvas/managers/layerManager.d.ts +88 -0
- package/dist/src/features/canvas/operations/edgeOperations.d.ts +52 -0
- package/dist/src/features/canvas/operations/graphOperations.d.ts +85 -0
- package/dist/src/features/canvas/operations/nodeOperations.d.ts +77 -0
- package/dist/src/features/data-source/components/DataSourceDialog.d.ts +26 -0
- package/dist/src/features/data-source/components/MappingConfigurator.d.ts +27 -0
- package/dist/src/features/data-source/index.d.ts +14 -0
- package/dist/src/features/data-source/services/dataBindingService.d.ts +86 -0
- package/dist/src/features/data-source/services/dataParser.d.ts +110 -0
- package/dist/src/features/data-source/services/dataSourceManager.d.ts +127 -0
- package/dist/src/features/data-source/services/httpService.d.ts +73 -0
- package/dist/src/features/data-source/services/mqttService.d.ts +110 -0
- package/dist/src/features/data-source/services/sseService.d.ts +75 -0
- package/dist/src/features/data-source/services/websocketService.d.ts +67 -0
- package/dist/src/features/data-source/types/dataAdapter.d.ts +184 -0
- package/dist/src/features/data-source/types/device.d.ts +131 -0
- package/dist/src/features/preview/Preview.d.ts +2 -0
- package/dist/src/features/preview/components/NodeTooltip.d.ts +62 -0
- package/dist/src/features/preview/index.d.ts +1 -0
- package/dist/src/features/property-panel/PropertyPanel.d.ts +45 -0
- package/dist/src/features/property-panel/cards/BindingCard.d.ts +39 -0
- package/dist/src/features/property-panel/cards/EventCard.d.ts +63 -0
- package/dist/src/features/property-panel/index.d.ts +6 -0
- package/dist/src/features/property-panel/tabs/BasicPropertiesTab.d.ts +51 -0
- package/dist/src/features/property-panel/tabs/DataPropertiesTab.d.ts +24 -0
- package/dist/src/features/property-panel/tabs/EdgePropertiesTab.d.ts +22 -0
- package/dist/src/features/workflow/WorkflowDialog.d.ts +37 -0
- package/dist/src/features/workflow/WorkflowEditor.d.ts +38 -0
- package/dist/src/features/workflow/components/AddNodeMenu.d.ts +32 -0
- package/dist/src/features/workflow/components/ElementSelector.d.ts +37 -0
- package/dist/src/features/workflow/components/PropertyPanel.d.ts +27 -0
- package/dist/src/features/workflow/components/WorkflowToolbar.d.ts +24 -0
- package/dist/src/features/workflow/components/node-configs/ClearTimerConfig.d.ts +20 -0
- package/dist/src/features/workflow/components/node-configs/ConditionConfig.d.ts +20 -0
- package/dist/src/features/workflow/components/node-configs/CustomCodeConfig.d.ts +20 -0
- package/dist/src/features/workflow/components/node-configs/GetPropertyConfig.d.ts +20 -0
- package/dist/src/features/workflow/components/node-configs/HttpRequestConfig.d.ts +20 -0
- package/dist/src/features/workflow/components/node-configs/SetPropertyConfig.d.ts +20 -0
- package/dist/src/features/workflow/components/node-configs/TimerConfig.d.ts +20 -0
- package/dist/src/features/workflow/config/nodeConfigRegistry.d.ts +5 -0
- package/dist/src/features/workflow/index.d.ts +6 -0
- package/dist/src/features/workflow/services/canvasElementService.d.ts +31 -0
- package/dist/src/features/workflow/types/element.d.ts +16 -0
- package/dist/src/features/workflow/types/node.d.ts +70 -0
- package/dist/src/index.d.ts +161 -0
- package/dist/src/main.d.ts +1 -0
- package/dist/src/scada-components/canvas/config.d.ts +17 -0
- package/dist/src/scada-components/canvas/index.d.ts +6 -0
- package/dist/src/scada-components/canvas/manager.d.ts +95 -0
- package/dist/src/scada-components/canvas/types.d.ts +77 -0
- package/dist/src/scada-components/chart/echarts-gauge/EChartsGauge.d.ts +14 -0
- package/dist/src/scada-components/chart/echarts-gauge/index.d.ts +6 -0
- package/dist/src/scada-components/chart/echarts-gauge/presets.d.ts +18 -0
- package/dist/src/scada-components/chart/echarts-line/EChartsLine.d.ts +14 -0
- package/dist/src/scada-components/chart/echarts-line/index.d.ts +6 -0
- package/dist/src/scada-components/chart/echarts-line/presets.d.ts +13 -0
- package/dist/src/scada-components/chart/index.d.ts +5 -0
- package/dist/src/scada-components/index.d.ts +7 -0
- package/dist/src/scada-components/registry.d.ts +117 -0
- package/dist/src/scada-components/types.d.ts +108 -0
- package/dist/src/shared/animation/animationEngine.d.ts +68 -0
- package/dist/src/shared/animation/animationScheduler.d.ts +85 -0
- package/dist/src/shared/animation/index.d.ts +2 -0
- package/dist/src/shared/components/ComponentLibrary.d.ts +34 -0
- package/dist/src/shared/components/ContextMenu.d.ts +63 -0
- package/dist/src/shared/components/Footer.d.ts +41 -0
- package/dist/src/shared/components/Header.d.ts +73 -0
- package/dist/src/shared/components/dialogs/AttributeConfigDialog.d.ts +39 -0
- package/dist/src/shared/components/dialogs/CustomCodeDialog.d.ts +30 -0
- package/dist/src/shared/components/dialogs/WorkflowSelectorDialog.d.ts +15 -0
- package/dist/src/shared/components/index.d.ts +8 -0
- package/dist/src/shared/components/selectors/ComponentPointSelector.d.ts +29 -0
- package/dist/src/shared/managers/contextMenuManager.d.ts +27 -0
- package/dist/src/shared/managers/eventManager.d.ts +62 -0
- package/dist/src/shared/managers/index.d.ts +3 -0
- package/dist/src/shared/managers/workerManager.d.ts +57 -0
- package/dist/src/shared/types/binding.d.ts +75 -0
- package/dist/src/shared/types/index.d.ts +2 -0
- package/dist/src/shared/types/workflow.d.ts +195 -0
- package/dist/src/shared/utils/commonUtils.d.ts +83 -0
- package/dist/src/shared/utils/edgeAnimationUtils.d.ts +16 -0
- package/dist/src/shared/utils/eventUtils.d.ts +43 -0
- package/dist/src/shared/utils/fileUtils.d.ts +43 -0
- package/dist/src/shared/utils/index.d.ts +7 -0
- package/dist/src/shared/utils/messageUtils.d.ts +56 -0
- package/dist/src/shared/utils/nodePropertyUtils.d.ts +33 -0
- package/dist/src/shared/utils/storageUtils.d.ts +32 -0
- package/dist/src/svg/core/index.d.ts +7 -0
- package/dist/src/svg/core/loader.d.ts +71 -0
- package/dist/src/svg/core/parser.d.ts +41 -0
- package/dist/src/svg/core/types.d.ts +297 -0
- package/dist/src/svg/helpers/demo.d.ts +20 -0
- package/dist/src/svg/helpers/index.d.ts +5 -0
- package/dist/src/svg/helpers/utils.d.ts +25 -0
- package/dist/src/svg/index.d.ts +9 -0
- package/dist/src/svg/rendering/SVGRenderer.d.ts +22 -0
- package/dist/src/svg/rendering/animationTemplates.d.ts +82 -0
- package/dist/src/svg/rendering/index.d.ts +6 -0
- package/dist/src/utils/authCrypto.d.ts +16 -0
- package/dist/src/utils/dracoLoader.d.ts +3 -0
- package/dist/src/utils/index.d.ts +29 -0
- package/dist/src/utils/viewportCulling.d.ts +63 -0
- package/dist/src/workers/dataProcessor.worker.d.ts +21 -0
- package/dist/utils-Ncgt7Dqu.js +1057 -0
- package/package.json +85 -0
package/LICENSE
ADDED
|
@@ -0,0 +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.
|
package/README.md
ADDED
|
@@ -0,0 +1,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 vue-router@^4.6.0 @antv/x6@^2.18.0 echarts@^5.5.0 pinia@^2.1.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
|
+
</script>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 目录结构
|
|
85
|
+
|
|
86
|
+
项目采用了清晰的模块划分:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
src/
|
|
90
|
+
├── components/ # 核心 UI 组件
|
|
91
|
+
│ ├── Header.vue # 顶部工具栏
|
|
92
|
+
│ ├── Footer.vue # 底部版权栏
|
|
93
|
+
│ ├── ScadaCanvas.vue # 核心画布组件
|
|
94
|
+
│ └── ...
|
|
95
|
+
├── scada-components/ # 业务组件库
|
|
96
|
+
│ ├── basic/ # 基础图形组件 (rect, circle, text)
|
|
97
|
+
│ ├── iot/ # IoT 设备组件 (gauge, motor, tank...)
|
|
98
|
+
│ ├── canvas/ # 画布配置管理
|
|
99
|
+
│ └── registry.ts # 组件注册表
|
|
100
|
+
├── views/workflow/ # 流程编排模块
|
|
101
|
+
├── services/ # 数据服务层
|
|
102
|
+
│ ├── websocketService.ts
|
|
103
|
+
│ ├── mqttService.ts
|
|
104
|
+
│ └── ...
|
|
105
|
+
├── utils/ # 工具函数与引擎核心
|
|
106
|
+
│ ├── animationEngine.ts # 动画引擎
|
|
107
|
+
│ ├── authCrypto.ts # 授权加密模块
|
|
108
|
+
│ └── viewportCulling.ts # 视口优化
|
|
109
|
+
└── styles/ # 样式文件
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 核心概念
|
|
113
|
+
|
|
114
|
+
### 画布 (ScadaCanvas)
|
|
115
|
+
|
|
116
|
+
画布是整个系统的核心,提供以下能力:
|
|
117
|
+
- **编辑模式**:用于设计组态画面。
|
|
118
|
+
- **预览模式**:用于运行展示,隐藏编辑 UI。
|
|
119
|
+
- **数据绑定**:支持将设备点位(Point)绑定到组件属性,实时更新显示。
|
|
120
|
+
|
|
121
|
+
### 组件注册系统 (ComponentRegistry)
|
|
122
|
+
|
|
123
|
+
引擎使用了懒加载注册机制来优化性能。
|
|
124
|
+
- 支持按分类(`basic`, `iot`)获取组件列表。
|
|
125
|
+
- 支持动态注册新组件。
|
|
126
|
+
|
|
127
|
+
### 数据服务 (Data Services)
|
|
128
|
+
|
|
129
|
+
引擎不强制绑定特定后端,提供了灵活的数据接入适配器:
|
|
130
|
+
- **WebSocket**:适用于高频实时数据。
|
|
131
|
+
- **MQTT**:适用于物联网消息订阅。
|
|
132
|
+
- **HTTP**:适用于请求-响应式查询。
|
|
133
|
+
- **SSE**:适用于服务器推送事件。
|
|
134
|
+
|
|
135
|
+
### 流程引擎 (Workflow Engine)
|
|
136
|
+
|
|
137
|
+
内置的可视化脚本系统,允许用户在画布上通过图形化节点编写逻辑,无需编写大量代码即可实现:
|
|
138
|
+
- 定时触发任务
|
|
139
|
+
- 条件判断分支
|
|
140
|
+
- HTTP 外部请求
|
|
141
|
+
- 自定义 JavaScript 代码执行
|
|
142
|
+
|
|
143
|
+
## API 参考
|
|
144
|
+
|
|
145
|
+
### ScadaCanvas 方法
|
|
146
|
+
|
|
147
|
+
通过 `ref` 可以直接调用画布的操作方法:
|
|
148
|
+
|
|
149
|
+
| 方法 | 说明 |
|
|
150
|
+
|------|------|
|
|
151
|
+
| `save()` | 保存当前画布数据到 LocalStorage |
|
|
152
|
+
| `export()` | 导出当前画布为 JSON 文件 |
|
|
153
|
+
| `import()` | 触发文件选择器导入 JSON |
|
|
154
|
+
| `getCanvasData()` | 获取画布完整数据对象(包含节点、连线和配置) |
|
|
155
|
+
| `zoomIn()` / `zoomOut()` | 放大/缩小画布 |
|
|
156
|
+
| `clearAll()` | 清空画布 |
|
|
157
|
+
|
|
158
|
+
### 数据结构示例
|
|
159
|
+
|
|
160
|
+
`getCanvasData()` 返回的结构大致如下:
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"version": "1.0",
|
|
165
|
+
"config": {
|
|
166
|
+
"width": 1920,
|
|
167
|
+
"height": 1080,
|
|
168
|
+
"grid": true
|
|
169
|
+
},
|
|
170
|
+
"cells": [
|
|
171
|
+
{
|
|
172
|
+
"id": "node-1",
|
|
173
|
+
"type": "rect",
|
|
174
|
+
"x": 100,
|
|
175
|
+
"y": 100,
|
|
176
|
+
"label": "电机",
|
|
177
|
+
"data": { "binding": "device_01_status" }
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## 许可证
|
|
184
|
+
|
|
185
|
+
本项目采用 MIT 许可证。内置的组件库和引擎功能可以免费用于学习和非商业项目。
|
|
186
|
+
|
|
187
|
+
**商业授权**:如需将本引擎用于商业产品并隐藏底部版权标识,请联系作者获取数字签名授权。
|
|
188
|
+
|
|
189
|
+
## 作者
|
|
190
|
+
|
|
191
|
+
- **nywqs**
|
|
192
|
+
|
|
193
|
+
如有问题或建议,欢迎提交 Issue 或联系作者。
|