@cpzxrobot/sdk 1.1.2 → 1.1.4
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/car_gateway.ts +7 -1
- package/chickenfarm_gateway.ts +0 -6
- package/device_gateway.ts +0 -1
- package/device_types/feedtower.ts +26 -20
- package/dist/car_gateway.js +5 -0
- package/dist/device_types/feedtower.js +6 -0
- package/dist/pigfarm_gateway.js +2 -0
- package/package.json +1 -1
- package/pigfarm_gateway.ts +2 -0
- package/types.d.ts +4 -2
package/car_gateway.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cpzxrobot, Device,
|
|
1
|
+
import { Cpzxrobot, Device, Factory } from ".";
|
|
2
2
|
|
|
3
3
|
export class CarGateway extends Object {
|
|
4
4
|
context: Cpzxrobot;
|
|
@@ -12,4 +12,10 @@ export class CarGateway extends Object {
|
|
|
12
12
|
.get(`/api/v2/car/${car.id}/weightRecords?date=`+date.toISOString())
|
|
13
13
|
.then((res) => res.data);
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
detections(factory: Factory,date: Date) {
|
|
17
|
+
return this.context.axios
|
|
18
|
+
.get(`/api/v2/car/${factory.pid}/detections?date=`+ date.toISOString())
|
|
19
|
+
.then((res) => res.data);
|
|
20
|
+
}
|
|
15
21
|
}
|
package/chickenfarm_gateway.ts
CHANGED
package/device_gateway.ts
CHANGED
|
@@ -42,7 +42,7 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
|
42
42
|
throw res[0].data.Error;
|
|
43
43
|
} else {
|
|
44
44
|
if (!args.ingoreInput) {
|
|
45
|
-
if (res[1].data.data.list == undefined){
|
|
45
|
+
if (res[1].data.data.list == undefined) {
|
|
46
46
|
throw "未查询到饲料下料数据,请联系管理员";
|
|
47
47
|
}
|
|
48
48
|
res[1].data.data.list.forEach((item: any) => {
|
|
@@ -166,22 +166,22 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
|
166
166
|
options:
|
|
167
167
|
| undefined
|
|
168
168
|
| {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
169
|
+
id?: Number | null | undefined; //工厂id
|
|
170
|
+
data?:
|
|
171
|
+
| "diffPerDay"
|
|
172
|
+
| "sumPerDay"
|
|
173
|
+
| "latest"
|
|
174
|
+
| "weekoverweek"
|
|
175
|
+
| "last"
|
|
176
|
+
| "rangeOfDay"
|
|
177
|
+
| "rangeToday"
|
|
178
|
+
| null; //如果data为null,则不获取数据,只获取设备列表,否则获取设备列表和数据
|
|
179
|
+
status?: string;
|
|
180
|
+
unit?: Number;
|
|
181
|
+
detail?: boolean;
|
|
182
|
+
type?: string;
|
|
183
|
+
supplier?: string; //供应商,可用于过滤设备
|
|
184
|
+
} = undefined
|
|
185
185
|
) => {
|
|
186
186
|
return this.context.axios.get(
|
|
187
187
|
`/api/v2/device/feedTower/list/${options?.id}`
|
|
@@ -193,12 +193,18 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
|
193
193
|
update: (ft: FeedTowerV2) => {
|
|
194
194
|
return this.context.axios.post("/api/v2/device/feedTower/update", ft);
|
|
195
195
|
},
|
|
196
|
-
adzero: (ft: FeedTowerV2,force = false) => {
|
|
197
|
-
return this.context.axios.post(`/api/v2/device/feedTower/adzero`,{
|
|
196
|
+
adzero: (ft: FeedTowerV2, force = false) => {
|
|
197
|
+
return this.context.axios.post(`/api/v2/device/feedTower/adzero`, {
|
|
198
198
|
id: ft.id,
|
|
199
199
|
force: force
|
|
200
200
|
});
|
|
201
|
-
|
|
201
|
+
},
|
|
202
|
+
correctWeight: (ft: FeedTowerV2, amount: Number) => {
|
|
203
|
+
return this.context.axios.post(`/api/v2/device/feedTower/correctWeight`, {
|
|
204
|
+
id: ft.id,
|
|
205
|
+
suttle: amount,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
202
208
|
};
|
|
203
209
|
}
|
|
204
210
|
}
|
package/dist/car_gateway.js
CHANGED
|
@@ -11,5 +11,10 @@ class CarGateway extends Object {
|
|
|
11
11
|
.get(`/api/v2/car/${car.id}/weightRecords?date=` + date.toISOString())
|
|
12
12
|
.then((res) => res.data);
|
|
13
13
|
}
|
|
14
|
+
detections(factory, date) {
|
|
15
|
+
return this.context.axios
|
|
16
|
+
.get(`/api/v2/car/${factory.pid}/detections?date=` + date.toISOString())
|
|
17
|
+
.then((res) => res.data);
|
|
18
|
+
}
|
|
14
19
|
}
|
|
15
20
|
exports.CarGateway = CarGateway;
|
|
@@ -136,6 +136,12 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
|
|
|
136
136
|
id: ft.id,
|
|
137
137
|
force: force
|
|
138
138
|
});
|
|
139
|
+
},
|
|
140
|
+
correctWeight: (ft, amount) => {
|
|
141
|
+
return this.context.axios.post(`/api/v2/device/feedTower/correctWeight`, {
|
|
142
|
+
id: ft.id,
|
|
143
|
+
suttle: amount,
|
|
144
|
+
});
|
|
139
145
|
}
|
|
140
146
|
};
|
|
141
147
|
}
|
package/dist/pigfarm_gateway.js
CHANGED
|
@@ -76,11 +76,13 @@ class PigfarmGateway extends Object {
|
|
|
76
76
|
});
|
|
77
77
|
},
|
|
78
78
|
add: (unit, data) => {
|
|
79
|
+
data.unitId = unit.id;
|
|
79
80
|
return this.context.ready.then((axios) => {
|
|
80
81
|
return axios.post(`/api/v2/pigfarm/relay/config/add`, data);
|
|
81
82
|
});
|
|
82
83
|
},
|
|
83
84
|
update: (unit, data) => {
|
|
85
|
+
data.unitId = unit.id;
|
|
84
86
|
return this.context.ready.then((axios) => {
|
|
85
87
|
return axios.post(`/api/v2/pigfarm/relay/config/update`, data);
|
|
86
88
|
});
|
package/package.json
CHANGED
package/pigfarm_gateway.ts
CHANGED
|
@@ -99,11 +99,13 @@ export class PigfarmGateway extends Object {
|
|
|
99
99
|
});
|
|
100
100
|
},
|
|
101
101
|
add: (unit: Unit, data: DeviceConfig) => {
|
|
102
|
+
data.unitId = unit.id;
|
|
102
103
|
return this.context.ready.then((axios) => {
|
|
103
104
|
return axios.post(`/api/v2/pigfarm/relay/config/add`, data);
|
|
104
105
|
});
|
|
105
106
|
},
|
|
106
107
|
update: (unit: Unit, data: DeviceConfig) => {
|
|
108
|
+
data.unitId = unit.id;
|
|
107
109
|
return this.context.ready.then((axios) => {
|
|
108
110
|
return axios.post(`/api/v2/pigfarm/relay/config/update`, data);
|
|
109
111
|
});
|
package/types.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { UserGateway } from "@cpzxrobot/sdk/user_gateway";
|
|
|
5
5
|
import { CameraGateway } from "@cpzxrobot/sdk/camera_gateway";
|
|
6
6
|
import { PigfarmGateway } from "@cpzxrobot/sdk/pigfarm_gateway";
|
|
7
7
|
import { ChickenFarmGateway } from "@cpzxrobot/sdk/chickenfarm_gateway";
|
|
8
|
-
import { UnitGateway } from "@cpzxrobot/sdk
|
|
8
|
+
import { UnitGateway } from "@cpzxrobot/sdk/unit_gateway";
|
|
9
|
+
import { CarGateway } from "@cpzxrobot/sdk/car_gateway";
|
|
9
10
|
import { FieldDatas } from "./sensor_datas";
|
|
10
11
|
|
|
11
12
|
type Device = {
|
|
@@ -75,7 +76,7 @@ type Factory = {
|
|
|
75
76
|
company_code: string;
|
|
76
77
|
id?: number;
|
|
77
78
|
type?: string;
|
|
78
|
-
pid?:
|
|
79
|
+
pid?: number;
|
|
79
80
|
};
|
|
80
81
|
type Unit = {
|
|
81
82
|
name?: string;
|
|
@@ -303,6 +304,7 @@ class Cpzxrobot {
|
|
|
303
304
|
camera: CameraGateway;
|
|
304
305
|
pigfarm: PigfarmGateway;
|
|
305
306
|
chickenfarm: ChickenfarmGateway;
|
|
307
|
+
car: CarGateway;
|
|
306
308
|
dict: (key: string) => any;
|
|
307
309
|
_getSelectedFarmFromMiniApp: () => Promise<Factory>;
|
|
308
310
|
_getSelectedUnitFromMiniApp: () => Promise<Unit>;
|