@cpzxrobot/sdk 1.0.55 → 1.0.57

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.
@@ -81,6 +81,58 @@ class PigfarmGateway extends Object {
81
81
  },
82
82
  };
83
83
  }
84
+ get weightMeter() {
85
+ return {
86
+ //获取仪表列表,
87
+ list: (factory) => {
88
+ return this.context.ready.then((axios) => {
89
+ return axios.get(`/api/v2/pigfarm/relay/weightMeter/list/${factory.id}`);
90
+ });
91
+ },
92
+ //获取仪表下的所有传感器,这里获得的都是已绑定的
93
+ sensors: (weightMeterId) => {
94
+ return this.context.ready.then((axios) => {
95
+ return axios.get(`/api/v2/pigfarm/weightMeterSensor/config/list/${weightMeterId}`);
96
+ });
97
+ },
98
+ add: (data) => {
99
+ return this.context.ready.then((axios) => {
100
+ return axios.post(`/api/v2/pigfarm/relay/weightMeter/add`, data);
101
+ });
102
+ },
103
+ //更新仪表信息
104
+ update: (data) => {
105
+ return this.context.ready.then((axios) => {
106
+ return axios.post(`/api/v2/pigfarm/relay/weightMeter/update`, data);
107
+ });
108
+ },
109
+ updateSensor: (data) => {
110
+ return this.context.ready.then((axios) => {
111
+ return axios.post(`/api/v2/pigfarm/weightMeterSensor/config/update`, data);
112
+ });
113
+ },
114
+ //首先创建料塔,然后绑定传感器,绑定时需要传入料塔设备id和仪表id
115
+ bind: (deviceId, meterId, args) => {
116
+ //检查endValue1和endValue2的长度是否为2
117
+ if (args.endValue1.length !== 2 || args.endValue2.length !== 2) {
118
+ throw new Error("endValue1和endValue2的长度必须为2");
119
+ }
120
+ //检查endValue1的第二个值是否等于endValue2的第一个值
121
+ if (args.endValue1[1] !== args.endValue2[0]) {
122
+ throw new Error("endValue1的第二个值必须等于endValue2的第一个值");
123
+ }
124
+ //检查endValue1的第一个值是否是0,最好界面就限制只能是0
125
+ if (args.endValue1[0] !== 0) {
126
+ throw new Error("endValue1的第一个值必须为0");
127
+ }
128
+ args.deviceId = deviceId;
129
+ args.weightMeterId = meterId;
130
+ return this.context.ready.then((axios) => {
131
+ return axios.post(`/api/v2/pigfarm/weightMeterSensor/config/add`, args);
132
+ });
133
+ },
134
+ };
135
+ }
84
136
  get heatlamp() {
85
137
  return {
86
138
  add: (unit, data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.55",
3
+ "version": "1.0.57",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,4 +1,12 @@
1
- import { Cpzxrobot, DeviceConfig, HeatLamp, Unit } from ".";
1
+ import {
2
+ Cpzxrobot,
3
+ DeviceConfig,
4
+ Factory,
5
+ HeatLamp,
6
+ Unit,
7
+ WeightMeter,
8
+ WeightMeterSensor,
9
+ } from ".";
2
10
 
3
11
  export class PigfarmGateway extends Object {
4
12
  context: Cpzxrobot;
@@ -92,6 +100,70 @@ export class PigfarmGateway extends Object {
92
100
  };
93
101
  }
94
102
 
103
+ get weightMeter() {
104
+ return {
105
+ //获取仪表列表,
106
+ list: (factory: Factory) => {
107
+ return this.context.ready.then((axios) => {
108
+ return axios.get(
109
+ `/api/v2/pigfarm/relay/weightMeter/list/${factory.id}`
110
+ );
111
+ });
112
+ },
113
+ //获取仪表下的所有传感器,这里获得的都是已绑定的
114
+ sensors: (weightMeterId: number) => {
115
+ return this.context.ready.then((axios) => {
116
+ return axios.get(
117
+ `/api/v2/pigfarm/weightMeterSensor/config/list/${weightMeterId}`
118
+ );
119
+ });
120
+ },
121
+ add: (data: WeightMeter) => {
122
+ return this.context.ready.then((axios) => {
123
+ return axios.post(`/api/v2/pigfarm/relay/weightMeter/add`, data);
124
+ });
125
+ },
126
+ //更新仪表信息
127
+ update: (data: any) => {
128
+ return this.context.ready.then((axios) => {
129
+ return axios.post(`/api/v2/pigfarm/relay/weightMeter/update`, data);
130
+ });
131
+ },
132
+ updateSensor: (data: any) => {
133
+ return this.context.ready.then((axios) => {
134
+ return axios.post(
135
+ `/api/v2/pigfarm/weightMeterSensor/config/update`,
136
+ data
137
+ );
138
+ });
139
+ },
140
+ //首先创建料塔,然后绑定传感器,绑定时需要传入料塔设备id和仪表id
141
+ bind: (
142
+ deviceId: number,
143
+ meterId: number,
144
+ args: WeightMeterSensor
145
+ ) => {
146
+ //检查endValue1和endValue2的长度是否为2
147
+ if (args.endValue1.length !== 2 || args.endValue2.length !== 2) {
148
+ throw new Error("endValue1和endValue2的长度必须为2");
149
+ }
150
+ //检查endValue1的第二个值是否等于endValue2的第一个值
151
+ if (args.endValue1[1] !== args.endValue2[0]) {
152
+ throw new Error("endValue1的第二个值必须等于endValue2的第一个值");
153
+ }
154
+ //检查endValue1的第一个值是否是0,最好界面就限制只能是0
155
+ if (args.endValue1[0] !== 0) {
156
+ throw new Error("endValue1的第一个值必须为0");
157
+ }
158
+ args.deviceId = deviceId;
159
+ args.weightMeterId = meterId;
160
+ return this.context.ready.then((axios) => {
161
+ return axios.post(`/api/v2/pigfarm/weightMeterSensor/config/add`, args);
162
+ });
163
+ },
164
+ };
165
+ }
166
+
95
167
  get heatlamp() {
96
168
  return {
97
169
  add: (unit: Unit, data: HeatLamp) => {
package/types.d.ts CHANGED
@@ -93,10 +93,10 @@ type HeatLamp = {
93
93
  alarmLower: number;
94
94
  //   告警阈值上限
95
95
  alarmUpper: number;
96
- address: number;
96
+ address: string;
97
97
  serialnumber: string;
98
- wirelessChannel: number;
99
- relayAddress: number;
98
+ wirelessChannel: string;
99
+ relayAddress: string;
100
100
  // 环境温度补偿值
101
101
  tempCompensation: number;
102
102
  periodList: {
@@ -125,6 +125,49 @@ type Camera = {
125
125
  name: string;
126
126
  };
127
127
 
128
+ // {
129
+ //         "id": "",
130
+ //         "serialNumber": "", //序列号
131
+ //         "type": "", //型号
132
+ //         "releaseDate": "2024-09-29", //出厂日期
133
+ //         "openZero": 20 //开机置零范围
134
+ //     }
135
+ type WeightMeter = {
136
+ id: number;
137
+ serialNumber: string; //序列号
138
+ type: string; //型号
139
+ releaseDate: string; //出厂日期
140
+ openZero: number; //开机置零范围
141
+ factoryId: number;
142
+ };
143
+
144
+ //{
145
+ //     "id":"",
146
+ //     "weightMeterId":"", //仪表id
147
+ //     "scaleDivision":5, //分度值
148
+ //     "fullScale":200, //满量程
149
+ //     "slopeRate":1.23, //斜率值
150
+ //     "pointnum":4, //小数点个数
151
+ //     "rate1":1.1231, //第一段标率
152
+ //     "endValue1": [0,30000],//第一段分界点重量值
153
+ //     "rate2":2.3431, //第二段标率
154
+ //     "endValue2": [30000,90000], //第二段分界点重量值
155
+ //     "deviceId":14443538863685, //料塔id
156
+ // }
157
+ type WeightMeterSensor = {
158
+ id: number;
159
+ weightMeterId: number; //仪表id
160
+ scaleDivision: number; //分度值
161
+ fullScale: number; //满量程
162
+ slopeRate: number; //斜率值
163
+ pointnum: number; //小数点个数
164
+ rate1: number; //第一段标率
165
+ endValue1: [number, number]; //第一段分界点重量值
166
+ rate2: number; //第二段标率
167
+ endValue2: [number, number]; //第二段分界点重量值
168
+ deviceId: number;
169
+ };
170
+
128
171
  export type FeedTower = {
129
172
  id: number;
130
173
  name: string;
@@ -243,6 +286,6 @@ declare module "@cpzxrobot/sdk" {
243
286
  Electricity,
244
287
  DeviceConfig,
245
288
  DataQueryArgs,
246
- HeatLamp
289
+ HeatLamp,
247
290
  };
248
291
  }