@cpzxrobot/sdk 1.0.44 → 1.0.46
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_types/feedtower.ts +19 -0
- package/dist/device_types/feedtower.js +18 -0
- package/dist/pigfarm_gateway.js +46 -1
- package/package.json +1 -1
- package/pigfarm_gateway.ts +51 -1
- package/readme.md +4 -0
|
@@ -89,4 +89,23 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
|
89
89
|
)
|
|
90
90
|
return res
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 查询指定设备的饲料统计信息
|
|
95
|
+
*
|
|
96
|
+
* @param deviceIds 设备ID数组
|
|
97
|
+
* @param start 开始时间,格式为yyyy-MM-dd
|
|
98
|
+
* @param end 结束时间,格式为yyyy-MM-dd
|
|
99
|
+
* @returns 饲料统计信息
|
|
100
|
+
*/
|
|
101
|
+
async stat(deviceIds: Number[], start: string, end: string) {
|
|
102
|
+
return this.context.ready.then((axios) => {
|
|
103
|
+
return axios.post(`/api/v1/pigfarm/feedStatics`, {
|
|
104
|
+
ids: deviceIds,
|
|
105
|
+
type: "device",
|
|
106
|
+
start: start,
|
|
107
|
+
end: end,
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
92
111
|
}
|
|
@@ -81,5 +81,23 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
|
|
|
81
81
|
const res = await this.context.axios.post('/api/v1/pigfarm/device/status/updateZeroTime' + '?id=' + id);
|
|
82
82
|
return res;
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* 查询指定设备的饲料统计信息
|
|
86
|
+
*
|
|
87
|
+
* @param deviceIds 设备ID数组
|
|
88
|
+
* @param start 开始时间,格式为yyyy-MM-dd
|
|
89
|
+
* @param end 结束时间,格式为yyyy-MM-dd
|
|
90
|
+
* @returns 饲料统计信息
|
|
91
|
+
*/
|
|
92
|
+
async stat(deviceIds, start, end) {
|
|
93
|
+
return this.context.ready.then((axios) => {
|
|
94
|
+
return axios.post(`/api/v1/pigfarm/feedStatics`, {
|
|
95
|
+
ids: deviceIds,
|
|
96
|
+
type: "device",
|
|
97
|
+
start: start,
|
|
98
|
+
end: end,
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
84
102
|
}
|
|
85
103
|
exports.FeedTowerGateway = FeedTowerGateway;
|
package/dist/pigfarm_gateway.js
CHANGED
|
@@ -17,6 +17,24 @@ class PigfarmGateway extends Object {
|
|
|
17
17
|
return this.context.ready.then((axios) => {
|
|
18
18
|
return axios.get(`/api/v1/pigfarm/pigcount/${unit.id}`);
|
|
19
19
|
});
|
|
20
|
+
/**
|
|
21
|
+
* 获取单元统计信息
|
|
22
|
+
*
|
|
23
|
+
* @param unitIds 单元ID数组
|
|
24
|
+
* @param start 开始时间,格式为"yyyy-MM-dd"
|
|
25
|
+
* @param end 结束时间,格式为"yyyy-MM-dd"
|
|
26
|
+
* @returns 返回Promise对象,解析后得到axios响应结果
|
|
27
|
+
*/
|
|
28
|
+
}
|
|
29
|
+
unitStat(unitIds, start, end) {
|
|
30
|
+
return this.context.ready.then((axios) => {
|
|
31
|
+
return axios.post(`/api/v1/pigfarm/feedStatics`, {
|
|
32
|
+
ids: unitIds,
|
|
33
|
+
type: "unit",
|
|
34
|
+
start: start,
|
|
35
|
+
end: end,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
20
38
|
}
|
|
21
39
|
//获得当日统计
|
|
22
40
|
dailyReportForUnit(unit, type) {
|
|
@@ -51,10 +69,37 @@ class PigfarmGateway extends Object {
|
|
|
51
69
|
return axios.post(`/api/v1/pigfarm/heatLamp/config/add`, Object.assign(Object.assign({}, data), { unitId: unit.id }));
|
|
52
70
|
});
|
|
53
71
|
},
|
|
54
|
-
|
|
72
|
+
configList: async (unit) => {
|
|
55
73
|
var axios = await this.context.ready;
|
|
56
74
|
return axios.post(`/api/v1/pigfarm/heatLamp/config/list?unitId=${unit.id}`);
|
|
57
75
|
},
|
|
76
|
+
list: async (unit) => {
|
|
77
|
+
var axios = await this.context.ready;
|
|
78
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/list/${unit.id}`);
|
|
79
|
+
},
|
|
80
|
+
//开关,传入id或对象,action为on或off
|
|
81
|
+
switch: async (lamp, action) => {
|
|
82
|
+
var axios = await this.context.ready;
|
|
83
|
+
var id = typeof lamp === "number" ? lamp : lamp.id;
|
|
84
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/switch`, {
|
|
85
|
+
id,
|
|
86
|
+
action,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
//设置,传入id或对象,action为dayage时需要传回设置的天数
|
|
90
|
+
set: async (lamp, action, arg) => {
|
|
91
|
+
var axios = await this.context.ready;
|
|
92
|
+
var url = action === "dayage" ? "/api/v1/pigfarm/heatLamp/syncDayage" : "";
|
|
93
|
+
var id = typeof lamp === "number" ? lamp : lamp.id;
|
|
94
|
+
var body = {
|
|
95
|
+
id
|
|
96
|
+
};
|
|
97
|
+
switch (action) {
|
|
98
|
+
case "dayage":
|
|
99
|
+
body["days"] = arg;
|
|
100
|
+
}
|
|
101
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/config/set`, lamp);
|
|
102
|
+
},
|
|
58
103
|
get: async (id) => {
|
|
59
104
|
var axios = await this.context.ready;
|
|
60
105
|
return axios.get(`/api/v1/pigfarm/heatLamp/config/${id}`);
|
package/package.json
CHANGED
package/pigfarm_gateway.ts
CHANGED
|
@@ -18,6 +18,24 @@ 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
|
+
* @param unitIds 单元ID数组
|
|
26
|
+
* @param start 开始时间,格式为"yyyy-MM-dd"
|
|
27
|
+
* @param end 结束时间,格式为"yyyy-MM-dd"
|
|
28
|
+
* @returns 返回Promise对象,解析后得到axios响应结果
|
|
29
|
+
*/ }
|
|
30
|
+
unitStat(unitIds: Number[], start: string, end: string) {
|
|
31
|
+
return this.context.ready.then((axios) => {
|
|
32
|
+
return axios.post(`/api/v1/pigfarm/feedStatics`, {
|
|
33
|
+
ids: unitIds,
|
|
34
|
+
type: "unit",
|
|
35
|
+
start: start,
|
|
36
|
+
end: end,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
21
39
|
}
|
|
22
40
|
|
|
23
41
|
//获得当日统计
|
|
@@ -63,12 +81,44 @@ export class PigfarmGateway extends Object {
|
|
|
63
81
|
});
|
|
64
82
|
});
|
|
65
83
|
},
|
|
66
|
-
|
|
84
|
+
configList: async (unit: Unit): Promise<any> => {
|
|
67
85
|
var axios = await this.context.ready;
|
|
68
86
|
return axios.post(
|
|
69
87
|
`/api/v1/pigfarm/heatLamp/config/list?unitId=${unit.id}`
|
|
70
88
|
);
|
|
71
89
|
},
|
|
90
|
+
list: async (unit: Unit): Promise<any> => {
|
|
91
|
+
var axios = await this.context.ready;
|
|
92
|
+
return axios.post(
|
|
93
|
+
`/api/v1/pigfarm/heatLamp/list/${unit.id}`
|
|
94
|
+
);
|
|
95
|
+
},
|
|
96
|
+
//开关,传入id或对象,action为on或off
|
|
97
|
+
switch: async (lamp: HeatLamp | number, action: "on" | "off") => {
|
|
98
|
+
var axios = await this.context.ready;
|
|
99
|
+
var id = typeof lamp === "number" ? lamp : lamp.id;
|
|
100
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/switch`, {
|
|
101
|
+
id,
|
|
102
|
+
action,
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
//设置,传入id或对象,action为dayage时需要传回设置的天数
|
|
106
|
+
set: async (lamp: HeatLamp, action: "dayage",arg: any): Promise<any> => {
|
|
107
|
+
var axios = await this.context.ready;
|
|
108
|
+
var url = action === "dayage" ? "/api/v1/pigfarm/heatLamp/syncDayage" : "";
|
|
109
|
+
var id = typeof lamp === "number" ? lamp : lamp.id;
|
|
110
|
+
var body:{
|
|
111
|
+
id: number,
|
|
112
|
+
days?: number,
|
|
113
|
+
} = {
|
|
114
|
+
id
|
|
115
|
+
};
|
|
116
|
+
switch (action) {
|
|
117
|
+
case "dayage":
|
|
118
|
+
body["days"] = arg;
|
|
119
|
+
}
|
|
120
|
+
return axios.post(`/api/v1/pigfarm/heatLamp/config/set`, lamp);
|
|
121
|
+
},
|
|
72
122
|
get: async (id: number): Promise<any> => {
|
|
73
123
|
var axios = await this.context.ready;
|
|
74
124
|
return axios.get(`/api/v1/pigfarm/heatLamp/config/${id}`);
|
package/readme.md
CHANGED
|
@@ -82,6 +82,10 @@ baseURL: "/"
|
|
|
82
82
|
| cpzxrobot().factory.entry| 获得工厂的可显示动态信息 |
|
|
83
83
|
| cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
|
|
84
84
|
| cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
|
|
85
|
+
| cpzxrobot().device.feedTower.stat | 获得料塔设备的料耗,饲料重量 |
|
|
86
|
+
| cpzxrobot().pigfarm.unitStat | 获得单元的统计信息,包括每日料耗,饲料消耗,日龄,存栏量等 |
|
|
87
|
+
| cpzxrobot().pigfarm.heatlamp.set | 设置保温灯的当前工作日龄,调用时,action传"dayage",argc传天数 |
|
|
88
|
+
| cpzxrobot().pigfarm.heatlamp.switch | 设置保温灯的当前工作日龄,调用时,action"on"或"off" |
|
|
85
89
|
|
|
86
90
|
|
|
87
91
|
### 工厂信息接口
|