@cpzxrobot/sdk 1.0.18 → 1.0.20
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/device_filter.ts +2 -14
- package/device_gateway.ts +12 -1
- package/device_types/feedtower.ts +2 -2
- package/dist/device_gateway.js +7 -0
- package/package.json +1 -1
- package/readme.md +2 -2
- package/types.d.ts +19 -1
package/device_filter.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { Cpzxrobot } from ".";
|
|
1
|
+
import { Cpzxrobot, DataQueryArgs } from ".";
|
|
2
2
|
import type { AxiosResponse } from "axios";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
start?: string;
|
|
6
|
-
stop?: string;
|
|
7
|
-
type?:
|
|
8
|
-
| "diffPerDay"
|
|
9
|
-
| "sumPerDay"
|
|
10
|
-
| "latest"
|
|
11
|
-
| "latestInRangePerDay"
|
|
12
|
-
| "last"
|
|
13
|
-
| "difference";
|
|
14
|
-
period?: "1mo" | "1d" | null;
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}
|
|
4
|
+
|
|
17
5
|
|
|
18
6
|
export abstract class DeviceFilter<T extends { id: number }> {
|
|
19
7
|
context: Cpzxrobot;
|
package/device_gateway.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeviceTypeGateway } from "./device_type_gateway";
|
|
2
2
|
import { DeviceFilter } from "./device_filter";
|
|
3
|
-
import type { ElectricMeter, Cpzxrobot } from ".";
|
|
3
|
+
import type { ElectricMeter, Cpzxrobot, DataQueryArgs } from ".";
|
|
4
4
|
import { FeedTowerGateway } from "./device_types/feedtower";
|
|
5
5
|
import { ElectricMeterGateway } from "./device_types/electricmeter";
|
|
6
6
|
import { NormalGateway } from "./device_types/normal_type";
|
|
@@ -88,4 +88,15 @@ export class DeviceGateway extends Object {
|
|
|
88
88
|
get getHistoryDatas() {
|
|
89
89
|
return this.normalFilter.getHistoryDatas;
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
data(
|
|
93
|
+
id: number,
|
|
94
|
+
args: DataQueryArgs = {
|
|
95
|
+
start: "",
|
|
96
|
+
stop: "",
|
|
97
|
+
type: "diffPerDay", // diffPerDay, sumPerDay, latest
|
|
98
|
+
}
|
|
99
|
+
) {
|
|
100
|
+
return this.normalFilter.getData(id,args);
|
|
101
|
+
}
|
|
91
102
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type FodderOrderList, type FeedTower,type FeedTowerExtraInfo } from '..'
|
|
2
|
-
import { DeviceFilter
|
|
1
|
+
import { type FodderOrderList, type FeedTower,type FeedTowerExtraInfo, DataQueryArgs } from '..'
|
|
2
|
+
import { DeviceFilter } from '../device_filter'
|
|
3
3
|
|
|
4
4
|
export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
5
5
|
// Add properties and methods specific to the FeedTower type here
|
package/dist/device_gateway.js
CHANGED
|
@@ -53,5 +53,12 @@ class DeviceGateway extends Object {
|
|
|
53
53
|
get getHistoryDatas() {
|
|
54
54
|
return this.normalFilter.getHistoryDatas;
|
|
55
55
|
}
|
|
56
|
+
data(id, args = {
|
|
57
|
+
start: "",
|
|
58
|
+
stop: "",
|
|
59
|
+
type: "diffPerDay", // diffPerDay, sumPerDay, latest
|
|
60
|
+
}) {
|
|
61
|
+
return this.normalFilter.getData(id, args);
|
|
62
|
+
}
|
|
56
63
|
}
|
|
57
64
|
exports.DeviceGateway = DeviceGateway;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -74,8 +74,8 @@ baseURL: "/"
|
|
|
74
74
|
| 调用入口 | 功能说明 |
|
|
75
75
|
| ----------------------- | -------------------- |
|
|
76
76
|
| cpzxrobot().factory.xxx | 获得工厂的相关信息 |
|
|
77
|
-
| cpzxrobot().device.
|
|
78
|
-
| cpzxrobot().device.
|
|
77
|
+
| cpzxrobot().device.list | 获得常见设备的列表(当没有特殊类型需求时调用) |
|
|
78
|
+
| cpzxrobot().device.data | 获得设备的数据 |
|
|
79
79
|
| cpzxrobot().device.feedTower.list | 获得料塔设备的列表 |
|
|
80
80
|
| cpzxrobot().device.xxx | 获得设备的相关信息 |
|
|
81
81
|
| cpzxrobot().camera.xxx | 获得摄像头的相关信息 |
|
package/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { FactoryGateway } from "@cpzxrobot/sdk/factory_gateway";
|
|
|
3
3
|
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
|
+
import { PigfarmGateway } from "@cpzxrobot/sdk/pigfarm_gateway";
|
|
6
7
|
|
|
7
8
|
type Device = {
|
|
8
9
|
id: number;
|
|
@@ -123,6 +124,20 @@ export interface ElectricMeter extends Device {
|
|
|
123
124
|
status: string;
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
export interface DataQueryArgs {
|
|
128
|
+
start?: string;
|
|
129
|
+
stop?: string;
|
|
130
|
+
type?:
|
|
131
|
+
| "diffPerDay"
|
|
132
|
+
| "sumPerDay"
|
|
133
|
+
| "latest"
|
|
134
|
+
| "latestInRangePerDay"
|
|
135
|
+
| "last"
|
|
136
|
+
| "difference";
|
|
137
|
+
period?: "1mo" | "1d" | null;
|
|
138
|
+
[key: string]: any;
|
|
139
|
+
}
|
|
140
|
+
|
|
126
141
|
export class Cpzxrobot {
|
|
127
142
|
transport: TransportGateway;
|
|
128
143
|
ready: Promise<MyAxiosInstance>;
|
|
@@ -132,8 +147,11 @@ export class Cpzxrobot {
|
|
|
132
147
|
mode: string;
|
|
133
148
|
axios: MyAxiosInstance;
|
|
134
149
|
camera: CameraGateway;
|
|
150
|
+
pigfarm: PigfarmGateway;
|
|
135
151
|
_getSelectedFarmFromMiniApp: () => Promise<Factory>;
|
|
136
152
|
_getSelectedUnitFromMiniApp: () => Promise<Unit>;
|
|
153
|
+
openMiniApp: (url: string) => void;
|
|
154
|
+
on: (event: string, callback: (data: any) => void) => void;
|
|
137
155
|
setTitle: (title: string) => void;
|
|
138
156
|
saveBase64: (base64: string, filename: string) => void;
|
|
139
157
|
saveBlob: (blob: Blob, filename: string) => void;
|
|
@@ -147,7 +165,7 @@ declare module "@cpzxrobot/sdk" {
|
|
|
147
165
|
export default function (
|
|
148
166
|
args: {
|
|
149
167
|
devAuth: string;
|
|
150
|
-
baseURL
|
|
168
|
+
baseURL?: string;
|
|
151
169
|
appCode: string;
|
|
152
170
|
selectedFarm: Factory;
|
|
153
171
|
selectedUnit: Unit;
|