1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
| #!/usr/bin/env node
|
| const assert = require('assert');
| const { Jh2028Decoder } = require('./decoder');
| const { buildFrame, buildRealtimePayload, buildBloodPressurePayload } = require('./tcp-simulator');
|
| function main() {
| const decoder = new Jh2028Decoder({ alModelPath: './alModel.json' });
|
| const realtimeFrame = buildFrame(1, 0x01, 0x00, buildRealtimePayload());
| const realtimeResult = decoder.push(realtimeFrame)[0];
|
| assert.ok(realtimeResult);
| assert.strictEqual(realtimeResult.publish, true);
| assert.deepStrictEqual(realtimeResult.metric, {
| AF: 36.5,
| F: 36.8,
| A: 2000,
| C: 500,
| B: 250,
| K: 90,
| L: 500,
| D: 320,
| H: -100,
| o: 120,
| J: -80,
| U: 2048,
| G: 138,
| Na: 140,
| HCO3: 25,
| O2Sat: 98.7,
| Hct: 36.5,
| Hb: 13.2,
| Tblood: 36.7,
| ktv: 1.5,
| });
|
| const bpFrame = buildFrame(2, 0x01, 0x01, buildBloodPressurePayload());
| const bpResult = decoder.push(bpFrame)[0];
|
| assert.ok(bpResult);
| assert.strictEqual(bpResult.publish, true);
| assert.deepStrictEqual(bpResult.metric, {
| N: 120,
| O: 80,
| P: 76,
| });
|
| console.log('协议验证通过');
| }
|
| main();
|
|