@cpzxrobot/sdk 1.0.79 → 1.0.81

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 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: boolean = true
66
+ start?: boolean,
67
+ stop?: boolean
65
68
  ): Promise<any> {
66
69
  var axios = await this.context.ready;
67
- const response = await axios.get(
68
- `/api/v1/camera/${data.id}/control/${action}?start=${start}`
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
  }
@@ -42,7 +42,10 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
42
42
  throw res[0].data.Error;
43
43
  } else {
44
44
  if (!args.ingoreInput) {
45
- res[1].data.data.forEach((item: any) => {
45
+ if (res[1].data.data.list == undefined){
46
+ throw "未查询到饲料下料数据,请联系管理员";
47
+ }
48
+ res[1].data.data.list.forEach((item: any) => {
46
49
  res[0].data[item.date] += item.data;
47
50
  });
48
51
  }
@@ -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 = true) {
35
+ async control(data, action, start, stop) {
36
36
  var axios = await this.context.ready;
37
- const response = await axios.get(`/api/v1/camera/${data.id}/control/${action}?start=${start}`);
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
  }
@@ -32,7 +32,10 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
32
32
  }
33
33
  else {
34
34
  if (!args.ingoreInput) {
35
- res[1].data.data.forEach((item) => {
35
+ if (res[1].data.data.list == undefined) {
36
+ throw "未查询到饲料下料数据,请联系管理员";
37
+ }
38
+ res[1].data.data.list.forEach((item) => {
36
39
  res[0].data[item.date] += item.data;
37
40
  });
38
41
  }
@@ -57,12 +57,23 @@ class UnitGateway extends Object {
57
57
  return axios.get(`/api/v2/unit/delete?id=${unit.id}`);
58
58
  });
59
59
  },
60
- //获取单元的展示布局信息
61
- layout: (unit) => {
60
+ };
61
+ }
62
+ layout() {
63
+ return {
64
+ get: (unit) => {
62
65
  return this.context.ready.then((axios) => {
63
66
  return axios.get(`/api/v2/unit/config/appLayout/${unit.id}`);
64
67
  });
65
68
  },
69
+ post: (unit, layout) => {
70
+ return this.context.ready.then((axios) => {
71
+ return axios.post(`/api/v2/unit/config/appLayout`, {
72
+ id: unit.id,
73
+ layout,
74
+ });
75
+ });
76
+ },
66
77
  };
67
78
  }
68
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.79",
3
+ "version": "1.0.81",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -85,6 +85,7 @@ baseURL: "/"
85
85
  | cpzxrobot().device.v2.list | 删除设备(仅限v2设备) |
86
86
  | cpzxrobot().device.v2.delete | 删除设备(仅限v2设备) |
87
87
  | cpzxrobot().camera.xxx | 获得摄像头的相关信息 |
88
+ | cpzxrobot().camera.control | 控制摄像头,例如:左移,右移,上移,下移等,如果传输start为true,则开始控制,如果传输stop为true,则停止控制,如果都没传输,则执行3秒后自动停止,传输start为true时,前端必须在需要停止时自行发送stop为true的消息 |
88
89
  | cpzxrobot().factory.entry| 获得工厂的可显示动态信息 |
89
90
  | cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
90
91
  | cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
@@ -109,7 +110,8 @@ baseURL: "/"
109
110
  | cpzxrobot().unit.v2.add | 添加单元,v2版本 |
110
111
  | cpzxrobot().unit.v2.update | 更新单元,v2版本 |
111
112
  | cpzxrobot().unit.v2.delete | 删除单元,v2版本 |
112
- | cpzxrobot().unit.v2.layout | 获取单元的展示布局,v2版本 |
113
+ | cpzxrobot().unit.layout.get | 获取单元的展示布局 |
114
+ | cpzxrobot().unit.layout.post | 设置单元的展示布局 |
113
115
 
114
116
 
115
117
  ### 工厂信息接口
package/types.d.ts CHANGED
@@ -280,6 +280,7 @@ interface DataQueryArgs {
280
280
  | "latest"
281
281
  | "latestInRangePerDay"
282
282
  | "last"
283
+ | "max"
283
284
  | "raw"
284
285
  | "difference";
285
286
  period?: "1mo" | "1d" | null;
package/unit_gateway.ts CHANGED
@@ -72,12 +72,24 @@ export class UnitGateway extends Object {
72
72
  return axios.get(`/api/v2/unit/delete?id=${unit.id}`);
73
73
  });
74
74
  },
75
- //获取单元的展示布局信息
76
- layout: (unit: Unit) => {
75
+ };
76
+ }
77
+
78
+ layout() {
79
+ return {
80
+ get: (unit: Unit) => {
77
81
  return this.context.ready.then((axios) => {
78
82
  return axios.get(`/api/v2/unit/config/appLayout/${unit.id}`);
79
83
  });
80
84
  },
85
+ post: (unit: Unit, layout: any) => {
86
+ return this.context.ready.then((axios) => {
87
+ return axios.post(`/api/v2/unit/config/appLayout`, {
88
+ id: unit.id,
89
+ layout,
90
+ });
91
+ });
92
+ },
81
93
  };
82
94
  }
83
95
  }