model-action 1.0.24 → 2.0.2
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/dist/index.d.ts +13 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -0
- package/dist/modules/Action.d.ts +5 -14
- package/dist/modules/Action.d.ts.map +1 -0
- package/dist/modules/Action.js +2 -10
- package/dist/modules/Action.js.map +1 -0
- package/dist/modules/Animation.d.ts +59 -0
- package/dist/modules/Animation.d.ts.map +1 -0
- package/dist/modules/Animation.js +117 -0
- package/dist/modules/Animation.js.map +1 -0
- package/dist/modules/Building.d.ts +28 -0
- package/dist/modules/Building.d.ts.map +1 -0
- package/dist/modules/Building.js +70 -0
- package/dist/modules/Building.js.map +1 -0
- package/dist/modules/Camera.d.ts +37 -0
- package/dist/modules/Camera.d.ts.map +1 -0
- package/dist/modules/Camera.js +110 -0
- package/dist/modules/Camera.js.map +1 -0
- package/dist/modules/CameraView.d.ts +37 -0
- package/dist/modules/CameraView.d.ts.map +1 -0
- package/dist/modules/CameraView.js +110 -0
- package/dist/modules/CameraView.js.map +1 -0
- package/dist/modules/Effect.d.ts +37 -0
- package/dist/modules/Effect.d.ts.map +1 -0
- package/dist/modules/Effect.js +72 -0
- package/dist/modules/Effect.js.map +1 -0
- package/dist/modules/Environment.d.ts +22 -0
- package/dist/modules/Environment.d.ts.map +1 -0
- package/dist/modules/Environment.js +53 -0
- package/dist/modules/Environment.js.map +1 -0
- package/dist/modules/Focus.d.ts +12 -0
- package/dist/modules/Focus.d.ts.map +1 -0
- package/dist/modules/Focus.js +22 -0
- package/dist/modules/Focus.js.map +1 -0
- package/dist/modules/GameMode.d.ts +17 -0
- package/dist/modules/GameMode.d.ts.map +1 -0
- package/dist/modules/GameMode.js +36 -0
- package/dist/modules/GameMode.js.map +1 -0
- package/dist/modules/Init.d.ts +28 -0
- package/dist/modules/Init.d.ts.map +1 -0
- package/dist/modules/Init.js +81 -0
- package/dist/modules/Init.js.map +1 -0
- package/dist/modules/Path.d.ts +76 -0
- package/dist/modules/Path.d.ts.map +1 -0
- package/dist/modules/Path.js +155 -0
- package/dist/modules/Path.js.map +1 -0
- package/dist/modules/Poi.d.ts +45 -62
- package/dist/modules/Poi.d.ts.map +1 -0
- package/dist/modules/Poi.js +117 -88
- package/dist/modules/Poi.js.map +1 -0
- package/dist/modules/Routing.d.ts +23 -31
- package/dist/modules/Routing.d.ts.map +1 -0
- package/dist/modules/Routing.js +62 -63
- package/dist/modules/Routing.js.map +1 -0
- package/dist/modules/Scene.d.ts +12 -15
- package/dist/modules/Scene.d.ts.map +1 -0
- package/dist/modules/Scene.js +26 -15
- package/dist/modules/Scene.js.map +1 -0
- package/dist/modules/Status.d.ts +59 -0
- package/dist/modules/Status.d.ts.map +1 -0
- package/dist/modules/Status.js +91 -0
- package/dist/modules/Status.js.map +1 -0
- package/dist/modules/Track.d.ts +65 -22
- package/dist/modules/Track.d.ts.map +1 -0
- package/dist/modules/Track.js +128 -20
- package/dist/modules/Track.js.map +1 -0
- package/dist/modules/VideoFusion.d.ts +1 -0
- package/dist/modules/VideoFusion.d.ts.map +1 -0
- package/dist/modules/VideoFusion.js +1 -0
- package/dist/modules/VideoFusion.js.map +1 -0
- package/dist/modules/Window.d.ts +1 -0
- package/dist/modules/Window.d.ts.map +1 -0
- package/dist/modules/Window.js +1 -0
- package/dist/modules/Window.js.map +1 -0
- package/dist/peer-stream.d.ts +123 -0
- package/dist/peer-stream.d.ts.map +1 -0
- package/dist/peer-stream.js +852 -0
- package/dist/peer-stream.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +12 -4
- package/src/modules/Action.ts +5 -25
- package/src/modules/Animation.ts +171 -0
- package/src/modules/Building.ts +103 -0
- package/src/modules/CameraView.ts +175 -0
- package/src/modules/Effect.ts +127 -0
- package/src/modules/Environment.ts +81 -0
- package/src/modules/Focus.ts +33 -0
- package/src/modules/GameMode.ts +60 -0
- package/src/modules/Init.ts +104 -0
- package/src/modules/Path.ts +293 -0
- package/src/modules/Poi.ts +194 -117
- package/src/modules/Routing.ts +96 -85
- package/src/modules/Scene.ts +43 -21
- package/src/modules/Status.ts +150 -0
- package/src/peer-stream.js +938 -0
- package/src/modules/Track.ts +0 -64
- package/src/modules/VideoFusion.ts +0 -122
- package/src/modules/Window.ts +0 -40
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 状态操作方法
|
|
3
|
+
*/
|
|
4
|
+
import { Action } from "./Action";
|
|
5
|
+
|
|
6
|
+
// 状态信息
|
|
7
|
+
export interface StatusInfo {
|
|
8
|
+
id: string; // 唯一标识
|
|
9
|
+
state: string; // 状态值:normal | alarm | color=FFFFFF
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Status命令类型(不继承SendParam,因为data中没有action字段)
|
|
13
|
+
type StatusType = {
|
|
14
|
+
cmd: "status";
|
|
15
|
+
data: {
|
|
16
|
+
isLocation?: boolean; // 是否定位到第一个ID对应的设备,默认false
|
|
17
|
+
type?: string; // 变换状态的类型,非必须,如"POI"
|
|
18
|
+
infos: StatusInfo[]; // 要切换状态的设备的数据
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class StatusAction extends Action {
|
|
23
|
+
/**
|
|
24
|
+
* 切换指定ID的模型、POI等的状态
|
|
25
|
+
* @param infos 状态信息数组,包含id和state
|
|
26
|
+
* @param options 可选参数
|
|
27
|
+
* @param options.isLocation 是否定位到第一个ID对应的设备,默认false
|
|
28
|
+
* @param options.type 变换状态的类型,如"POI"
|
|
29
|
+
*/
|
|
30
|
+
static statusChange(
|
|
31
|
+
infos: StatusInfo[],
|
|
32
|
+
options?: {
|
|
33
|
+
isLocation?: boolean;
|
|
34
|
+
type?: string;
|
|
35
|
+
}
|
|
36
|
+
) {
|
|
37
|
+
const data: {
|
|
38
|
+
isLocation?: boolean;
|
|
39
|
+
type?: string;
|
|
40
|
+
infos: StatusInfo[];
|
|
41
|
+
} = {
|
|
42
|
+
infos
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// 如果提供了 isLocation,则添加(默认false,所以只有为true时才添加)
|
|
46
|
+
if (options?.isLocation !== undefined) {
|
|
47
|
+
data.isLocation = options.isLocation;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 如果提供了 type,则添加
|
|
51
|
+
if (options?.type) {
|
|
52
|
+
data.type = options.type;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const param: StatusType = {
|
|
56
|
+
cmd: "status",
|
|
57
|
+
data
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// 生成描述信息
|
|
61
|
+
let msg = '切换状态';
|
|
62
|
+
if (options?.type) {
|
|
63
|
+
msg = `切换${options.type}状态`;
|
|
64
|
+
}
|
|
65
|
+
if (infos.length === 1) {
|
|
66
|
+
msg += ` - ID: ${infos[0].id}, 状态: ${infos[0].state}`;
|
|
67
|
+
} else {
|
|
68
|
+
msg += ` - 共${infos.length}个设备`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 使用类型断言调用sendParam,因为StatusType不严格符合SendParam(缺少action字段)
|
|
72
|
+
this.sendParam(param as any, msg);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 设置设备为正常状态
|
|
77
|
+
* @param id 设备ID
|
|
78
|
+
* @param options 可选参数
|
|
79
|
+
*/
|
|
80
|
+
static setNormal(
|
|
81
|
+
id: string,
|
|
82
|
+
options?: {
|
|
83
|
+
isLocation?: boolean;
|
|
84
|
+
type?: string;
|
|
85
|
+
}
|
|
86
|
+
) {
|
|
87
|
+
this.statusChange([{ id, state: 'normal' }], options);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 设置设备为报警状态
|
|
92
|
+
* @param id 设备ID
|
|
93
|
+
* @param options 可选参数
|
|
94
|
+
*/
|
|
95
|
+
static setAlarm(
|
|
96
|
+
id: string,
|
|
97
|
+
options?: {
|
|
98
|
+
isLocation?: boolean;
|
|
99
|
+
type?: string;
|
|
100
|
+
}
|
|
101
|
+
) {
|
|
102
|
+
this.statusChange([{ id, state: 'alarm' }], options);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 设置设备颜色
|
|
107
|
+
* @param id 设备ID
|
|
108
|
+
* @param color 颜色值,格式如 "FFFFFF" 或 "93050C"(不需要#前缀)
|
|
109
|
+
* @param options 可选参数
|
|
110
|
+
*/
|
|
111
|
+
static setColor(
|
|
112
|
+
id: string,
|
|
113
|
+
color: string,
|
|
114
|
+
options?: {
|
|
115
|
+
isLocation?: boolean;
|
|
116
|
+
type?: string;
|
|
117
|
+
}
|
|
118
|
+
) {
|
|
119
|
+
// 移除可能的#前缀
|
|
120
|
+
const colorValue = color.startsWith('#') ? color.slice(1) : color;
|
|
121
|
+
this.statusChange([{ id, state: `color=${colorValue}` }], options);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 批量设置多个设备的状态
|
|
126
|
+
* @param statusMap 状态映射,key为设备ID,value为状态值(normal | alarm | color值)
|
|
127
|
+
* @param options 可选参数
|
|
128
|
+
*/
|
|
129
|
+
static batchSetStatus(
|
|
130
|
+
statusMap: Record<string, string>,
|
|
131
|
+
options?: {
|
|
132
|
+
isLocation?: boolean;
|
|
133
|
+
type?: string;
|
|
134
|
+
}
|
|
135
|
+
) {
|
|
136
|
+
const infos: StatusInfo[] = [];
|
|
137
|
+
for (const id in statusMap) {
|
|
138
|
+
if (statusMap.hasOwnProperty(id)) {
|
|
139
|
+
const state = statusMap[id];
|
|
140
|
+
// 如果state是颜色值(6位十六进制),自动添加color=前缀
|
|
141
|
+
let finalState = state;
|
|
142
|
+
if (/^[0-9A-Fa-f]{6}$/.test(state) && !state.startsWith('color=')) {
|
|
143
|
+
finalState = `color=${state}`;
|
|
144
|
+
}
|
|
145
|
+
infos.push({ id, state: finalState });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.statusChange(infos, options);
|
|
149
|
+
}
|
|
150
|
+
}
|