@hangtime/grip-connect 0.10.1 → 0.10.3
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/README.md +1 -1
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/callback.interface.d.ts +19 -12
- package/dist/cjs/interfaces/callback.interface.d.ts.map +1 -1
- package/dist/cjs/interfaces/command.interface.d.ts +14 -6
- package/dist/cjs/interfaces/command.interface.d.ts.map +1 -1
- package/dist/cjs/interfaces/device/progressor.interface.d.ts +47 -0
- package/dist/cjs/interfaces/device/progressor.interface.d.ts.map +1 -1
- package/dist/cjs/interfaces/device.interface.d.ts +1 -1
- package/dist/cjs/interfaces/download.interface.d.ts +8 -11
- package/dist/cjs/interfaces/download.interface.d.ts.map +1 -1
- package/dist/cjs/models/device/climbro.model.d.ts.map +1 -1
- package/dist/cjs/models/device/climbro.model.js +34 -16
- package/dist/cjs/models/device/climbro.model.js.map +1 -1
- package/dist/cjs/models/device/entralpi.model.d.ts.map +1 -1
- package/dist/cjs/models/device/entralpi.model.js +11 -14
- package/dist/cjs/models/device/entralpi.model.js.map +1 -1
- package/dist/cjs/models/device/forceboard.model.d.ts.map +1 -1
- package/dist/cjs/models/device/forceboard.model.js +12 -17
- package/dist/cjs/models/device/forceboard.model.js.map +1 -1
- package/dist/cjs/models/device/motherboard.model.d.ts.map +1 -1
- package/dist/cjs/models/device/motherboard.model.js +28 -20
- package/dist/cjs/models/device/motherboard.model.js.map +1 -1
- package/dist/cjs/models/device/pb-700bt.model.d.ts.map +1 -1
- package/dist/cjs/models/device/pb-700bt.model.js +11 -14
- package/dist/cjs/models/device/pb-700bt.model.js.map +1 -1
- package/dist/cjs/models/device/progressor.model.d.ts +52 -5
- package/dist/cjs/models/device/progressor.model.d.ts.map +1 -1
- package/dist/cjs/models/device/progressor.model.js +211 -57
- package/dist/cjs/models/device/progressor.model.js.map +1 -1
- package/dist/cjs/models/device/smartboard-pro.model.d.ts.map +1 -1
- package/dist/cjs/models/device/smartboard-pro.model.js +11 -16
- package/dist/cjs/models/device/smartboard-pro.model.js.map +1 -1
- package/dist/cjs/models/device/wh-c06.model.d.ts.map +1 -1
- package/dist/cjs/models/device/wh-c06.model.js +11 -14
- package/dist/cjs/models/device/wh-c06.model.js.map +1 -1
- package/dist/cjs/models/device.model.d.ts +64 -3
- package/dist/cjs/models/device.model.d.ts.map +1 -1
- package/dist/cjs/models/device.model.js +142 -37
- package/dist/cjs/models/device.model.js.map +1 -1
- package/dist/cjs/utils.d.ts +1 -1
- package/dist/cjs/utils.d.ts.map +1 -1
- package/dist/cjs/utils.js +29 -6
- package/dist/cjs/utils.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/callback.interface.d.ts +19 -12
- package/dist/interfaces/callback.interface.d.ts.map +1 -1
- package/dist/interfaces/command.interface.d.ts +14 -6
- package/dist/interfaces/command.interface.d.ts.map +1 -1
- package/dist/interfaces/device/progressor.interface.d.ts +47 -0
- package/dist/interfaces/device/progressor.interface.d.ts.map +1 -1
- package/dist/interfaces/device.interface.d.ts +1 -1
- package/dist/interfaces/download.interface.d.ts +8 -11
- package/dist/interfaces/download.interface.d.ts.map +1 -1
- package/dist/models/device/climbro.model.d.ts.map +1 -1
- package/dist/models/device/climbro.model.js +34 -16
- package/dist/models/device/climbro.model.js.map +1 -1
- package/dist/models/device/entralpi.model.d.ts.map +1 -1
- package/dist/models/device/entralpi.model.js +11 -14
- package/dist/models/device/entralpi.model.js.map +1 -1
- package/dist/models/device/forceboard.model.d.ts.map +1 -1
- package/dist/models/device/forceboard.model.js +12 -17
- package/dist/models/device/forceboard.model.js.map +1 -1
- package/dist/models/device/motherboard.model.d.ts.map +1 -1
- package/dist/models/device/motherboard.model.js +28 -20
- package/dist/models/device/motherboard.model.js.map +1 -1
- package/dist/models/device/pb-700bt.model.d.ts.map +1 -1
- package/dist/models/device/pb-700bt.model.js +11 -14
- package/dist/models/device/pb-700bt.model.js.map +1 -1
- package/dist/models/device/progressor.model.d.ts +52 -5
- package/dist/models/device/progressor.model.d.ts.map +1 -1
- package/dist/models/device/progressor.model.js +210 -57
- package/dist/models/device/progressor.model.js.map +1 -1
- package/dist/models/device/smartboard-pro.model.d.ts.map +1 -1
- package/dist/models/device/smartboard-pro.model.js +11 -16
- package/dist/models/device/smartboard-pro.model.js.map +1 -1
- package/dist/models/device/wh-c06.model.d.ts.map +1 -1
- package/dist/models/device/wh-c06.model.js +11 -14
- package/dist/models/device/wh-c06.model.js.map +1 -1
- package/dist/models/device.model.d.ts +64 -3
- package/dist/models/device.model.d.ts.map +1 -1
- package/dist/models/device.model.js +146 -37
- package/dist/models/device.model.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +29 -6
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -3
- package/src/interfaces/callback.interface.ts +21 -12
- package/src/interfaces/command.interface.ts +16 -6
- package/src/interfaces/device/progressor.interface.ts +56 -0
- package/src/interfaces/device.interface.ts +1 -1
- package/src/interfaces/download.interface.ts +9 -11
- package/src/models/device/climbro.model.ts +38 -20
- package/src/models/device/entralpi.model.ts +15 -17
- package/src/models/device/forceboard.model.ts +15 -19
- package/src/models/device/motherboard.model.ts +38 -26
- package/src/models/device/pb-700bt.model.ts +14 -16
- package/src/models/device/progressor.model.ts +227 -58
- package/src/models/device/smartboard-pro.model.ts +14 -19
- package/src/models/device/wh-c06.model.ts +14 -17
- package/src/models/device.model.ts +181 -41
- package/src/utils.ts +31 -6
|
@@ -161,9 +161,10 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
161
161
|
*/
|
|
162
162
|
override handleNotifications = (value: DataView): void => {
|
|
163
163
|
if (value) {
|
|
164
|
-
// Update timestamp
|
|
165
164
|
this.updateTimestamp()
|
|
166
165
|
if (value.buffer) {
|
|
166
|
+
this.currentSamplesPerPacket = 1
|
|
167
|
+
this.recordPacketReceived()
|
|
167
168
|
const receivedTime: number = Date.now()
|
|
168
169
|
const receivedData: string = (value.getUint16(0) / 100).toFixed(1)
|
|
169
170
|
|
|
@@ -173,31 +174,28 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
173
174
|
// This will display the removed or 'no-hanging' weight.
|
|
174
175
|
const tare = this.applyTare(convertedData)
|
|
175
176
|
const numericData = tare === 0 ? convertedData : (convertedData - tare) * -1
|
|
176
|
-
// Add data to downloadable Array
|
|
177
|
-
this.downloadPackets.push({
|
|
178
|
-
received: receivedTime,
|
|
179
|
-
sampleNum: this.dataPointCount,
|
|
180
|
-
battRaw: 0,
|
|
181
|
-
samples: [convertedData],
|
|
182
|
-
masses: [numericData],
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
// Update peak
|
|
186
|
-
this.peak = Math.max(this.peak, numericData)
|
|
187
|
-
|
|
188
|
-
// Update running sum and count
|
|
189
177
|
const currentMassTotal = Math.max(-1000, numericData)
|
|
178
|
+
|
|
179
|
+
// Update session stats before building packet
|
|
180
|
+
this.peak = Math.max(this.peak, numericData)
|
|
181
|
+
this.min = Math.min(this.min, Math.max(-1000, numericData))
|
|
190
182
|
this.sum += currentMassTotal
|
|
191
183
|
this.dataPointCount++
|
|
192
|
-
|
|
193
|
-
// Calculate the average dynamically
|
|
194
184
|
this.mean = this.sum / this.dataPointCount
|
|
195
185
|
|
|
186
|
+
// Add data to downloadable Array
|
|
187
|
+
this.downloadPackets.push(
|
|
188
|
+
this.buildDownloadPacket(currentMassTotal, [convertedData], {
|
|
189
|
+
timestamp: receivedTime,
|
|
190
|
+
sampleIndex: this.dataPointCount,
|
|
191
|
+
}),
|
|
192
|
+
)
|
|
193
|
+
|
|
196
194
|
// Check if device is being used
|
|
197
195
|
this.activityCheck(numericData)
|
|
198
196
|
|
|
199
197
|
// Notify with weight data
|
|
200
|
-
this.notifyCallback(this.buildForceMeasurement(
|
|
198
|
+
this.notifyCallback(this.buildForceMeasurement(currentMassTotal))
|
|
201
199
|
}
|
|
202
200
|
}
|
|
203
201
|
}
|
|
@@ -190,16 +190,15 @@ export class ForceBoard extends Device implements IForceBoard {
|
|
|
190
190
|
*/
|
|
191
191
|
override handleNotifications = (value: DataView): void => {
|
|
192
192
|
if (value) {
|
|
193
|
-
// Update timestamp
|
|
194
193
|
this.updateTimestamp()
|
|
195
194
|
if (value.buffer) {
|
|
196
195
|
const receivedTime: number = Date.now()
|
|
197
196
|
const dataArray = new Uint8Array(value.buffer)
|
|
198
197
|
|
|
199
|
-
// First two bytes contain the number of samples in the packet
|
|
200
198
|
const numSamples = (dataArray[0] << 8) | dataArray[1]
|
|
199
|
+
this.currentSamplesPerPacket = numSamples
|
|
200
|
+
this.recordPacketReceived()
|
|
201
201
|
|
|
202
|
-
// Process each sample (3 bytes per sample)
|
|
203
202
|
for (let i = 0; i < numSamples; i++) {
|
|
204
203
|
const offset = 2 + i * 3 // Skip the first 2 bytes which indicate number of samples
|
|
205
204
|
if (offset + 2 < dataArray.length) {
|
|
@@ -207,31 +206,28 @@ export class ForceBoard extends Device implements IForceBoard {
|
|
|
207
206
|
const receivedData = dataArray[offset] * 32768 + dataArray[offset + 1] * 256 + dataArray[offset + 2]
|
|
208
207
|
// Tare correction
|
|
209
208
|
const numericData = receivedData - this.applyTare(receivedData)
|
|
210
|
-
|
|
211
|
-
this.downloadPackets.push({
|
|
212
|
-
received: receivedTime,
|
|
213
|
-
sampleNum: this.dataPointCount,
|
|
214
|
-
battRaw: 0,
|
|
215
|
-
samples: [receivedData],
|
|
216
|
-
masses: [numericData],
|
|
217
|
-
})
|
|
209
|
+
const currentMassTotal = Math.max(-1000, numericData)
|
|
218
210
|
|
|
219
|
-
// Update
|
|
211
|
+
// Update session stats before building packet
|
|
220
212
|
this.peak = Math.max(this.peak, numericData)
|
|
221
|
-
|
|
222
|
-
// Update running sum and count
|
|
223
|
-
const currentMassTotal = Math.max(-1000, numericData)
|
|
213
|
+
this.min = Math.min(this.min, Math.max(-1000, numericData))
|
|
224
214
|
this.sum += currentMassTotal
|
|
225
215
|
this.dataPointCount++
|
|
226
|
-
|
|
227
|
-
// Calculate the average dynamically
|
|
228
216
|
this.mean = this.sum / this.dataPointCount
|
|
229
217
|
|
|
218
|
+
// Add data to downloadable Array (raw and tare-adjusted, both in LBS)
|
|
219
|
+
this.downloadPackets.push(
|
|
220
|
+
this.buildDownloadPacket(currentMassTotal, [receivedData], {
|
|
221
|
+
timestamp: receivedTime,
|
|
222
|
+
sampleIndex: this.dataPointCount,
|
|
223
|
+
}),
|
|
224
|
+
)
|
|
225
|
+
|
|
230
226
|
// Check if device is being used
|
|
231
227
|
this.activityCheck(numericData)
|
|
232
228
|
|
|
233
229
|
// Notify with weight data
|
|
234
|
-
this.notifyCallback(this.buildForceMeasurement(
|
|
230
|
+
this.notifyCallback(this.buildForceMeasurement(currentMassTotal))
|
|
235
231
|
}
|
|
236
232
|
}
|
|
237
233
|
}
|
|
@@ -268,7 +264,7 @@ export class ForceBoard extends Device implements IForceBoard {
|
|
|
268
264
|
* @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
|
|
269
265
|
*/
|
|
270
266
|
stream = async (duration = 0): Promise<void> => {
|
|
271
|
-
|
|
267
|
+
this.resetPacketTracking()
|
|
272
268
|
await this.write("weight", "tx", this.commands.START_WEIGHT_MEAS, duration)
|
|
273
269
|
}
|
|
274
270
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Device } from "../device.model.js"
|
|
2
2
|
import type { IMotherboard } from "../../interfaces/device/motherboard.interface.js"
|
|
3
|
-
import type { DownloadPacket } from "../../interfaces/download.interface.js"
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Represents a Griptonite Motherboard device.
|
|
@@ -235,18 +234,22 @@ export class Motherboard extends Device implements IMotherboard {
|
|
|
235
234
|
|
|
236
235
|
// Handle streaming packet
|
|
237
236
|
if (isAllHex && receivedData.length === Motherboard.packetLength) {
|
|
237
|
+
this.currentSamplesPerPacket = Motherboard.samplesNumber
|
|
238
|
+
this.recordPacketReceived()
|
|
238
239
|
// Base-16 decode the string: convert hex pairs to byte values
|
|
239
240
|
const bytes: number[] = Array.from({ length: receivedData.length / 2 }, (_, i) =>
|
|
240
241
|
Number(`0x${receivedData.substring(i * 2, i * 2 + 2)}`),
|
|
241
242
|
)
|
|
242
243
|
|
|
243
244
|
// Translate header into packet, number of samples from the packet length
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
const sampleIndex = new DataView(new Uint8Array(bytes).buffer).getUint16(0, true)
|
|
246
|
+
const battRaw = new DataView(new Uint8Array(bytes).buffer).getUint16(2, true)
|
|
247
|
+
const packet = {
|
|
248
|
+
timestamp: receivedTime,
|
|
249
|
+
sampleIndex,
|
|
250
|
+
battRaw,
|
|
251
|
+
samples: [] as number[],
|
|
252
|
+
forces: [] as number[],
|
|
250
253
|
}
|
|
251
254
|
|
|
252
255
|
const dataView = new DataView(new Uint8Array(bytes).buffer)
|
|
@@ -265,24 +268,15 @@ export class Motherboard extends Device implements IMotherboard {
|
|
|
265
268
|
if (packet.samples[i] >= 0x7fffff) {
|
|
266
269
|
packet.samples[i] -= 0x1000000
|
|
267
270
|
}
|
|
268
|
-
packet.
|
|
271
|
+
packet.forces[i] = this.applyCalibration(packet.samples[i], this.calibrationData[i])
|
|
269
272
|
}
|
|
270
273
|
// invert center and right values
|
|
271
|
-
packet.
|
|
272
|
-
packet.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
sampleNum: packet.battRaw,
|
|
278
|
-
battRaw: packet.received,
|
|
279
|
-
samples: [...packet.samples],
|
|
280
|
-
masses: [...packet.masses],
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
let left: number = packet.masses[0]
|
|
284
|
-
let center: number = packet.masses[1]
|
|
285
|
-
let right: number = packet.masses[2]
|
|
274
|
+
packet.forces[1] *= -1
|
|
275
|
+
packet.forces[2] *= -1
|
|
276
|
+
|
|
277
|
+
let left: number = packet.forces[0]
|
|
278
|
+
let center: number = packet.forces[1]
|
|
279
|
+
let right: number = packet.forces[2]
|
|
286
280
|
|
|
287
281
|
// Tare correction
|
|
288
282
|
left -= this.applyTare(left)
|
|
@@ -294,9 +288,9 @@ export class Motherboard extends Device implements IMotherboard {
|
|
|
294
288
|
const centerClamped = Math.max(-1000, center)
|
|
295
289
|
const rightClamped = Math.max(-1000, right)
|
|
296
290
|
|
|
291
|
+
// Update session stats before building packet
|
|
297
292
|
this.peak = Math.max(this.peak, totalCurrent)
|
|
298
|
-
|
|
299
|
-
// Update running sum and count (total)
|
|
293
|
+
this.min = Math.min(this.min, totalCurrent)
|
|
300
294
|
this.sum += totalCurrent
|
|
301
295
|
this.dataPointCount++
|
|
302
296
|
this.mean = this.sum / this.dataPointCount
|
|
@@ -309,6 +303,24 @@ export class Motherboard extends Device implements IMotherboard {
|
|
|
309
303
|
this.rightPeak = Math.max(this.rightPeak, rightClamped)
|
|
310
304
|
this.rightSum += rightClamped
|
|
311
305
|
|
|
306
|
+
// Add data to downloadable Array (distribution = per-zone measurements)
|
|
307
|
+
this.downloadPackets.push(
|
|
308
|
+
this.buildDownloadPacket(totalCurrent, [...packet.samples], {
|
|
309
|
+
timestamp: packet.timestamp,
|
|
310
|
+
battRaw: packet.battRaw,
|
|
311
|
+
sampleIndex: packet.sampleIndex,
|
|
312
|
+
distribution: {
|
|
313
|
+
left: this.buildZoneMeasurement(leftClamped, this.leftPeak, this.leftSum / this.dataPointCount),
|
|
314
|
+
center: this.buildZoneMeasurement(
|
|
315
|
+
centerClamped,
|
|
316
|
+
this.centerPeak,
|
|
317
|
+
this.centerSum / this.dataPointCount,
|
|
318
|
+
),
|
|
319
|
+
right: this.buildZoneMeasurement(rightClamped, this.rightPeak, this.rightSum / this.dataPointCount),
|
|
320
|
+
},
|
|
321
|
+
}),
|
|
322
|
+
)
|
|
323
|
+
|
|
312
324
|
// Check if device is being used
|
|
313
325
|
this.activityCheck(center)
|
|
314
326
|
|
|
@@ -400,7 +412,7 @@ export class Motherboard extends Device implements IMotherboard {
|
|
|
400
412
|
* @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
|
|
401
413
|
*/
|
|
402
414
|
stream = async (duration = 0): Promise<void> => {
|
|
403
|
-
|
|
415
|
+
this.resetPacketTracking()
|
|
404
416
|
this.downloadPackets.length = 0
|
|
405
417
|
// Read calibration data if not already available
|
|
406
418
|
if (!this.calibrationData[0].length) {
|
|
@@ -164,13 +164,14 @@ export class PB700BT extends Device {
|
|
|
164
164
|
*/
|
|
165
165
|
override handleNotifications = (value: DataView): void => {
|
|
166
166
|
if (value) {
|
|
167
|
-
// Update timestamp
|
|
168
167
|
this.updateTimestamp()
|
|
169
168
|
if (value.buffer) {
|
|
170
169
|
const period = value.getUint32(0, false)
|
|
171
170
|
|
|
172
171
|
if (!Number.isFinite(period) || period === 0) return
|
|
173
172
|
|
|
173
|
+
this.currentSamplesPerPacket = 1
|
|
174
|
+
this.recordPacketReceived()
|
|
174
175
|
const ts = value.getUint32(4, false)
|
|
175
176
|
|
|
176
177
|
const rpmFloat = 60 * (666666 / period)
|
|
@@ -183,31 +184,28 @@ export class PB700BT extends Device {
|
|
|
183
184
|
|
|
184
185
|
const numericData = receivedData - this.applyTare(receivedData)
|
|
185
186
|
|
|
186
|
-
|
|
187
|
-
this.downloadPackets.push({
|
|
188
|
-
received: receivedTime,
|
|
189
|
-
sampleNum: ts,
|
|
190
|
-
battRaw: 0,
|
|
191
|
-
samples: [numericData],
|
|
192
|
-
masses: [numericData],
|
|
193
|
-
})
|
|
187
|
+
const currentMassTotal = Math.max(-1000, numericData)
|
|
194
188
|
|
|
195
|
-
// Update
|
|
189
|
+
// Update session stats before building packet
|
|
196
190
|
this.peak = Math.max(this.peak, numericData)
|
|
197
|
-
|
|
198
|
-
// Update running sum and count
|
|
199
|
-
const currentMassTotal = Math.max(-1000, numericData)
|
|
191
|
+
this.min = Math.min(this.min, Math.max(-1000, numericData))
|
|
200
192
|
this.sum += currentMassTotal
|
|
201
193
|
this.dataPointCount++
|
|
202
|
-
|
|
203
|
-
// Calculate the average dynamically
|
|
204
194
|
this.mean = this.sum / this.dataPointCount
|
|
205
195
|
|
|
196
|
+
// Add data to downloadable Array
|
|
197
|
+
this.downloadPackets.push(
|
|
198
|
+
this.buildDownloadPacket(currentMassTotal, [numericData], {
|
|
199
|
+
timestamp: receivedTime,
|
|
200
|
+
sampleIndex: ts,
|
|
201
|
+
}),
|
|
202
|
+
)
|
|
203
|
+
|
|
206
204
|
// Check if device is being used
|
|
207
205
|
this.activityCheck(numericData)
|
|
208
206
|
|
|
209
207
|
// Notify with weight data
|
|
210
|
-
this.notifyCallback(this.buildForceMeasurement(
|
|
208
|
+
this.notifyCallback(this.buildForceMeasurement(currentMassTotal))
|
|
211
209
|
}
|
|
212
210
|
}
|
|
213
211
|
}
|