Untitled
unknown
typescript
a year ago
33 kB
3
Indexable
Never
import { ElMessage } from "element-plus"; const { ipcRenderer } = require("electron"); //#region analyse packet data export function dealPacket(packet: any, status: any, chartData: any): void { switch (packet[3]) { case 0xaa: break; //检测参数-周期 case 0xab: break; //检测参数-实时 case 0xac: break; //消息类参数 case 0xad: break; //操作类参数 case 0xae: break; //设置参数 case 0xaf: break; //治疗设置参数上行 case 0xb0: { // 混合类数据信息 analyseB0(packet, status, chartData); break; } case 0xb3: { analyseB3(packet, status); break; } case 0xb5: { status.mode = getMode(packet[5]); analyseB5(packet, status); break; } default: break; } } function getMode(byte: any) { switch (byte) { case 0x01: return "CPAP"; case 0x02: return "APAP"; case 0x03: return "S"; case 0x04: return "S/T"; case 0x05: return "AS"; case 0x06: return "AST"; case 0x07: return "STVT"; case 0x08: return "T"; default: return ""; } } function analyseB3(packet: any, status: any) { if (packet[7] == 0x01) { // HeartBeat packet return; } if (packet[4] == 0x01 && packet[7] == 0xad && packet[8] == 0x11) { // 设置命令 status.mode = getMode(packet[9]); return; } if (packet[4] == 0x01) { ElMessage({ message: "设置参数成功", type: "success", }); } if (packet[4] == 0x02) { ElMessage({ message: "设置超出范围", type: "warning", }); return; } if (packet[4] == 0x03) { ElMessage({ message: "设置参数失败", type: "error", }); return; } if ((packet[4] = 0x01 && packet[7] == 0xaf)) { switch (packet[8]) { case 0x01: { //CPAP switch (packet[9]) { case 0x01: { status.CPAP.治疗压力 = decode2Byte(packet, 10); break; } case 0x0e: { status.CPAP.窒息提示 = decode2Byte(packet, 10); break; } } break; } case 0x02: { //APAP switch (packet[9]) { case 0x03: { status.APAP.起始压力 = decode2Byte(packet, 10); break; } case 0x02: { status.APAP.最大压力 = decode2Byte(packet, 10); break; } case 0x0e: { status.APAP.窒息提示 = decode2Byte(packet, 10); break; } } break; } case 0x03: { //S switch (packet[9]) { case 0x04: { status.S.吸气压力 = decode2Byte(packet, 10); break; } case 0x05: { status.S.呼气压力 = decode2Byte(packet, 10); break; } case 0x08: { status.S.吸气触发 = decode2Byte(packet, 10); break; } case 0x09: { status.S.呼气触发 = decode2Byte(packet, 10); break; } case 0x0a: { status.S.吸气流量 = decode2Byte(packet, 10); break; } case 0x0b: { status.S.最短吸气 = decode2Byte(packet, 10); break; } case 0x0c: { status.S.最长吸气 = decode2Byte(packet, 10); break; } case 0x0f: { status.S.低压提示 = decode2Byte(packet, 10); break; } case 0x10: { status.S.低频提示 = decode2Byte(packet, 10); break; } case 0x11: { status.S.高频提示 = decode2Byte(packet, 10); break; } case 0x12: { status.S.低漏气 = decode2Byte(packet, 10); break; } case 0x13: { status.S.高漏气 = decode2Byte(packet, 10); break; } case 0x14: { status.S.低通气量 = decode2Byte(packet, 10); break; } case 0x15: { status.S.高通气量 = decode2Byte(packet, 10); break; } case 0x16: { status.S.低潮气量 = decode2Byte(packet, 10); break; } case 0x0e: { status.S.窒息提示 = decode2Byte(packet, 10); break; } } break; } case 0x04: { //ST switch (packet[9]) { case 0x04: { status.ST.吸气压力 = decode2Byte(packet, 10); break; } case 0x05: { status.ST.呼气压力 = decode2Byte(packet, 10); break; } case 0x06: { status.ST.呼吸频率 = decode2Byte(packet, 10); break; } case 0x07: { status.ST.吸气时间 = decode2Byte(packet, 10); break; } case 0x08: { status.ST.吸气触发 = decode2Byte(packet, 10); break; } case 0x09: { status.ST.呼气触发 = decode2Byte(packet, 10); break; } case 0x0a: { status.ST.吸气流量 = decode2Byte(packet, 10); break; } case 0x0b: { status.ST.最短吸气 = decode2Byte(packet, 10); break; } case 0x0c: { status.ST.最长吸气 = decode2Byte(packet, 10); break; } case 0x0f: { status.ST.低压提示 = decode2Byte(packet, 10); break; } case 0x10: { status.ST.低频提示 = decode2Byte(packet, 10); break; } case 0x11: { status.ST.高频提示 = decode2Byte(packet, 10); break; } case 0x12: { status.ST.低漏气 = decode2Byte(packet, 10); break; } case 0x13: { status.ST.高漏气 = decode2Byte(packet, 10); break; } case 0x14: { status.ST.低通气量 = decode2Byte(packet, 10); break; } case 0x15: { status.ST.高通气量 = decode2Byte(packet, 10); break; } case 0x16: { status.ST.低潮气量 = decode2Byte(packet, 10); break; } } break; } case 0x05: { //AS switch (packet[9]) { case 0x02: { status.AS.吸气高压 = decode2Byte(packet, 10); break; } case 0x04: { status.AS.吸气压力 = decode2Byte(packet, 10); break; } case 0x05: { status.AS.呼气压力 = decode2Byte(packet, 10); break; } case 0x08: { status.AS.吸气触发 = decode2Byte(packet, 10); break; } case 0x09: { status.AS.呼气触发 = decode2Byte(packet, 10); break; } case 0x0a: { status.AS.吸气流量 = decode2Byte(packet, 10); break; } case 0x0b: { status.AS.最短吸气 = decode2Byte(packet, 10); break; } case 0x0c: { status.AS.最长吸气 = decode2Byte(packet, 10); break; } case 0x0e: { status.AS.窒息提示 = decode2Byte(packet, 10); break; } } break; } case 0x06: { //AST switch (packet[9]) { case 0x02: { status.AST.吸气高压 = decode2Byte(packet, 10); break; } case 0x04: { status.AST.吸气压力 = decode2Byte(packet, 10); break; } case 0x05: { status.AST.呼气压力 = decode2Byte(packet, 10); break; } case 0x06: { status.AST.呼吸频率 = decode2Byte(packet, 10); break; } case 0x07: { status.AST.吸气时间 = decode2Byte(packet, 10); break; } case 0x08: { status.AST.吸气触发 = decode2Byte(packet, 10); break; } case 0x09: { status.AST.呼气触发 = decode2Byte(packet, 10); break; } case 0x0a: { status.AST.吸气流量 = decode2Byte(packet, 10); break; } case 0x0b: { status.AST.最短吸气 = decode2Byte(packet, 10); break; } case 0x0c: { status.AST.最长吸气 = decode2Byte(packet, 10); break; } } break; } case 0x07: { //STVT switch (packet[9]) { case 0x02: { status.STVT.吸气高压 = decode2Byte(packet, 10); break; } case 0x04: { status.STVT.吸气压力 = decode2Byte(packet, 10); break; } case 0x05: { status.STVT.呼气压力 = decode2Byte(packet, 10); break; } case 0x06: { status.STVT.呼吸频率 = decode2Byte(packet, 10); break; } case 0x07: { status.STVT.吸气时间 = decode2Byte(packet, 10); break; } case 0x08: { status.STVT.吸气触发 = decode2Byte(packet, 10); break; } case 0x09: { status.STVT.呼气触发 = decode2Byte(packet, 10); break; } case 0x0a: { status.STVT.吸气流量 = decode2Byte(packet, 10); break; } case 0x0d: { status.STVT.潮气量 = decode2Byte(packet, 10); break; } case 0x0b: { status.STVT.最短吸气 = decode2Byte(packet, 10); break; } case 0x0c: { status.STVT.最长吸气 = decode2Byte(packet, 10); break; } case 0x0f: { status.STVT.低压提示 = decode2Byte(packet, 10); break; } case 0x10: { status.STVT.低频提示 = decode2Byte(packet, 10); break; } case 0x11: { status.STVT.高频提示 = decode2Byte(packet, 10); break; } case 0x12: { status.STVT.低漏气 = decode2Byte(packet, 10); break; } case 0x13: { status.STVT.高漏气 = decode2Byte(packet, 10); break; } case 0x14: { status.STVT.低通气量 = decode2Byte(packet, 10); break; } case 0x15: { status.STVT.高通气量 = decode2Byte(packet, 10); break; } case 0x16: { status.STVT.低潮气量 = decode2Byte(packet, 10); break; } } break; } case 0x08: { //T switch (packet[9]) { case 0x04: { status.T.吸气压力 = decode2Byte(packet, 10); break; } case 0x05: { status.T.呼气压力 = decode2Byte(packet, 10); break; } case 0x06: { status.T.呼吸频率 = decode2Byte(packet, 10); break; } case 0x07: { status.T.吸气时间 = decode2Byte(packet, 10); break; } case 0x08: { status.T.吸气触发 = decode2Byte(packet, 10); break; } case 0x0a: { status.T.吸气流量 = decode2Byte(packet, 10); break; } case 0x0f: { status.T.低压提示 = decode2Byte(packet, 10); break; } case 0x10: { status.T.低频提示 = decode2Byte(packet, 10); break; } case 0x11: { status.T.高频提示 = decode2Byte(packet, 10); break; } case 0x12: { status.T.低漏气 = decode2Byte(packet, 10); break; } case 0x13: { status.T.高漏气 = decode2Byte(packet, 10); break; } case 0x14: { status.T.低通气量 = decode2Byte(packet, 10); break; } case 0x15: { status.T.高通气量 = decode2Byte(packet, 10); break; } case 0x16: { status.T.低潮气量 = decode2Byte(packet, 10); break; } } break; } } } if ((packet[4] = 0x01 && packet[7] == 0xae)) { switch (packet[8]) { case 0x03: { status.SYS.面罩脱落 = decode2Byte(packet, 10); break; } case 0x04: { status.SYS.延时升压 = decode2Byte(packet, 10); break; } case 0x05: { status.SYS.压力释放 = decode2Byte(packet, 10); break; } case 0x06: { status.SYS.管道类型 = decode2Byte(packet, 10); break; } case 0x07: { status.SYS.面罩类型 = decode2Byte(packet, 10); break; } case 0x08: { status.SYS.适用 = decode2Byte(packet, 10); break; } case 0x09: { status.SYS.自动开机 = decode2Byte(packet, 10); break; } case 0x0a: { status.SYS.自动关机 = decode2Byte(packet, 10); break; } case 0x0b: { status.SYS.背光时长 = decode2Byte(packet, 10); break; } } } } function decode2Byte(packet: any, index: any) { return packet[index] * 256 + packet[index + 1]; } function analyseB5(packet: any, status: any) { status.isRunning = false; const ch = packet[4]; switch (ch) { case 0x00: break; //容错 case 0x01: { //CPAP status.CPAP.治疗压力 = decode2Byte(packet, 6); status.CPAP.窒息提示 = decode2Byte(packet, 8); break; } case 0x02: { status.APAP.最大压力 = decode2Byte(packet, 6); status.APAP.起始压力 = decode2Byte(packet, 8); status.APAP.窒息提示 = decode2Byte(packet, 10); break; } case 0x03: { status.S.吸气压力 = decode2Byte(packet, 6); status.S.呼气压力 = decode2Byte(packet, 8); status.S.吸气触发 = decode2Byte(packet, 10); status.S.呼气触发 = decode2Byte(packet, 12); status.S.吸气流量 = decode2Byte(packet, 14); status.S.最短吸气 = decode2Byte(packet, 16); status.S.最长吸气 = decode2Byte(packet, 18); status.S.低压提示 = decode2Byte(packet, 20); status.S.低频提示 = decode2Byte(packet, 22); status.S.高频提示 = decode2Byte(packet, 24); status.S.低漏气 = decode2Byte(packet, 26); status.S.高漏气 = decode2Byte(packet, 28); status.S.低通气量 = decode2Byte(packet, 30); status.S.高通气量 = decode2Byte(packet, 32); status.S.低潮气量 = decode2Byte(packet, 34); status.S.窒息提示 = decode2Byte(packet, 36); break; } case 0x04: { status.ST.吸气压力 = decode2Byte(packet, 6); status.ST.呼气压力 = decode2Byte(packet, 8); status.ST.呼吸频率 = decode2Byte(packet, 10); status.ST.吸气时间 = decode2Byte(packet, 12); status.ST.吸气触发 = decode2Byte(packet, 14); status.ST.呼气触发 = decode2Byte(packet, 16); status.ST.吸气流量 = decode2Byte(packet, 18); status.ST.最短吸气 = decode2Byte(packet, 20); status.ST.最长吸气 = decode2Byte(packet, 22); status.ST.低压提示 = decode2Byte(packet, 24); status.ST.低频提示 = decode2Byte(packet, 26); status.ST.高频提示 = decode2Byte(packet, 28); status.ST.低漏气 = decode2Byte(packet, 30); status.ST.高漏气 = decode2Byte(packet, 32); status.ST.低通气量 = decode2Byte(packet, 34); status.ST.高通气量 = decode2Byte(packet, 36); status.ST.低潮气量 = decode2Byte(packet, 38); break; } case 0x05: { status.AS.吸气高压 = decode2Byte(packet, 6); status.AS.吸气压力 = decode2Byte(packet, 8); status.AS.呼气压力 = decode2Byte(packet, 10); status.AS.吸气触发 = decode2Byte(packet, 12); status.AS.呼气触发 = decode2Byte(packet, 14); status.AS.吸气流量 = decode2Byte(packet, 16); status.AS.最短吸气 = decode2Byte(packet, 18); status.AS.最长吸气 = decode2Byte(packet, 20); status.AS.窒息提示 = decode2Byte(packet, 22); break; } case 0x06: { status.AST.吸气高压 = decode2Byte(packet, 6); status.AST.吸气压力 = decode2Byte(packet, 8); status.AST.呼气压力 = decode2Byte(packet, 10); status.AST.呼吸频率 = decode2Byte(packet, 12); status.AST.吸气时间 = decode2Byte(packet, 14); status.AST.吸气触发 = decode2Byte(packet, 16); status.AST.呼气触发 = decode2Byte(packet, 18); status.AST.吸气流量 = decode2Byte(packet, 20); status.AST.最短吸气 = decode2Byte(packet, 22); status.AST.最长吸气 = decode2Byte(packet, 24); break; } case 0x07: { status.STVT.吸气高压 = decode2Byte(packet, 6); status.STVT.吸气压力 = decode2Byte(packet, 8); status.STVT.呼气压力 = decode2Byte(packet, 10); status.STVT.呼吸频率 = decode2Byte(packet, 12); status.STVT.吸气时间 = decode2Byte(packet, 14); status.STVT.吸气触发 = decode2Byte(packet, 16); status.STVT.呼气触发 = decode2Byte(packet, 18); status.STVT.吸气流量 = decode2Byte(packet, 20); status.STVT.潮气量 = decode2Byte(packet, 22); status.STVT.最短吸气 = decode2Byte(packet, 24); status.STVT.最长吸气 = decode2Byte(packet, 26); status.STVT.低压提示 = decode2Byte(packet, 28); status.STVT.低频提示 = decode2Byte(packet, 30); status.STVT.高频提示 = decode2Byte(packet, 32); status.STVT.低漏气 = decode2Byte(packet, 34); status.STVT.高漏气 = decode2Byte(packet, 36); status.STVT.低通气量 = decode2Byte(packet, 38); status.STVT.高通气量 = decode2Byte(packet, 40); status.STVT.低潮气量 = decode2Byte(packet, 42); break; } case 0x08: { status.T.吸气压力 = decode2Byte(packet, 6); status.T.呼气压力 = decode2Byte(packet, 8); status.T.呼吸频率 = decode2Byte(packet, 10); status.T.吸气时间 = decode2Byte(packet, 12); status.T.吸气触发 = decode2Byte(packet, 14); status.T.吸气流量 = decode2Byte(packet, 16); status.T.低压提示 = decode2Byte(packet, 18); status.T.低频提示 = decode2Byte(packet, 20); status.T.高频提示 = decode2Byte(packet, 22); status.T.低漏气 = decode2Byte(packet, 24); status.T.高漏气 = decode2Byte(packet, 26); status.T.低通气量 = decode2Byte(packet, 28); status.T.高通气量 = decode2Byte(packet, 30); status.T.低潮气量 = decode2Byte(packet, 32); break; } case 0x09: { status.SYS.面罩脱落 = decode2Byte(packet, 6); status.SYS.自动开机 = decode2Byte(packet, 8); status.SYS.自动关机 = decode2Byte(packet, 10); status.SYS.背光时长 = decode2Byte(packet, 12); status.SYS.延时升压 = decode2Byte(packet, 14); status.SYS.压力释放 = decode2Byte(packet, 16); status.SYS.管道类型 = decode2Byte(packet, 18); status.SYS.面罩类型 = decode2Byte(packet, 20); status.SYS.适用 = decode2Byte(packet, 22); status.SYS.数据单位 = decode2Byte(packet, 24); status.SYS.语言 = decode2Byte(packet, 26); break; } // case 0x0a: { // console.log(packet); // console.log(Buffer.from("AC6Q1010148")); // console.log(packet.slice(6, 17)); // console.log(Buffer.from(packet, "hex").toString()); // console.log(Buffer.from(packet.slice(6, 17), "hex").toString()); // console.log(Buffer.from(packet.slice(6, 17), "hex").toString()); // console.log(Buffer.from(packet.slice(6, 17), "hex").toString()); // } case 0x0a: break; // NOTE INFO? case 0x0b: break; // NOTE STATUS? case 0x0c: break; //心跳 useless case 0x0d: break; //ACK useless case 0x0e: break; //容错 useless default: break; } } function decodeSub(subpayload: any, index: any) { return subpayload[index] * 256 + subpayload[index + 1]; } function analyseB0(packet: any, status: any, chartData: any) { writePeriodData(packet); let payload = packet.slice(4, -4); for (let i = 0; i < 3; i++) { let subPayload_len = payload[1]; if (payload[subPayload_len - 1] == 0xff) { switch (payload[0]) { case 0xc0: { status.dashboard.peak = decodeSub(payload, 4); status.dashboard.peep = decodeSub(payload, 6); status.dashboard.vt = decodeSub(payload, 8); status.dashboard.ie = decodeSub(payload, 10); status.dashboard.mv = decodeSub(payload, 12); status.dashboard.leak = decodeSub(payload, 14); status.dashboard.rr = decodeSub(payload, 16); break; } case 0xc1: { // 实时压力和流量数据 for echat // | 0 | 1 | 2 | 3 | 4 | 5 | 6 | ... | 49 | // | ----- | ------------- | --------------- | ---- | ---- | ----- | ----- | ---- | ---- | // | c1 | 32 | 0f | 04 | 77 | 80 | 11 | ... | ff | // | start | 50(c1 length) | 15(data groups) | ms?? | flow | presH | presL | ... | end | // NOTE 未实装:*自主触发标示位: 在press数据的最高bit, 1代表触发数据, 0代表非触发数据 // flow = dataQueueFlow.ElementAt(i); // int tt = Convert.ToInt32(dataQueuePress.ElementAt(i)); // press = (double)(tt % 32768) / 100; // ms一个点? chartData.flow = []; chartData.pres = []; chartData.trigger = []; for (let i = 4; i < 49; i += 3) { chartData.flow.push(payload[i]); chartData.pres.push(payload[i + 1] * 256 + payload[i + 2]); chartData.trigger.push((payload[i + 1] & 0b10000000) != 0); } break; } case 0xc2: { status.湿化器 = payload[2]; status.延时升压 = payload[3]; status.mode = getMode(payload[4] + 1); status.isRunning = payload[5] == 3 ? true : false; // NOTE 报警提示 if (payload[6] != 0) { status.提示1 = payload[6]; // 提示1 // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | // | -------- | ------ | ------ | -------- | ------ | ------ | -------- | -------- | // | 湿化超温 | 高频率 | 低频率 | 面罩脱落 | 高漏气 | 低漏气 | 高压提示 | 低压提示 | if ((payload[6] & 0x10000000) == 1) { ElMessage({ message: "湿化超温", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[6] & 0x01000000) == 1) { ElMessage({ message: "高频率", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[6] & 0x00100000) == 1) { ElMessage({ message: "低频率", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[6] & 0x00010000) == 1) { ElMessage({ message: "面罩脱落", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[6] & 0x00001000) == 1) { ElMessage({ message: "高漏气", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[6] & 0x00000100) == 1) { ElMessage({ message: "低漏气", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[6] & 0x00000010) == 1) { ElMessage({ message: "高压提示", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[6] & 0x00000001) == 1) { ElMessage({ message: "低压提示", duration: 0, showClose: true, grouping: true, type: "error", }); } } if (payload[7] != 0) { status.提示2 = payload[7]; if ((payload[7] & 0x00100000) == 1) { ElMessage({ message: "供电异常", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[7] & 0x00010000) == 1) { ElMessage({ message: "窒息提示", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[7] & 0x00001000) == 1) { ElMessage({ message: "低潮气量", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[7] & 0x00000100) == 1) { ElMessage({ message: "高通气量", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[7] & 0x00000010) == 1) { ElMessage({ message: "低通气量", duration: 0, showClose: true, grouping: true, type: "error", }); } if ((payload[7] & 0x00000001) == 1) { ElMessage({ message: "湿化故障", duration: 0, showClose: true, grouping: true, type: "error", }); } } // 提示2 // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | // | ---- | ---- | -------- | -------- | -------- | -------- | -------- | -------- | // | 暂无 | 暂无 | 供电异常 | 窒息提示 | 低潮气量 | 高通气量 | 低通气量 | 湿化故障 | break; } } } payload = payload.slice(subPayload_len); if (payload.length == 0) { break; } } function writePeriodData(packet: any) { let periodData = Array.from([ 0xaa, 0x55, 0x13, 0x1a, 0x20, 0x62, 0x01, 0x00, 0x20, ]); let now = new Date(); const year = Number(now.getFullYear() - 2000); const month = Number(now.getMonth() + 1); const day = Number(now.getDate()); const hour = Number(now.getHours()); const minute = Number(now.getMinutes()); const second = Number(now.getSeconds()); periodData = periodData.concat([year, month, day, hour, minute, second]); periodData = periodData.concat([ 0x00, 0x00, // [2] crc 0xfc, 0xa1, // status header 0x00, 0x00, // ramp 0x00, 0x00, 0x00, 0x00, // ramp 剩余时间 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 湿化器 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 加热管 0x00, 0x00, 0x00, // 臭氧 0xfc, 0xa2, //header 0x00, ]); periodData = periodData.concat(packet[8]); // runmode periodData = periodData.concat([ 0x00, // AI 0x00, // HI 0x00, // pmean ]); periodData = periodData.concat(packet[69]); periodData = periodData.concat(packet[70]); // peak periodData = periodData.concat(packet[77]); periodData = periodData.concat(packet[78]); // mv periodData = periodData.concat([0x00, 0x00]); // flowmax periodData = periodData.concat(packet[72]); // peep periodData = periodData.concat(packet[82]); // rate periodData = periodData.concat(packet[76]); // ie periodData = periodData.concat(packet[79]); periodData = periodData.concat(packet[80]); // leak periodData = periodData.concat([0x00, 0x00]); //meanLeak periodData = periodData.concat([0x00, 0x00]); //inspirTime periodData = periodData.concat([0x00, 0x00]); //expirTime periodData = periodData.concat(packet[73]); periodData = periodData.concat(packet[74]); // vt periodData = periodData.concat([0x00]); // inspirAppTrigerFlag periodData = periodData.concat([0x00]); // breathStatus periodData = periodData.concat([0x00]); // maskOffFlag periodData = periodData.concat([ status.CPAP.治疗压力 / 256, status.CPAP.治疗压力 % 256, ]); // CPAP设置值 periodData = periodData.concat([ status.APAP.最大压力 / 256, status.APAP.最大压力 % 256, ]); // APAP最大压力 periodData = periodData.concat([ status.APAP.起始压力 / 256, status.APAP.起始压力 % 256, ]); // APAP起始压力 periodData = periodData.concat([ status.SYS.压力释放 / 256, status.SYS.压力释放 % 256, ]); // 压力释放 periodData = periodData.concat([0x00, 0x00]); //ipap control periodData = periodData.concat([0x00, 0x00]); //epep control let tempIpap = 0; let tempEpap = 0; let tempmaxIpap = 0; switch (status.mode) { case "S": { tempIpap = status.S.吸气压力; tempEpap = status.S.呼气压力; break; } case "S/T": { tempIpap = status.ST.吸气压力; tempEpap = status.ST.呼气压力; break; } case "AS": { tempIpap = status.AS.吸气压力; tempEpap = status.AS.呼气压力; tempmaxIpap = status.AS.吸气高压; break; } case "AST": { tempIpap = status.AST.吸气压力; tempEpap = status.AST.呼气压力; tempmaxIpap = status.AST.吸气高压; break; } case "STVT": { tempIpap = status.STVT.吸气压力; tempEpap = status.STVT.呼气压力; tempmaxIpap = status.STVT.吸气高压; break; } case "T": { tempIpap = status.T.吸气压力; tempEpap = status.T.呼气压力; break; } default: break; } periodData = periodData.concat([tempIpap / 256, tempIpap % 256]); // 吸气压力 periodData = periodData.concat([tempEpap / 256, tempEpap % 256]); // 呼气压力 periodData = periodData.concat([tempmaxIpap / 256, tempmaxIpap % 256]); // 吸气高压 periodData = periodData.concat([ status.STVT.潮气量 / 256, status.STVT.潮气量 % 256, ]); // 目标潮气量设置值 periodData = periodData.concat([ status.STVT.潮气量 / 256, status.STVT.潮气量 % 256, ]); // 潮气量模型设置值 periodData = periodData.concat([0x00, 0x00]); //null periodData = periodData.concat([0x00, 0x00]); //crc periodData = periodData.concat([0xfc, 0xa2, 0x0d]); //crc // console.debug(periodData); ipcRenderer.send("append-data", Buffer.from(periodData)); } } //#endregion dealpacket