@ray-js/robot-data-stream 0.0.14 → 0.0.15-beta.10
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/lib/api/sweeperP2p.js +1 -1
- package/lib/mqtt/createCommonOptions.d.ts +4 -2
- package/lib/mqtt/createCommonOptions.js +10 -5
- package/lib/mqtt/hooks/useStructuredMessage.d.ts +17 -0
- package/lib/mqtt/hooks/useStructuredMessage.js +206 -0
- package/lib/mqtt/mqttProvider.d.ts +28 -1
- package/lib/mqtt/mqttProvider.js +72 -9
- package/lib/mqtt/promise.d.ts +57 -4
- package/lib/mqtt/promise.js +115 -36
- package/lib/mqtt/type/fun.d.ts +233 -0
- package/lib/mqtt/type/fun.js +145 -0
- package/lib/mqtt/type/index.d.ts +0 -7
- package/lib/mqtt/type/index.js +0 -1
- package/lib/mqtt/type/protocols/base.d.ts +21 -0
- package/lib/mqtt/type/protocols/base.js +32 -0
- package/lib/mqtt/type/protocols/carpetCleanProtocol.d.ts +14 -0
- package/lib/mqtt/type/protocols/carpetCleanProtocol.js +14 -0
- package/lib/mqtt/type/protocols/carpetProtocol.d.ts +102 -0
- package/lib/mqtt/type/protocols/carpetProtocol.js +202 -0
- package/lib/mqtt/type/protocols/devInfoProtocol.d.ts +11 -0
- package/lib/mqtt/type/protocols/devInfoProtocol.js +10 -0
- package/lib/mqtt/type/protocols/deviceModelProtocol.d.ts +31 -0
- package/lib/mqtt/type/protocols/deviceModelProtocol.js +32 -0
- package/lib/mqtt/type/protocols/furnitureModelProtocol.d.ts +27 -0
- package/lib/mqtt/type/protocols/furnitureModelProtocol.js +27 -0
- package/lib/mqtt/type/protocols/historyMapProtocol.d.ts +39 -0
- package/lib/mqtt/type/protocols/historyMapProtocol.js +37 -0
- package/lib/mqtt/type/protocols/index.d.ts +20 -0
- package/lib/mqtt/type/protocols/index.js +20 -0
- package/lib/mqtt/type/protocols/partDivisionProtocol.d.ts +20 -0
- package/lib/mqtt/type/protocols/partDivisionProtocol.js +12 -0
- package/lib/mqtt/type/protocols/partMergeProtocol.d.ts +13 -0
- package/lib/mqtt/type/protocols/partMergeProtocol.js +12 -0
- package/lib/mqtt/type/protocols/passwordProtocol.d.ts +24 -0
- package/lib/mqtt/type/protocols/passwordProtocol.js +25 -0
- package/lib/mqtt/type/protocols/quietHoursProtocol.d.ts +29 -0
- package/lib/mqtt/type/protocols/quietHoursProtocol.js +35 -0
- package/lib/mqtt/type/protocols/resetMapProtocol.d.ts +4 -0
- package/lib/mqtt/type/protocols/resetMapProtocol.js +1 -0
- package/lib/mqtt/type/protocols/roomPropertyProtocol.d.ts +42 -0
- package/lib/mqtt/type/protocols/roomPropertyProtocol.js +113 -0
- package/lib/mqtt/type/protocols/scheduleProtocol.d.ts +62 -0
- package/lib/mqtt/type/protocols/scheduleProtocol.js +100 -0
- package/lib/mqtt/type/protocols/selectRoomCleanProtocol.d.ts +27 -0
- package/lib/mqtt/type/protocols/selectRoomCleanProtocol.js +40 -0
- package/lib/mqtt/type/protocols/spotCleanProtocol.d.ts +38 -0
- package/lib/mqtt/type/protocols/spotCleanProtocol.js +72 -0
- package/lib/mqtt/type/protocols/virtualAreaProtocol.d.ts +32 -0
- package/lib/mqtt/type/protocols/virtualAreaProtocol.js +36 -0
- package/lib/mqtt/type/protocols/virtualWallProtocol.d.ts +27 -0
- package/lib/mqtt/type/protocols/virtualWallProtocol.js +25 -0
- package/lib/mqtt/type/protocols/voiceProtocol.d.ts +21 -0
- package/lib/mqtt/type/protocols/voiceProtocol.js +23 -0
- package/lib/mqtt/type/protocols/wifiMapProtocol.d.ts +16 -0
- package/lib/mqtt/type/protocols/wifiMapProtocol.js +14 -0
- package/lib/mqtt/type/protocols/zoneCleanProtocol.d.ts +47 -0
- package/lib/mqtt/type/protocols/zoneCleanProtocol.js +49 -0
- package/lib/mqtt/useCarpet.d.ts +7 -67
- package/lib/mqtt/useCarpet.js +101 -181
- package/lib/mqtt/useCarpetClean.d.ts +2 -11
- package/lib/mqtt/useCarpetClean.js +26 -50
- package/lib/mqtt/useDevInfo.d.ts +8 -6
- package/lib/mqtt/useDevInfo.js +44 -36
- package/lib/mqtt/useDeviceModel.d.ts +6 -19
- package/lib/mqtt/useDeviceModel.js +31 -42
- package/lib/mqtt/useFurnitureModel.d.ts +6 -18
- package/lib/mqtt/useFurnitureModel.js +31 -43
- package/lib/mqtt/useHistoryMap.d.ts +2 -18
- package/lib/mqtt/useHistoryMap.js +102 -119
- package/lib/mqtt/usePartDivision.d.ts +2 -9
- package/lib/mqtt/usePartDivision.js +48 -57
- package/lib/mqtt/usePartMerge.d.ts +2 -8
- package/lib/mqtt/usePartMerge.js +34 -49
- package/lib/mqtt/usePassword.d.ts +6 -13
- package/lib/mqtt/usePassword.js +84 -74
- package/lib/mqtt/useQuiteHours.d.ts +4 -37
- package/lib/mqtt/useQuiteHours.js +66 -100
- package/lib/mqtt/useResetMap.d.ts +2 -8
- package/lib/mqtt/useResetMap.js +27 -34
- package/lib/mqtt/useRoomProperty.d.ts +8 -9
- package/lib/mqtt/useRoomProperty.js +67 -65
- package/lib/mqtt/useSchedule.d.ts +3 -23
- package/lib/mqtt/useSchedule.js +72 -101
- package/lib/mqtt/useSelectRoomClean.d.ts +3 -24
- package/lib/mqtt/useSelectRoomClean.js +107 -133
- package/lib/mqtt/useSpotClean.d.ts +5 -15
- package/lib/mqtt/useSpotClean.js +68 -121
- package/lib/mqtt/useVirtualArea.d.ts +6 -17
- package/lib/mqtt/useVirtualArea.js +109 -119
- package/lib/mqtt/useVirtualWall.d.ts +2 -18
- package/lib/mqtt/useVirtualWall.js +69 -90
- package/lib/mqtt/useVoice.d.ts +2 -16
- package/lib/mqtt/useVoice.js +48 -68
- package/lib/mqtt/useWifiMap.d.ts +6 -5
- package/lib/mqtt/useWifiMap.js +43 -42
- package/lib/mqtt/useZoneClean.d.ts +2 -21
- package/lib/mqtt/useZoneClean.js +125 -137
- package/lib/myLib/zod/mini/index.d.cts +1 -0
- package/lib/myLib/zod/mini/index.d.ts +1 -0
- package/lib/myLib/zod/mini/index.js +1 -0
- package/lib/myLib/zod/mini/package.json +6 -0
- package/lib/myLib/zod/src/mini/index.d.ts +1 -0
- package/lib/myLib/zod/src/mini/index.js +1 -0
- package/lib/myLib/zod/src/v4/core/api.d.ts +306 -0
- package/lib/myLib/zod/src/v4/core/api.js +1256 -0
- package/lib/myLib/zod/src/v4/core/checks.d.ts +278 -0
- package/lib/myLib/zod/src/v4/core/checks.js +816 -0
- package/lib/myLib/zod/src/v4/core/config.d.ts +9 -0
- package/lib/myLib/zod/src/v4/core/config.js +5 -0
- package/lib/myLib/zod/src/v4/core/core.d.ts +70 -0
- package/lib/myLib/zod/src/v4/core/core.js +95 -0
- package/lib/myLib/zod/src/v4/core/doc.d.ts +14 -0
- package/lib/myLib/zod/src/v4/core/doc.js +42 -0
- package/lib/myLib/zod/src/v4/core/errors.d.ts +220 -0
- package/lib/myLib/zod/src/v4/core/errors.js +232 -0
- package/lib/myLib/zod/src/v4/core/index.d.ts +15 -0
- package/lib/myLib/zod/src/v4/core/index.js +15 -0
- package/lib/myLib/zod/src/v4/core/json-schema-generator.d.ts +65 -0
- package/lib/myLib/zod/src/v4/core/json-schema-generator.js +120 -0
- package/lib/myLib/zod/src/v4/core/json-schema-processors.d.ts +49 -0
- package/lib/myLib/zod/src/v4/core/json-schema-processors.js +593 -0
- package/lib/myLib/zod/src/v4/core/json-schema.d.ts +88 -0
- package/lib/myLib/zod/src/v4/core/json-schema.js +1 -0
- package/lib/myLib/zod/src/v4/core/parse.d.ts +49 -0
- package/lib/myLib/zod/src/v4/core/parse.js +147 -0
- package/lib/myLib/zod/src/v4/core/regexes.d.ts +78 -0
- package/lib/myLib/zod/src/v4/core/regexes.js +146 -0
- package/lib/myLib/zod/src/v4/core/registries.d.ts +35 -0
- package/lib/myLib/zod/src/v4/core/registries.js +51 -0
- package/lib/myLib/zod/src/v4/core/schemas.d.ts +1136 -0
- package/lib/myLib/zod/src/v4/core/schemas.js +2745 -0
- package/lib/myLib/zod/src/v4/core/standard-schema.d.ts +126 -0
- package/lib/myLib/zod/src/v4/core/standard-schema.js +1 -0
- package/lib/myLib/zod/src/v4/core/to-json-schema.d.ts +114 -0
- package/lib/myLib/zod/src/v4/core/to-json-schema.js +488 -0
- package/lib/myLib/zod/src/v4/core/util.d.ts +199 -0
- package/lib/myLib/zod/src/v4/core/util.js +656 -0
- package/lib/myLib/zod/src/v4/core/versions.d.ts +5 -0
- package/lib/myLib/zod/src/v4/core/versions.js +5 -0
- package/lib/myLib/zod/src/v4/core/zsf.d.ts +91 -0
- package/lib/myLib/zod/src/v4/core/zsf.js +1 -0
- package/lib/myLib/zod/src/v4/mini/checks.d.ts +1 -0
- package/lib/myLib/zod/src/v4/mini/checks.js +1 -0
- package/lib/myLib/zod/src/v4/mini/coerce.d.ts +7 -0
- package/lib/myLib/zod/src/v4/mini/coerce.js +27 -0
- package/lib/myLib/zod/src/v4/mini/external.d.ts +11 -0
- package/lib/myLib/zod/src/v4/mini/external.js +16 -0
- package/lib/myLib/zod/src/v4/mini/index.d.ts +530 -0
- package/lib/myLib/zod/src/v4/mini/index.js +30 -0
- package/lib/myLib/zod/src/v4/mini/iso.d.ts +22 -0
- package/lib/myLib/zod/src/v4/mini/iso.js +46 -0
- package/lib/myLib/zod/src/v4/mini/parse.d.ts +1 -0
- package/lib/myLib/zod/src/v4/mini/parse.js +1 -0
- package/lib/myLib/zod/src/v4/mini/schemas.js +1244 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +2 -1
- package/package.json +5 -3
package/lib/mqtt/useWifiMap.js
CHANGED
|
@@ -1,53 +1,54 @@
|
|
|
1
|
-
import { createSetCommonParams } from './createCommonOptions';
|
|
2
|
-
import { normalResolve } from './promise';
|
|
3
1
|
import { WifiMapEnum } from './type';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import { useStructuredMessage, handleMqttError } from './hooks/useStructuredMessage';
|
|
3
|
+
import { validator } from './type/fun';
|
|
4
|
+
/**
|
|
5
|
+
* 自定义 Hook,用于 WiFi 地图管理
|
|
6
|
+
* @returns 包含 requestWifiMap 和 setWifiMap 函数的对象
|
|
7
|
+
*/
|
|
8
|
+
export const useWifiMap = () => {
|
|
7
9
|
const {
|
|
8
|
-
|
|
9
|
-
} =
|
|
10
|
+
sendStructuredMessage
|
|
11
|
+
} = useStructuredMessage();
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
/**
|
|
14
|
+
* 请求 WiFi 地图状态
|
|
15
|
+
* @param data 可选参数(目前为空对象)
|
|
16
|
+
* @returns Promise<WifiMapResponse> 响应结果
|
|
17
|
+
*/
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
/**
|
|
20
|
+
* 设置 WiFi 地图
|
|
21
|
+
* @param data 包含 taskId 的参数对象(taskId 可选,不提供时自动生成)
|
|
22
|
+
* @returns Promise<WifiMapResponse> 响应结果
|
|
23
|
+
*/
|
|
14
24
|
|
|
15
25
|
return {
|
|
16
26
|
requestWifiMap: () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
ty.device.sendMqttMessage(params);
|
|
26
|
-
const {
|
|
27
|
-
taskId
|
|
28
|
-
} = params.message;
|
|
29
|
-
return normalResolve(WifiMapEnum.query, taskId);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
return Promise.reject(error instanceof Error ? error : new Error('Failed to request WiFi map'));
|
|
32
|
-
}
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
try {
|
|
29
|
+
sendStructuredMessage(WifiMapEnum.query, {}, resolve, error => reject(handleMqttError(error, 'Failed to request WiFi map')));
|
|
30
|
+
} catch (error) {
|
|
31
|
+
reject(handleMqttError(error, 'Failed to request WiFi map'));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
33
34
|
},
|
|
34
|
-
setWifiMap: ()
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
taskId: String(Date.now())
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
35
|
+
setWifiMap: function () {
|
|
36
|
+
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
try {
|
|
39
|
+
// 如果没有提供 taskId,自动生成
|
|
40
|
+
const wifiMapData = {
|
|
41
|
+
taskId: data.taskId || String(Date.now())
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// 使用 TypeBox Schema 进行参数验证
|
|
45
|
+
const validatedData = validator.validate('set_wifi_map', wifiMapData);
|
|
46
|
+
sendStructuredMessage(WifiMapEnum.set, validatedData, resolve, error => reject(handleMqttError(error, 'Failed to set WiFi map')), WifiMapEnum.rst // 响应类型是 rst,不是 set
|
|
47
|
+
);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
reject(handleMqttError(error, 'Failed to set WiFi map'));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
54
|
};
|
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Point, Zone } from '@ray-js/robot-protocol';
|
|
3
|
-
interface ZoneCleanResponse extends BaseResponse {
|
|
4
|
-
reqType: ZoneCleanEnum.query;
|
|
5
|
-
polygons: string[];
|
|
6
|
-
names?: string[];
|
|
7
|
-
suctions?: string[];
|
|
8
|
-
cisterns?: string[];
|
|
9
|
-
cleanCounts?: number[];
|
|
10
|
-
yMops?: number[];
|
|
11
|
-
sweepMopModes?: string[];
|
|
12
|
-
}
|
|
13
|
-
interface SetZoneCleanParams extends Partial<Pick<RoomPreference, 'suctions' | 'cisterns' | 'cleanCounts' | 'yMops' | 'sweepMopModes'>> {
|
|
14
|
-
zones: Zone[];
|
|
15
|
-
origin: Point;
|
|
16
|
-
}
|
|
17
|
-
type TRequestZoneClean = () => Promise<ZoneCleanResponse>;
|
|
18
|
-
type TSetZoneClean = (params: SetZoneCleanParams) => Promise<ZoneCleanResponse>;
|
|
1
|
+
import { type TRequestZoneClean, type TSetZoneClean } from './type/protocols';
|
|
19
2
|
/**
|
|
20
3
|
* 自定义 Hook,用于划区清扫
|
|
21
|
-
* @param devId 设备ID
|
|
22
4
|
* @returns 包含 requestZoneClean 和 setZoneClean 函数的对象
|
|
23
5
|
*/
|
|
24
|
-
export declare const useZoneClean: (
|
|
6
|
+
export declare const useZoneClean: () => {
|
|
25
7
|
requestZoneClean: TRequestZoneClean;
|
|
26
8
|
setZoneClean: TSetZoneClean;
|
|
27
9
|
};
|
|
28
|
-
export {};
|
package/lib/mqtt/useZoneClean.js
CHANGED
|
@@ -1,35 +1,25 @@
|
|
|
1
|
-
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
-
import "core-js/modules/esnext.iterator.for-each.js";
|
|
3
1
|
import "core-js/modules/esnext.iterator.map.js";
|
|
4
2
|
// 划区清扫
|
|
5
|
-
import { isArray } from 'lodash-es';
|
|
6
|
-
import { createSetCommonParams } from './createCommonOptions';
|
|
7
|
-
import { normalResolve } from './promise';
|
|
8
|
-
import { ZoneCleanEnum } from './type';
|
|
9
|
-
import { useContext } from 'react';
|
|
10
|
-
import { SingletonContext } from './mqttProvider';
|
|
11
3
|
import { encodeZoneClean0x3a, requestZoneClean0x3b } from '@ray-js/robot-protocol';
|
|
4
|
+
import { useContext } from 'react';
|
|
12
5
|
import { pointsToString } from '../utils';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// 请求划区清扫函数类型定义
|
|
19
|
-
|
|
20
|
-
// 设置划区清扫函数类型定义
|
|
21
|
-
|
|
6
|
+
import { handleMqttError, useStructuredMessage } from './hooks/useStructuredMessage';
|
|
7
|
+
import { SingletonContext } from './mqttProvider';
|
|
8
|
+
import { ZoneCleanEnum } from './type';
|
|
9
|
+
import { validator } from './type/fun';
|
|
22
10
|
/**
|
|
23
11
|
* 自定义 Hook,用于划区清扫
|
|
24
|
-
* @param devId 设备ID
|
|
25
12
|
* @returns 包含 requestZoneClean 和 setZoneClean 函数的对象
|
|
26
13
|
*/
|
|
27
|
-
export const useZoneClean =
|
|
14
|
+
export const useZoneClean = () => {
|
|
28
15
|
const {
|
|
29
16
|
useMqtt,
|
|
30
17
|
commandVersion,
|
|
31
18
|
devices
|
|
32
19
|
} = useContext(SingletonContext);
|
|
20
|
+
const {
|
|
21
|
+
sendStructuredMessage
|
|
22
|
+
} = useStructuredMessage();
|
|
33
23
|
|
|
34
24
|
/**
|
|
35
25
|
* 请求划区清扫信息
|
|
@@ -46,53 +36,42 @@ export const useZoneClean = devId => {
|
|
|
46
36
|
|
|
47
37
|
return {
|
|
48
38
|
requestZoneClean: () => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
ty.device.sendMqttMessage(params);
|
|
56
|
-
const {
|
|
57
|
-
taskId
|
|
58
|
-
} = params.message;
|
|
59
|
-
return normalResolve(ZoneCleanEnum.query, taskId);
|
|
60
|
-
}
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
try {
|
|
41
|
+
if (useMqtt) {
|
|
42
|
+
sendStructuredMessage(ZoneCleanEnum.query, {}, resolve, error => reject(handleMqttError(error, 'Failed to request zone clean')));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
61
45
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
46
|
+
// 非 MQTT 模式:使用命令传输
|
|
47
|
+
devices.common.model.actions.command_trans.set(requestZoneClean0x3b({
|
|
48
|
+
version: commandVersion
|
|
49
|
+
}));
|
|
66
50
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
51
|
+
// 非 MQTT 模式下无法立即获取响应数据,返回默认响应
|
|
52
|
+
resolve({
|
|
53
|
+
success: true,
|
|
54
|
+
errCode: 0,
|
|
55
|
+
reqType: ZoneCleanEnum.query,
|
|
56
|
+
version: commandVersion,
|
|
57
|
+
taskId: `${Date.now()}`,
|
|
58
|
+
polygons: [],
|
|
59
|
+
names: []
|
|
60
|
+
});
|
|
61
|
+
} catch (error) {
|
|
62
|
+
reject(handleMqttError(error, 'Failed to request zone clean'));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
80
65
|
},
|
|
81
66
|
setZoneClean: params => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
try {
|
|
69
|
+
const {
|
|
70
|
+
zones,
|
|
71
|
+
origin
|
|
72
|
+
} = params;
|
|
86
73
|
|
|
87
|
-
|
|
88
|
-
if (!isArray(zones) || zones.length === 0) {
|
|
89
|
-
throw new Error('zones is required and must be a non-empty array');
|
|
90
|
-
}
|
|
91
|
-
if (!origin || typeof origin.x !== 'number' || typeof origin.y !== 'number') {
|
|
92
|
-
throw new Error('origin is required and must be a valid Point object with x and y properties');
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
if (useMqtt) {
|
|
74
|
+
// 将业务参数转换为协议数据格式
|
|
96
75
|
const num = zones.length;
|
|
97
76
|
const {
|
|
98
77
|
suctions = new Array(num).fill(''),
|
|
@@ -101,88 +80,97 @@ export const useZoneClean = devId => {
|
|
|
101
80
|
yMops = new Array(num).fill(-1),
|
|
102
81
|
sweepMopModes = new Array(num).fill('only_sweep')
|
|
103
82
|
} = params;
|
|
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
|
-
|
|
83
|
+
|
|
84
|
+
// 构建符合 SetZoneCleanData 格式的数据
|
|
85
|
+
const zoneCleanData = {
|
|
86
|
+
zones: zones.map(_ref => {
|
|
87
|
+
let {
|
|
88
|
+
points,
|
|
89
|
+
name,
|
|
90
|
+
advanced
|
|
91
|
+
} = _ref;
|
|
92
|
+
return {
|
|
93
|
+
points,
|
|
94
|
+
name,
|
|
95
|
+
advanced
|
|
96
|
+
};
|
|
97
|
+
}),
|
|
98
|
+
origin,
|
|
99
|
+
suctions,
|
|
100
|
+
cisterns,
|
|
101
|
+
cleanCounts,
|
|
102
|
+
yMops,
|
|
103
|
+
sweepMopModes
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// 使用 TypeBox Schema 进行参数验证
|
|
107
|
+
const validatedData = validator.validate('set_zone_clean', zoneCleanData);
|
|
108
|
+
if (useMqtt) {
|
|
109
|
+
// 将 zones 转换为 polygons 字符串格式(用于 MQTT 消息)
|
|
110
|
+
const polygons = zones.map(_ref2 => {
|
|
111
|
+
let {
|
|
112
|
+
points
|
|
113
|
+
} = _ref2;
|
|
114
|
+
return pointsToString(points, origin);
|
|
115
|
+
});
|
|
116
|
+
const names = zones.map(_ref3 => {
|
|
117
|
+
let {
|
|
118
|
+
name
|
|
119
|
+
} = _ref3;
|
|
120
|
+
return name || '';
|
|
121
|
+
});
|
|
122
|
+
sendStructuredMessage(ZoneCleanEnum.set, {
|
|
136
123
|
num: zones.length,
|
|
137
124
|
switchGo: true,
|
|
138
125
|
polygons,
|
|
139
|
-
suctions,
|
|
140
|
-
cisterns,
|
|
141
|
-
cleanCounts,
|
|
142
|
-
yMops,
|
|
143
|
-
sweepMopModes,
|
|
126
|
+
suctions: validatedData.suctions,
|
|
127
|
+
cisterns: validatedData.cisterns,
|
|
128
|
+
cleanCounts: validatedData.cleanCounts,
|
|
129
|
+
yMops: validatedData.yMops,
|
|
130
|
+
sweepMopModes: validatedData.sweepMopModes,
|
|
144
131
|
names
|
|
145
|
-
}
|
|
132
|
+
}, resolve, error => reject(handleMqttError(error, 'Failed to set zone clean')), ZoneCleanEnum.query // 响应类型是 query,不是 set
|
|
133
|
+
);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 非 MQTT 模式:使用命令传输
|
|
138
|
+
const command = encodeZoneClean0x3a({
|
|
139
|
+
protocolVersion: 1,
|
|
140
|
+
version: commandVersion,
|
|
141
|
+
origin: validatedData.origin,
|
|
142
|
+
zones: validatedData.zones.map(zone => ({
|
|
143
|
+
points: zone.points,
|
|
144
|
+
name: zone.name,
|
|
145
|
+
advanced: zone.advanced
|
|
146
|
+
}))
|
|
146
147
|
});
|
|
147
|
-
|
|
148
|
-
const {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
devices.common.model.actions.command_trans.set(command);
|
|
149
|
+
const polygons = zones.map(_ref4 => {
|
|
150
|
+
let {
|
|
151
|
+
points
|
|
152
|
+
} = _ref4;
|
|
153
|
+
return pointsToString(points, origin);
|
|
154
|
+
});
|
|
155
|
+
const names = zones.map(_ref5 => {
|
|
156
|
+
let {
|
|
157
|
+
name
|
|
158
|
+
} = _ref5;
|
|
159
|
+
return name || '';
|
|
160
|
+
});
|
|
161
|
+
resolve({
|
|
162
|
+
success: true,
|
|
163
|
+
errCode: 0,
|
|
164
|
+
reqType: ZoneCleanEnum.query,
|
|
165
|
+
version: commandVersion,
|
|
166
|
+
taskId: `${Date.now()}`,
|
|
167
|
+
polygons,
|
|
168
|
+
names
|
|
169
|
+
});
|
|
170
|
+
} catch (error) {
|
|
171
|
+
reject(handleMqttError(error, 'Failed to set zone clean'));
|
|
152
172
|
}
|
|
153
|
-
|
|
154
|
-
// 非 MQTT 模式:使用命令传输
|
|
155
|
-
const command = encodeZoneClean0x3a({
|
|
156
|
-
protocolVersion: 1,
|
|
157
|
-
version: commandVersion,
|
|
158
|
-
origin,
|
|
159
|
-
zones
|
|
160
|
-
});
|
|
161
|
-
devices.common.model.actions.command_trans.set(command);
|
|
162
|
-
const polygons = zones.map(_ref2 => {
|
|
163
|
-
let {
|
|
164
|
-
points
|
|
165
|
-
} = _ref2;
|
|
166
|
-
return pointsToString(points, origin);
|
|
167
|
-
});
|
|
168
|
-
const names = zones.map(_ref3 => {
|
|
169
|
-
let {
|
|
170
|
-
name
|
|
171
|
-
} = _ref3;
|
|
172
|
-
return name || '';
|
|
173
|
-
});
|
|
174
|
-
return Promise.resolve({
|
|
175
|
-
success: true,
|
|
176
|
-
errCode: 0,
|
|
177
|
-
reqType: ZoneCleanEnum.query,
|
|
178
|
-
version: commandVersion,
|
|
179
|
-
taskId: `${Date.now()}`,
|
|
180
|
-
polygons,
|
|
181
|
-
names
|
|
182
|
-
});
|
|
183
|
-
} catch (error) {
|
|
184
|
-
throw error instanceof Error ? error : new Error('Failed to set zone clean');
|
|
185
|
-
}
|
|
173
|
+
});
|
|
186
174
|
}
|
|
187
175
|
};
|
|
188
176
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../src/v4/mini/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../src/v4/mini/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../src/v4/mini/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../v4/mini/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../v4/mini/index.js";
|