diff --git a/entry/src/main/ets/pages/compontents/SignDisplayCom.ets b/entry/src/main/ets/pages/compontents/SignDisplayCom.ets index fb142cc6..eaf03065 100644 --- a/entry/src/main/ets/pages/compontents/SignDisplayCom.ets +++ b/entry/src/main/ets/pages/compontents/SignDisplayCom.ets @@ -1,5 +1,6 @@ import router from '@ohos.router'; -import FileLog from '../judgeSDK/utils/file-log'; +import UdpClient from '../../common/utils/UdpClient'; +import FileLog from '../judgeSDK/utils/fileLog'; import RealTime from '../compontents/judge/RealTime'; import { GPSData, SignalData } from '../../mock'; import { SignalDataType } from '../../model'; @@ -20,6 +21,7 @@ export default struct SignDisplayCom { @State @Watch('outClick') outFlag: boolean = false; @State url: string = '' private timer = null + private udpClient: UdpClient = null private FileLog: FileLog private vocObj = null; @@ -306,15 +308,13 @@ export default struct SignDisplayCom { if (showBack) { - this.ratio=1.2 - globalThis.udpClient&&globalThis.udpClient.onMessage_1((msg) => { + globalThis.udpClient.onMessage_1((msg) => { console.log('msgmsg', msg) if (msg) { getSignal(msg) } }) } else { - this.ratio=1 clearInterval(globalThis.signalTimer) globalThis.signalTimer = setInterval(() => { const msgStr = globalThis.msgStr diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index c16d8f3c..1af8f29a 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -2,19 +2,16 @@ import systemTime from '@ohos.systemDateTime'; import router from '@ohos.router'; import util from '@ohos.util'; import buffer from '@ohos.buffer'; - import { testKmItems, testMarkRules } from './dataTest/index'; import { EXAMDATA, SOUND } from './api/judgeSDK'; - -import VoiceAnnounce from './utils/voice-announcements'; -import FileModel from './utils/file-model'; -import FilePhoto from './utils/file-photo'; +import VoiceAnnounce from './utils/voiceAnnouncements'; +import FileModel from './utils/fileModel'; +import FilePhoto from './utils/filePhoto'; import FileUtil from '../../common/utils/File'; -import FileLog from '../judgeSDK/utils/file-log'; +import FileLog from './utils/fileLog'; -import JudgeTask from './utils/judge-task'; -import SimulateLights from './utils/simulate-lights'; -import { judgeConfig } from './utils/judge-config'; +import JudgeTask from './utils/judgeTask'; +import { judgeConfig } from './utils/judgeConfig'; import { uploadExamProgressData, writeObjectOut } from '../../api/judge'; import { @@ -36,35 +33,32 @@ import { plcStrToWXJson, promptWxCode, senorToWXDataStr -} from './utils/judge-common'; +} from './utils/judgeCommon'; import { examJudgeArtificialItem, examJudgeArtificialMark, examJudgeBeginExam, examJudgeEndExam, examJudgeInit, - examJudgeMapSetParam, - examJudgeMapSetScaling, + examJudgeSoundEnd, examJudgeRealExam, examJudgeSetLogCallback, examJudgeSetPerformCallback, examJudgeSetRealExamCallback } from './api/index'; import UsbService from '../../common/service/usbService'; + import Prompt from '@system.prompt'; const judgeTag = 'SURENJUN_JUDGE' export default class Judge { - - constructor(judgeUI) { this.serialIndex = 1; this.judgeUI = judgeUI //语音播放工具 this.avPlayer = new VoiceAnnounce(); - new SimulateLights(this.avPlayer) //模型工具 this.fileModel = new FileModel(judgeUI.context); //文件工具 @@ -104,7 +98,6 @@ export default class Judge { public async onJudgeFn(fn: Function) { await this.judging(fn) } - //开始评判 private async judging(callBack: Function) { const {judgeUI} = this; @@ -130,10 +123,10 @@ export default class Judge { await fileLog.setExamJudgeLogData(info); }) - console.info(judgeTag, '2.注册日志回调完成') + console.info(judgeTag, '2.注册日志回调完成',isTrajectoryOpen) let initInfo = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData(); - console.log('SURENJUN_JUDGE',isJudgeInitBool,isTrajectoryOpen,JSON.stringify(initInfo)) + //相关评判初始化只做一次 if (!isJudgeInitBool) { await fileLog.setExamJudgeData(initInfo) @@ -141,6 +134,7 @@ export default class Judge { globalThis.isJudgeInitBool = true console.info(judgeTag, '4.评判初始化完成') } else { + await fileLog.setExamJudgeData(initInfo) } globalThis.isJudge = true @@ -155,26 +149,21 @@ export default class Judge { console.info('评判实时数据', info) const performInfo = JSON.parse(info) this.performInfo = performInfo - this.judgeUI.jl = Math.ceil((performInfo.qjjl + performInfo.dcjl) / 100) + this.judgeUI.jl = Math.floor((performInfo.qjjl + performInfo.dcjl) / 100) }) + // 3.开始考试 let beginExamInfo = isTrajectoryOpen ? { ...JSON.parse(strArr[1]), replay: 1 } : await getJudgeBeginData() - console.log(judgeTag,'22222',JSON.stringify(beginExamInfo),strArr[1]) - await fileLog.setExamJudgeData(beginExamInfo) - console.log(judgeTag,'333333') - await examJudgeBeginExam(beginExamInfo); - console.log(judgeTag,'4444444') + await fileLog.setExamJudgeData(beginExamInfo) + await examJudgeBeginExam(beginExamInfo); console.info(judgeTag, '6.开始考试注册完成') avPlayer.playAudio(['voice/ksks.WAV']) - await examJudgeMapSetParam(640, 480); //设置参数宽、高 - await examJudgeMapSetScaling(120); //设置缩放比例,一般默认填100(就是100%的意思) ,数字越大视野越大,数字越小视野越小,不能为0 - this.judgeUI.draw = true // 处理轨迹plc信息 @@ -183,15 +172,308 @@ export default class Judge { return } - // 处理实时udp里的plc信号 globalThis.udpClient.onMessage_1(async (msg) => { handleUdp(msg) }) + } + // 获取评判初始化数据 + getJudgeInitData = async () => { + const {getModelData,getKm3JudgeInitConfig} = this + const carInfo = globalThis.carInfo; + const { examSubject,plateNo,carId } = carInfo; + const judgeUI = this.judgeUI + const {projectsObj,cdsbInfoObj,markRuleListObj,carType,carName,systemparmArr} = judgeUI + const examType = examSubject == 2 ? 'km2' : 'km3' + let allitems = []; + if (examSubject == 2) { + allitems = Reflect.ownKeys(cdsbInfoObj).map(cdsbKey => { + const cdsb = cdsbInfoObj[cdsbKey]; + const {xmdm,xmxh,modelKey} = cdsb + return { + xmdm, xmxh, model: getModelData(`${examType}/${modelKey}.txt`) + } + }) + } + const initInfo = { + kskm: examSubject * 1, + kchp: plateNo, + kchm: carId * 1, + kscx: carType, + cxcode: '1', + name: carName, + carmodel: getModelData(`${examType}/${carType}.txt`), + allitems, + iteminfo:[], + systemparm: systemparmArr, + mark: Reflect.ownKeys(markRuleListObj).map(ruleKey => (markRuleListObj[ruleKey])) || testMarkRules, + sysset: judgeUI.judgeConfig, + }; + let km3Config = {} + + if (examSubject == 3) { + km3Config = await getKm3JudgeInitConfig(); + } + // 获取科目三的评判配置 + console.info(judgeTag, '3.获取评判初始化数据完成') + return { + ...initInfo, + ...km3Config, + } + } + // 获取开始考试数据 + getJudgeBeginData = async () => { + const {code,name:examinerName} = globalThis.examinerInfo; + let currentParams: any = router.getParams(); + const {sczb,kfdm} = currentParams; + const {isExam} = this; + const judgeUI = this.judgeUI + const {projects,carType,isDdxk,ddxkTime,projectsCenterObj,ddxkKsxmArr,ddxkKfArr} = judgeUI; + const beginInfo = { + kgid: '012', + kgxm: decodeURI(examinerName || ''), + exam: isExam ? 1 : 0, + //是否回放 + replay: 0, + //生成的轨迹文件 + track: '', + xm: judgeUI.name, + sex: 0, + kslsh: judgeUI.lsh, + sfzmhm: judgeUI.idCard, + ksyy: '', + kscx: carType, + kkcs: 1, + sfyk: 0, + ykkkcs: 1, + wayno: judgeUI.wayno * 1, + czlx: 0, + kskssj: await systemTime.getCurrentTime(), + ksxm: projects.map(project => { + return { + xmdm: project.projectCode * 1, + xmxh: '', + } + }), + //断点续考 + ddxk: isDdxk ? 1 : 0, + ddkssj: ddxkTime, + ykxm: isDdxk ? (ddxkKsxmArr?.map(projectCenterCode => (projectsCenterObj[projectCenterCode]?.projectCode) * 1)) : [], + kfxm: isDdxk ? (ddxkKfArr?.map(kf => { + const [xmdm, kfdm] = kf.split(',') + return { + xmdm: xmdm * 1, + kfdm + } + })) : [], + yklc: 0, + special: [], + //TODO 科目三参数临时写死 + sczb: (sczb === undefined || sczb == 0)?0:1, + sczbkf:kfdm, + dmndg: false, + nitem1: false, + nitem41: false, + mfxx: false, + mfxxn: false + } + console.info(judgeTag, '5.获取开始考试数据完成') + return beginInfo } + //处理评判过程回调 + handleRealExam = async (strData, callBack) => { + let examData: EXAMDATA = JSON.parse(strData); + const {getDqxmStr,getKfStr,goJudgeVoice,setMndg,setRoadAndLane,judgeUI} = this; + const {carzt,xmks,kf,event,xmjs,ksjs,sound,mndg,lane} = examData + //获取项目结束、项目开始代码 + const xmdm = event == 2 ? xmjs.xmdm : xmks.xmdm + const xmxh = event == 2 ? xmjs.xmxh : xmks.xmxh; + const isManualProjectIn = this.artSubject3ProjectsCodesArr.includes(xmdm); + const {examSubject} = this.judgeUI + switch (event) { + //项目开始 + case 1: + judgeUI.projectsObj[xmdm].type = '2'; + if(isManualProjectIn){ + //手动项目是否在进行中 + this.judgeUI.isManualProjectIn = true + } + if(xmdm == 41 && examSubject == 3){ + this.rmndg = 1 + } + this.judgeUI.currentXmdm = xmdm; + const xmmcStr = judgeUI.projectsObj[xmdm].name; + const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; + const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; + this.testKmItems[xmmcCode].status = 2; + this.xmmcStr = xmmcStr; + this.xmmcCode = xmmcCode; + this.xmmcSingleCode = xmmcSingleCode + this.xmdm = xmdm; + this.xmxh = xmxh; + this.judgeUI.isProjectIn = true; + this.judgeUI.isDeductedPopShow = true + break; + + //项目结束 + case 2: + judgeUI.projectsObj[xmdm].type = (xmjs.xmhg === 0 ? '4' : '3'); + this.judgeUI.isManualProjectIn = false + //统计必考项目数量 + this.xmmcStr = '无'; + this.xmmcCode = ''; + this.xmmcSingleCode = 0; + this.xmdm = ''; + this.judgeUI.isProjectIn = false; + this.judgeUI.isDeductedPopShow = false + this.judgeUI.currentXmdm = undefined; + break; + + //扣分 + case 3: + const thisKf = getKfStr(`${kf.xmdm}_${kf.kfdm}`) + //扣分信息 + this.kfArr.push({ + //扣分项目名称 + xmmcStr: getDqxmStr(kf.xmdm), + xmdm: kf.xmdm, + //扣分描述 + desc: thisKf.desc, + //扣分分数 + score: thisKf.score, + // 扣分无锡所代码 + markcatalog: thisKf.markcatalog, + markserial: thisKf.markserial, + kfxh: thisKf.kfxh + }) + this.judgeUI.totalScore += thisKf.score * 1; + break; + + //考车状态 + case 4: + this.carztStr = getCarStatus(carzt); + break; + + //考试结束 + case 5: + this.ksjs = ksjs; + break; + + //项目取消 + case 6: + break; + + //语音播放和提示 + case 7: + goJudgeVoice(sound) + break; + + //模拟灯光事件 + case 8: + setMndg(mndg) + break; + //车道和路段变化 + case 9: + this.judgeUI.lane = lane + break; + + default: + ;break; + + } + + const {xmmcStr,carztStr,kfArr} = this; + + await callBack({ + //项目名称 考车状态 扣分arr + xmmcStr, carztStr, kfArr + }); + + //语音播报 + this.goVoiceAnnounce(event, xmdm, this.kfArr, xmjs) + + //更新UI + if (event == 1 || event == 2 || event == 3) { + const copyProjectsObj = this.judgeUI.projectsObj; + judgeUI.projectsObj = deepClone(copyProjectsObj); + //科目三统计必考数量 + this.setCountItems() + } + } + // 更改考试状态 + goVoiceAnnounce = async (event, xmdm, kf, xmjs) => { + const {beginProject,pointsDedute,endProject,avPlayer,uploadProgressPhoto,judgeTask,handEndExam,judgeUI} = this; + const {projectsObj,judgeConfigObj,examSubject} = judgeUI; + const kfLen = kf.length + + //不报语音的项目列表 + const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',') + switch (event) { + + // 项目开始 + case 1: + const code = projectsObj[xmdm].projectCodeCenter; + const kmCode = getKmProjectVoice(code, 1) + if (!ignoreVoiceCodeArr.includes(code)) { + kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`]) + } + await judgeTask.addTask(async () => { + console.info(judgeTag, `项目开始-${xmdm}-${projectsObj[xmdm].name}`) + await beginProject(xmdm) + // console.info(judgeTag,'上传照片 start') + await uploadProgressPhoto(xmdm) + }) + break; + + // 项目结束 + case 2: + const endCode = projectsObj[xmdm].projectCodeCenter; + const endKmCode = getKmProjectVoice(endCode, 2) + if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) { + endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`]) + } + await judgeTask.addTask(async () => { + console.info(judgeTag, `项目结束-${xmdm}-${projectsObj[xmdm].name}`) + await endProject(xmdm); + //TODO 靠边停车结束 + if(xmdm === 11){ + + } + }) + break; + + // 扣分 + case 3: + //扣分时实时播报语音(0-否+1-是) + if(judgeConfigObj['418'] == '1'){ + avPlayer.playAudio([`voice/${kf[kfLen -1].markcatalog}.mp3`]) + } + await judgeTask.addTask(async () => { + console.info(judgeTag, `项目扣分-${kf[kfLen -1].markcatalog}-${kf[kfLen -1].desc}`) + await pointsDedute(kf[kfLen -1].xmdm, kf[kfLen -1]) + }) + break; + + // 考车状态 + case 4: + break + + // 考试结束 + case 5: + console.info(judgeTag,'考试结束') + clearInterval(globalThis.judgeTimer) + await judgeTask.addTask(async () => { + console.info(judgeTag, '考试结束 start') + await handEndExam() + }) + break + default: + break + } + } // 项目开始接口同步 beginProject = async (ksxm) => { const carInfo = globalThis.carInfo; @@ -332,32 +614,33 @@ export default class Judge { fileLog.setExamJudgeWuxiData(data) console.info(judgeTag, '上传照片 end') } - // 评判语音提示 goJudgeVoice = async (sound: SOUND) => { - const {avPlayer} = this; - const {xmdm,code} = sound; + const {avPlayer,fileLog} = this; + const {xmdm,code,type} = sound; //判断是不是模拟灯光语音 - const isLight = code.slice(0, 3) === '417'; - if (isLight) { + console.info(judgeTag,JSON.stringify(sound)) + if(type == 1){ console.info(judgeTag, '模拟灯光开始播放:' + code) } avPlayer.playAudio([`voice/${code}.mp3`], true, () => { - if (isLight) { + if (type == 1) { console.info(judgeTag, '播放结束:' + code) - setTimeout(() => { - this.wav = 1; + examJudgeSoundEnd({itemno:xmdm,code,type}) + fileLog.setExamJudgeData({ + method: 'examJudgeSoundEnd', + itemno: xmdm, + code, + type, }) } }) - - } - // 处理考试结束 public handEndExam = async (isManual?: Boolean) => { - const {isExam,judgeUI,endExam,handleSEP,avPlayer} = this; - const {judgeConfigObj,totalScore} = judgeUI + const {isExam,judgeUI,endExam,handleSEP,kfArr,avPlayer,judgeTask} = this; + const singlePlay = globalThis.singlePlay + const {judgeConfigObj,totalScore,} = judgeUI if (judgeConfigObj['344'] == 1) { Prompt.showToast({ @@ -367,43 +650,44 @@ export default class Judge { return } + //TODO 科目三考试合格 考官综合评判 + + //TODO 语音播放扣分项 + let score = 0; + if(kfArr.length){ + avPlayer.playAudio([`voice/kfdesc.mp3`]) + kfArr.forEach(kf => { + score += Math.abs(Number(kf.score)); + if(score <= 100){ + judgeTask.addTask(()=>{ + avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`]) + }) + } + }) + } await handleSEP(306); - avPlayer.playAudio(['voice/exam_waiting.mp3'], true) - this.isEnd = true - try { - const bytes = await this.getMessageHeartbeat(true); - const singlePlay = globalThis.singlePlay - singlePlay || globalThis.judgeUdp.send(bytes) - //结束评判函数 - await examJudgeEndExam(); - globalThis.isJudge = false - await endExam(isManual) - - } catch (e) { - setTimeout(() => { - router.back(); - }, 3000) - } - - } - - // 当前项目转换 - getDqxmStr = (type) => { - const projectsObj = this.judgeUI.projectsObj - return projectsObj[type]?.abbreviation || '通用评判' - } - - // 扣分项目转换 - getKfStr = (code) => { - const markRuleListObj = this.judgeUI.markRuleListObj; - const thisMark = markRuleListObj[code] - return { - desc: thisMark.markshow, - score: thisMark.markreal, - markcatalog: thisMark.markcatalog, - markserial: thisMark.markserial, - kfxh: thisMark.kfxh - } + judgeTask.addTask(()=>{ + avPlayer.playAudio(['voice/exam_waiting.mp3'],false,async ()=>{ + this.isEnd = true + try { + if(!singlePlay){ + const bytes = await this.getMessageHeartbeat(true); + globalThis.judgeUdp.send(bytes) + } + //结束评判函数 + await examJudgeEndExam(); + globalThis.isJudge = false + //TODO endExam函数逻辑待验证 + !singlePlay && await endExam(isManual) + router.back(); + } catch (e) { + // setTimeout(() => { + // // avPlayer.avPlayerStop(); + // router.back(); + // }, 3000) + } + }) + }) } // 考试结束 @@ -436,74 +720,48 @@ export default class Judge { promptWxCode('17C56', code) console.info(judgeTag, '考试结束 end') if (!isManual) { - if (totalScore < 80) { - judgeUI.loadingPopupVisible = true - if (kssycs == 1) { - avPlayer.playAudio(['voice/unqualified_one.wav'], true) - } else { - avPlayer.playAudio(['voice/unqualified_two.wav'], true) - } + judgeUI.loadingPopupVisible = true; + if (examSubject == 2 && totalScore < 80) { + avPlayer.playAudio([ + `voice/unqualified_${kssycs == 1?'one':'two'}.wav`, + ], true) } else { avPlayer.playAudio(['voice/qualified.mp3'], true) } + + if (examSubject == 3 && totalScore < 90) { + avPlayer.playAudio([ + `voice/${kssycs == 1?'exam_no_pass':'exam_no_pass_finish'}.mp3`, + ], true) + } else { + avPlayer.playAudio(['voice/exam_pass.mp3'], true) + } } console.info(judgeTag, `考试成绩:${totalScore}`) - fileLog.setExamJudgeWuxiData(data) + // fileLog.setExamJudgeWuxiData(data) await uploadProgressData(); setTimeout(() => { router.back(); }, 3000) } - - // 获取评判初始化数据 - getJudgeInitData = async () => { - const {getModelData,getKm3JudgeInitConfig} = this - const carInfo = globalThis.carInfo; - const { examSubject,plateNo,carId } = carInfo; - const {fileLog} = this - const judgeUI = this.judgeUI - const {projectsObj,cdsbInfoObj,markRuleListObj,carType,carName} = judgeUI - - const examType = examSubject == 2 ? 'km2' : 'km3' - - let allitems = []; - - if (examSubject == 2) { - allitems = Reflect.ownKeys(cdsbInfoObj).map(cdsbKey => { - const cdsb = cdsbInfoObj[cdsbKey]; - const {xmdm,xmxh,modelKey} = cdsb - return { - xmdm, xmxh, model: getModelData(`${examType}/${modelKey}.txt`) - } - }) - } - const initInfo = { - kskm: examSubject * 1, - kchp: plateNo, - kchm: carId * 1, - kscx: carType, - cxcode: '1', - name: carName, - carmodel: getModelData(`${examType}/${carType}.txt`), - allitems, - mark: Reflect.ownKeys(markRuleListObj).map(ruleKey => (markRuleListObj[ruleKey])) || testMarkRules, - sysset: judgeUI.judgeConfig, - }; - - let km3Config = {} - - if (examSubject) { - km3Config = await getKm3JudgeInitConfig(); - } - // 获取科目三的评判配置 - console.info(judgeTag, '3.获取评判初始化数据完成') + // 当前项目转换 + getDqxmStr = (type) => { + const projectsObj = this.judgeUI.projectsObj + return projectsObj[type]?.abbreviation || '通用评判' + } + // 扣分项目转换 + getKfStr = (code) => { + const markRuleListObj = this.judgeUI.markRuleListObj; + const thisMark = markRuleListObj[code] return { - ...initInfo, - ...km3Config, + desc: thisMark.markshow, + score: thisMark.markreal, + markcatalog: thisMark.markcatalog, + markserial: thisMark.markserial, + kfxh: thisMark.kfxh } } - // 消息心跳发送 getMessageHeartbeat = async (isEnd?: Boolean) => { const carInfo = globalThis.carInfo; @@ -603,66 +861,6 @@ export default class Judge { this.serialIndex += 1; return Array2Byte(tempArr) } - - // 获取开始考试数据 - getJudgeBeginData = async () => { - console.log('globalThis.carInfo.wayno',globalThis.carInfo.wayno) - const {code,name:examinerName} = globalThis.examinerInfo; - const {isExam,isTrajectoryOpen} = this; - const judgeUI = this.judgeUI - const {projects,carType,isDdxk,ddxkTime,projectsCenterObj,ddxkKsxmArr,ddxkKfArr} = judgeUI; - const beginInfo = { - kgid: '012', - kgxm: decodeURI(examinerName || ''), - exam: isExam ? 1 : 0, - //是否回放 - replay: 0, - //生成的轨迹文件 - track: '', - xm: judgeUI.name, - sex: 0, - kslsh: judgeUI.lsh, - sfzmhm: judgeUI.idCard, - ksyy: '', - kscx: carType, - kkcs: 1, - sfyk: 0, - ykkkcs: 1, - wayno: Number(globalThis.carInfo.wayno)|| 0, - czlx: 0, - kskssj: await systemTime.getCurrentTime(), - ksxm: projects.map(project => { - return { - xmdm: project.projectCode * 1, - xmxh: '', - } - }), - //断点续考 - ddxk: isDdxk ? 1 : 0, - ddkssj: ddxkTime, - ykxm: isDdxk ? (ddxkKsxmArr?.map(projectCenterCode => (projectsCenterObj[projectCenterCode]?.projectCode) * 1)) : [], - kfxm: isDdxk ? (ddxkKfArr?.map(kf => { - const [xmdm, kfdm] = kf.split(',') - return { - xmdm: xmdm * 1, - kfdm - } - })) : [], - yklc: 0, - special: [], - //TODO 科目三参数临时写死 - sczb: 0, - sczbkf: [], - dmndg: false, - nitem1: false, - nitem41: false, - mfxx: false, - mfxxn: false - } - console.info(judgeTag, '5.获取开始考试数据完成') - return beginInfo - } - //获取场地序号 getSbxh = (ksxm, xmxh) => { const {judgeUI} = this; @@ -690,7 +888,6 @@ export default class Judge { const sbxh = currentCdsb.sbbm || '00000000' return sbxh } - // 中心所有项目转换 getTranslateProject = () => { // const {testKmItems} = this; @@ -713,13 +910,11 @@ export default class Judge { } return arr.map(numStr => parseInt(numStr, 2)); } - // 获取考试项目详情 getProjectInfo = (projectCode) => { const judgeUI = this.judgeUI; return judgeUI.projectsObj[projectCode] } - // 获取模型数据 getModelData = (modelName) => { const modelPath = this.modelPath @@ -740,19 +935,16 @@ export default class Judge { return photoBase64 } } - //人工进入项目 - public setJudgeItem = async (itemno) => { - const {fileLog} = this - await examJudgeArtificialItem(itemno * 1); - + //人工操作项目 + public setJudgeItem = async (itemno,type:1|2) => { + const {fileLog} = this; + await examJudgeArtificialItem(itemno * 1,type); await fileLog.setExamJudgeData({ method: 'examJudgeArtificialItem', itemno: itemno * 1, - type: 1 + type }) - - console.info(judgeTag, `人工评判进入项目-${itemno}`) - + console.info(judgeTag, `人工评判${type == 1?'进入':'取消'}项目-${itemno}`) } //人工扣分 public setJudgeMark = async (itemno, serial) => { @@ -818,11 +1010,10 @@ export default class Judge { //获取科目三的评判初始化配置 getKm3JudgeInitConfig = async () => { const {judgeUI,getModelData} = this; - const {carinfoArrr,mapPointArr,mapPointItemArr,systemparmArr} = judgeUI; + const {carinfoArrr,mapPointArr,mapPointItemArr} = judgeUI; return { carinfo: carinfoArrr, map_point: mapPointArr, - systemparm: systemparmArr, map_point_item: mapPointItemArr, //科目三暂时为空 iteminfo: [], @@ -833,7 +1024,7 @@ export default class Judge { // 处理udp plc信号 handleUdp = async (msg) => { console.info('plc信号', msg) - const {fileLog,getPlcData} = this + const {fileLog,getPlcData,usbService} = this const stachArr = msg.split(',') const {isEnd} = this; if (stachArr[0] != '#DN_GD' || isEnd) { @@ -842,6 +1033,11 @@ export default class Judge { const plcData = await getPlcData(msg); // 4.过程数据 await fileLog.setExamJudgeData(plcData) + //检测到有无锡所设备接入,需要发送特定的数据,供检测 + if (usbService.isWXUSBDevice) { + const str = await senorToWXDataStr(msg); + usbService.sendUSB(str) + } await examJudgeRealExam(plcData) const udpIndex = globalThis.udpIndex; if (udpIndex % 5 === 0) { @@ -866,88 +1062,16 @@ export default class Judge { avPlayer.playAudio(['voice/406001.mp3']) } break; - - } } - public plcStr: string - private judgeUI - // 更改考试状态 - goVoiceAnnounce = async (event, xmdm, kf, xmjs) => { - const {projectsObj,judgeConfigObj} = this.judgeUI; - - const {beginProject,pointsDedute,endProject,avPlayer,uploadProgressPhoto,judgeTask,handEndExam} = this; - const xmhg = xmjs.xmhg - const kfLen = kf.length - - //不报语音的项目列表 - const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',') - switch (event) { - - // 项目开始 - case 1: - const code = projectsObj[xmdm].projectCodeCenter; - const kmCode = getKmProjectVoice(code, 1) - if (!ignoreVoiceCodeArr.includes(code)) { - kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`]) - } - await judgeTask.addTask(async () => { - console.info(judgeTag, `项目开始-${xmdm}-${projectsObj[xmdm].name}`) - await beginProject(xmdm) - // console.info(judgeTag,'上传照片 start') - await uploadProgressPhoto(xmdm) - }) - break; - - // 项目结束 - case 2: - const endCode = projectsObj[xmdm].projectCodeCenter; - const endKmCode = getKmProjectVoice(endCode, 2) - if (!ignoreVoiceCodeArr.includes(endCode)) { - endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`]) - } - await judgeTask.addTask(async () => { - console.info(judgeTag, `项目结束-${xmdm}-${projectsObj[xmdm].name}`) - await endProject(xmdm) - }) - break; - - // 扣分 - case 3: - avPlayer.playAudio([`voice/${kf[kfLen -1].markcatalog}.mp3`]) - await judgeTask.addTask(async () => { - console.info(judgeTag, `项目扣分-${kf[kfLen -1].markcatalog}-${kf[kfLen -1].desc}`) - await pointsDedute(kf[kfLen -1].xmdm, kf[kfLen -1]) - }) - break; - - // 考车状态 - case 4: - break - - // 考试结束 - case 5: - clearInterval(globalThis.judgeTimer) - await judgeTask.addTask(async () => { - console.info(judgeTag, '考试结束 start') - await handEndExam() - }) - break - default: - break - } - } - // 获取plc数据 getPlcData = async (plc: string) => { - const {fileLog,mndgStr,rmndg,wav} = this; + const {fileLog,mndgStr,rmndg} = this; await fileLog.setPlcProgressData(plc) //plc字符串转化成评判初始化数据 const tempData = await plcStrToJson(plc); //模拟灯光回放时刻 tempData.sensor.rmndg = rmndg; - //模拟灯光单个灯光结束时刻 - tempData.sensor.wav = wav; //模拟灯灯光灯光项目 tempData.sensor.mndg = mndgStr; //plc字符串转化成无锡所过程数据 @@ -958,17 +1082,14 @@ export default class Judge { this.plcStr = plc; this.mndgStr = ''; this.rmndg = 0; - this.wav = 0; globalThis.msgStr = plc return tempData } // 处理轨迹plc信号 handleTrajectoryUdp = async (strArr) => { - const {fileLog} = this; - console.log('kkkkk') + const {fileLog,setJudgeItem,setJudgeMark,endExam} = this; let num = 2; - const {usbService} = this; const judgeTimer = setInterval(async () => { const msg = JSON.parse(strArr[num]); await fileLog.setExamJudgeData(msg) @@ -983,118 +1104,52 @@ export default class Judge { this.tempData = msg this.plcData = msg globalThis.msgStr = '' - const str = await senorToWXDataStr(msg); - //检测到有无锡所设备接入,需要发送特定的数据,供检测 - if (usbService.isWXUSBDevice) { - usbService.sendUSB(str) + if(msg.method === 'examJudgeArtificialItem'){ + setJudgeItem(msg.itemno,msg.type) + } + if(msg.method === 'examJudgeArtificialMark'){ + setJudgeItem(msg.itemno,msg.serial) } await examJudgeRealExam(msg) num++ - }, 200) + }, 100) globalThis.judgeTimer = judgeTimer; } - //处理评判过程回调 - handleRealExam = async (strData, callBack) => { - // console.log('过程数据:' + strData); - let examData: EXAMDATA = JSON.parse(strData); - const {getDqxmStr,getKfStr,goJudgeVoice,setMndg,judgeUI} = this; - const {carzt,xmks,kf,event,xmjs,ksjs,sound,mndg} = examData - - //获取项目结束、项目开始代码 - const xmdm = event == 2 ? xmjs.xmdm : xmks.xmdm - const xmxh = event == 2 ? xmjs.xmxh : xmks.xmxh; - - switch (event) { - //项目开始 - case 1: - judgeUI.projectsObj[xmdm].type = '2'; - const xmmcStr = judgeUI.projectsObj[xmdm].name; - const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; - const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; - this.testKmItems[xmmcCode].status = 2; - this.xmmcStr = xmmcStr; - this.xmmcCode = xmmcCode; - this.xmmcSingleCode = xmmcSingleCode - this.xmdm = xmdm; - this.xmxh = xmxh; - - break; - - //项目结束 - case 2: - judgeUI.projectsObj[xmdm].type = (xmjs.xmhg === 0 ? '4' : '3'); - this.xmmcStr = '无'; - this.xmmcCode = ''; - this.xmmcSingleCode = 0; - this.xmdm = ''; - break; - - //扣分 - case 3: - const thisKf = getKfStr(`${kf.xmdm}_${kf.kfdm}`) - //扣分信息 - this.kfArr.push({ - //扣分项目名称 - xmmcStr: getDqxmStr(kf.xmdm), - xmdm: kf.xmdm, - //扣分描述 - desc: thisKf.desc, - //扣分分数 - score: thisKf.score, - // 扣分无锡所代码 - markcatalog: thisKf.markcatalog, - markserial: thisKf.markserial, - kfxh: thisKf.kfxh - }) - this.judgeUI.totalScore += thisKf.score * 1; - break; - - //考车状态 - case 4: - this.carztStr = getCarStatus(carzt); - break; - - //考试结束 - case 5: - this.ksjs = ksjs; - break; - - //项目取消 - case 6: - break; - - //语音播放和提示 - case 7: - goJudgeVoice(sound) - break; - - //模拟灯光事件 - case 8: - setMndg(mndg) - break; - - default: - ;break; - - } - - const {xmmcStr,carztStr,kfArr} = this; - - await callBack({ - //项目名称 考车状态 扣分arr - xmmcStr, carztStr, kfArr - }); - - //语音播报 - this.goVoiceAnnounce(event, xmdm, this.kfArr, xmjs) - - //更新UI - if (event == 1 || event == 2 || event == 3) { - const copyProjectsObj = this.judgeUI.projectsObj; - judgeUI.projectsObj = deepClone(copyProjectsObj) + // 统计必考项目数量 + setCountItems = async () => { + const carInfo = globalThis.carInfo; + const { examSubject} = carInfo; + const {projectsObj} = this.judgeUI; + if(examSubject == 3){ + //必考项目数量 必考项目已考数量 + let projectNum = 0,endProjectsNum =0; + Reflect.ownKeys(projectsObj).forEach(projectKey=>{ + const {type,isRequired} = projectsObj[projectKey]; + if(isRequired){ + projectNum += 1; + if(type == 3 || type == 4){ + endProjectsNum += 1; + } + } + }) + //必考项目除靠边停车是否全部完成 + this.judgeUI.isRequiredProjectsEnd = (projectNum - endProjectsNum === 0) } } + // 模拟灯光 + setMndg = async (mndgStr: string) => { + this.mndgStr = mndgStr + } + + // 路段信息处理 + setRoadAndLane = async (lane)=>{ + const {road,num,count} = lane; + + } + + public plcStr: string + private judgeUI private fileLog private totalScore: number private folderPath: string @@ -1102,13 +1157,7 @@ export default class Judge { private avPlayer private carztStr: string private rmndg: 0 | 1 - private wav: 0 | 1 private mndgStr: string | undefined - // 模拟灯光 - setMndg = async (mndgStr: string) => { - this.mndgStr = mndgStr - this.rmndg = 1; - } private xmmcStr: string private xmmcCode: string private xmmcSingleCode: number @@ -1159,5 +1208,6 @@ export default class Judge { private isTrajectoryOpen: boolean; // 调代理接口是否断网了 private isJudgeDisConnect: boolean; + private artSubject3ProjectsCodesArr:number[] = [3, 9, 4, 10, 12, 11] } \ No newline at end of file diff --git a/entry/src/main/ets/pages/judgeSDK/utils/file-photo.ts b/entry/src/main/ets/pages/judgeSDK/utils/file-photo.ts deleted file mode 100644 index 2cfbba54..00000000 --- a/entry/src/main/ets/pages/judgeSDK/utils/file-photo.ts +++ /dev/null @@ -1,36 +0,0 @@ -import mediaLibrary from '@ohos.multimedia.mediaLibrary' -import onvifclient from '@ohos.onvifclient'; -import fs from '@ohos.file.fs' -import util from '@ohos.util'; -import FileUtil from '../../../common/utils/File' - -interface Params{ - userName:string - pwd:string - ip:string - port:string - rlls:string -} - -export default class FilePhoto{ - - private params:Params - private context:any - private fileUtil:FileUtil - public mediaTest - - constructor(context) { - (async ()=>{ - const fileUtil = new FileUtil(context) - const strConfig = await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/local/files/logs/config/config3.txt'); - const config = JSON.parse(strConfig) - const {userName,ip,pwd,port,rlls} = config - this.params = {userName,pwd,ip,port,rlls} - this.context = context - this.fileUtil = fileUtil - })() - } - - public async getPhoto(){ - } -} \ No newline at end of file