From e22def4691bd59de29f95184e55ddac5ac7449fc Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Wed, 23 Jul 2025 16:30:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E8=AF=84=E5=88=A4?= =?UTF-8?q?=E9=97=AE=E9=A2=98,=E5=88=A0=E9=99=A4=E8=80=81=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/model/Judge.ets | 1 + entry/src/main/ets/pages/Judge.ets | 16 +- .../pages/Judge/SignalTrajectoryDialog.ets | 9 +- entry/src/main/ets/pages/TerminalInfo.ets | 309 ++++++++++-------- .../ets/pages/compontents/SignalDisplay.ets | 5 +- entry/src/main/ets/pages/judgeSDK/judge.ets | 49 ++- .../main/ets/pages/judgeSDK/utils/fileLog.ets | 4 +- entry/src/main/ets/workers/Log.ets | 35 +- 8 files changed, 254 insertions(+), 174 deletions(-) diff --git a/entry/src/main/ets/model/Judge.ets b/entry/src/main/ets/model/Judge.ets index bebf75e..59b62b2 100644 --- a/entry/src/main/ets/model/Judge.ets +++ b/entry/src/main/ets/model/Judge.ets @@ -498,6 +498,7 @@ export interface JudgeUI { dw: string endExamDialogController: CustomDialogController generateExamRecordsDialogController: CustomDialogController + laneSignal:PerLane } diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index 83c7076..ab0a76c 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -38,14 +38,15 @@ import { SyssetConfig, SYSTEMPARMARR, User, - ProcessDataEnumType + ProcessDataEnumType, + PerLane } from '../model'; import { GetSyncData } from '../utils/table/Operation'; import dayTs from '../utils/Date'; import { GetCurrentTime } from '../utils/Common'; import FileUtils from '../utils/FileUtils'; import SignalTrajectoryDialog from './Judge/SignalTrajectoryDialog'; -import { DefaultJudgeConfigData, ProcessDataMock } from '../mock'; +import { DefaultJudgeConfigData, InitialPerLane, ProcessDataMock } from '../mock'; import { dConsole } from '../utils/LogWorker'; import ConfirmDialog from './compontents/ConfirmDialog'; import CarLoadingDialog from './compontents/CarLoading'; @@ -146,10 +147,13 @@ struct JudgePage { @State carInfo: CarInfoType = {} @State isErrorMsgEnd: boolean = false @State disConnectErrorOpen: boolean = false + @State laneSignal: PerLane = InitialPerLane public context = getContext(this) as common.UIAbilityContext; // 信号查看弹窗 signalTrajectoryDialogController: CustomDialogController = new CustomDialogController({ - builder: SignalTrajectoryDialog(), + builder: SignalTrajectoryDialog({ + laneSignal: this.laneSignal + }), customStyle: true, autoCancel: true }) @@ -167,8 +171,7 @@ struct JudgePage { text: "确认结束考试?", onConfirm: async () => { if (this.isErrorMsgEnd) { - dConsole.log(JudgeTag, "结束考试") - this.judge.closeAllFiles() + dConsole.log(JudgeTag, "router back1") router.back() return } @@ -187,7 +190,7 @@ struct JudgePage { try { this.judge.checkExamIsEnd(true); } catch (e) { - this.judge.closeAllFiles() + dConsole.log(JudgeTag, "router back2") router.back() } } @@ -505,6 +508,7 @@ struct JudgePage { message: '读取数据库信息失败,请重新联网更新!', duration: 8000 }); + dConsole.log(JudgeTag, "router back3") router.back(); } } diff --git a/entry/src/main/ets/pages/Judge/SignalTrajectoryDialog.ets b/entry/src/main/ets/pages/Judge/SignalTrajectoryDialog.ets index d0c1ea2..358344d 100644 --- a/entry/src/main/ets/pages/Judge/SignalTrajectoryDialog.ets +++ b/entry/src/main/ets/pages/Judge/SignalTrajectoryDialog.ets @@ -1,9 +1,15 @@ +import { PerLane } from '../../model' +import { dConsole } from '../../utils/LogWorker' import SignalDisplayComponent from '../compontents/SignalDisplay' import TabComponent from '../compontents/Tab' @CustomDialog export default struct SignalTrajectoryDialog { @State active: number = 0 + @Prop laneSignal: PerLane + + + private controller?: CustomDialogController build() { @@ -32,7 +38,8 @@ export default struct SignalTrajectoryDialog { Scroll() { Column() { SignalDisplayComponent({ - active: this.active + active: this.active, + laneSignal: this.laneSignal }) }.height(890) }.width("100%") diff --git a/entry/src/main/ets/pages/TerminalInfo.ets b/entry/src/main/ets/pages/TerminalInfo.ets index 277cdbc..1ff452e 100644 --- a/entry/src/main/ets/pages/TerminalInfo.ets +++ b/entry/src/main/ets/pages/TerminalInfo.ets @@ -14,6 +14,7 @@ struct TerminalInfoPage { @State config: EnvironmentConfigurationType = {} private fileUtil!: FileUtils private context = getContext(this) as common.UIAbilityContext; + @State isProcessing: boolean = false; async aboutToAppear() { this.fileUtil = new FileUtils(this.context) @@ -39,172 +40,199 @@ struct TerminalInfoPage { Column() { Column() { Button().opacity(1).width(0).height(0) - Flex({ - wrap: FlexWrap.Wrap, - }) { - if (this.config.isOpenFiniteDifference === "1") { + Scroll() { + Flex({ + wrap: FlexWrap.Wrap, + }) { + if (this.config.isOpenFiniteDifference === "1") { + blockComponent({ + value: this.config.tcpOppositeIp, + change: (value: string) => { + this.config.tcpOppositeIp = value; + } + }) + blockComponent({ + label: "差分响应端口", + value: this.config.tcpOppositePort, + change: (value: string) => { + this.config.tcpOppositePort = value; + } + }) + } blockComponent({ - value: this.config.tcpOppositeIp, + label: "中心服务器IP", + value: this.config.centerIp, change: (value: string) => { - this.config.tcpOppositeIp = value; + this.config.centerIp = value; } }) blockComponent({ - label: "差分响应端口", - value: this.config.tcpOppositePort, + label: "中心响应端口", + value: this.config.centerPort, change: (value: string) => { - this.config.tcpOppositePort = value; + this.config.centerPort = value; } }) - } - blockComponent({ - label: "中心服务器IP", - value: this.config.centerIp, - change: (value: string) => { - this.config.centerIp = value; - } - }) - blockComponent({ - label: "中心响应端口", - value: this.config.centerPort, - change: (value: string) => { - this.config.centerPort = value; - } - }) - blockComponent({ - label: "后置机IP", - value: this.config.udpOppositeIp, - change: (value: string) => { - this.config.udpOppositeIp = value; - } - }) - blockComponent({ - label: "后置机响应端口", - value: this.config.udpOppositeIpPort, - change: (value: string) => { - this.config.udpOppositeIpPort = value; - } - }) - if (this.config.carType === "4") { blockComponent({ - label: "后置机响应端口2", - value: this.config.udpOppositeIpPortTwo, + label: "后置机IP", + value: this.config.udpOppositeIp, change: (value: string) => { - this.config.udpOppositeIpPortTwo = value; + this.config.udpOppositeIp = value; } }) - } - blockComponent({ - label: "前置机IP", - value: this.config.udplocalIp, - change: (value: string) => { - this.config.udplocalIp = value; - this.config.tcplocalIp = value - } - }) - blockComponent({ - label: "后置机UDP本地端口", - value: this.config.udplocalIpPort, - change: (value: string) => { - this.config.udplocalIpPort = value; - } - }) - if (this.config.carType === "4") { blockComponent({ - label: "后置机UDP本地端口2", - value: this.config.udplocalIpPortTwo, + label: "后置机响应端口", + value: this.config.udpOppositeIpPort, change: (value: string) => { - this.config.udplocalIpPortTwo = value; + this.config.udpOppositeIpPort = value; } }) - } - // blockComponent({ - // label: "TCP本地端口", - // value: this.config.tcplocalIpPort, - // change: (value: string) => { - // this.config.tcplocalIpPort = value; - // } - // }) - blockComponent({ - label: "子网掩码", - value: this.config.netMask, - change: (value: string) => { - this.config.netMask = value; + if (this.config.carType === "4") { + blockComponent({ + label: "后置机响应端口2", + value: this.config.udpOppositeIpPortTwo, + change: (value: string) => { + this.config.udpOppositeIpPortTwo = value; + } + }) } - }) - blockComponent({ - label: "默认网关", - value: this.config.gateway, - change: (value: string) => { - this.config.gateway = value; + blockComponent({ + label: "前置机IP", + value: this.config.udplocalIp, + change: (value: string) => { + this.config.udplocalIp = value; + this.config.tcplocalIp = value + } + }) + blockComponent({ + label: "后置机UDP本地端口", + value: this.config.udplocalIpPort, + change: (value: string) => { + this.config.udplocalIpPort = value; + } + }) + if (this.config.carType === "4") { + blockComponent({ + label: "后置机UDP本地端口2", + value: this.config.udplocalIpPortTwo, + change: (value: string) => { + this.config.udplocalIpPortTwo = value; + } + }) } - }) - blockComponent({ - label: "DNS", - value: this.config.dnsServers, - change: (value: string) => { - this.config.dnsServers = value; - } - }) - blockComponent({ - label: "车型", - type: 4, - value: this.config.carType, - change: (value: string) => { - this.config.carType = value; - } - }) - blockComponent({ - label: "后置机类型", - type: 1, - value: this.config.rearMachineModel, - change: (value: string) => { - this.config.rearMachineModel = value; - } - }) - blockComponent({ - label: "是否开启差分", - type: 5, - value: this.config.isOpenFiniteDifference, - change: (value: string) => { - this.config.isOpenFiniteDifference = value; - } - }) - blockComponent({ - label: "是否开启日志", - type: 2, - value: this.config.isOpenLog, - change: (value: string) => { - this.config.isOpenLog = value; - } - }) - blockComponent({ - label: "板卡类型", - type: 3, - value: this.config.boardType, - change: (value: string) => { - this.config.boardType = value; - } - }) - blockComponent({ - label: "是否开启调试", - type: 6, - value: this.config.isOpenDebugger, - change: (value: string) => { - this.config.isOpenDebugger = value; - } - }) + // blockComponent({ + // label: "TCP本地端口", + // value: this.config.tcplocalIpPort, + // change: (value: string) => { + // this.config.tcplocalIpPort = value; + // } + // }) + blockComponent({ + label: "子网掩码", + value: this.config.netMask, + change: (value: string) => { + this.config.netMask = value; + } + }) + blockComponent({ + label: "默认网关", + value: this.config.gateway, + change: (value: string) => { + this.config.gateway = value; + } + }) + blockComponent({ + label: "DNS", + value: this.config.dnsServers, + change: (value: string) => { + this.config.dnsServers = value; + } + }) + blockComponent({ + label: "外壳版本", + value: this.config.version, + change: (value: string) => { + this.config.version = value; + } + }) + blockComponent({ + label: "评判版本", + value: this.config.judgeVersion, + change: (value: string) => { + this.config.judgeVersion = value; + } + }) + blockComponent({ + label: "车型", + type: 4, + value: this.config.carType, + change: (value: string) => { + this.config.carType = value; + } + }) + blockComponent({ + label: "后置机类型", + type: 1, + value: this.config.rearMachineModel, + change: (value: string) => { + this.config.rearMachineModel = value; + } + }) + blockComponent({ + label: "是否开启差分", + type: 5, + value: this.config.isOpenFiniteDifference, + change: (value: string) => { + this.config.isOpenFiniteDifference = value; + } + }) + blockComponent({ + label: "是否开启日志", + type: 2, + value: this.config.isOpenLog, + change: (value: string) => { + this.config.isOpenLog = value; + } + }) + blockComponent({ + label: "板卡类型", + type: 3, + value: this.config.boardType, + change: (value: string) => { + this.config.boardType = value; + } + }) + blockComponent({ + label: "开启调试(重启APP)", + type: 6, + value: this.config.isOpenDebugger, + change: (value: string) => { + this.config.isOpenDebugger = value; + } + }) + }.margin(20) + } - .backgroundColor("#282828") .height(650) + .width("100%") + .backgroundColor("#282828") .borderRadius(20) .margin(20) .padding({ top: 10 }) + Row() { Image($r('app.media.bc')).height(80).objectFit(ImageFit.Contain).onClick(() => { + if (this.isProcessing) { + Prompt.showToast({ + message: "请勿频繁点击", + duration: 3000 + }) + return + } + this.isProcessing = true dConsole.log(TerminalInfoTag, "保存配置", JSON.stringify(this.config)) AppStorage.setOrCreate("EnvironmentConfiguration", this.config) this.fileUtil.addFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt', JSON.stringify(this.config)) @@ -228,8 +256,13 @@ struct TerminalInfoPage { message: '设置成功', duration: 3000 }); + // 延迟几秒 + setTimeout(() => { + this.isProcessing = false + }, 3000) } }); + }) } .width("100%") diff --git a/entry/src/main/ets/pages/compontents/SignalDisplay.ets b/entry/src/main/ets/pages/compontents/SignalDisplay.ets index 5676596..0c0407a 100644 --- a/entry/src/main/ets/pages/compontents/SignalDisplay.ets +++ b/entry/src/main/ets/pages/compontents/SignalDisplay.ets @@ -28,7 +28,9 @@ export default struct SignalDisplayComponent { // 原始数据 @State rawData: string = "$GPS,,,,,,,,,,,,,,,,,,,,,,,,,,,,," // 车道信息 - @State laneSignal: PerLane = InitialPerLane + @Prop laneSignal: PerLane + + aboutToAppear(): void { DifferentialAndSignal.onMsg(this.getMsg) @@ -243,6 +245,7 @@ struct LaneComponent { ] getValues(roadColumn: RoadDataType) { + dConsole.log(SignDisplayTag, "车道信息", this.laneSignal) let key = roadColumn.key; let str = '' if (Array.isArray(key)) { diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index 8a80c64..aa5b6ea 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -285,6 +285,16 @@ export default class Judge { if (stachArr[0] != '#DN_GD' || this.isUdpEnd) { return } + if (msg[336]) { + if (msg[336] === "4") { + dConsole.log(JudgeTag, "差分状态正常") + this.judgeUI.isDwztRight = true + } else { + dConsole.log(JudgeTag, "差分状态异常") + this.judgeUI.isDwztRight = false + } + } + this.judgeUI.isDwztRight const plcData = await this.getPlcData(msg); // 4.过程数据 await this.fileLog?.setExamJudgeData(JSON.stringify(plcData)) @@ -591,7 +601,7 @@ export default class Judge { num++ // 4.过程数据 this.tempData = msg - this.judgeUI.isDwztRight = (msg?.gps?.dwzt == 4 && msg?.gps?.jdzt == 3); + // this.judgeUI.isDwztRight = (msg?.gps?.dwzt == 4 && msg?.gps?.jdzt == 3); this.judgeUI.sd = Math.floor(msg?.gps?.sd * 1.852) + ''; this.judgeUI.dw = Math.floor(msg?.sensor?.dw) + '' this.plcData = msg @@ -1075,7 +1085,6 @@ export default class Judge { const checkExamIsEnd = this.checkExamIsEnd const checkProjectIsStart = this.checkProjectIsStart const lane = this.lane - const closeAllFiles = this.closeAllFiles const projectsObj: object = judgeUI.projectsObj const judgeConfigObj: object = judgeUI.judgeConfigObj @@ -1332,7 +1341,6 @@ export default class Judge { const avPlayer = this.avPlayer const judgeTask = this.judgeTask const isManual = this.isManual - const closeAllFiles = this.closeAllFiles const judgeConfigObj = judgeUI.judgeConfigObj const examSubject = judgeUI.examSubject @@ -1354,7 +1362,7 @@ export default class Judge { if (!singlePlay && isManual && !isAllProjectsEnd) { avPlayer?.playAudio(['voice/empty.mp3'], true, () => { this.isUdpEnd = true; - closeAllFiles() + dConsole.log(JudgeTag, "router back7") router.back(); }) return @@ -1396,7 +1404,6 @@ export default class Judge { const avPlayer = this.avPlayer const kfArr = this.kfArr const filePath = this.filePath - const closeAllFiles = this.closeAllFiles const lsh = judgeUI.lsh; const idCard = judgeUI.idCard; @@ -1436,6 +1443,7 @@ export default class Judge { drvexam } let backTimeOut = setTimeout(() => { + dConsole.log(JudgeTag, "router back6") router.back() }, 90 * 1000) const temp = await this.sendWriteObjectOut(data, filePath); @@ -1449,7 +1457,6 @@ export default class Judge { this.judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!' } this.isUdpEnd = true; - closeAllFiles() // this.judgeUI.loadingPopupVisible = false; dConsole.log(JudgeTag, ' 关闭车辆loading1') this.judgeUI.generateExamRecordsDialogController.close() @@ -1536,7 +1543,7 @@ export default class Judge { if (kfArr && kfArr.length - 1 === index) { avPlayer?.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { this.isUdpEnd = true; - closeAllFiles() + dConsole.log(JudgeTag, "router back4") router.back(); }) throw new Error('End Loop') @@ -1545,7 +1552,7 @@ export default class Judge { } else { avPlayer?.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { this.isUdpEnd = true; - closeAllFiles() + dConsole.log(JudgeTag, "router back5") router.back(); }) throw new Error('End Loop') @@ -1559,9 +1566,10 @@ export default class Judge { avPlayer?.playAudio([voiceURL], true, () => { setTimeout(() => { this.isUdpEnd = true - closeAllFiles() dConsole.log(JudgeTag, ' 关闭车辆loading2') this.judgeUI.generateExamRecordsDialogController.close() + dConsole.log(JudgeTag, "router back8") + DifferentialAndSignal.clearMsg() router.back(); }, param302 == '8' ? 3000 : 0) }) @@ -1841,11 +1849,7 @@ export default class Judge { break; } } - closeAllFiles = () => { - setTimeout(() => { - this.fileLog?.closeAllFiles() - }, 1000) - } + //开始评判 private async judging(callBack: Function) { @@ -1857,15 +1861,9 @@ export default class Judge { const kssycs = judgeUI.kssycs const manualMarkRules = judgeUI.manualMarkRules - const fileLog = new FileLog(judgeUI.context); - const filePath = await fileLog?.initFileLogo({ - name, lsh, idCard - }); - this.fileLog = fileLog; - this.filePath = filePath; + const getJudgeBeginData = this.getJudgeBeginData; - const handleUdp = this.handleUdp; const handDistance = this.getJudgeBeginData; const handleTrajectoryUdp = this.handleTrajectoryUdp; const isTrajectoryOpen = this.isTrajectoryOpen; @@ -1884,7 +1882,7 @@ export default class Judge { await examJudgeSetLogCallback(3, async (level: number, info: string, len: number) => { dConsole.log(JudgeTag, '评判日志:' + info) // await fileLog?.setExamJudgeLogData(info); - dConsole.writeProcessData(ProcessDataEnumType.JudgeLogData,info) + dConsole.writeProcessData(ProcessDataEnumType.JudgeLogData, info) }) dConsole.info(JudgeTag, '2.注册日志回调完成') @@ -1903,7 +1901,7 @@ export default class Judge { await examJudgeSetRealExamCallback(async (strData: string, len: number) => { // 评判回调日志 // await fileLog?.setExamJudgeCallbackData(strData) - dConsole.writeProcessData(ProcessDataEnumType.JudgeProgressCallbackData,strData) + dConsole.writeProcessData(ProcessDataEnumType.JudgeProgressCallbackData, strData) dConsole.info(JudgeTag, '评判回调数据', strData) await this.handleRealExam(strData, callBack) }) @@ -1919,6 +1917,8 @@ export default class Judge { this.judgeUI.jl = jl //TODO 待优化 跨组件传值不生效 // globalThis.laneData = performInfo.lane; + dConsole.log(JudgeTag, "车道信息", performInfo.lane) + this.judgeUI.laneSignal = performInfo.lane }) let beginExamInfo: JudgeBeginObj | undefined = undefined @@ -1929,7 +1929,6 @@ export default class Judge { } else { beginExamInfo = await getJudgeBeginData() } - await fileLog?.setExamJudgeData(JSON.stringify(beginExamInfo)) if (beginExamInfo) { await examJudgeBeginExam(beginExamInfo); } @@ -1961,7 +1960,7 @@ export default class Judge { DifferentialAndSignal.onMsg((data: string) => { const result: WorkerBackMessage = JSON.parse(data) if (result.type === WorkerBackMessageType.ObtainUdpData) { - handleUdp(result.data as string) + this.handleUdp(result.data as string) dConsole.writeProcessData(ProcessDataEnumType.PlcData, result.data as string) } //TODO UDP修改 diff --git a/entry/src/main/ets/pages/judgeSDK/utils/fileLog.ets b/entry/src/main/ets/pages/judgeSDK/utils/fileLog.ets index 187178f..a651b5f 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/fileLog.ets +++ b/entry/src/main/ets/pages/judgeSDK/utils/fileLog.ets @@ -29,8 +29,8 @@ export default class FileLog { } // 无锡所接口数据 public setExamJudgeWuxiData = async (str: string) => { - this.examJudgeWuxiDataFd = - await this.fileUtil.editFile(`${this.folderPath}/wuxi_exam_data.txt`, str); + // this.examJudgeWuxiDataFd = + // await this.fileUtil.editFile(`${this.folderPath}/wuxi_exam_data.txt`, str); } // 无锡所过程数据 public setExamJudgeWuxiProgressData = async (str: string) => { diff --git a/entry/src/main/ets/workers/Log.ets b/entry/src/main/ets/workers/Log.ets index 03042aa..8709e26 100644 --- a/entry/src/main/ets/workers/Log.ets +++ b/entry/src/main/ets/workers/Log.ets @@ -98,7 +98,40 @@ async function InitExam(dirName: string) { // 写过程数据 async function WriteProcessData(type: ProcessDataEnumType, data: string) { - writeQueue.push({ type, data }); + if (type === ProcessDataEnumType.WuxiExam) { + // 改变数据为无锡所需要的数据 + const plcData = data.split(','); + const time = dayTs().format("YYYY-MM-DD HH:mm:ss") + const lineData = [ + /*帧头*/time, + /*卫星时间*/time, + /*经度*/ plcData[95], + /*纬度*/ plcData[95], + /*高度*/ plcData[86], + /*方位角*/ 0, + /*俯仰角*/ plcData[91], + /*速度角*/'', + /*速度*/ plcData[97], + /*横滚*/'', + /*卫星定位状态*/'', + /*卫星定向状态*/'', + /*前天线可用星数*/'', + /*后天线可用星数*/'', + /*东向位置坐标*/'', + /*北向位置坐标*/'', + /*天向位置坐标*/'', + /*东向速度*/'', + /*北向速度*/'', + /*评判信号1*/[plcData[14], plcData[19], plcData[5], '', plcData[2], plcData[3], plcData[7], plcData[8], + plcData[13], plcData[12], plcData[17], '', plcData[4], plcData[11], plcData[20], plcData[9], 0].join(','), + /*评判信号2*/['', plcData[28], '', '', plcData[10], '', '', '', '', '', '', '', '', '', '', '', '', ''].join(','), + /*发动机转速*/ plcData[25], + /*结束符*/ time, + ]; + writeQueue.push({ type, data: JSON.stringify(lineData) }); + } else { + writeQueue.push({ type, data }); + } if (!isProcessing) { processQueue();