@ray-js/robot-data-stream 0.0.15-beta.17 → 0.0.15-beta.19
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/mqtt/type/fun.d.ts +10 -6
- package/lib/mqtt/type/fun.js +2 -1
- package/lib/mqtt/type/index.d.ts +1 -1
- package/lib/mqtt/type/protocols/carpetCleanProtocol.d.ts +2 -2
- package/lib/mqtt/type/protocols/carpetCleanProtocol.js +2 -2
- package/lib/mqtt/type/protocols/carpetProtocol.d.ts +5 -5
- package/lib/mqtt/type/protocols/carpetProtocol.js +5 -5
- package/lib/mqtt/type/protocols/scheduleProtocol.js +17 -0
- package/lib/mqtt/type/protocols/selectRoomCleanProtocol.d.ts +6 -2
- package/lib/mqtt/type/protocols/selectRoomCleanProtocol.js +12 -4
- package/lib/mqtt/type/protocols/spotCleanProtocol.d.ts +3 -1
- package/lib/mqtt/type/protocols/spotCleanProtocol.js +15 -1
- package/lib/mqtt/type/protocols/zoneCleanProtocol.d.ts +7 -2
- package/lib/mqtt/type/protocols/zoneCleanProtocol.js +31 -4
- package/lib/mqtt/useRoomProperty.js +4 -11
- package/lib/mqtt/useSchedule.js +17 -13
- package/lib/mqtt/useSelectRoomClean.js +37 -14
- package/lib/mqtt/useSpotClean.js +17 -12
- package/lib/mqtt/useZoneClean.js +38 -46
- package/lib/mqtt/waterPreference.d.ts +20 -0
- package/lib/mqtt/waterPreference.js +70 -0
- package/package.json +1 -1
package/lib/mqtt/type/fun.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare const ProtocolSchemas: {
|
|
|
16
16
|
sideBrushRotating: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumber<number>>>;
|
|
17
17
|
}, z.core.$strip>;
|
|
18
18
|
update_carpet: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
19
|
-
ids: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
19
|
+
ids: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
20
20
|
shape: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
21
21
|
type: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumber<number>>>;
|
|
22
22
|
cleanMode: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumber<number>>>;
|
|
@@ -29,7 +29,7 @@ export declare const ProtocolSchemas: {
|
|
|
29
29
|
}, z.core.$strip>>>>;
|
|
30
30
|
}, z.core.$strip>;
|
|
31
31
|
delete_carpet: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
32
|
-
ids: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
32
|
+
ids: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
33
33
|
}, z.core.$strip>;
|
|
34
34
|
set_carpet: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
35
35
|
num: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat;
|
|
@@ -39,7 +39,7 @@ export declare const ProtocolSchemas: {
|
|
|
39
39
|
}, z.core.$strip>>>;
|
|
40
40
|
cleanMode: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>;
|
|
41
41
|
shape: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
42
|
-
ids: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
42
|
+
ids: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
43
43
|
type: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
44
44
|
autoBoost: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
45
45
|
fineCleaning: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
@@ -88,10 +88,12 @@ export declare const ProtocolSchemas: {
|
|
|
88
88
|
y: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumber<number>;
|
|
89
89
|
}, z.core.$strip>;
|
|
90
90
|
suctions: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
91
|
-
cisterns: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
91
|
+
cisterns: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
92
|
+
waterValues: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
92
93
|
cleanCounts: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
93
94
|
yMops: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
94
95
|
sweepMopModes: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
96
|
+
routePreferences: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
95
97
|
}, z.core.$strip>;
|
|
96
98
|
set_wifi_map: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
97
99
|
taskId: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>;
|
|
@@ -148,10 +150,12 @@ export declare const ProtocolSchemas: {
|
|
|
148
150
|
set_select_room_clean: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
149
151
|
roomId: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat;
|
|
150
152
|
suction: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>;
|
|
151
|
-
cistern: import("../../myLib/zod/src/v4/mini/schemas").
|
|
153
|
+
cistern: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<any>;
|
|
154
|
+
waterValue: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<any>;
|
|
152
155
|
cleanTimes: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>;
|
|
153
156
|
yMop: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>;
|
|
154
157
|
sweepMopMode: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>;
|
|
158
|
+
routePreference: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>;
|
|
155
159
|
}, z.core.$strip>>;
|
|
156
160
|
set_quiet_hours: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
157
161
|
startTime: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
@@ -205,7 +209,7 @@ export declare const ProtocolSchemas: {
|
|
|
205
209
|
position: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumber<number>>;
|
|
206
210
|
subDevId: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>;
|
|
207
211
|
}, z.core.$strip>>;
|
|
208
|
-
set_carpet_clean: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
212
|
+
set_carpet_clean: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
209
213
|
set_room_property: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
210
214
|
num: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>;
|
|
211
215
|
ids: import("../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>;
|
package/lib/mqtt/type/fun.js
CHANGED
|
@@ -21,7 +21,7 @@ import { setVirtualAreaSchema } from './protocols/virtualAreaProtocol';
|
|
|
21
21
|
import { setVirtualWallSchema } from './protocols/virtualWallProtocol';
|
|
22
22
|
import { setVoiceSchema } from './protocols/voiceProtocol';
|
|
23
23
|
import { setWifiMapSchema } from './protocols/wifiMapProtocol';
|
|
24
|
-
import { setZoneCleanSchema } from './protocols/zoneCleanProtocol';
|
|
24
|
+
import { setZoneCleanSchema, validateSetZoneClean } from './protocols/zoneCleanProtocol';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* 验证失败错误代码
|
|
@@ -68,6 +68,7 @@ const protocolValidators = {
|
|
|
68
68
|
set_carpet: validateSetCarpet,
|
|
69
69
|
set_schedule: validateSetSchedule,
|
|
70
70
|
set_spot_clean: validateSetSpotClean,
|
|
71
|
+
set_zone_clean: validateSetZoneClean,
|
|
71
72
|
set_room_property: validateSetRoomProperty
|
|
72
73
|
// query_carpet 没有自定义验证逻辑,不需要注册
|
|
73
74
|
// delete_carpet 没有自定义验证逻辑,不需要注册
|
package/lib/mqtt/type/index.d.ts
CHANGED
|
@@ -27,9 +27,9 @@ export type RoomPreference = {
|
|
|
27
27
|
cleanCounts?: number[];
|
|
28
28
|
yMops?: number[];
|
|
29
29
|
sweepMopModes?: string[];
|
|
30
|
+
routePreferences?: string[];
|
|
30
31
|
floorTypes?: number[];
|
|
31
32
|
names?: string[];
|
|
32
|
-
routePreferences?: string[];
|
|
33
33
|
nameLabels?: number[];
|
|
34
34
|
ids?: number[];
|
|
35
35
|
orders?: number[];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as z from '../../../myLib/zod/mini';
|
|
2
|
-
export declare const setCarpetCleanSchema: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
2
|
+
export declare const setCarpetCleanSchema: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
3
3
|
declare const carpetCleanResponseSchema: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
4
4
|
success: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniBoolean<boolean>;
|
|
5
5
|
errCode: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumber<number>;
|
|
6
6
|
reqType: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>;
|
|
7
7
|
version: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>;
|
|
8
8
|
taskId: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>;
|
|
9
|
-
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
9
|
+
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
10
10
|
}, z.core.$strip>;
|
|
11
11
|
export type CarpetCleanResponse = z.infer<typeof carpetCleanResponseSchema>;
|
|
12
12
|
export type TRequestCarpetClean = () => Promise<CarpetCleanResponse>;
|
|
@@ -2,11 +2,11 @@ import * as z from '../../../myLib/zod/mini';
|
|
|
2
2
|
import { BaseResponseSchema } from './base';
|
|
3
3
|
|
|
4
4
|
// 设置地毯清扫参数 Schema
|
|
5
|
-
export const setCarpetCleanSchema = z.array(z.number()
|
|
5
|
+
export const setCarpetCleanSchema = z.array(z.union([z.number(), z.string()]));
|
|
6
6
|
|
|
7
7
|
// 地毯清扫响应 Schema
|
|
8
8
|
const carpetCleanResponseSchema = z.extend(BaseResponseSchema, {
|
|
9
|
-
ids: z.array(z.number())
|
|
9
|
+
ids: z.array(z.union([z.number(), z.string()]))
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
// 类型导出
|
|
@@ -15,7 +15,7 @@ export declare const addCarpetSchema: import("../../../myLib/zod/src/v4/mini/sch
|
|
|
15
15
|
sideBrushRotating: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumber<number>>>;
|
|
16
16
|
}, z.core.$strip>;
|
|
17
17
|
export declare const updateCarpetSchema: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
18
|
-
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
18
|
+
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
19
19
|
shape: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
20
20
|
type: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumber<number>>>;
|
|
21
21
|
cleanMode: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumber<number>>>;
|
|
@@ -28,7 +28,7 @@ export declare const updateCarpetSchema: import("../../../myLib/zod/src/v4/mini/
|
|
|
28
28
|
}, z.core.$strip>>>>;
|
|
29
29
|
}, z.core.$strip>;
|
|
30
30
|
export declare const deleteCarpetSchema: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
31
|
-
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
31
|
+
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
32
32
|
}, z.core.$strip>;
|
|
33
33
|
export declare const setCarpetSchema: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
34
34
|
num: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat;
|
|
@@ -38,7 +38,7 @@ export declare const setCarpetSchema: import("../../../myLib/zod/src/v4/mini/sch
|
|
|
38
38
|
}, z.core.$strip>>>;
|
|
39
39
|
cleanMode: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>;
|
|
40
40
|
shape: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
41
|
-
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
41
|
+
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
42
42
|
type: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
43
43
|
autoBoost: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
44
44
|
fineCleaning: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
@@ -50,7 +50,7 @@ declare const addCarpetResponseSchema: import("../../../myLib/zod/src/v4/mini/sc
|
|
|
50
50
|
reqType: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>;
|
|
51
51
|
version: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>;
|
|
52
52
|
taskId: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>;
|
|
53
|
-
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
53
|
+
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>;
|
|
54
54
|
}, z.core.$strip>;
|
|
55
55
|
declare const carpetQueryResponseSchema: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
56
56
|
success: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniBoolean<boolean>;
|
|
@@ -63,7 +63,7 @@ declare const carpetQueryResponseSchema: import("../../../myLib/zod/src/v4/mini/
|
|
|
63
63
|
cleanMode: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
64
64
|
shape: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
65
65
|
type: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
66
|
-
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
66
|
+
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
67
67
|
autoBoost: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
68
68
|
fineCleaning: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
69
69
|
sideBrushRotating: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
@@ -28,7 +28,7 @@ export const addCarpetSchema = z.object({
|
|
|
28
28
|
|
|
29
29
|
// 更新地毯参数 Schema(所有字段都是可选的,除了 ids)
|
|
30
30
|
export const updateCarpetSchema = z.object({
|
|
31
|
-
ids: z.array(z.number()),
|
|
31
|
+
ids: z.array(z.union([z.number(), z.string()])),
|
|
32
32
|
shape: z.optional(z.array(ShapeType)),
|
|
33
33
|
type: z.optional(z.array(z.number())),
|
|
34
34
|
cleanMode: z.optional(z.array(z.number())),
|
|
@@ -40,7 +40,7 @@ export const updateCarpetSchema = z.object({
|
|
|
40
40
|
|
|
41
41
|
// 删除地毯参数 Schema
|
|
42
42
|
export const deleteCarpetSchema = z.object({
|
|
43
|
-
ids: z.array(z.number())
|
|
43
|
+
ids: z.array(z.union([z.number(), z.string()]))
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
// 设置地毯参数 Schema
|
|
@@ -49,7 +49,7 @@ export const setCarpetSchema = z.object({
|
|
|
49
49
|
polygons: z.array(z.array(Point)),
|
|
50
50
|
cleanMode: z.array(z.int()),
|
|
51
51
|
shape: z.array(ShapeType),
|
|
52
|
-
ids: z.array(z.int()),
|
|
52
|
+
ids: z.array(z.union([z.int(), z.string()])),
|
|
53
53
|
type: z.optional(z.array(z.int())),
|
|
54
54
|
autoBoost: z.optional(z.array(z.int())),
|
|
55
55
|
fineCleaning: z.optional(z.array(z.int())),
|
|
@@ -59,7 +59,7 @@ export const setCarpetSchema = z.object({
|
|
|
59
59
|
// 添加地毯响应 Schema
|
|
60
60
|
const addCarpetResponseSchema = z.extend(BaseResponseSchema, {
|
|
61
61
|
// 返回的地毯ID数组
|
|
62
|
-
ids: z.array(z.int())
|
|
62
|
+
ids: z.array(z.union([z.int(), z.string()]))
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
// 地毯查询响应 Schema
|
|
@@ -75,7 +75,7 @@ const carpetQueryResponseSchema = z.extend(BaseResponseSchema, {
|
|
|
75
75
|
// 材质
|
|
76
76
|
type: z.optional(z.array(z.int())),
|
|
77
77
|
// 地毯ID数组
|
|
78
|
-
ids: z.optional(z.array(z.int())),
|
|
78
|
+
ids: z.optional(z.array(z.union([z.int(), z.string()]))),
|
|
79
79
|
// 自动增压
|
|
80
80
|
autoBoost: z.optional(z.array(z.int())),
|
|
81
81
|
// 精细清扫
|
|
@@ -58,6 +58,7 @@ export function validateSetSchedule(data) {
|
|
|
58
58
|
|
|
59
59
|
// 验证每个定时任务项
|
|
60
60
|
list.forEach((item, index) => {
|
|
61
|
+
var _item$ids;
|
|
61
62
|
// 验证 time 数组的有效性
|
|
62
63
|
if (item.time.length !== 2) {
|
|
63
64
|
throw new MqttError(`list[${index}].time 必须包含 2 个元素 [小时, 分钟]`, {
|
|
@@ -86,6 +87,22 @@ export function validateSetSchedule(data) {
|
|
|
86
87
|
reqType: 'set_schedule'
|
|
87
88
|
});
|
|
88
89
|
}
|
|
90
|
+
const expectedLength = ((_item$ids = item.ids) === null || _item$ids === void 0 ? void 0 : _item$ids.length) || 1;
|
|
91
|
+
const validateLength = (field, value) => {
|
|
92
|
+
if (value && value.length !== expectedLength) {
|
|
93
|
+
throw new MqttError(`list[${index}].${field} 长度必须为 ${expectedLength},实际为 ${value.length}`, {
|
|
94
|
+
errCode: VALIDATION_ERROR_CODE,
|
|
95
|
+
reqType: 'set_schedule'
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
validateLength('suctions', item.suctions);
|
|
100
|
+
validateLength('cisterns', item.cisterns);
|
|
101
|
+
validateLength('waterValues', item.waterValues);
|
|
102
|
+
validateLength('cleanCounts', item.cleanCounts);
|
|
103
|
+
validateLength('yMops', item.yMops);
|
|
104
|
+
validateLength('sweepMopModes', item.sweepMopModes);
|
|
105
|
+
validateLength('routePreferences', item.routePreferences);
|
|
89
106
|
});
|
|
90
107
|
}
|
|
91
108
|
|
|
@@ -2,10 +2,12 @@ import * as z from '../../../myLib/zod/mini';
|
|
|
2
2
|
export declare const setSelectRoomCleanSchema: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
3
3
|
roomId: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat;
|
|
4
4
|
suction: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>;
|
|
5
|
-
cistern: import("../../../myLib/zod/src/v4/mini/schemas").
|
|
5
|
+
cistern: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<any>;
|
|
6
|
+
waterValue: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<any>;
|
|
6
7
|
cleanTimes: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>;
|
|
7
8
|
yMop: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>;
|
|
8
9
|
sweepMopMode: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>;
|
|
10
|
+
routePreference: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>;
|
|
9
11
|
}, z.core.$strip>>;
|
|
10
12
|
declare const selectRoomCleanResponseSchema: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
11
13
|
success: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniBoolean<boolean>;
|
|
@@ -15,10 +17,12 @@ declare const selectRoomCleanResponseSchema: import("../../../myLib/zod/src/v4/m
|
|
|
15
17
|
taskId: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>;
|
|
16
18
|
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>;
|
|
17
19
|
suctions: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
18
|
-
cisterns: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
20
|
+
cisterns: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
21
|
+
waterValues: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
19
22
|
cleanCounts: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
20
23
|
yMops: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
21
24
|
sweepMopModes: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
25
|
+
routePreferences: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
22
26
|
}, z.core.$strip>;
|
|
23
27
|
export type SetSelectRoomCleanData = z.infer<typeof setSelectRoomCleanSchema>;
|
|
24
28
|
export type SelectRoomCleanResponse = z.infer<typeof selectRoomCleanResponseSchema>;
|
|
@@ -7,13 +7,17 @@ const roomInfoSchema = z.object({
|
|
|
7
7
|
// 房间id
|
|
8
8
|
suction: z.optional(z.string()),
|
|
9
9
|
// 吸力, closed - 关闭 gentle - 安静 normal - 正常 strong - 强劲 max - 超强 ,默认值为''
|
|
10
|
-
cistern: z.string(),
|
|
10
|
+
cistern: z.optional(z.union([z.string(), z.number()])),
|
|
11
11
|
// 拖地水量 "closed"- 关闭,"low"-低,"middle"-中,"high"-高,默认值为''
|
|
12
|
+
waterValue: z.optional(z.union([z.string(), z.number()])),
|
|
13
|
+
// 自定义拖地水量
|
|
12
14
|
cleanTimes: z.optional(z.int()),
|
|
13
15
|
// 清扫次数 默认值1
|
|
14
16
|
yMop: z.optional(z.int()),
|
|
15
17
|
// 拖地模式 1:开启Y型拖地 0:关闭Y型拖地 -1 未设置 默认值-1
|
|
16
|
-
sweepMopMode: z.optional(z.string())
|
|
18
|
+
sweepMopMode: z.optional(z.string()),
|
|
19
|
+
// 扫拖模式 "only_sweep":仅扫,"only_mop":仅拖,"both_work":扫拖同时,"clean_before_mop":先扫后拖,默认值为'only_sweep'
|
|
20
|
+
routePreference: z.optional(z.string()) // 路线偏好 "standard"-标准, "fast"-快速, "deep"-深度, "custom"-自定义
|
|
17
21
|
});
|
|
18
22
|
|
|
19
23
|
// 设置选区清扫参数 Schema
|
|
@@ -26,13 +30,17 @@ const selectRoomCleanResponseSchema = z.extend(BaseResponseSchema, {
|
|
|
26
30
|
// 吸力, closed - 关闭 gentle - 安静 normal - 正常 strong - 强劲 max - 超强 ,默认值为''
|
|
27
31
|
suctions: z.optional(z.array(z.string())),
|
|
28
32
|
// 拖地水量 "closed"- 关闭,"low"-低,"middle"-中,"high"-高,默认值为''
|
|
29
|
-
cisterns: z.optional(z.array(z.string())),
|
|
33
|
+
cisterns: z.optional(z.array(z.union([z.string(), z.number()]))),
|
|
34
|
+
// 自定义拖地水量
|
|
35
|
+
waterValues: z.optional(z.array(z.union([z.string(), z.number()]))),
|
|
30
36
|
// 清扫次数 默认值1
|
|
31
37
|
cleanCounts: z.optional(z.array(z.int())),
|
|
32
38
|
// 拖地模式 1:开启Y型拖地 0:关闭Y型拖地 -1 未设置 默认值-1
|
|
33
39
|
yMops: z.optional(z.array(z.int())),
|
|
34
40
|
// 扫拖模式 "only_sweep":仅扫,"only_mop":仅拖,"both_work":扫拖同时,"clean_before_mop":先扫后拖,默认值为'only_sweep'
|
|
35
|
-
sweepMopModes: z.optional(z.array(z.string()))
|
|
41
|
+
sweepMopModes: z.optional(z.array(z.string())),
|
|
42
|
+
// 路线偏好
|
|
43
|
+
routePreferences: z.optional(z.array(z.string()))
|
|
36
44
|
});
|
|
37
45
|
|
|
38
46
|
// 类型导出
|
|
@@ -25,10 +25,12 @@ declare const spotCleanResponseSchema: import("../../../myLib/zod/src/v4/mini/sc
|
|
|
25
25
|
version: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>;
|
|
26
26
|
taskId: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>;
|
|
27
27
|
suctions: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
28
|
-
cisterns: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
28
|
+
cisterns: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
29
|
+
waterValues: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
29
30
|
cleanCounts: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
30
31
|
yMops: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
31
32
|
sweepMopModes: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
33
|
+
routePreferences: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
32
34
|
ids: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
33
35
|
polygons: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>;
|
|
34
36
|
names: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
@@ -19,10 +19,12 @@ export const setSpotCleanSchema = z.extend(RoomPreferenceFieldsSchema, {
|
|
|
19
19
|
const spotCleanResponseSchema = z.extend(BaseResponseSchema, {
|
|
20
20
|
// RoomPreferenceFieldsSchema 的字段
|
|
21
21
|
suctions: z.optional(z.array(z.string())),
|
|
22
|
-
cisterns: z.optional(z.array(z.string())),
|
|
22
|
+
cisterns: z.optional(z.array(z.union([z.string(), z.number()]))),
|
|
23
|
+
waterValues: z.optional(z.array(z.union([z.string(), z.number()]))),
|
|
23
24
|
cleanCounts: z.optional(z.array(z.int())),
|
|
24
25
|
yMops: z.optional(z.array(z.int())),
|
|
25
26
|
sweepMopModes: z.optional(z.array(z.string())),
|
|
27
|
+
routePreferences: z.optional(z.array(z.string())),
|
|
26
28
|
ids: z.optional(z.array(z.int())),
|
|
27
29
|
// 多边形数组(字符串格式)
|
|
28
30
|
polygons: z.array(z.string()),
|
|
@@ -49,6 +51,12 @@ export function validateSetSpotClean(data) {
|
|
|
49
51
|
reqType: 'set_spot_clean'
|
|
50
52
|
});
|
|
51
53
|
}
|
|
54
|
+
if (data.waterValues && data.waterValues.length !== num) {
|
|
55
|
+
throw new MqttError(`waterValues 数组长度 (${data.waterValues.length}) 与 spots 数组长度 (${num}) 不一致`, {
|
|
56
|
+
errCode: VALIDATION_ERROR_CODE,
|
|
57
|
+
reqType: 'set_spot_clean'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
52
60
|
if (data.cleanCounts && data.cleanCounts.length !== num) {
|
|
53
61
|
throw new MqttError(`cleanCounts 数组长度 (${data.cleanCounts.length}) 与 spots 数组长度 (${num}) 不一致`, {
|
|
54
62
|
errCode: VALIDATION_ERROR_CODE,
|
|
@@ -67,6 +75,12 @@ export function validateSetSpotClean(data) {
|
|
|
67
75
|
reqType: 'set_spot_clean'
|
|
68
76
|
});
|
|
69
77
|
}
|
|
78
|
+
if (data.routePreferences && data.routePreferences.length !== num) {
|
|
79
|
+
throw new MqttError(`routePreferences 数组长度 (${data.routePreferences.length}) 与 spots 数组长度 (${num}) 不一致`, {
|
|
80
|
+
errCode: VALIDATION_ERROR_CODE,
|
|
81
|
+
reqType: 'set_spot_clean'
|
|
82
|
+
});
|
|
83
|
+
}
|
|
70
84
|
}
|
|
71
85
|
|
|
72
86
|
// 函数类型定义
|
|
@@ -21,10 +21,12 @@ export declare const setZoneCleanSchema: import("../../../myLib/zod/src/v4/mini/
|
|
|
21
21
|
y: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumber<number>;
|
|
22
22
|
}, z.core.$strip>;
|
|
23
23
|
suctions: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
24
|
-
cisterns: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
24
|
+
cisterns: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
25
|
+
waterValues: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
25
26
|
cleanCounts: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
26
27
|
yMops: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
27
28
|
sweepMopModes: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
29
|
+
routePreferences: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
28
30
|
}, z.core.$strip>;
|
|
29
31
|
declare const setZoneCleanResponseSchema: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniObject<{
|
|
30
32
|
success: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniBoolean<boolean>;
|
|
@@ -35,13 +37,16 @@ declare const setZoneCleanResponseSchema: import("../../../myLib/zod/src/v4/mini
|
|
|
35
37
|
polygons: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>;
|
|
36
38
|
names: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
37
39
|
suctions: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
38
|
-
cisterns: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<
|
|
40
|
+
cisterns: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
41
|
+
waterValues: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<any>>;
|
|
39
42
|
cleanCounts: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
40
43
|
yMops: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniNumberFormat>>;
|
|
41
44
|
sweepMopModes: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
45
|
+
routePreferences: import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniOptional<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniArray<import("../../../myLib/zod/src/v4/mini/schemas").ZodMiniString<string>>>;
|
|
42
46
|
}, z.core.$strip>;
|
|
43
47
|
export type SetZoneCleanData = z.infer<typeof setZoneCleanSchema>;
|
|
44
48
|
export type ZoneCleanResponse = z.infer<typeof setZoneCleanResponseSchema>;
|
|
49
|
+
export declare function validateSetZoneClean(data: SetZoneCleanData): void;
|
|
45
50
|
export type TSetZoneClean = (data: SetZoneCleanData) => Promise<ZoneCleanResponse>;
|
|
46
51
|
export type TRequestZoneClean = () => Promise<ZoneCleanResponse>;
|
|
47
52
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as z from '../../../myLib/zod/mini';
|
|
2
|
+
import { MqttError } from '../../promise';
|
|
2
3
|
import { BaseResponseSchema, Point } from './base';
|
|
4
|
+
const VALIDATION_ERROR_CODE = -2;
|
|
3
5
|
const zoneSchema = z.object({
|
|
4
6
|
// 区域点集
|
|
5
7
|
points: z.array(Point),
|
|
@@ -20,10 +22,12 @@ export const setZoneCleanSchema = z.object({
|
|
|
20
22
|
zones: z.array(zoneSchema),
|
|
21
23
|
origin: Point,
|
|
22
24
|
suctions: z.optional(z.array(z.string())),
|
|
23
|
-
cisterns: z.optional(z.array(z.string())),
|
|
25
|
+
cisterns: z.optional(z.array(z.union([z.string(), z.number()]))),
|
|
26
|
+
waterValues: z.optional(z.array(z.union([z.string(), z.number()]))),
|
|
24
27
|
cleanCounts: z.optional(z.array(z.int())),
|
|
25
28
|
yMops: z.optional(z.array(z.int())),
|
|
26
|
-
sweepMopModes: z.optional(z.array(z.string()))
|
|
29
|
+
sweepMopModes: z.optional(z.array(z.string())),
|
|
30
|
+
routePreferences: z.optional(z.array(z.string()))
|
|
27
31
|
});
|
|
28
32
|
|
|
29
33
|
// 划区清扫响应 Schema
|
|
@@ -35,15 +39,38 @@ const setZoneCleanResponseSchema = z.extend(BaseResponseSchema, {
|
|
|
35
39
|
// 吸力, closed - 关闭 gentle - 安静 normal - 正常 strong - 强劲 max - 超强 ,默认值为''
|
|
36
40
|
suctions: z.optional(z.array(z.string())),
|
|
37
41
|
// 拖地水量 "closed"- 关闭,"low"-低,"middle"-中,"high"-高,默认值为''
|
|
38
|
-
cisterns: z.optional(z.array(z.string())),
|
|
42
|
+
cisterns: z.optional(z.array(z.union([z.string(), z.number()]))),
|
|
43
|
+
// 自定义拖地水量
|
|
44
|
+
waterValues: z.optional(z.array(z.union([z.string(), z.number()]))),
|
|
39
45
|
// 清扫次数 默认值1
|
|
40
46
|
cleanCounts: z.optional(z.array(z.int())),
|
|
41
47
|
// 拖地模式 1:开启Y型拖地 0:关闭Y型拖地 -1 未设置 默认值-1
|
|
42
48
|
yMops: z.optional(z.array(z.int())),
|
|
43
49
|
// 扫拖模式 "only_sweep":仅扫,"only_mop":仅拖,"both_work":扫拖同时,"clean_before_mop":先扫后拖,默认值为'only_sweep'
|
|
44
|
-
sweepMopModes: z.optional(z.array(z.string()))
|
|
50
|
+
sweepMopModes: z.optional(z.array(z.string())),
|
|
51
|
+
// 路线偏好
|
|
52
|
+
routePreferences: z.optional(z.array(z.string()))
|
|
45
53
|
});
|
|
46
54
|
|
|
47
55
|
// 类型导出
|
|
48
56
|
|
|
57
|
+
export function validateSetZoneClean(data) {
|
|
58
|
+
const num = data.zones.length;
|
|
59
|
+
const validateLength = (name, value) => {
|
|
60
|
+
if (value && value.length !== num) {
|
|
61
|
+
throw new MqttError(`${name} length must be ${num}, actual is ${value.length}`, {
|
|
62
|
+
errCode: VALIDATION_ERROR_CODE,
|
|
63
|
+
reqType: 'set_zone_clean'
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
validateLength('suctions', data.suctions);
|
|
68
|
+
validateLength('cisterns', data.cisterns);
|
|
69
|
+
validateLength('waterValues', data.waterValues);
|
|
70
|
+
validateLength('cleanCounts', data.cleanCounts);
|
|
71
|
+
validateLength('yMops', data.yMops);
|
|
72
|
+
validateLength('sweepMopModes', data.sweepMopModes);
|
|
73
|
+
validateLength('routePreferences', data.routePreferences);
|
|
74
|
+
}
|
|
75
|
+
|
|
49
76
|
// 函数类型定义
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import { useContext } from 'react';
|
|
2
3
|
import { handleMqttError, useStructuredMessage } from './hooks/useStructuredMessage';
|
|
3
4
|
import { SingletonContext } from './mqttProvider';
|
|
4
5
|
import { RoomPropertyEnum } from './type';
|
|
5
6
|
import { validator } from './type/fun';
|
|
7
|
+
import { normalizeWaterPreferencePayload } from './waterPreference';
|
|
6
8
|
/**
|
|
7
9
|
* 自定义 Hook,用于房间属性管理
|
|
8
10
|
* @param devId 设备ID(可选,如果不提供则从 MqttProvider Context 获取)
|
|
@@ -56,7 +58,7 @@ export const useRoomProperty = () => {
|
|
|
56
58
|
ids
|
|
57
59
|
} = data;
|
|
58
60
|
const len = ids.length;
|
|
59
|
-
const sendData = {
|
|
61
|
+
const sendData = _objectSpread({
|
|
60
62
|
num: (_data$num = data.num) !== null && _data$num !== void 0 ? _data$num : len,
|
|
61
63
|
ids,
|
|
62
64
|
suctions: (_data$suctions = data.suctions) !== null && _data$suctions !== void 0 ? _data$suctions : new Array(len).fill('closed'),
|
|
@@ -68,16 +70,7 @@ export const useRoomProperty = () => {
|
|
|
68
70
|
floorTypes: data.floorTypes,
|
|
69
71
|
orders: data.orders,
|
|
70
72
|
routePreferences: (_data$routePreference = data.routePreferences) !== null && _data$routePreference !== void 0 ? _data$routePreference : new Array(len).fill('standard')
|
|
71
|
-
};
|
|
72
|
-
// 水量:传什么带什么,都没传时默认 cisterns
|
|
73
|
-
if (data.waterValues) {
|
|
74
|
-
var _data$waterValues;
|
|
75
|
-
sendData.waterValues = (_data$waterValues = data.waterValues) !== null && _data$waterValues !== void 0 ? _data$waterValues : new Array(len).fill(1);
|
|
76
|
-
}
|
|
77
|
-
if (data.cisterns || !data.waterValues) {
|
|
78
|
-
var _data$cisterns;
|
|
79
|
-
sendData.cisterns = (_data$cisterns = data.cisterns) !== null && _data$cisterns !== void 0 ? _data$cisterns : new Array(len).fill('closed');
|
|
80
|
-
}
|
|
73
|
+
}, normalizeWaterPreferencePayload(data.cisterns, data.waterValues));
|
|
81
74
|
|
|
82
75
|
// 使用 TypeBox Schema 进行参数验证(包含自定义验证逻辑)
|
|
83
76
|
const validatedData = validator.validate('set_room_property', sendData);
|
package/lib/mqtt/useSchedule.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import "core-js/modules/esnext.iterator.map.js";
|
|
2
3
|
// 定时
|
|
3
4
|
import { encodeDeviceTimer0x30 } from '@ray-js/robot-protocol';
|
|
4
5
|
import { useContext } from 'react';
|
|
5
|
-
import {
|
|
6
|
+
import { CLEAN_MODE_MAP, SUCTION_MAP, ROUTE_PREFERENCE_MAP } from '../constant';
|
|
7
|
+
import { normalizeWaterPreferencePayload, resolveWaterLevel } from './waterPreference';
|
|
6
8
|
import { handleMqttError, useStructuredMessage } from './hooks/useStructuredMessage';
|
|
7
9
|
import { SingletonContext } from './mqttProvider';
|
|
8
10
|
import { ScheduleEnum } from './type';
|
|
@@ -53,8 +55,16 @@ export const useSchedule = () => {
|
|
|
53
55
|
try {
|
|
54
56
|
// 使用 TypeBox Schema 进行参数验证
|
|
55
57
|
const validatedData = validator.validate('set_schedule', message);
|
|
58
|
+
const list = validatedData.list.map(item => {
|
|
59
|
+
var _item$routePreference, _item$ids;
|
|
60
|
+
return _objectSpread(_objectSpread(_objectSpread({}, item), normalizeWaterPreferencePayload(item.cisterns, item.waterValues)), {}, {
|
|
61
|
+
routePreferences: (_item$routePreference = item.routePreferences) !== null && _item$routePreference !== void 0 ? _item$routePreference : new Array(((_item$ids = item.ids) === null || _item$ids === void 0 ? void 0 : _item$ids.length) || 1).fill('standard')
|
|
62
|
+
});
|
|
63
|
+
});
|
|
56
64
|
if (useMqtt) {
|
|
57
|
-
sendStructuredMessage(ScheduleEnum.set,
|
|
65
|
+
sendStructuredMessage(ScheduleEnum.set, _objectSpread(_objectSpread({}, validatedData), {}, {
|
|
66
|
+
list
|
|
67
|
+
}), resolve, error => reject(handleMqttError(error, 'Failed to set schedule')), ScheduleEnum.query // 响应类型是 query,不是 set
|
|
58
68
|
);
|
|
59
69
|
return;
|
|
60
70
|
}
|
|
@@ -63,8 +73,7 @@ export const useSchedule = () => {
|
|
|
63
73
|
const command = encodeDeviceTimer0x30({
|
|
64
74
|
version: commandVersion,
|
|
65
75
|
number: validatedData.num,
|
|
66
|
-
list:
|
|
67
|
-
var _ref2, _cisterns$;
|
|
76
|
+
list: list.map(_ref => {
|
|
68
77
|
let {
|
|
69
78
|
active,
|
|
70
79
|
suctions,
|
|
@@ -75,17 +84,13 @@ export const useSchedule = () => {
|
|
|
75
84
|
cisterns,
|
|
76
85
|
waterValues,
|
|
77
86
|
time,
|
|
78
|
-
routePreferences
|
|
79
|
-
nameLabels
|
|
87
|
+
routePreferences
|
|
80
88
|
} = _ref;
|
|
81
|
-
// 水量:优先 cisterns,其次 waterValues,都没有默认 closed
|
|
82
|
-
const raw = (_ref2 = (_cisterns$ = cisterns === null || cisterns === void 0 ? void 0 : cisterns[0]) !== null && _cisterns$ !== void 0 ? _cisterns$ : waterValues === null || waterValues === void 0 ? void 0 : waterValues[0]) !== null && _ref2 !== void 0 ? _ref2 : 'closed';
|
|
83
|
-
const waterLevel = typeof raw === 'number' ? raw : CISTERN_MAP[raw];
|
|
84
89
|
return {
|
|
85
90
|
effectiveness: active,
|
|
86
91
|
cleanMode: CLEAN_MODE_MAP[(sweepMopModes === null || sweepMopModes === void 0 ? void 0 : sweepMopModes[0]) || ''],
|
|
87
92
|
fanLevel: SUCTION_MAP[(suctions === null || suctions === void 0 ? void 0 : suctions[0]) || ''],
|
|
88
|
-
waterLevel,
|
|
93
|
+
waterLevel: resolveWaterLevel(waterValues === null || waterValues === void 0 ? void 0 : waterValues[0], cisterns === null || cisterns === void 0 ? void 0 : cisterns[0]),
|
|
89
94
|
time: {
|
|
90
95
|
hour: time[0],
|
|
91
96
|
minute: time[1]
|
|
@@ -94,8 +99,7 @@ export const useSchedule = () => {
|
|
|
94
99
|
sweepCount: (cleanCounts === null || cleanCounts === void 0 ? void 0 : cleanCounts[0]) || 1,
|
|
95
100
|
roomIds: ids || [],
|
|
96
101
|
roomNum: (ids === null || ids === void 0 ? void 0 : ids.length) || 0,
|
|
97
|
-
routePreference: ROUTE_PREFERENCE_MAP[(routePreferences === null || routePreferences === void 0 ? void 0 : routePreferences[0]) || 'standard']
|
|
98
|
-
nameLabel: nameLabels === null || nameLabels === void 0 ? void 0 : nameLabels[0]
|
|
102
|
+
routePreference: ROUTE_PREFERENCE_MAP[(routePreferences === null || routePreferences === void 0 ? void 0 : routePreferences[0]) || 'standard']
|
|
99
103
|
};
|
|
100
104
|
})
|
|
101
105
|
});
|
|
@@ -106,7 +110,7 @@ export const useSchedule = () => {
|
|
|
106
110
|
reqType: ScheduleEnum.query,
|
|
107
111
|
version: commandVersion,
|
|
108
112
|
taskId: `${Date.now()}`,
|
|
109
|
-
list
|
|
113
|
+
list,
|
|
110
114
|
num: validatedData.num
|
|
111
115
|
});
|
|
112
116
|
} catch (error) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
3
|
import "core-js/modules/esnext.iterator.for-each.js";
|
|
3
4
|
import "core-js/modules/esnext.iterator.map.js";
|
|
@@ -8,6 +9,7 @@ import { handleMqttError, useStructuredMessage } from './hooks/useStructuredMess
|
|
|
8
9
|
import { SingletonContext } from './mqttProvider';
|
|
9
10
|
import { RoomCleanSetEnum } from './type';
|
|
10
11
|
import { validator } from './type/fun';
|
|
12
|
+
import { normalizeWaterPreferencePayload } from './waterPreference';
|
|
11
13
|
/**
|
|
12
14
|
* 自定义 Hook,用于选区清扫
|
|
13
15
|
* @returns 包含 requestSelectRoomClean 和 setRoomClean 函数的对象
|
|
@@ -59,9 +61,11 @@ export const useSelectRoomClean = () => {
|
|
|
59
61
|
ids: [],
|
|
60
62
|
suctions: [],
|
|
61
63
|
cisterns: [],
|
|
64
|
+
waterValues: [],
|
|
62
65
|
cleanCounts: [],
|
|
63
66
|
yMops: [],
|
|
64
|
-
sweepMopModes: []
|
|
67
|
+
sweepMopModes: [],
|
|
68
|
+
routePreferences: []
|
|
65
69
|
});
|
|
66
70
|
} catch (error) {
|
|
67
71
|
reject(handleMqttError(error, 'Failed to request select room clean'));
|
|
@@ -77,28 +81,36 @@ export const useSelectRoomClean = () => {
|
|
|
77
81
|
if (useMqtt) {
|
|
78
82
|
const ids = [];
|
|
79
83
|
const suctions = [];
|
|
80
|
-
const cisterns = [];
|
|
81
84
|
const cleanCounts = [];
|
|
82
85
|
const yMops = [];
|
|
83
86
|
const sweepMopModes = [];
|
|
87
|
+
const routePreferences = [];
|
|
84
88
|
rooms.forEach(room => {
|
|
85
|
-
var _room$suction, _room$cleanTimes, _room$yMop, _room$sweepMopMode;
|
|
89
|
+
var _room$suction, _room$cleanTimes, _room$yMop, _room$sweepMopMode, _room$routePreference;
|
|
86
90
|
ids.push(room.roomId);
|
|
87
91
|
suctions.push((_room$suction = room.suction) !== null && _room$suction !== void 0 ? _room$suction : '');
|
|
88
|
-
cisterns.push(room.cistern);
|
|
89
92
|
cleanCounts.push((_room$cleanTimes = room.cleanTimes) !== null && _room$cleanTimes !== void 0 ? _room$cleanTimes : 1);
|
|
90
93
|
yMops.push((_room$yMop = room.yMop) !== null && _room$yMop !== void 0 ? _room$yMop : -1);
|
|
91
94
|
sweepMopModes.push((_room$sweepMopMode = room.sweepMopMode) !== null && _room$sweepMopMode !== void 0 ? _room$sweepMopMode : 'only_sweep');
|
|
95
|
+
routePreferences.push((_room$routePreference = room.routePreference) !== null && _room$routePreference !== void 0 ? _room$routePreference : 'standard');
|
|
92
96
|
});
|
|
93
|
-
|
|
97
|
+
const waterPayload = normalizeWaterPreferencePayload(rooms.map(room => {
|
|
98
|
+
var _room$cistern;
|
|
99
|
+
return (_room$cistern = room.cistern) !== null && _room$cistern !== void 0 ? _room$cistern : '';
|
|
100
|
+
}), rooms.map(room => {
|
|
101
|
+
var _room$waterValue;
|
|
102
|
+
return (_room$waterValue = room.waterValue) !== null && _room$waterValue !== void 0 ? _room$waterValue : '';
|
|
103
|
+
}));
|
|
104
|
+
sendStructuredMessage(RoomCleanSetEnum.set, _objectSpread(_objectSpread({
|
|
94
105
|
ids,
|
|
95
|
-
suctions
|
|
96
|
-
|
|
106
|
+
suctions
|
|
107
|
+
}, waterPayload), {}, {
|
|
97
108
|
cleanCounts,
|
|
98
109
|
yMops,
|
|
99
110
|
sweepMopModes,
|
|
111
|
+
routePreferences,
|
|
100
112
|
num: rooms.length
|
|
101
|
-
}, resolve, error => reject(handleMqttError(error, 'Failed to set room clean')), RoomCleanSetEnum.query // 响应类型是 query,不是 set
|
|
113
|
+
}), resolve, error => reject(handleMqttError(error, 'Failed to set room clean')), RoomCleanSetEnum.query // 响应类型是 query,不是 set
|
|
102
114
|
);
|
|
103
115
|
return;
|
|
104
116
|
}
|
|
@@ -115,7 +127,13 @@ export const useSelectRoomClean = () => {
|
|
|
115
127
|
var _room$suction2;
|
|
116
128
|
return (_room$suction2 = room.suction) !== null && _room$suction2 !== void 0 ? _room$suction2 : '';
|
|
117
129
|
});
|
|
118
|
-
const
|
|
130
|
+
const waterPayload = normalizeWaterPreferencePayload(rooms.map(room => {
|
|
131
|
+
var _room$cistern2;
|
|
132
|
+
return (_room$cistern2 = room.cistern) !== null && _room$cistern2 !== void 0 ? _room$cistern2 : '';
|
|
133
|
+
}), rooms.map(room => {
|
|
134
|
+
var _room$waterValue2;
|
|
135
|
+
return (_room$waterValue2 = room.waterValue) !== null && _room$waterValue2 !== void 0 ? _room$waterValue2 : '';
|
|
136
|
+
}));
|
|
119
137
|
const cleanCounts = rooms.map(room => {
|
|
120
138
|
var _room$cleanTimes2;
|
|
121
139
|
return (_room$cleanTimes2 = room.cleanTimes) !== null && _room$cleanTimes2 !== void 0 ? _room$cleanTimes2 : 1;
|
|
@@ -128,19 +146,24 @@ export const useSelectRoomClean = () => {
|
|
|
128
146
|
var _room$sweepMopMode2;
|
|
129
147
|
return (_room$sweepMopMode2 = room.sweepMopMode) !== null && _room$sweepMopMode2 !== void 0 ? _room$sweepMopMode2 : 'only_sweep';
|
|
130
148
|
});
|
|
131
|
-
|
|
149
|
+
const routePreferences = rooms.map(room => {
|
|
150
|
+
var _room$routePreference2;
|
|
151
|
+
return (_room$routePreference2 = room.routePreference) !== null && _room$routePreference2 !== void 0 ? _room$routePreference2 : 'standard';
|
|
152
|
+
});
|
|
153
|
+
resolve(_objectSpread(_objectSpread({
|
|
132
154
|
success: true,
|
|
133
155
|
errCode: 0,
|
|
134
156
|
reqType: RoomCleanSetEnum.query,
|
|
135
157
|
version: commandVersion,
|
|
136
158
|
taskId: `${Date.now()}`,
|
|
137
159
|
ids,
|
|
138
|
-
suctions
|
|
139
|
-
|
|
160
|
+
suctions
|
|
161
|
+
}, waterPayload), {}, {
|
|
140
162
|
cleanCounts,
|
|
141
163
|
yMops,
|
|
142
|
-
sweepMopModes
|
|
143
|
-
|
|
164
|
+
sweepMopModes,
|
|
165
|
+
routePreferences
|
|
166
|
+
}));
|
|
144
167
|
} catch (error) {
|
|
145
168
|
reject(handleMqttError(error, 'Failed to set room clean'));
|
|
146
169
|
}
|
package/lib/mqtt/useSpotClean.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import "core-js/modules/esnext.iterator.map.js";
|
|
2
3
|
// 定点清扫
|
|
3
4
|
|
|
@@ -8,6 +9,7 @@ import { encodeSpotClean0x16 } from '@ray-js/robot-protocol';
|
|
|
8
9
|
import { pointsToString } from '../utils';
|
|
9
10
|
import { useStructuredMessage, handleMqttError } from './hooks/useStructuredMessage';
|
|
10
11
|
import { validator } from './type/fun';
|
|
12
|
+
import { normalizeWaterPreferencePayload } from './waterPreference';
|
|
11
13
|
/**
|
|
12
14
|
* 自定义 Hook,用于定点清扫
|
|
13
15
|
* @returns 包含 requestSpotClean 和 setSpotClean 函数的对象
|
|
@@ -57,25 +59,27 @@ export const useSpotClean = () => {
|
|
|
57
59
|
origin
|
|
58
60
|
} = validatedData;
|
|
59
61
|
const num = spots.length;
|
|
62
|
+
const waterPayload = normalizeWaterPreferencePayload(validatedData.cisterns, validatedData.waterValues);
|
|
60
63
|
|
|
61
64
|
// 为可选字段设置默认值
|
|
62
65
|
const {
|
|
63
66
|
suctions = new Array(num).fill(''),
|
|
64
|
-
cisterns = new Array(num).fill(''),
|
|
65
67
|
cleanCounts = new Array(num).fill(1),
|
|
66
68
|
yMops = new Array(num).fill(-1),
|
|
67
|
-
sweepMopModes = new Array(num).fill('only_sweep')
|
|
69
|
+
sweepMopModes = new Array(num).fill('only_sweep'),
|
|
70
|
+
routePreferences = new Array(num).fill('standard')
|
|
68
71
|
} = validatedData;
|
|
69
72
|
if (useMqtt) {
|
|
70
|
-
sendStructuredMessage(SpotCleanEnum.set, {
|
|
73
|
+
sendStructuredMessage(SpotCleanEnum.set, _objectSpread(_objectSpread({
|
|
71
74
|
num,
|
|
72
75
|
polygons: spots.map(spot => pointsToString([spot], origin)),
|
|
73
|
-
suctions
|
|
74
|
-
|
|
76
|
+
suctions
|
|
77
|
+
}, waterPayload), {}, {
|
|
75
78
|
cleanCounts,
|
|
76
79
|
yMops,
|
|
77
|
-
sweepMopModes
|
|
78
|
-
|
|
80
|
+
sweepMopModes,
|
|
81
|
+
routePreferences
|
|
82
|
+
}), resolve, error => reject(handleMqttError(error, 'Failed to set spot clean')), SpotCleanEnum.query // 响应类型是 query,不是 set
|
|
79
83
|
);
|
|
80
84
|
return;
|
|
81
85
|
}
|
|
@@ -87,19 +91,20 @@ export const useSpotClean = () => {
|
|
|
87
91
|
point: spots[0]
|
|
88
92
|
});
|
|
89
93
|
devices.common.model.actions.command_trans.set(command);
|
|
90
|
-
resolve({
|
|
94
|
+
resolve(_objectSpread(_objectSpread({
|
|
91
95
|
success: true,
|
|
92
96
|
errCode: 0,
|
|
93
97
|
reqType: SpotCleanEnum.query,
|
|
94
98
|
version: commandVersion,
|
|
95
99
|
taskId: `${Date.now()}`,
|
|
96
100
|
polygons: spots.map(spot => pointsToString([spot], origin)),
|
|
97
|
-
suctions
|
|
98
|
-
|
|
101
|
+
suctions
|
|
102
|
+
}, waterPayload), {}, {
|
|
99
103
|
cleanCounts,
|
|
100
104
|
yMops,
|
|
101
|
-
sweepMopModes
|
|
102
|
-
|
|
105
|
+
sweepMopModes,
|
|
106
|
+
routePreferences
|
|
107
|
+
}));
|
|
103
108
|
} catch (error) {
|
|
104
109
|
reject(handleMqttError(error, 'Failed to set spot clean'));
|
|
105
110
|
}
|
package/lib/mqtt/useZoneClean.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import "core-js/modules/esnext.iterator.map.js";
|
|
2
3
|
// 划区清扫
|
|
3
4
|
import { encodeZoneClean0x3a, requestZoneClean0x3b } from '@ray-js/robot-protocol';
|
|
@@ -7,6 +8,7 @@ import { handleMqttError, useStructuredMessage } from './hooks/useStructuredMess
|
|
|
7
8
|
import { SingletonContext } from './mqttProvider';
|
|
8
9
|
import { ZoneCleanEnum } from './type';
|
|
9
10
|
import { validator } from './type/fun';
|
|
11
|
+
import { normalizeWaterPreferencePayload } from './waterPreference';
|
|
10
12
|
/**
|
|
11
13
|
* 自定义 Hook,用于划区清扫
|
|
12
14
|
* @returns 包含 requestZoneClean 和 setZoneClean 函数的对象
|
|
@@ -73,16 +75,15 @@ export const useZoneClean = () => {
|
|
|
73
75
|
|
|
74
76
|
// 将业务参数转换为协议数据格式
|
|
75
77
|
const num = zones.length;
|
|
78
|
+
const waterPayload = normalizeWaterPreferencePayload(params.cisterns, params.waterValues);
|
|
76
79
|
const {
|
|
77
80
|
suctions = new Array(num).fill(''),
|
|
78
|
-
cisterns = new Array(num).fill(''),
|
|
79
81
|
cleanCounts = new Array(num).fill(1),
|
|
80
82
|
yMops = new Array(num).fill(-1),
|
|
81
|
-
sweepMopModes = new Array(num).fill('only_sweep')
|
|
83
|
+
sweepMopModes = new Array(num).fill('only_sweep'),
|
|
84
|
+
routePreferences = new Array(num).fill('standard')
|
|
82
85
|
} = params;
|
|
83
|
-
|
|
84
|
-
// 构建符合 SetZoneCleanData 格式的数据
|
|
85
|
-
const zoneCleanData = {
|
|
86
|
+
const zoneCleanData = _objectSpread(_objectSpread({
|
|
86
87
|
zones: zones.map(_ref => {
|
|
87
88
|
let {
|
|
88
89
|
points,
|
|
@@ -96,41 +97,44 @@ export const useZoneClean = () => {
|
|
|
96
97
|
};
|
|
97
98
|
}),
|
|
98
99
|
origin,
|
|
99
|
-
suctions
|
|
100
|
-
|
|
100
|
+
suctions
|
|
101
|
+
}, waterPayload), {}, {
|
|
101
102
|
cleanCounts,
|
|
102
103
|
yMops,
|
|
103
|
-
sweepMopModes
|
|
104
|
-
|
|
104
|
+
sweepMopModes,
|
|
105
|
+
routePreferences
|
|
106
|
+
});
|
|
105
107
|
|
|
106
108
|
// 使用 TypeBox Schema 进行参数验证
|
|
107
109
|
const validatedData = validator.validate('set_zone_clean', zoneCleanData);
|
|
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
|
+
const commonFields = _objectSpread(_objectSpread({
|
|
123
|
+
suctions: validatedData.suctions
|
|
124
|
+
}, waterPayload), {}, {
|
|
125
|
+
cleanCounts: validatedData.cleanCounts,
|
|
126
|
+
yMops: validatedData.yMops,
|
|
127
|
+
sweepMopModes: validatedData.sweepMopModes,
|
|
128
|
+
routePreferences: validatedData.routePreferences
|
|
129
|
+
});
|
|
108
130
|
if (useMqtt) {
|
|
109
|
-
|
|
110
|
-
|
|
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, {
|
|
123
|
-
num: zones.length,
|
|
131
|
+
sendStructuredMessage(ZoneCleanEnum.set, _objectSpread(_objectSpread({
|
|
132
|
+
num,
|
|
124
133
|
switchGo: true,
|
|
125
|
-
polygons
|
|
126
|
-
|
|
127
|
-
cisterns: validatedData.cisterns,
|
|
128
|
-
cleanCounts: validatedData.cleanCounts,
|
|
129
|
-
yMops: validatedData.yMops,
|
|
130
|
-
sweepMopModes: validatedData.sweepMopModes,
|
|
134
|
+
polygons
|
|
135
|
+
}, commonFields), {}, {
|
|
131
136
|
names
|
|
132
|
-
}, resolve, error => reject(handleMqttError(error, 'Failed to set zone clean')), ZoneCleanEnum.query
|
|
133
|
-
);
|
|
137
|
+
}), resolve, error => reject(handleMqttError(error, 'Failed to set zone clean')), ZoneCleanEnum.query);
|
|
134
138
|
return;
|
|
135
139
|
}
|
|
136
140
|
|
|
@@ -146,19 +150,7 @@ export const useZoneClean = () => {
|
|
|
146
150
|
}))
|
|
147
151
|
});
|
|
148
152
|
devices.common.model.actions.command_trans.set(command);
|
|
149
|
-
|
|
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({
|
|
153
|
+
resolve(_objectSpread({
|
|
162
154
|
success: true,
|
|
163
155
|
errCode: 0,
|
|
164
156
|
reqType: ZoneCleanEnum.query,
|
|
@@ -166,7 +158,7 @@ export const useZoneClean = () => {
|
|
|
166
158
|
taskId: `${Date.now()}`,
|
|
167
159
|
polygons,
|
|
168
160
|
names
|
|
169
|
-
});
|
|
161
|
+
}, commonFields));
|
|
170
162
|
} catch (error) {
|
|
171
163
|
reject(handleMqttError(error, 'Failed to set zone clean'));
|
|
172
164
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type WaterPreferenceValue = string | number;
|
|
2
|
+
/**
|
|
3
|
+
* 将自定义水量 / 标准水量统一归一化为设备命令需要的数值。
|
|
4
|
+
* 优先使用 waterValue,其次回退到 cistern。
|
|
5
|
+
*/
|
|
6
|
+
export declare const resolveWaterLevel: (waterValue?: WaterPreferenceValue, cistern?: WaterPreferenceValue, fallback?: number) => number;
|
|
7
|
+
export declare const hasPreferenceValue: (value?: WaterPreferenceValue | null) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* MQTT 水量相关字段是可选的。
|
|
10
|
+
* 当数组里全是空字符串时,认为该字段未设置,避免把空 cisterns/waterValues 发给设备。
|
|
11
|
+
*/
|
|
12
|
+
export declare const normalizeOptionalPreferenceArray: <T extends WaterPreferenceValue>(values?: T[] | undefined) => T[] | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* 自定义水量优先于旧 cistern 水量。
|
|
15
|
+
* 当某一项存在自定义水量时,同位置的 cistern 会被清空;最终空数组字段会被省略。
|
|
16
|
+
*/
|
|
17
|
+
export declare const normalizeWaterPreferencePayload: (cisterns?: WaterPreferenceValue[], waterValues?: WaterPreferenceValue[]) => {
|
|
18
|
+
cisterns?: WaterPreferenceValue[] | undefined;
|
|
19
|
+
waterValues?: WaterPreferenceValue[] | undefined;
|
|
20
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.some.js";
|
|
4
|
+
import { CISTERN_MAP } from '../constant';
|
|
5
|
+
/**
|
|
6
|
+
* 将自定义水量 / 标准水量统一归一化为设备命令需要的数值。
|
|
7
|
+
* 优先使用 waterValue,其次回退到 cistern。
|
|
8
|
+
*/
|
|
9
|
+
export const resolveWaterLevel = function (waterValue, cistern) {
|
|
10
|
+
var _ref, _resolveValue;
|
|
11
|
+
let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : CISTERN_MAP.closed;
|
|
12
|
+
const resolveValue = value => {
|
|
13
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
if (typeof value !== 'string') {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
if (value in CISTERN_MAP) {
|
|
20
|
+
return CISTERN_MAP[value];
|
|
21
|
+
}
|
|
22
|
+
const parsed = Number(value);
|
|
23
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
24
|
+
};
|
|
25
|
+
return (_ref = (_resolveValue = resolveValue(waterValue)) !== null && _resolveValue !== void 0 ? _resolveValue : resolveValue(cistern)) !== null && _ref !== void 0 ? _ref : fallback;
|
|
26
|
+
};
|
|
27
|
+
export const hasPreferenceValue = value => value !== '' && value !== null && value !== undefined;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* MQTT 水量相关字段是可选的。
|
|
31
|
+
* 当数组里全是空字符串时,认为该字段未设置,避免把空 cisterns/waterValues 发给设备。
|
|
32
|
+
*/
|
|
33
|
+
export const normalizeOptionalPreferenceArray = values => {
|
|
34
|
+
if (!values) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return values.some(hasPreferenceValue) ? values : undefined;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 自定义水量优先于旧 cistern 水量。
|
|
42
|
+
* 当某一项存在自定义水量时,同位置的 cistern 会被清空;最终空数组字段会被省略。
|
|
43
|
+
*/
|
|
44
|
+
export const normalizeWaterPreferencePayload = (cisterns, waterValues) => {
|
|
45
|
+
var _cisterns$length, _waterValues$length;
|
|
46
|
+
const maxLength = Math.max((_cisterns$length = cisterns === null || cisterns === void 0 ? void 0 : cisterns.length) !== null && _cisterns$length !== void 0 ? _cisterns$length : 0, (_waterValues$length = waterValues === null || waterValues === void 0 ? void 0 : waterValues.length) !== null && _waterValues$length !== void 0 ? _waterValues$length : 0);
|
|
47
|
+
if (maxLength === 0) {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
const normalizedCisterns = normalizeOptionalPreferenceArray(Array.from({
|
|
51
|
+
length: maxLength
|
|
52
|
+
}, (_, index) => {
|
|
53
|
+
var _cisterns$index;
|
|
54
|
+
if (hasPreferenceValue(waterValues === null || waterValues === void 0 ? void 0 : waterValues[index])) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
return (_cisterns$index = cisterns === null || cisterns === void 0 ? void 0 : cisterns[index]) !== null && _cisterns$index !== void 0 ? _cisterns$index : '';
|
|
58
|
+
}));
|
|
59
|
+
const normalizedWaterValues = normalizeOptionalPreferenceArray(Array.from({
|
|
60
|
+
length: maxLength
|
|
61
|
+
}, (_, index) => {
|
|
62
|
+
var _waterValues$index;
|
|
63
|
+
return (_waterValues$index = waterValues === null || waterValues === void 0 ? void 0 : waterValues[index]) !== null && _waterValues$index !== void 0 ? _waterValues$index : '';
|
|
64
|
+
}));
|
|
65
|
+
return _objectSpread(_objectSpread({}, normalizedCisterns ? {
|
|
66
|
+
cisterns: normalizedCisterns
|
|
67
|
+
} : {}), normalizedWaterValues ? {
|
|
68
|
+
waterValues: normalizedWaterValues
|
|
69
|
+
} : {});
|
|
70
|
+
};
|