@cpzxrobot/sdk 1.0.75 → 1.0.77

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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Cpzxrobot, DataQueryArgs } from ".";
2
2
  import type { AxiosResponse } from "axios";
3
+ import { FieldDatas, SensorDatas } from "./sensor_datas";
3
4
 
4
5
  export abstract class DeviceFilter<T extends { id: number }> {
5
6
  context: Cpzxrobot;
@@ -199,11 +200,15 @@ export abstract class DeviceFilter<T extends { id: number }> {
199
200
  }
200
201
  })
201
202
  .then((res: AxiosResponse) => {
202
- if (res.data.Error) {
203
- throw res.data.Error;
203
+ if (args.type == "raw") {
204
+ return res;
205
+ } else {
206
+ if (res.data.Error) {
207
+ throw res.data.Error;
208
+ }
209
+ // this.devices.push(res.data);
210
+ return res.data;
204
211
  }
205
- // this.devices.push(res.data);
206
- return res.data;
207
212
  });
208
213
  }
209
214
 
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceFilter = void 0;
4
+ const sensor_datas_1 = require("./sensor_datas");
4
5
  class DeviceFilter {
5
6
  // private getDetail!: (info: T, id: number, context: Shzx) => Promise<any> | null
6
7
  // axios: MyAxiosInstance;
@@ -128,7 +129,7 @@ class DeviceFilter {
128
129
  string = string.replace(/\r/g, "");
129
130
  var arr = string.split("\n");
130
131
  var inAnnotation = false;
131
- var dataGroups = new SensorDatas();
132
+ var dataGroups = new sensor_datas_1.SensorDatas();
132
133
  var field = null;
133
134
  for (var i = 0; i < arr.length; i++) {
134
135
  var values = arr[i].split(",");
@@ -138,7 +139,7 @@ class DeviceFilter {
138
139
  if (field) {
139
140
  dataGroups.push(field);
140
141
  }
141
- field = new FieldDatas();
142
+ field = new sensor_datas_1.FieldDatas();
142
143
  }
143
144
  switch (values[0]) {
144
145
  case "#datatype":
@@ -179,11 +180,16 @@ class DeviceFilter {
179
180
  }
180
181
  })
181
182
  .then((res) => {
182
- if (res.data.Error) {
183
- throw res.data.Error;
183
+ if (args.type == "raw") {
184
+ return res;
185
+ }
186
+ else {
187
+ if (res.data.Error) {
188
+ throw res.data.Error;
189
+ }
190
+ // this.devices.push(res.data);
191
+ return res.data;
184
192
  }
185
- // this.devices.push(res.data);
186
- return res.data;
187
193
  });
188
194
  }
189
195
  //按月获取数据:period = '1mo',按天获取数据:period = '1d'
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SensorDatas = exports.FieldDatas = void 0;
2
4
  class FieldDatas {
3
5
  constructor() {
4
6
  this.datatypes = [];
@@ -33,6 +35,7 @@ class FieldDatas {
33
35
  return fields;
34
36
  }
35
37
  }
38
+ exports.FieldDatas = FieldDatas;
36
39
  class SensorDatas {
37
40
  constructor() {
38
41
  this.data_fields = [];
@@ -70,3 +73,4 @@ class SensorDatas {
70
73
  return fields;
71
74
  }
72
75
  }
76
+ exports.SensorDatas = SensorDatas;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.75",
3
+ "version": "1.0.77",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/sensor_datas.ts CHANGED
@@ -1,5 +1,4 @@
1
-
2
- class FieldDatas {
1
+ export class FieldDatas {
3
2
  datatypes: string[] = [];
4
3
  groups: boolean[] = [];
5
4
  defaults: string[] = [];
@@ -36,7 +35,7 @@ class FieldDatas {
36
35
  }
37
36
  }
38
37
 
39
- class SensorDatas {
38
+ export class SensorDatas {
40
39
  push(datas: FieldDatas) {
41
40
  this.data_fields.push(datas);
42
41
  }
package/types.d.ts CHANGED
@@ -5,6 +5,7 @@ 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 { UnitGateway } from "@cpzxrobot/sdk//unit_gateway";
8
+ import { FieldDatas } from "./sensor_datas";
8
9
 
9
10
  type Device = {
10
11
  id: number;
@@ -19,7 +20,7 @@ type Device = {
19
20
  typeCode: string;
20
21
  };
21
22
 
22
- export type FeedTowerExtraInfo = {
23
+ type FeedTowerExtraInfo = {
23
24
  currentAmount: number;
24
25
  loadAmount: number;
25
26
  feedTowerAmount: number;
@@ -29,7 +30,7 @@ export type FeedTowerExtraInfo = {
29
30
  };
30
31
 
31
32
  //FodderOrder 料单信息
32
- export type FodderOrder = {
33
+ type FodderOrder = {
33
34
  id?: number;
34
35
  fodderId?: string;
35
36
  fodderAmount: number;
@@ -42,7 +43,7 @@ export type FodderOrder = {
42
43
  type?: string;
43
44
  };
44
45
  //
45
- export type FodderOrderList = {
46
+ type FodderOrderList = {
46
47
  car: string; //车牌号
47
48
  date: string; //日期
48
49
  source: string; //来源
@@ -55,7 +56,7 @@ type FodderOrderInFactory = {
55
56
  towers: FodderOrderInTower[];
56
57
  };
57
58
 
58
- export type FodderOrderInTower = {
59
+ type FodderOrderInTower = {
59
60
  name: string; //料塔名称
60
61
  unit: string; //单位
61
62
  weight: number; //重量
@@ -67,7 +68,7 @@ type Assistant = {
67
68
  name: String;
68
69
  id: Number;
69
70
  };
70
- export type Factory = {
71
+ type Factory = {
71
72
  code: string;
72
73
  name?: string;
73
74
  company_code: string;
@@ -115,6 +116,21 @@ type DeviceConfig = {
115
116
  type?: string;
116
117
  };
117
118
 
119
+ type FieldDatas = {
120
+ length: number;
121
+ valuesAt(at: string): Map<string, any>;
122
+ fields: string[];
123
+ };
124
+
125
+ type SensorDatas = {
126
+ push: (data: FieldDatas) => void;
127
+ datas: {
128
+ time: string;
129
+ [key: string]: any;
130
+ }[];
131
+ fields: string[];
132
+ };
133
+
118
134
  type Electricity = {
119
135
  deviceId: string;
120
136
  nextDeviceList: number[] | [];
@@ -219,7 +235,7 @@ type FeedTowerV2 = {
219
235
  buildTime: string;
220
236
  };
221
237
 
222
- export type FeedTower = {
238
+ type FeedTower = {
223
239
  id: number;
224
240
  name: string;
225
241
  currentAmount: number;
@@ -237,23 +253,23 @@ export type FeedTower = {
237
253
  diff: number;
238
254
  };
239
255
 
240
- export interface MyAxiosInstance {
256
+ interface MyAxiosInstance {
241
257
  get: (url: string, config?: any) => Promise<any>;
242
258
  post: (url: string, data?: any, config?: any) => Promise<any>;
243
259
  }
244
260
 
245
- export interface Assistant {
261
+ interface Assistant {
246
262
  info: String;
247
263
  status: Number;
248
264
  name: String;
249
265
  id: Number;
250
266
  }
251
- export interface ElectricMeter extends Device {
267
+ interface ElectricMeter extends Device {
252
268
  coefficient: number;
253
269
  status: string;
254
270
  }
255
271
 
256
- export interface DataQueryArgs {
272
+ interface DataQueryArgs {
257
273
  start?: string;
258
274
  stop?: string;
259
275
  type?:
@@ -271,7 +287,7 @@ export interface DataQueryArgs {
271
287
  [key: string]: any;
272
288
  }
273
289
 
274
- export class Cpzxrobot {
290
+ class Cpzxrobot {
275
291
  transport: TransportGateway;
276
292
  ready: Promise<MyAxiosInstance>;
277
293
  factory: FactoryGateway;
@@ -290,7 +306,7 @@ export class Cpzxrobot {
290
306
  setTitle: (title: string) => void;
291
307
  saveBase64: (base64: string, filename: string) => void;
292
308
  saveBlob: (blob: Blob, filename: string) => void;
293
- scanQrcode:() => Promise<string>;
309
+ scanQrcode: () => Promise<string>;
294
310
  vibrate: (time?: number) => void;
295
311
  }
296
312
 
@@ -342,5 +358,7 @@ declare module "@cpzxrobot/sdk" {
342
358
  DataQueryArgs,
343
359
  HeatLamp,
344
360
  DeviceV2,
361
+ FieldDatas,
362
+ SensorDatas,
345
363
  };
346
364
  }