@cpzxrobot/sdk 1.0.51 → 1.0.53
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/pigfarm_gateway.js +24 -3
- package/package.json +1 -1
- package/pigfarm_gateway.ts +42 -22
- package/types.d.ts +19 -7
package/dist/pigfarm_gateway.js
CHANGED
|
@@ -24,7 +24,7 @@ class PigfarmGateway extends Object {
|
|
|
24
24
|
* @param start 开始时间,格式为"yyyy-MM-dd"
|
|
25
25
|
* @param end 结束时间,格式为"yyyy-MM-dd"
|
|
26
26
|
* @returns 返回Promise对象,解析后得到axios响应结果
|
|
27
|
-
*/
|
|
27
|
+
*/
|
|
28
28
|
}
|
|
29
29
|
unitStat(unitIds, start, end) {
|
|
30
30
|
return this.context.ready.then((axios) => {
|
|
@@ -62,6 +62,25 @@ class PigfarmGateway extends Object {
|
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
+
get relay() {
|
|
66
|
+
return {
|
|
67
|
+
list: (unit) => {
|
|
68
|
+
return this.context.ready.then((axios) => {
|
|
69
|
+
return axios.get(`/api/v2/pigfarm/relay/config/${unit.id}`);
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
add: (unit, data) => {
|
|
73
|
+
return this.context.ready.then((axios) => {
|
|
74
|
+
return axios.post(`/api/v2/pigfarm/relay/config/add/${unit.id}`, data);
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
update: (unit, data) => {
|
|
78
|
+
return this.context.ready.then((axios) => {
|
|
79
|
+
return axios.post(`/api/v2/pigfarm/relay/config/update/${unit.id}`, data);
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
65
84
|
get heatlamp() {
|
|
66
85
|
return {
|
|
67
86
|
add: (unit, data) => {
|
|
@@ -94,10 +113,12 @@ class PigfarmGateway extends Object {
|
|
|
94
113
|
//设置,传入id或对象,action为dayage时需要传回设置的天数
|
|
95
114
|
set: async (lamp, action, arg) => {
|
|
96
115
|
var axios = await this.context.ready;
|
|
97
|
-
var url = action === "dayage"
|
|
116
|
+
var url = action === "dayage"
|
|
117
|
+
? "/api/v1/pigfarm/heatLamp/syncDayage"
|
|
118
|
+
: `/api/v1/pigfarm/heatLamp/config/set`;
|
|
98
119
|
var id = typeof lamp === "number" ? lamp : lamp.id;
|
|
99
120
|
var body = {
|
|
100
|
-
id
|
|
121
|
+
id,
|
|
101
122
|
};
|
|
102
123
|
switch (action) {
|
|
103
124
|
case "dayage":
|
package/package.json
CHANGED
package/pigfarm_gateway.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cpzxrobot, HeatLamp, Unit } from ".";
|
|
1
|
+
import { Cpzxrobot, DeviceConfig, HeatLamp, Unit } from ".";
|
|
2
2
|
|
|
3
3
|
export class PigfarmGateway extends Object {
|
|
4
4
|
context: Cpzxrobot;
|
|
@@ -18,15 +18,16 @@ export class PigfarmGateway extends Object {
|
|
|
18
18
|
return this.context.ready.then((axios) => {
|
|
19
19
|
return axios.get(`/api/v1/pigfarm/pigcount/${unit.id}`);
|
|
20
20
|
});
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 获取单元统计信息
|
|
24
|
+
*
|
|
25
|
+
* @param unitIds 单元ID数组
|
|
26
|
+
* @param start 开始时间,格式为"yyyy-MM-dd"
|
|
27
|
+
* @param end 结束时间,格式为"yyyy-MM-dd"
|
|
28
|
+
* @returns 返回Promise对象,解析后得到axios响应结果
|
|
29
|
+
*/
|
|
30
|
+
}
|
|
30
31
|
unitStat(unitIds: Number[], start: string, end: string) {
|
|
31
32
|
return this.context.ready.then((axios) => {
|
|
32
33
|
return axios.post(`/api/v1/pigfarm/feedStatics`, {
|
|
@@ -71,6 +72,26 @@ export class PigfarmGateway extends Object {
|
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
get relay() {
|
|
76
|
+
return {
|
|
77
|
+
list: (unit: Unit) => {
|
|
78
|
+
return this.context.ready.then((axios) => {
|
|
79
|
+
return axios.get(`/api/v2/pigfarm/relay/config/${unit.id}`);
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
add: (unit: Unit, data: DeviceConfig) => {
|
|
83
|
+
return this.context.ready.then((axios) => {
|
|
84
|
+
return axios.post(`/api/v2/pigfarm/relay/config/add/${unit.id}`, data);
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
update: (unit: Unit, data: DeviceConfig) => {
|
|
88
|
+
return this.context.ready.then((axios) => {
|
|
89
|
+
return axios.post(`/api/v2/pigfarm/relay/config/update/${unit.id}`, data);
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
74
95
|
get heatlamp() {
|
|
75
96
|
return {
|
|
76
97
|
add: (unit: Unit, data: HeatLamp) => {
|
|
@@ -89,16 +110,12 @@ export class PigfarmGateway extends Object {
|
|
|
89
110
|
},
|
|
90
111
|
list: async (unit: Unit): Promise<any> => {
|
|
91
112
|
var axios = await this.context.ready;
|
|
92
|
-
return axios.post(
|
|
93
|
-
`/api/v1/pigfarm/heatLamp/list/${unit.id}`
|
|
94
|
-
);
|
|
113
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/list/${unit.id}`);
|
|
95
114
|
},
|
|
96
115
|
//返回物联网相关的字段
|
|
97
116
|
iotFields: async (lamp: HeatLamp): Promise<any> => {
|
|
98
117
|
var axios = await this.context.ready;
|
|
99
|
-
return axios.post(
|
|
100
|
-
`/api/v1/pigfarm/heatLamp/iotFields/${lamp.id}`
|
|
101
|
-
);
|
|
118
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/iotFields/${lamp.id}`);
|
|
102
119
|
},
|
|
103
120
|
//开关,传入id或对象,action为on或off
|
|
104
121
|
switch: async (lamp: HeatLamp | number, action: "on" | "off") => {
|
|
@@ -110,15 +127,18 @@ export class PigfarmGateway extends Object {
|
|
|
110
127
|
});
|
|
111
128
|
},
|
|
112
129
|
//设置,传入id或对象,action为dayage时需要传回设置的天数
|
|
113
|
-
set: async (lamp: HeatLamp, action: "dayage",arg: any): Promise<any> => {
|
|
130
|
+
set: async (lamp: HeatLamp, action: "dayage", arg: any): Promise<any> => {
|
|
114
131
|
var axios = await this.context.ready;
|
|
115
|
-
var url =
|
|
132
|
+
var url =
|
|
133
|
+
action === "dayage"
|
|
134
|
+
? "/api/v1/pigfarm/heatLamp/syncDayage"
|
|
135
|
+
: `/api/v1/pigfarm/heatLamp/config/set`;
|
|
116
136
|
var id = typeof lamp === "number" ? lamp : lamp.id;
|
|
117
|
-
var body:{
|
|
118
|
-
id: number
|
|
119
|
-
days?: number
|
|
137
|
+
var body: {
|
|
138
|
+
id: number;
|
|
139
|
+
days?: number;
|
|
120
140
|
} = {
|
|
121
|
-
id
|
|
141
|
+
id,
|
|
122
142
|
};
|
|
123
143
|
switch (action) {
|
|
124
144
|
case "dayage":
|
package/types.d.ts
CHANGED
|
@@ -96,10 +96,19 @@ type HeatLamp = {
|
|
|
96
96
|
// 环境温度补偿值
|
|
97
97
|
tempCompensation: number;
|
|
98
98
|
periodList: {
|
|
99
|
-
startTemp: number
|
|
100
|
-
startDayage: number
|
|
101
|
-
}[]
|
|
102
|
-
}
|
|
99
|
+
startTemp: number;
|
|
100
|
+
startDayage: number;
|
|
101
|
+
}[];
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
//针对具有SN码的设备的统一配置
|
|
105
|
+
type DeviceConfig = {
|
|
106
|
+
id?: "";
|
|
107
|
+
unitId?: number;
|
|
108
|
+
serialNumber: string;
|
|
109
|
+
address?: string;
|
|
110
|
+
type?: string;
|
|
111
|
+
};
|
|
103
112
|
|
|
104
113
|
type Electricity = {
|
|
105
114
|
deviceId: string;
|
|
@@ -179,9 +188,9 @@ export class Cpzxrobot {
|
|
|
179
188
|
_getSelectedUnitFromMiniApp: () => Promise<Unit>;
|
|
180
189
|
openMiniApp: (url: string) => void;
|
|
181
190
|
on: (event: string, callback: (data: any) => void) => void;
|
|
182
|
-
setTitle:
|
|
183
|
-
saveBase64:
|
|
184
|
-
saveBlob:
|
|
191
|
+
setTitle: (title: string) => void;
|
|
192
|
+
saveBase64: (base64: string, filename: string) => void;
|
|
193
|
+
saveBlob: (blob: Blob, filename: string) => void;
|
|
185
194
|
}
|
|
186
195
|
|
|
187
196
|
declare global {
|
|
@@ -228,5 +237,8 @@ declare module "@cpzxrobot/sdk" {
|
|
|
228
237
|
Camera,
|
|
229
238
|
FeedTowerExtraInfo,
|
|
230
239
|
Electricity,
|
|
240
|
+
DeviceConfig,
|
|
241
|
+
DataQueryArgs,
|
|
242
|
+
HeatLamp
|
|
231
243
|
};
|
|
232
244
|
}
|