@cpzxrobot/sdk 1.0.80 → 1.0.82
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/camera_gateway.ts +11 -4
- package/dist/camera_gateway.js +9 -2
- package/dist/factory_gateway.js +17 -7
- package/factory_gateway.ts +54 -32
- package/package.json +1 -1
- package/readme.md +4 -1
- package/types.d.ts +1 -0
package/camera_gateway.ts
CHANGED
|
@@ -59,14 +59,21 @@ export class CameraGateway extends Object {
|
|
|
59
59
|
| "right_down"
|
|
60
60
|
| "up"
|
|
61
61
|
| "down"
|
|
62
|
+
| "focus_near"
|
|
63
|
+
| "focus_far"
|
|
62
64
|
| "zoom_in"
|
|
63
65
|
| "zoom_out",
|
|
64
|
-
start
|
|
66
|
+
start?: boolean,
|
|
67
|
+
stop?: boolean
|
|
65
68
|
): Promise<any> {
|
|
66
69
|
var axios = await this.context.ready;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
var url = `/api/v1/camera/${data.id}/control/${action}`;
|
|
71
|
+
if (start) {
|
|
72
|
+
url += `?start=${start}`;
|
|
73
|
+
} else if (stop) {
|
|
74
|
+
url += `?stop=${stop}`;
|
|
75
|
+
}
|
|
76
|
+
const response = await axios.get(url);
|
|
70
77
|
return response.data;
|
|
71
78
|
}
|
|
72
79
|
}
|
package/dist/camera_gateway.js
CHANGED
|
@@ -32,9 +32,16 @@ class CameraGateway extends Object {
|
|
|
32
32
|
const response = await axios.get(`/api/v1/weather?code=${id}`);
|
|
33
33
|
return response.data;
|
|
34
34
|
}
|
|
35
|
-
async control(data, action, start
|
|
35
|
+
async control(data, action, start, stop) {
|
|
36
36
|
var axios = await this.context.ready;
|
|
37
|
-
|
|
37
|
+
var url = `/api/v1/camera/${data.id}/control/${action}`;
|
|
38
|
+
if (start) {
|
|
39
|
+
url += `?start=${start}`;
|
|
40
|
+
}
|
|
41
|
+
else if (stop) {
|
|
42
|
+
url += `?stop=${stop}`;
|
|
43
|
+
}
|
|
44
|
+
const response = await axios.get(url);
|
|
38
45
|
return response.data;
|
|
39
46
|
}
|
|
40
47
|
}
|
package/dist/factory_gateway.js
CHANGED
|
@@ -5,16 +5,16 @@ class FactoryGateway extends Object {
|
|
|
5
5
|
constructor(context) {
|
|
6
6
|
super();
|
|
7
7
|
this._selectedFarm = {
|
|
8
|
-
code:
|
|
9
|
-
name:
|
|
10
|
-
company_code:
|
|
11
|
-
id: 0
|
|
8
|
+
code: "",
|
|
9
|
+
name: "",
|
|
10
|
+
company_code: "",
|
|
11
|
+
id: 0,
|
|
12
12
|
};
|
|
13
13
|
this.context = context;
|
|
14
14
|
}
|
|
15
15
|
async search(data) {
|
|
16
16
|
await this.context.ready;
|
|
17
|
-
const response = await this.context.axios.post(
|
|
17
|
+
const response = await this.context.axios.post("/api/v1/factory/search", data);
|
|
18
18
|
return response.data;
|
|
19
19
|
}
|
|
20
20
|
//获得工厂的单元信息
|
|
@@ -29,6 +29,16 @@ class FactoryGateway extends Object {
|
|
|
29
29
|
const response = await axios.get(`/api/v1/workshop/${id}`);
|
|
30
30
|
return response.data;
|
|
31
31
|
}
|
|
32
|
+
get info() {
|
|
33
|
+
return {
|
|
34
|
+
get: (factory) => {
|
|
35
|
+
return this.context.axios.get(`/api/v2/factory/${factory.id}/info`);
|
|
36
|
+
},
|
|
37
|
+
post: (info) => {
|
|
38
|
+
return this.context.axios.post(`/api/v2/factory/${info.id}/info`, info);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
32
42
|
//获得工厂的所有车间信息
|
|
33
43
|
async workshops(id) {
|
|
34
44
|
var axios = await this.context.ready;
|
|
@@ -49,9 +59,9 @@ class FactoryGateway extends Object {
|
|
|
49
59
|
//支持以下三个name:'capacity'(规模),'used_capacity'(存栏量),'workshop_count'(栋舍/车间数量),'manager'(负责人),'electric'/'water'/'feed' (电耗/水耗/饲料耗)
|
|
50
60
|
async entry(factory, name) {
|
|
51
61
|
var axios = await this.context.ready;
|
|
52
|
-
if ([
|
|
62
|
+
if (["electric", "water", "feed"].includes(name)) {
|
|
53
63
|
const response = await axios.post(`/api/v1/pigfarm/consumption/${factory.id}`, {
|
|
54
|
-
type: name
|
|
64
|
+
type: name,
|
|
55
65
|
});
|
|
56
66
|
return response.data;
|
|
57
67
|
}
|
package/factory_gateway.ts
CHANGED
|
@@ -1,67 +1,89 @@
|
|
|
1
|
-
import { Cpzxrobot, Factory } from "./types"
|
|
1
|
+
import { Cpzxrobot, Factory } from "./types";
|
|
2
2
|
|
|
3
3
|
export class FactoryGateway extends Object {
|
|
4
4
|
_selectedFarm: Factory = {
|
|
5
|
-
code:
|
|
6
|
-
name:
|
|
7
|
-
company_code:
|
|
8
|
-
id: 0
|
|
9
|
-
}
|
|
10
|
-
context: Cpzxrobot
|
|
5
|
+
code: "",
|
|
6
|
+
name: "",
|
|
7
|
+
company_code: "",
|
|
8
|
+
id: 0,
|
|
9
|
+
};
|
|
10
|
+
context: Cpzxrobot;
|
|
11
11
|
constructor(context: Cpzxrobot) {
|
|
12
|
-
super()
|
|
13
|
-
this.context = context
|
|
12
|
+
super();
|
|
13
|
+
this.context = context;
|
|
14
14
|
}
|
|
15
15
|
async search(data: Factory): Promise<any> {
|
|
16
|
-
await this.context.ready
|
|
17
|
-
const response = await this.context.axios.post(
|
|
18
|
-
|
|
16
|
+
await this.context.ready;
|
|
17
|
+
const response = await this.context.axios.post(
|
|
18
|
+
"/api/v1/factory/search",
|
|
19
|
+
data
|
|
20
|
+
);
|
|
21
|
+
return response.data;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
//获得工厂的单元信息
|
|
22
25
|
async unit(id: number): Promise<any> {
|
|
23
|
-
var axios = await this.context.ready
|
|
24
|
-
const response = await axios.get(`/api/v1/workshop/unit/${id}`)
|
|
25
|
-
return response.data
|
|
26
|
+
var axios = await this.context.ready;
|
|
27
|
+
const response = await axios.get(`/api/v1/workshop/unit/${id}`);
|
|
28
|
+
return response.data;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
//获得工厂的车间信息
|
|
29
32
|
async workshop(id: number): Promise<any> {
|
|
30
|
-
var axios = await this.context.ready
|
|
31
|
-
const response = await axios.get(`/api/v1/workshop/${id}`)
|
|
32
|
-
return response.data
|
|
33
|
+
var axios = await this.context.ready;
|
|
34
|
+
const response = await axios.get(`/api/v1/workshop/${id}`);
|
|
35
|
+
return response.data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get info() {
|
|
39
|
+
return {
|
|
40
|
+
get: (factory: Factory) => {
|
|
41
|
+
return this.context.axios.get(`/api/v2/factory/${factory.id}/info`);
|
|
42
|
+
},
|
|
43
|
+
post: (info: any) => {
|
|
44
|
+
return this.context.axios.post(`/api/v2/factory/${info.id}/info`, info);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
//获得工厂的所有车间信息
|
|
36
50
|
async workshops(id: number): Promise<any> {
|
|
37
|
-
var axios = await this.context.ready
|
|
38
|
-
const response = await axios.get(`/api/v1/factory/${id}/workshops`)
|
|
39
|
-
return response.data
|
|
51
|
+
var axios = await this.context.ready;
|
|
52
|
+
const response = await axios.get(`/api/v1/factory/${id}/workshops`);
|
|
53
|
+
return response.data;
|
|
40
54
|
}
|
|
41
55
|
|
|
42
56
|
//获得工厂的所有单元信息,以车间为单位树状结构
|
|
43
57
|
async units(id: number): Promise<any> {
|
|
44
|
-
var axios = await this.context.ready
|
|
45
|
-
const response = await axios.get(`/api/v1/factory/${id}/units`)
|
|
46
|
-
return response.data
|
|
58
|
+
var axios = await this.context.ready;
|
|
59
|
+
const response = await axios.get(`/api/v1/factory/${id}/units`);
|
|
60
|
+
return response.data;
|
|
47
61
|
}
|
|
48
62
|
|
|
49
63
|
async company(data: Factory): Promise<any> {
|
|
50
64
|
var axios = await this.context.ready;
|
|
51
|
-
const response = await axios.get(
|
|
65
|
+
const response = await axios.get(
|
|
66
|
+
`/api/v1/factory/${data.id}/organizaion`,
|
|
67
|
+
data
|
|
68
|
+
);
|
|
52
69
|
return response.data;
|
|
53
70
|
}
|
|
54
71
|
|
|
55
72
|
//支持以下三个name:'capacity'(规模),'used_capacity'(存栏量),'workshop_count'(栋舍/车间数量),'manager'(负责人),'electric'/'water'/'feed' (电耗/水耗/饲料耗)
|
|
56
|
-
async entry(factory:Factory,name:string): Promise<any> {
|
|
73
|
+
async entry(factory: Factory, name: string): Promise<any> {
|
|
57
74
|
var axios = await this.context.ready;
|
|
58
|
-
if ([
|
|
59
|
-
const response = await axios.post(
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
if (["electric", "water", "feed"].includes(name)) {
|
|
76
|
+
const response = await axios.post(
|
|
77
|
+
`/api/v1/pigfarm/consumption/${factory.id}`,
|
|
78
|
+
{
|
|
79
|
+
type: name,
|
|
80
|
+
}
|
|
81
|
+
);
|
|
62
82
|
return response.data;
|
|
63
83
|
}
|
|
64
|
-
const response = await axios.get(
|
|
84
|
+
const response = await axios.get(
|
|
85
|
+
`/api/v1/factory/${factory.id}/entry/${name}`
|
|
86
|
+
);
|
|
65
87
|
return response.data;
|
|
66
|
-
}
|
|
88
|
+
}
|
|
67
89
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -85,7 +85,10 @@ baseURL: "/"
|
|
|
85
85
|
| cpzxrobot().device.v2.list | 删除设备(仅限v2设备) |
|
|
86
86
|
| cpzxrobot().device.v2.delete | 删除设备(仅限v2设备) |
|
|
87
87
|
| cpzxrobot().camera.xxx | 获得摄像头的相关信息 |
|
|
88
|
-
| cpzxrobot().
|
|
88
|
+
| cpzxrobot().camera.control | 控制摄像头,例如:左移,右移,上移,下移等,如果传输start为true,则开始控制,如果传输stop为true,则停止控制,如果都没传输,则执行3秒后自动停止,传输start为true时,前端必须在需要停止时自行发送stop为true的消息 |
|
|
89
|
+
| cpzxrobot().factory.entry | 获得工厂的可显示动态信息 |
|
|
90
|
+
| cpzxrobot().factory.info.get | 获得工厂的附加信息 |
|
|
91
|
+
| cpzxrobot().factory.info.post | 更新或更新工厂的附加信息 |
|
|
89
92
|
| cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
|
|
90
93
|
| cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
|
|
91
94
|
| cpzxrobot().pigfarm.weightMeter.config.list | 获取称重计的配置信息 |
|