@cpzxrobot/sdk 1.0.45 → 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/dist/pigfarm_gateway.js +28 -1
- package/package.json +1 -1
- package/pigfarm_gateway.ts +33 -1
- package/readme.md +2 -0
package/dist/pigfarm_gateway.js
CHANGED
|
@@ -69,10 +69,37 @@ class PigfarmGateway extends Object {
|
|
|
69
69
|
return axios.post(`/api/v1/pigfarm/heatLamp/config/add`, Object.assign(Object.assign({}, data), { unitId: unit.id }));
|
|
70
70
|
});
|
|
71
71
|
},
|
|
72
|
-
|
|
72
|
+
configList: async (unit) => {
|
|
73
73
|
var axios = await this.context.ready;
|
|
74
74
|
return axios.post(`/api/v1/pigfarm/heatLamp/config/list?unitId=${unit.id}`);
|
|
75
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
|
+
},
|
|
76
103
|
get: async (id) => {
|
|
77
104
|
var axios = await this.context.ready;
|
|
78
105
|
return axios.get(`/api/v1/pigfarm/heatLamp/config/${id}`);
|
package/package.json
CHANGED
package/pigfarm_gateway.ts
CHANGED
|
@@ -81,12 +81,44 @@ export class PigfarmGateway extends Object {
|
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
},
|
|
84
|
-
|
|
84
|
+
configList: async (unit: Unit): Promise<any> => {
|
|
85
85
|
var axios = await this.context.ready;
|
|
86
86
|
return axios.post(
|
|
87
87
|
`/api/v1/pigfarm/heatLamp/config/list?unitId=${unit.id}`
|
|
88
88
|
);
|
|
89
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
|
+
},
|
|
90
122
|
get: async (id: number): Promise<any> => {
|
|
91
123
|
var axios = await this.context.ready;
|
|
92
124
|
return axios.get(`/api/v1/pigfarm/heatLamp/config/${id}`);
|
package/readme.md
CHANGED
|
@@ -84,6 +84,8 @@ baseURL: "/"
|
|
|
84
84
|
| cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
|
|
85
85
|
| cpzxrobot().device.feedTower.stat | 获得料塔设备的料耗,饲料重量 |
|
|
86
86
|
| cpzxrobot().pigfarm.unitStat | 获得单元的统计信息,包括每日料耗,饲料消耗,日龄,存栏量等 |
|
|
87
|
+
| cpzxrobot().pigfarm.heatlamp.set | 设置保温灯的当前工作日龄,调用时,action传"dayage",argc传天数 |
|
|
88
|
+
| cpzxrobot().pigfarm.heatlamp.switch | 设置保温灯的当前工作日龄,调用时,action"on"或"off" |
|
|
87
89
|
|
|
88
90
|
|
|
89
91
|
### 工厂信息接口
|