@cpzxrobot/sdk 1.1.1 → 1.1.3

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { Cpzxrobot, Device, Unit } from ".";
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
  }
@@ -1,12 +1,6 @@
1
1
  import {
2
2
  Cpzxrobot,
3
- DeviceConfig,
4
3
  Factory,
5
- HeatLamp,
6
- Unit,
7
- WeightMeter,
8
- WeightMeterSensor,
9
- weightMeterSensorsConfig,
10
4
  } from "./types";
11
5
 
12
6
  export class ChickenFarmGateway extends Object {
package/device_gateway.ts CHANGED
@@ -5,7 +5,6 @@ import type {
5
5
  Cpzxrobot,
6
6
  DataQueryArgs,
7
7
  DeviceV2,
8
- Unit,
9
8
  } from ".";
10
9
  import { FeedTowerGateway } from "./device_types/feedtower";
11
10
  import { ElectricMeterGateway } from "./device_types/electricmeter";
@@ -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;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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//unit_gateway";
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,6 +76,7 @@ type Factory = {
75
76
  company_code: string;
76
77
  id?: number;
77
78
  type?: string;
79
+ pid?: number;
78
80
  };
79
81
  type Unit = {
80
82
  name?: string;
@@ -302,6 +304,7 @@ class Cpzxrobot {
302
304
  camera: CameraGateway;
303
305
  pigfarm: PigfarmGateway;
304
306
  chickenfarm: ChickenfarmGateway;
307
+ car: CarGateway;
305
308
  dict: (key: string) => any;
306
309
  _getSelectedFarmFromMiniApp: () => Promise<Factory>;
307
310
  _getSelectedUnitFromMiniApp: () => Promise<Unit>;