@cpzxrobot/sdk 1.0.36 → 1.0.38
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/camera_gateway.ts +13 -2
- package/dist/camera_gateway.js +12 -2
- package/dist/pigfarm_gateway.js +21 -0
- package/dist/transport_gateway.js +1 -1
- package/package.json +1 -1
- package/pigfarm_gateway.ts +26 -1
- package/readme.md +12 -1
- package/transport_gateway.ts +2 -2
- package/types.d.ts +21 -0
package/camera_gateway.ts
CHANGED
|
@@ -6,11 +6,22 @@ export class CameraGateway extends Object {
|
|
|
6
6
|
super();
|
|
7
7
|
this.context = context;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
//搜索摄像头,传入unit对象或者unit的id
|
|
10
10
|
async search(data: Unit): Promise<any> {
|
|
11
11
|
var axios = await this.context.ready;
|
|
12
|
+
var id = data.id;
|
|
13
|
+
|
|
14
|
+
if (!id) {
|
|
15
|
+
//if data is string
|
|
16
|
+
if (typeof data === "string") {
|
|
17
|
+
id = data;
|
|
18
|
+
}else{
|
|
19
|
+
throw new Error("请传入正确的Unit对象");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
const response = await axios.post("/api/v1/camera/search", {
|
|
13
|
-
unit_id:
|
|
24
|
+
unit_id: id,
|
|
14
25
|
});
|
|
15
26
|
return response.data;
|
|
16
27
|
}
|
package/dist/camera_gateway.js
CHANGED
|
@@ -6,11 +6,21 @@ class CameraGateway extends Object {
|
|
|
6
6
|
super();
|
|
7
7
|
this.context = context;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
//搜索摄像头,传入unit对象或者unit的id
|
|
10
10
|
async search(data) {
|
|
11
11
|
var axios = await this.context.ready;
|
|
12
|
+
var id = data.id;
|
|
13
|
+
if (!id) {
|
|
14
|
+
//if data is string
|
|
15
|
+
if (typeof data === "string") {
|
|
16
|
+
id = data;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
throw new Error("请传入正确的Unit对象");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
12
22
|
const response = await axios.post("/api/v1/camera/search", {
|
|
13
|
-
unit_id:
|
|
23
|
+
unit_id: id,
|
|
14
24
|
});
|
|
15
25
|
return response.data;
|
|
16
26
|
}
|
package/dist/pigfarm_gateway.js
CHANGED
|
@@ -44,5 +44,26 @@ class PigfarmGateway extends Object {
|
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
+
get heatlamp() {
|
|
48
|
+
return {
|
|
49
|
+
add: (unit, data) => {
|
|
50
|
+
return this.context.ready.then((axios) => {
|
|
51
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/config/add`, Object.assign(Object.assign({}, data), { unitId: unit.id }));
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
list: async (unit) => {
|
|
55
|
+
var axios = await this.context.ready;
|
|
56
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/config/list?unitId=${unit.id}`);
|
|
57
|
+
},
|
|
58
|
+
get: async (id) => {
|
|
59
|
+
var axios = await this.context.ready;
|
|
60
|
+
return axios.get(`/api/v1/pigfarm/heatLamp/config/${id}`);
|
|
61
|
+
},
|
|
62
|
+
update: async (lamp) => {
|
|
63
|
+
var axios = await this.context.ready;
|
|
64
|
+
return axios.get(`/api/v1/pigfarm/heatLamp/config/update`, lamp);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
47
68
|
}
|
|
48
69
|
exports.PigfarmGateway = PigfarmGateway;
|
|
@@ -37,7 +37,7 @@ class TransportGateway extends Object {
|
|
|
37
37
|
getDeviceByFodderld: (id) => {
|
|
38
38
|
return this.context.ready.then(() => {
|
|
39
39
|
return this.context.axios
|
|
40
|
-
.get("/api/v1/pigfarm/device/fodderTower/
|
|
40
|
+
.get("/api/v1/pigfarm/device/fodderTower/getDeviceByFodderId", {
|
|
41
41
|
params: {
|
|
42
42
|
fodderld: id,
|
|
43
43
|
},
|
package/package.json
CHANGED
package/pigfarm_gateway.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cpzxrobot, Unit } from ".";
|
|
1
|
+
import { Cpzxrobot, HeatLamp, Unit } from ".";
|
|
2
2
|
|
|
3
3
|
export class PigfarmGateway extends Object {
|
|
4
4
|
context: Cpzxrobot;
|
|
@@ -52,4 +52,29 @@ export class PigfarmGateway extends Object {
|
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
get heatlamp() {
|
|
57
|
+
return {
|
|
58
|
+
add: (unit:Unit, data: HeatLamp) => {
|
|
59
|
+
return this.context.ready.then((axios) => {
|
|
60
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/config/add`, {
|
|
61
|
+
...data,
|
|
62
|
+
unitId: unit.id,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
list: async (unit:Unit):Promise<any>=> {
|
|
67
|
+
var axios = await this.context.ready;
|
|
68
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/config/list?unitId=${unit.id}`)
|
|
69
|
+
},
|
|
70
|
+
get: async (id: number):Promise<any>=> {
|
|
71
|
+
var axios = await this.context.ready;
|
|
72
|
+
return axios.get(`/api/v1/pigfarm/heatLamp/config/${id}`)
|
|
73
|
+
},
|
|
74
|
+
update:async (lamp: HeatLamp):Promise<any>=> {
|
|
75
|
+
var axios = await this.context.ready;
|
|
76
|
+
return axios.get(`/api/v1/pigfarm/heatLamp/config/update`,lamp)
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
55
80
|
}
|
package/readme.md
CHANGED
|
@@ -81,6 +81,8 @@ baseURL: "/"
|
|
|
81
81
|
| cpzxrobot().camera.xxx | 获得摄像头的相关信息 |
|
|
82
82
|
| cpzxrobot().factory.entry| 获得工厂的可显示动态信息 |
|
|
83
83
|
| cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
|
|
84
|
+
| cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
|
|
85
|
+
|
|
84
86
|
|
|
85
87
|
### 工厂信息接口
|
|
86
88
|
|
|
@@ -123,4 +125,13 @@ factory_id: 工厂id
|
|
|
123
125
|
|
|
124
126
|
`cpzxrobot().saveBase64(base64,filename)`
|
|
125
127
|
|
|
126
|
-
保存Base64内容为文件
|
|
128
|
+
保存Base64内容为文件
|
|
129
|
+
|
|
130
|
+
### 保温灯相关接口
|
|
131
|
+
|
|
132
|
+
heatlamp 属性提供了一组方法,用于管理猪场的热灯配置。它包含以下方法:
|
|
133
|
+
|
|
134
|
+
**cpzxrobot().pigfarm.heatlamp.add(unit, data)**:添加新的热灯配置。
|
|
135
|
+
**cpzxrobot().pigfarm.heatlamp.list(unit)**:列出指定单元的所有热灯配置。
|
|
136
|
+
**cpzxrobot().pigfarm.heatlamp.get(id)**:获取指定 ID 的热灯配置。
|
|
137
|
+
**cpzxrobot().pigfarm.heatlamp.update(lamp)**:更新热灯配置。
|
package/transport_gateway.ts
CHANGED
|
@@ -44,10 +44,10 @@ export class TransportGateway extends Object {
|
|
|
44
44
|
return this.getDetail;
|
|
45
45
|
},
|
|
46
46
|
//按料单获得对应的料塔
|
|
47
|
-
getDeviceByFodderld: (id:
|
|
47
|
+
getDeviceByFodderld: (id: string): Promise<any> => {
|
|
48
48
|
return this.context.ready.then(() => {
|
|
49
49
|
return this.context.axios
|
|
50
|
-
.get("/api/v1/pigfarm/device/fodderTower/
|
|
50
|
+
.get("/api/v1/pigfarm/device/fodderTower/getDeviceByFodderId", {
|
|
51
51
|
params: {
|
|
52
52
|
fodderld: id,
|
|
53
53
|
},
|
package/types.d.ts
CHANGED
|
@@ -79,6 +79,27 @@ type Unit = {
|
|
|
79
79
|
workshopName?: string;
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
type HeatLamp = {
|
|
83
|
+
id: number;
|
|
84
|
+
unitId: number;
|
|
85
|
+
lampLine: number;
|
|
86
|
+
lampColumn: number;
|
|
87
|
+
startDate: string;
|
|
88
|
+
//运行天数
|
|
89
|
+
runDays: number;
|
|
90
|
+
workMode: "auto" | "manual";
|
|
91
|
+
// 告警阈值下限
|
|
92
|
+
alarmLower: number;
|
|
93
|
+
// 告警阈值上限
|
|
94
|
+
alarmUpper: number;
|
|
95
|
+
// 环境温度补偿值
|
|
96
|
+
tempCompensation: number;
|
|
97
|
+
periodList: {
|
|
98
|
+
startTemp: number,
|
|
99
|
+
startDayage: number,
|
|
100
|
+
}[]
|
|
101
|
+
}
|
|
102
|
+
|
|
82
103
|
type Electricity = {
|
|
83
104
|
deviceId: string;
|
|
84
105
|
nextDeviceList: number[] | [];
|