@nywqs/scada-engine 1.1.27 → 1.1.28
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/README.md +28 -13
- package/dist/scada-engine.css +1 -1
- package/dist/scada-engine.es.js +13685 -12370
- package/dist/scada-engine.umd.js +26 -26
- package/dist/src/components/BindingCard.d.ts +3 -6
- package/dist/src/components/{DevicePointSelector.d.ts → ComponentPointSelector.d.ts} +5 -9
- package/dist/src/components/DataPropertiesTab.d.ts +0 -2
- package/dist/src/scada-components/iot/industrial-3d-fluid.d.ts +9 -0
- package/dist/src/scada-components/registry.d.ts +4 -0
- package/dist/src/scada-components/types.d.ts +28 -3
- package/dist/src/services/dataParser.d.ts +110 -0
- package/dist/src/services/dataSourceManager.d.ts +7 -1
- package/dist/src/services/httpService.d.ts +73 -0
- package/dist/src/services/mqttService.d.ts +5 -5
- package/dist/src/services/sseService.d.ts +75 -0
- package/dist/src/services/websocketService.d.ts +67 -0
- package/dist/src/types/dataAdapter.d.ts +184 -0
- package/dist/src/utils/dataBindingService.d.ts +40 -11
- package/dist/src/views/workflow/components/WorkflowToolbar.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ComponentPoint } from '../scada-components/types';
|
|
1
2
|
import { BindingConfig } from '../types/binding';
|
|
2
3
|
|
|
3
4
|
interface NodeProperty {
|
|
@@ -10,9 +11,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
10
11
|
index: number;
|
|
11
12
|
isCollapsed: boolean;
|
|
12
13
|
nodeProperties: NodeProperty[];
|
|
13
|
-
|
|
14
|
-
nodeDeviceId?: string;
|
|
15
|
-
nodeDeviceName?: string;
|
|
14
|
+
componentPoints: ComponentPoint[];
|
|
16
15
|
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
17
16
|
"toggle-collapse": () => void;
|
|
18
17
|
remove: () => void;
|
|
@@ -22,9 +21,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
22
21
|
index: number;
|
|
23
22
|
isCollapsed: boolean;
|
|
24
23
|
nodeProperties: NodeProperty[];
|
|
25
|
-
|
|
26
|
-
nodeDeviceId?: string;
|
|
27
|
-
nodeDeviceName?: string;
|
|
24
|
+
componentPoints: ComponentPoint[];
|
|
28
25
|
}>>> & Readonly<{
|
|
29
26
|
"onToggle-collapse"?: (() => any) | undefined;
|
|
30
27
|
onRemove?: (() => any) | undefined;
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPoint } from '../scada-components/types';
|
|
2
2
|
|
|
3
3
|
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
4
4
|
visible: boolean;
|
|
5
|
-
deviceId: string;
|
|
6
|
-
deviceName?: string;
|
|
7
5
|
modelValue?: string;
|
|
8
|
-
|
|
6
|
+
componentPoints: ComponentPoint[];
|
|
9
7
|
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
10
8
|
"update:visible": (value: boolean) => void;
|
|
11
9
|
"update:modelValue": (value: string) => void;
|
|
12
|
-
confirm: (pointId: string, point:
|
|
10
|
+
confirm: (pointId: string, point: ComponentPoint) => void;
|
|
13
11
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
14
12
|
visible: boolean;
|
|
15
|
-
deviceId: string;
|
|
16
|
-
deviceName?: string;
|
|
17
13
|
modelValue?: string;
|
|
18
|
-
|
|
14
|
+
componentPoints: ComponentPoint[];
|
|
19
15
|
}>>> & Readonly<{
|
|
20
16
|
"onUpdate:visible"?: ((value: boolean) => any) | undefined;
|
|
21
17
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
22
|
-
onConfirm?: ((pointId: string, point:
|
|
18
|
+
onConfirm?: ((pointId: string, point: ComponentPoint) => any) | undefined;
|
|
23
19
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
24
20
|
export default _default;
|
|
25
21
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
@@ -6,12 +6,10 @@ interface Props {
|
|
|
6
6
|
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<Props>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
7
7
|
"update-data-source": (config: {
|
|
8
8
|
dataSourceId: string;
|
|
9
|
-
deviceId: string;
|
|
10
9
|
}) => void;
|
|
11
10
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<Props>>> & Readonly<{
|
|
12
11
|
"onUpdate-data-source"?: ((config: {
|
|
13
12
|
dataSourceId: string;
|
|
14
|
-
deviceId: string;
|
|
15
13
|
}) => any) | undefined;
|
|
16
14
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
17
15
|
export default _default;
|
|
@@ -4,6 +4,15 @@ import { ComponentConfig } from '../types';
|
|
|
4
4
|
* 3D管道组件配置
|
|
5
5
|
*/
|
|
6
6
|
export declare const Pipe3DComponent: ComponentConfig;
|
|
7
|
+
/**
|
|
8
|
+
* 3D过滤器组件配置
|
|
9
|
+
*/
|
|
7
10
|
export declare const Filter3DComponent: ComponentConfig;
|
|
11
|
+
/**
|
|
12
|
+
* 3D换热器组件配置
|
|
13
|
+
*/
|
|
8
14
|
export declare const HeatExchanger3DComponent: ComponentConfig;
|
|
15
|
+
/**
|
|
16
|
+
* 3D三通组件配置
|
|
17
|
+
*/
|
|
9
18
|
export declare const Tee3DComponent: ComponentConfig;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
import { ComponentDataAdapter } from '../types/dataAdapter';
|
|
2
|
+
|
|
4
3
|
/**
|
|
5
4
|
* 属性配置类型
|
|
6
5
|
*/
|
|
@@ -57,6 +56,30 @@ export interface ComponentData {
|
|
|
57
56
|
property?: string;
|
|
58
57
|
[key: string]: any;
|
|
59
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* 组件点位定义(组件预定义的数据点)
|
|
61
|
+
*/
|
|
62
|
+
export interface ComponentPoint {
|
|
63
|
+
/** 点位ID(组件内部标识) */
|
|
64
|
+
id: string;
|
|
65
|
+
/** 点位名称 */
|
|
66
|
+
name: string;
|
|
67
|
+
/** 点位描述 */
|
|
68
|
+
description?: string;
|
|
69
|
+
/** 数据类型 */
|
|
70
|
+
dataType: 'boolean' | 'number' | 'string' | 'json';
|
|
71
|
+
/** 单位 */
|
|
72
|
+
unit?: string;
|
|
73
|
+
/** 默认值 */
|
|
74
|
+
defaultValue?: any;
|
|
75
|
+
/** 是否必需 */
|
|
76
|
+
required?: boolean;
|
|
77
|
+
/** 数值范围(仅number类型) */
|
|
78
|
+
range?: {
|
|
79
|
+
min?: number;
|
|
80
|
+
max?: number;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
60
83
|
/**
|
|
61
84
|
* 组件配置
|
|
62
85
|
*/
|
|
@@ -71,6 +94,8 @@ export interface ComponentConfig {
|
|
|
71
94
|
ports?: any;
|
|
72
95
|
props: ComponentProp[];
|
|
73
96
|
component?: any;
|
|
97
|
+
dataAdapter?: ComponentDataAdapter;
|
|
98
|
+
points?: ComponentPoint[];
|
|
74
99
|
}
|
|
75
100
|
/**
|
|
76
101
|
* 组件注册表
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 数据解析工具
|
|
3
|
+
* 提供通用的数据格式解析和转换功能
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 设备数据接口
|
|
7
|
+
*/
|
|
8
|
+
export interface DeviceData {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
points: Array<{
|
|
12
|
+
id: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
value: any;
|
|
15
|
+
quality?: 'good' | 'bad' | 'uncertain';
|
|
16
|
+
timestamp?: string;
|
|
17
|
+
unit?: string;
|
|
18
|
+
dataType?: 'number' | 'boolean' | 'string';
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 数据解析器类
|
|
23
|
+
*/
|
|
24
|
+
export declare class DataParser {
|
|
25
|
+
/**
|
|
26
|
+
* 自动解析设备数据(支持多种格式)
|
|
27
|
+
* @param data 原始数据
|
|
28
|
+
* @param defaultDeviceId 默认设备ID(用于简化点位数组格式)
|
|
29
|
+
* @param defaultDeviceName 默认设备名称(用于简化点位数组格式)
|
|
30
|
+
*/
|
|
31
|
+
static parseDeviceData(data: any, defaultDeviceId?: string, defaultDeviceName?: string): DeviceData | null;
|
|
32
|
+
/**
|
|
33
|
+
* 检查是否为简化点位数组格式
|
|
34
|
+
*/
|
|
35
|
+
private static isSimplifiedPointsArray;
|
|
36
|
+
/**
|
|
37
|
+
* 解析简化点位数组格式
|
|
38
|
+
*/
|
|
39
|
+
private static parseSimplifiedPointsArray;
|
|
40
|
+
/**
|
|
41
|
+
* 检查是否为标准格式
|
|
42
|
+
*/
|
|
43
|
+
private static isStandardFormat;
|
|
44
|
+
/**
|
|
45
|
+
* 解析标准格式
|
|
46
|
+
*/
|
|
47
|
+
private static parseStandardFormat;
|
|
48
|
+
/**
|
|
49
|
+
* 检查是否为单点位格式
|
|
50
|
+
*/
|
|
51
|
+
private static isSinglePointFormat;
|
|
52
|
+
/**
|
|
53
|
+
* 解析单点位格式
|
|
54
|
+
*/
|
|
55
|
+
private static parseSinglePointFormat;
|
|
56
|
+
/**
|
|
57
|
+
* 检查是否为扁平化格式
|
|
58
|
+
*/
|
|
59
|
+
private static isFlatFormat;
|
|
60
|
+
/**
|
|
61
|
+
* 解析扁平化格式
|
|
62
|
+
*/
|
|
63
|
+
private static parseFlatFormat;
|
|
64
|
+
/**
|
|
65
|
+
* 检查是否为嵌套格式
|
|
66
|
+
*/
|
|
67
|
+
private static isNestedFormat;
|
|
68
|
+
/**
|
|
69
|
+
* 解析嵌套格式
|
|
70
|
+
*/
|
|
71
|
+
private static parseNestedFormat;
|
|
72
|
+
/**
|
|
73
|
+
* 推断数据类型
|
|
74
|
+
*/
|
|
75
|
+
private static inferDataType;
|
|
76
|
+
/**
|
|
77
|
+
* 创建自定义解析器
|
|
78
|
+
* @param mappingConfig 字段映射配置
|
|
79
|
+
* @returns 解析函数
|
|
80
|
+
*/
|
|
81
|
+
static createCustomParser(mappingConfig: {
|
|
82
|
+
deviceId: string | ((data: any) => string);
|
|
83
|
+
deviceName?: string | ((data: any) => string);
|
|
84
|
+
points: string | ((data: any) => any[]);
|
|
85
|
+
pointId?: string | ((data: any, point: any) => string);
|
|
86
|
+
pointValue?: string | ((data: any, point: any) => any);
|
|
87
|
+
}): (data: any) => DeviceData;
|
|
88
|
+
/**
|
|
89
|
+
* 通过路径获取值
|
|
90
|
+
*/
|
|
91
|
+
private static getValueByPath;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 常用解析器预设
|
|
95
|
+
*/
|
|
96
|
+
export declare const ParserPresets: {
|
|
97
|
+
/**
|
|
98
|
+
* 物联网平台标准格式
|
|
99
|
+
*/
|
|
100
|
+
iotPlatform: (data: any) => DeviceData;
|
|
101
|
+
/**
|
|
102
|
+
* Modbus 格式
|
|
103
|
+
*/
|
|
104
|
+
modbus: (data: any) => DeviceData;
|
|
105
|
+
/**
|
|
106
|
+
* OPC UA 格式
|
|
107
|
+
*/
|
|
108
|
+
opcua: (data: any) => DeviceData;
|
|
109
|
+
};
|
|
110
|
+
export declare const defaultParser: typeof DataParser.parseDeviceData;
|
|
@@ -22,6 +22,7 @@ export interface DataSource {
|
|
|
22
22
|
eventType?: string;
|
|
23
23
|
dataPath?: string;
|
|
24
24
|
retryCount?: number;
|
|
25
|
+
customParser?: (data: any) => any;
|
|
25
26
|
};
|
|
26
27
|
status?: {
|
|
27
28
|
connected: boolean;
|
|
@@ -100,9 +101,14 @@ export declare class DataSourceManager {
|
|
|
100
101
|
*/
|
|
101
102
|
private connectSSE;
|
|
102
103
|
/**
|
|
103
|
-
*
|
|
104
|
+
* 处理接收到的原始数据
|
|
105
|
+
* 解析并更新设备列表,然后传递给回调
|
|
104
106
|
*/
|
|
105
107
|
private handleDeviceData;
|
|
108
|
+
/**
|
|
109
|
+
* 解析并更新设备列表
|
|
110
|
+
*/
|
|
111
|
+
private parseAndUpdateDevices;
|
|
106
112
|
/**
|
|
107
113
|
* 注册数据接收回调
|
|
108
114
|
*/
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP 轮询服务模块
|
|
3
|
+
* 负责 HTTP 轮询原始数据接收
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* HTTP 配置接口
|
|
7
|
+
*/
|
|
8
|
+
export interface HttpConfig {
|
|
9
|
+
/** 接口地址 */
|
|
10
|
+
url: string;
|
|
11
|
+
/** 请求方法 */
|
|
12
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
13
|
+
/** 轮询间隔(ms) */
|
|
14
|
+
pollInterval?: number;
|
|
15
|
+
/** 请求头 */
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
/** 请求体(POST/PUT) */
|
|
18
|
+
body?: any;
|
|
19
|
+
/** 数据路径(用于解析嵌套数据) */
|
|
20
|
+
dataPath?: string;
|
|
21
|
+
/** 启用状态 */
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
/** 超时时间(ms) */
|
|
24
|
+
timeout?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* HTTP 轮询服务类
|
|
28
|
+
*/
|
|
29
|
+
export declare class HttpService {
|
|
30
|
+
private config;
|
|
31
|
+
private onDataCallback;
|
|
32
|
+
private onErrorCallback;
|
|
33
|
+
private onStatusChangeCallback;
|
|
34
|
+
private intervalId;
|
|
35
|
+
private isPolling;
|
|
36
|
+
private abortController;
|
|
37
|
+
/**
|
|
38
|
+
* 启动轮询
|
|
39
|
+
*/
|
|
40
|
+
start(config: HttpConfig): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* 执行轮询请求
|
|
43
|
+
*/
|
|
44
|
+
private poll;
|
|
45
|
+
/**
|
|
46
|
+
* 设置数据接收回调
|
|
47
|
+
*/
|
|
48
|
+
onData(callback: (data: any) => void): void;
|
|
49
|
+
/**
|
|
50
|
+
* 设置错误回调
|
|
51
|
+
*/
|
|
52
|
+
onError(callback: (error: Error) => void): void;
|
|
53
|
+
/**
|
|
54
|
+
* 设置状态变化回调
|
|
55
|
+
*/
|
|
56
|
+
onStatusChange(callback: (connected: boolean) => void): void;
|
|
57
|
+
/**
|
|
58
|
+
* 停止轮询
|
|
59
|
+
*/
|
|
60
|
+
stop(): void;
|
|
61
|
+
/**
|
|
62
|
+
* 获取轮询状态
|
|
63
|
+
*/
|
|
64
|
+
getPollingStatus(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* 获取当前配置
|
|
67
|
+
*/
|
|
68
|
+
getConfig(): HttpConfig | null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 创建 HTTP 服务实例
|
|
72
|
+
*/
|
|
73
|
+
export declare function createHttpService(): HttpService;
|
|
@@ -69,16 +69,12 @@ export declare class MqttService {
|
|
|
69
69
|
private config;
|
|
70
70
|
private onDataCallback;
|
|
71
71
|
private onErrorCallback;
|
|
72
|
+
private onStatusChangeCallback;
|
|
72
73
|
private isConnected;
|
|
73
74
|
/**
|
|
74
75
|
* 连接 MQTT 服务器
|
|
75
76
|
*/
|
|
76
77
|
connect(config: MqttConfig): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* 解析设备数据
|
|
79
|
-
* 支持多种数据格式
|
|
80
|
-
*/
|
|
81
|
-
private parseDeviceData;
|
|
82
78
|
/**
|
|
83
79
|
* 设置数据接收回调
|
|
84
80
|
*/
|
|
@@ -87,6 +83,10 @@ export declare class MqttService {
|
|
|
87
83
|
* 设置错误回调
|
|
88
84
|
*/
|
|
89
85
|
onError(callback: (error: Error) => void): void;
|
|
86
|
+
/**
|
|
87
|
+
* 设置连接状态变化回调
|
|
88
|
+
*/
|
|
89
|
+
onStatusChange(callback: (connected: boolean) => void): void;
|
|
90
90
|
/**
|
|
91
91
|
* 发布消息
|
|
92
92
|
*/
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE (Server-Sent Events) 服务模块
|
|
3
|
+
* 负责 SSE 连接管理和原始数据接收
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* SSE 配置接口
|
|
7
|
+
*/
|
|
8
|
+
export interface SseConfig {
|
|
9
|
+
/** SSE 服务地址 */
|
|
10
|
+
url: string;
|
|
11
|
+
/** 事件类型(默认 'message') */
|
|
12
|
+
eventType?: string;
|
|
13
|
+
/** 数据路径(用于解析嵌套数据) */
|
|
14
|
+
dataPath?: string;
|
|
15
|
+
/** 启用状态 */
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
/** 自动重连 */
|
|
18
|
+
autoReconnect?: boolean;
|
|
19
|
+
/** 重连延迟(ms) */
|
|
20
|
+
reconnectDelay?: number;
|
|
21
|
+
/** 请求头(用于认证等) */
|
|
22
|
+
withCredentials?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* SSE 服务类
|
|
26
|
+
*/
|
|
27
|
+
export declare class SseService {
|
|
28
|
+
private eventSource;
|
|
29
|
+
private config;
|
|
30
|
+
private onDataCallback;
|
|
31
|
+
private onErrorCallback;
|
|
32
|
+
private onStatusChangeCallback;
|
|
33
|
+
private isConnected;
|
|
34
|
+
private reconnectTimer;
|
|
35
|
+
/**
|
|
36
|
+
* 连接 SSE 服务器
|
|
37
|
+
*/
|
|
38
|
+
connect(config: SseConfig): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* 处理接收到的消息
|
|
41
|
+
*/
|
|
42
|
+
private handleMessage;
|
|
43
|
+
/**
|
|
44
|
+
* 设置数据接收回调
|
|
45
|
+
*/
|
|
46
|
+
onData(callback: (data: any) => void): void;
|
|
47
|
+
/**
|
|
48
|
+
* 设置错误回调
|
|
49
|
+
*/
|
|
50
|
+
onError(callback: (error: Error) => void): void;
|
|
51
|
+
/**
|
|
52
|
+
* 设置状态变化回调
|
|
53
|
+
*/
|
|
54
|
+
onStatusChange(callback: (connected: boolean) => void): void;
|
|
55
|
+
/**
|
|
56
|
+
* 断开连接
|
|
57
|
+
*/
|
|
58
|
+
disconnect(): void;
|
|
59
|
+
/**
|
|
60
|
+
* 获取连接状态
|
|
61
|
+
*/
|
|
62
|
+
getConnectionStatus(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* 获取当前配置
|
|
65
|
+
*/
|
|
66
|
+
getConfig(): SseConfig | null;
|
|
67
|
+
/**
|
|
68
|
+
* 获取 EventSource readyState
|
|
69
|
+
*/
|
|
70
|
+
getReadyState(): number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 创建 SSE 服务实例
|
|
74
|
+
*/
|
|
75
|
+
export declare function createSseService(): SseService;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket 服务模块
|
|
3
|
+
* 负责 WebSocket 连接管理和原始数据接收
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* WebSocket 配置接口
|
|
7
|
+
*/
|
|
8
|
+
export interface WebSocketConfig {
|
|
9
|
+
/** WebSocket 服务地址 */
|
|
10
|
+
url: string;
|
|
11
|
+
/** 数据路径(用于解析嵌套数据) */
|
|
12
|
+
dataPath?: string;
|
|
13
|
+
/** 启用状态 */
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
/** 自动重连 */
|
|
16
|
+
autoReconnect?: boolean;
|
|
17
|
+
/** 重连延迟(ms) */
|
|
18
|
+
reconnectDelay?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* WebSocket 服务类
|
|
22
|
+
*/
|
|
23
|
+
export declare class WebSocketService {
|
|
24
|
+
private ws;
|
|
25
|
+
private config;
|
|
26
|
+
private onDataCallback;
|
|
27
|
+
private onErrorCallback;
|
|
28
|
+
private onStatusChangeCallback;
|
|
29
|
+
private isConnected;
|
|
30
|
+
private reconnectTimer;
|
|
31
|
+
/**
|
|
32
|
+
* 连接 WebSocket 服务器
|
|
33
|
+
*/
|
|
34
|
+
connect(config: WebSocketConfig): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* 发送消息
|
|
37
|
+
*/
|
|
38
|
+
send(data: any): void;
|
|
39
|
+
/**
|
|
40
|
+
* 设置数据接收回调
|
|
41
|
+
*/
|
|
42
|
+
onData(callback: (data: any) => void): void;
|
|
43
|
+
/**
|
|
44
|
+
* 设置错误回调
|
|
45
|
+
*/
|
|
46
|
+
onError(callback: (error: Error) => void): void;
|
|
47
|
+
/**
|
|
48
|
+
* 设置状态变化回调
|
|
49
|
+
*/
|
|
50
|
+
onStatusChange(callback: (connected: boolean) => void): void;
|
|
51
|
+
/**
|
|
52
|
+
* 断开连接
|
|
53
|
+
*/
|
|
54
|
+
disconnect(): void;
|
|
55
|
+
/**
|
|
56
|
+
* 获取连接状态
|
|
57
|
+
*/
|
|
58
|
+
getConnectionStatus(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* 获取当前配置
|
|
61
|
+
*/
|
|
62
|
+
getConfig(): WebSocketConfig | null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 创建 WebSocket 服务实例
|
|
66
|
+
*/
|
|
67
|
+
export declare function createWebSocketService(): WebSocketService;
|