@cpzxrobot/sdk 1.3.23 → 1.3.24
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 +43 -4
- package/dist/device_gateway.js +40 -4
- package/package.json +1 -1
- package/platform_interface.ts +1 -1
- package/production_gateway.ts +2 -1
package/device_gateway.ts
CHANGED
|
@@ -386,10 +386,49 @@ export class DeviceGateway extends Object {
|
|
|
386
386
|
|
|
387
387
|
get ctrl() {
|
|
388
388
|
return {
|
|
389
|
-
//
|
|
390
|
-
get: (deviceId: number
|
|
389
|
+
// 获取设备可控制参数
|
|
390
|
+
get: (deviceId: number): Promise<any> => {
|
|
391
391
|
return this.context.ready.then(() => {
|
|
392
|
-
return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}
|
|
392
|
+
return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/paramType`)
|
|
393
|
+
.then((res) => {
|
|
394
|
+
if (res.data.code != 200) {
|
|
395
|
+
throw res.data.message;
|
|
396
|
+
}
|
|
397
|
+
return res.data;
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
// 获取设备控制部件列表
|
|
403
|
+
parts: (deviceId: number, paramType: string): Promise<any> => {
|
|
404
|
+
return this.context.ready.then(() => {
|
|
405
|
+
return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${paramType}/parts`)
|
|
406
|
+
.then((res) => {
|
|
407
|
+
if (res.data.code != 200) {
|
|
408
|
+
throw res.data.message;
|
|
409
|
+
}
|
|
410
|
+
return res.data;
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
|
|
415
|
+
// 获取部件下的控制点
|
|
416
|
+
points: (deviceId: number, paramType: string, partName: string): Promise<any> => {
|
|
417
|
+
return this.context.ready.then(() => {
|
|
418
|
+
return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${paramType}/${partName}/points`)
|
|
419
|
+
.then((res) => {
|
|
420
|
+
if (res.data.code != 200) {
|
|
421
|
+
throw res.data.message;
|
|
422
|
+
}
|
|
423
|
+
return res.data;
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
},
|
|
427
|
+
|
|
428
|
+
// 设置控制点值
|
|
429
|
+
setPoint: (deviceId: number, paramType: string, partName: string, pointId: string, value: any): Promise<any> => {
|
|
430
|
+
return this.context.ready.then(() => {
|
|
431
|
+
return this.context.axios.post(`/api/v2/device/ctrl/${deviceId}/${paramType}/${partName}/point/${pointId}`, { value })
|
|
393
432
|
.then((res) => {
|
|
394
433
|
if (res.data.code != 200) {
|
|
395
434
|
throw res.data.message;
|
|
@@ -412,7 +451,7 @@ export class DeviceGateway extends Object {
|
|
|
412
451
|
});
|
|
413
452
|
},
|
|
414
453
|
|
|
415
|
-
//
|
|
454
|
+
// 获取设备控制参数配置
|
|
416
455
|
configs: (deviceId: number, type: string): Promise<any> => {
|
|
417
456
|
return this.context.ready.then(() => {
|
|
418
457
|
return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${type}/configs`)
|
package/dist/device_gateway.js
CHANGED
|
@@ -284,10 +284,46 @@ class DeviceGateway extends Object {
|
|
|
284
284
|
}
|
|
285
285
|
get ctrl() {
|
|
286
286
|
return {
|
|
287
|
-
//
|
|
288
|
-
get: (deviceId
|
|
287
|
+
// 获取设备可控制参数
|
|
288
|
+
get: (deviceId) => {
|
|
289
289
|
return this.context.ready.then(() => {
|
|
290
|
-
return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}
|
|
290
|
+
return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/paramType`)
|
|
291
|
+
.then((res) => {
|
|
292
|
+
if (res.data.code != 200) {
|
|
293
|
+
throw res.data.message;
|
|
294
|
+
}
|
|
295
|
+
return res.data;
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
},
|
|
299
|
+
// 获取设备控制部件列表
|
|
300
|
+
parts: (deviceId, paramType) => {
|
|
301
|
+
return this.context.ready.then(() => {
|
|
302
|
+
return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${paramType}/parts`)
|
|
303
|
+
.then((res) => {
|
|
304
|
+
if (res.data.code != 200) {
|
|
305
|
+
throw res.data.message;
|
|
306
|
+
}
|
|
307
|
+
return res.data;
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
// 获取部件下的控制点
|
|
312
|
+
points: (deviceId, paramType, partName) => {
|
|
313
|
+
return this.context.ready.then(() => {
|
|
314
|
+
return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${paramType}/${partName}/points`)
|
|
315
|
+
.then((res) => {
|
|
316
|
+
if (res.data.code != 200) {
|
|
317
|
+
throw res.data.message;
|
|
318
|
+
}
|
|
319
|
+
return res.data;
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
},
|
|
323
|
+
// 设置控制点值
|
|
324
|
+
setPoint: (deviceId, paramType, partName, pointId, value) => {
|
|
325
|
+
return this.context.ready.then(() => {
|
|
326
|
+
return this.context.axios.post(`/api/v2/device/ctrl/${deviceId}/${paramType}/${partName}/point/${pointId}`, { value })
|
|
291
327
|
.then((res) => {
|
|
292
328
|
if (res.data.code != 200) {
|
|
293
329
|
throw res.data.message;
|
|
@@ -308,7 +344,7 @@ class DeviceGateway extends Object {
|
|
|
308
344
|
});
|
|
309
345
|
});
|
|
310
346
|
},
|
|
311
|
-
//
|
|
347
|
+
// 获取设备控制参数配置
|
|
312
348
|
configs: (deviceId, type) => {
|
|
313
349
|
return this.context.ready.then(() => {
|
|
314
350
|
return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${type}/configs`)
|
package/package.json
CHANGED
package/platform_interface.ts
CHANGED
package/production_gateway.ts
CHANGED
|
@@ -34,7 +34,7 @@ export class ProductionGateway extends Object {
|
|
|
34
34
|
get stat() {
|
|
35
35
|
return {
|
|
36
36
|
get: async (
|
|
37
|
-
type: 'sale' | 'order' | 'production',
|
|
37
|
+
type: 'sale' | 'order' | 'production' | 'manufacture',
|
|
38
38
|
period: 'month' | 'quater' | 'year', factoryId?: number): Promise<Array<{
|
|
39
39
|
time: string;
|
|
40
40
|
products: Record<number, number>;
|
|
@@ -54,6 +54,7 @@ export class ProductionGateway extends Object {
|
|
|
54
54
|
factory_id?: number;
|
|
55
55
|
time: Date;
|
|
56
56
|
period: number; // 1:月度, 2:季度, 3:年度
|
|
57
|
+
type: 'sale' | 'order' | 'production' | 'manufacture'
|
|
57
58
|
products: Record<number, number>; // 产品名称到产量的映射
|
|
58
59
|
}) => {
|
|
59
60
|
if (!request.factory_id) {
|