@cpzxrobot/sdk 1.3.42 → 1.3.43
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/device_gateway.ts +8 -2
- package/dist/device_gateway.js +9 -2
- package/package.json +1 -1
- package/types.d.ts +3 -3
package/device_gateway.ts
CHANGED
|
@@ -211,11 +211,17 @@ export class DeviceGateway extends Object {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
async watch(
|
|
214
|
-
|
|
214
|
+
ids: number|number[],
|
|
215
215
|
fn: any,
|
|
216
216
|
) {
|
|
217
217
|
var axios = await this.context.ready;
|
|
218
|
-
|
|
218
|
+
var idQuery = "";
|
|
219
|
+
if (Array.isArray(ids)) {
|
|
220
|
+
idQuery = ids.map(x => `ids=${x}`).join("&");
|
|
221
|
+
}else{
|
|
222
|
+
idQuery = `ids=${ids}`;
|
|
223
|
+
}
|
|
224
|
+
return axios.getAsSse(`/api/v1/device/watch?`+idQuery, fn)
|
|
219
225
|
}
|
|
220
226
|
|
|
221
227
|
private getFilter<T extends { id: number }>(
|
package/dist/device_gateway.js
CHANGED
|
@@ -168,9 +168,16 @@ class DeviceGateway extends Object {
|
|
|
168
168
|
show(id, type = "datapoint") {
|
|
169
169
|
this.context.platform.showInDeviceManager(id, type);
|
|
170
170
|
}
|
|
171
|
-
async watch(
|
|
171
|
+
async watch(ids, fn) {
|
|
172
172
|
var axios = await this.context.ready;
|
|
173
|
-
|
|
173
|
+
var idQuery = "";
|
|
174
|
+
if (Array.isArray(ids)) {
|
|
175
|
+
idQuery = ids.map(x => `ids=${x}`).join("&");
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
idQuery = `ids=${ids}`;
|
|
179
|
+
}
|
|
180
|
+
return axios.getAsSse(`/api/v1/device/watch?` + idQuery, fn);
|
|
174
181
|
}
|
|
175
182
|
getFilter(type, cls) {
|
|
176
183
|
// 如果filters中已经有对应type的过滤器,则直接返回该过滤器
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ type Device = {
|
|
|
33
33
|
currentAmount: number;
|
|
34
34
|
location: string;
|
|
35
35
|
supplier?: string;
|
|
36
|
-
data?:
|
|
36
|
+
data?: any;
|
|
37
37
|
typeCode: string;
|
|
38
38
|
unitId: number;
|
|
39
39
|
};
|
|
@@ -87,9 +87,9 @@ type Assistant = {
|
|
|
87
87
|
id: Number;
|
|
88
88
|
};
|
|
89
89
|
type Factory = {
|
|
90
|
-
code
|
|
90
|
+
code?: string;
|
|
91
91
|
name?: string;
|
|
92
|
-
company_code
|
|
92
|
+
company_code?: string;
|
|
93
93
|
id?: number;
|
|
94
94
|
type?: string;
|
|
95
95
|
kind?: string;
|