@cpzxrobot/sdk 1.0.50 → 1.0.51
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/index.js +2 -0
- package/dist/unit_gateway.js +42 -0
- package/index.ts +3 -0
- package/package.json +1 -1
- package/types.d.ts +2 -0
- package/unit_gateway.ts +53 -0
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const assistant_gateway_1 = require("./assistant_gateway");
|
|
|
14
14
|
const energy_gateway_1 = require("./energy_gateway");
|
|
15
15
|
const camera_gateway_1 = require("./camera_gateway");
|
|
16
16
|
const pigfarm_gateway_1 = require("./pigfarm_gateway");
|
|
17
|
+
const unit_gateway_1 = require("./unit_gateway");
|
|
17
18
|
class Cpzxrobot {
|
|
18
19
|
constructor(appCode) {
|
|
19
20
|
this.pigfarm = new pigfarm_gateway_1.PigfarmGateway(this);
|
|
@@ -30,6 +31,7 @@ class Cpzxrobot {
|
|
|
30
31
|
this.appCode = appCode;
|
|
31
32
|
this.user = new user_gateway_1.UserGateway(this);
|
|
32
33
|
this.factory = new factory_gateway_1.FactoryGateway(this);
|
|
34
|
+
this.unit = new unit_gateway_1.UnitGateway(this);
|
|
33
35
|
this.device = new device_gateway_1.DeviceGateway(this);
|
|
34
36
|
this.transport = new transport_gateway_1.TransportGateway(this);
|
|
35
37
|
this.assistant = new assistant_gateway_1.AssistantGateway(this);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnitGateway = void 0;
|
|
4
|
+
class UnitGateway extends Object {
|
|
5
|
+
constructor(context) {
|
|
6
|
+
super();
|
|
7
|
+
this.context = context;
|
|
8
|
+
}
|
|
9
|
+
get config() {
|
|
10
|
+
return {
|
|
11
|
+
add: (unit, type, config) => {
|
|
12
|
+
return this.context.ready.then((axios) => {
|
|
13
|
+
return axios.post(`/api/v2/unit/config/add`, {
|
|
14
|
+
unitId: unit.id,
|
|
15
|
+
type,
|
|
16
|
+
config,
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
update: (unit, type, config) => {
|
|
21
|
+
return this.context.ready.then((axios) => {
|
|
22
|
+
return axios.post(`/api/v2/unit/config/update`, {
|
|
23
|
+
unitId: unit.id,
|
|
24
|
+
type,
|
|
25
|
+
config,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
get: (unit, type) => {
|
|
30
|
+
return this.context.ready.then((axios) => {
|
|
31
|
+
return axios.get(`/api/v2/unit/config`, {
|
|
32
|
+
params: {
|
|
33
|
+
unitId: unit.id,
|
|
34
|
+
type,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.UnitGateway = UnitGateway;
|
package/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { CameraGateway } from "./camera_gateway";
|
|
|
9
9
|
import { type ElectricMeterRate } from "./energy_types/electric_meter_gateway";
|
|
10
10
|
import { PigfarmGateway } from "./pigfarm_gateway";
|
|
11
11
|
import { Device, Factory, MyAxiosInstance, Unit } from "./types";
|
|
12
|
+
import { UnitGateway } from "./unit_gateway";
|
|
12
13
|
|
|
13
14
|
export class Cpzxrobot {
|
|
14
15
|
device: DeviceGateway;
|
|
@@ -37,6 +38,7 @@ export class Cpzxrobot {
|
|
|
37
38
|
assistant: AssistantGateway;
|
|
38
39
|
energy: EnergyGateway;
|
|
39
40
|
camera: CameraGateway;
|
|
41
|
+
unit: UnitGateway;
|
|
40
42
|
|
|
41
43
|
constructor(appCode: string) {
|
|
42
44
|
//获取当前浏览器的域名
|
|
@@ -48,6 +50,7 @@ export class Cpzxrobot {
|
|
|
48
50
|
this.appCode = appCode;
|
|
49
51
|
this.user = new UserGateway(this);
|
|
50
52
|
this.factory = new FactoryGateway(this);
|
|
53
|
+
this.unit = new UnitGateway(this);
|
|
51
54
|
this.device = new DeviceGateway(this);
|
|
52
55
|
this.transport = new TransportGateway(this);
|
|
53
56
|
this.assistant = new AssistantGateway(this);
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { TransportGateway } from "@cpzxrobot/sdk/transport_gateway";
|
|
|
4
4
|
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
|
+
import { UnitGateway } from "@cpzxrobot/sdk//unit_gateway";
|
|
7
8
|
|
|
8
9
|
type Device = {
|
|
9
10
|
id: number;
|
|
@@ -166,6 +167,7 @@ export class Cpzxrobot {
|
|
|
166
167
|
transport: TransportGateway;
|
|
167
168
|
ready: Promise<MyAxiosInstance>;
|
|
168
169
|
factory: FactoryGateway;
|
|
170
|
+
unit: UnitGateway;
|
|
169
171
|
user: UserGateway;
|
|
170
172
|
device: DeviceGateway;
|
|
171
173
|
mode: string;
|
package/unit_gateway.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Cpzxrobot, Unit } from "./types";
|
|
2
|
+
|
|
3
|
+
export class UnitGateway extends Object {
|
|
4
|
+
context: Cpzxrobot;
|
|
5
|
+
constructor(context: Cpzxrobot) {
|
|
6
|
+
super();
|
|
7
|
+
this.context = context;
|
|
8
|
+
}
|
|
9
|
+
get config() {
|
|
10
|
+
return {
|
|
11
|
+
add: (
|
|
12
|
+
unit: Unit,
|
|
13
|
+
type: "heatLamp",
|
|
14
|
+
config: {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
) => {
|
|
18
|
+
return this.context.ready.then((axios) => {
|
|
19
|
+
return axios.post(`/api/v2/unit/config/add`, {
|
|
20
|
+
unitId: unit.id,
|
|
21
|
+
type,
|
|
22
|
+
config,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
update: (
|
|
27
|
+
unit: Unit,
|
|
28
|
+
type: "heatLamp",
|
|
29
|
+
config: {
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
32
|
+
) => {
|
|
33
|
+
return this.context.ready.then((axios) => {
|
|
34
|
+
return axios.post(`/api/v2/unit/config/update`, {
|
|
35
|
+
unitId: unit.id,
|
|
36
|
+
type,
|
|
37
|
+
config,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
get: (unit: Unit, type: "heatLamp") => {
|
|
42
|
+
return this.context.ready.then((axios) => {
|
|
43
|
+
return axios.get(`/api/v2/unit/config`, {
|
|
44
|
+
params: {
|
|
45
|
+
unitId: unit.id,
|
|
46
|
+
type,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|