1155 lines
34 KiB
TypeScript
Raw Normal View History

2024-01-05 11:11:15 +08:00
import systemTime from '@ohos.systemDateTime';
import router from '@ohos.router';
import util from '@ohos.util';
import buffer from '@ohos.buffer';
2024-05-15 16:22:48 +08:00
2024-07-02 10:42:53 +08:00
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 FileUtil from '../../common/utils/File';
import FileLog from '../judgeSDK/utils/file-log';
import JudgeTask from './utils/judge-task';
import SimulateLights from './utils/simulate-lights';
import { judgeConfig } from './utils/judge-config';
import { uploadExamProgressData, writeObjectOut } from '../../api/judge';
2024-07-02 10:14:38 +08:00
import {
2024-07-02 10:42:53 +08:00
Array2Byte,
convertGpsCoord2,
deepClone,
fillZero,
getCurrentTime,
string2Bytes,
stringToASC
} from '../../common/utils/tools';
import {
getCarStatus,
getCarStatusType,
getCenterProjectStatus,
getKmProjectVoice,
getTranslateSignals,
plcStrToJson,
plcStrToWXJson,
promptWxCode,
senorToWXDataStr
} from './utils/judge-common';
import {
examJudgeArtificialItem,
examJudgeArtificialMark,
2024-07-02 10:14:38 +08:00
examJudgeBeginExam,
2024-07-02 10:42:53 +08:00
examJudgeEndExam,
2024-07-02 10:14:38 +08:00
examJudgeInit,
2024-07-02 10:42:53 +08:00
examJudgeMapSetParam,
examJudgeMapSetScaling,
2024-07-02 10:14:38 +08:00
examJudgeRealExam,
2024-07-02 10:42:53 +08:00
examJudgeSetLogCallback,
2024-07-02 10:14:38 +08:00
examJudgeSetPerformCallback,
2024-07-02 10:42:53 +08:00
examJudgeSetRealExamCallback
} from './api/index';
import UsbService from '../../common/service/usbService';
2024-07-02 10:26:42 +08:00
import Prompt from '@system.prompt';
2024-01-05 11:11:15 +08:00
2024-07-02 10:42:53 +08:00
const judgeTag = 'SURENJUN_JUDGE'
2024-05-15 16:22:48 +08:00
2024-07-02 10:42:53 +08:00
export default class Judge {
// 过程照片拍照
getPhoto = async (empty?: boolean) => {
const singlePlay = globalThis.singlePlay
//单机模式返回空照片
if (singlePlay) {
return ''
} else {
const {filePhoto} = this;
const photoBase64 = await filePhoto.getPhoto();
console.info(judgeTag, '拍照完成')
return photoBase64
}
}
//人工进入项目
public setJudgeItem = async (itemno) => {
const {fileLog} = this
await examJudgeArtificialItem(itemno * 1);
2024-02-21 14:53:53 +08:00
2024-07-02 10:42:53 +08:00
await fileLog.setExamJudgeData({
method: 'examJudgeArtificialItem',
itemno: itemno * 1,
type: 1
})
2024-02-21 14:53:53 +08:00
2024-07-02 10:42:53 +08:00
console.info(judgeTag, `人工评判进入项目-${itemno}`)
2024-01-05 11:11:15 +08:00
}
2024-07-02 10:42:53 +08:00
//人工扣分
public setJudgeMark = async (itemno, serial) => {
const {fileLog} = this
await examJudgeArtificialMark(itemno * 1, serial);
2024-01-05 11:11:15 +08:00
2024-07-02 10:42:53 +08:00
await fileLog.setExamJudgeData({
method: 'examJudgeArtificialMark',
itemno: itemno * 1,
serial
})
2024-05-15 16:22:48 +08:00
2024-07-02 10:42:53 +08:00
console.info(judgeTag, `人工扣分-${itemno}-${serial}`)
}
// 断网数据补传
uploadDisConnectData = async () => {
const {isJudgeDisConnect,fileLog,fileUtil} = this;
if (!isJudgeDisConnect) {
return
2024-01-05 11:11:15 +08:00
}
2024-07-02 10:42:53 +08:00
const folderPath = fileLog.folderPath
const examDataStr = await fileUtil.readFile(`${folderPath}/wuxi_dis_progress_data.txt`);
const examDataArr = examDataStr.split('\n');
for (let examDataStr of examDataArr) {
const examData = JSON.parse(examDataStr)
const code = await writeObjectOut(examData);
}
}
//上传无锡所过程数据
uploadProgressData = async () => {
const {judgeUI,fileUtil,fileLog} = this;
const {idCard,startFullTime} = judgeUI
const carInfo = globalThis.carInfo;
const {carId,examinationRoomId} = carInfo
const folderPath = fileLog.folderPath
const base64 = new util.Base64();
const time = await getCurrentTime();
const endTime = await getCurrentTime(1)
let examDataBase64
//@ts-ignore
//TODO try catch报错待优化
const examDataStr: string = await fileUtil.readFile(`${folderPath}/wuxi_progress_data.txt`);
try {
let tempBuff = buffer.alloc(examDataStr.length, examDataStr)
let examData: Uint8Array = new Uint8Array(tempBuff.buffer)
examDataBase64 = base64.encodeToStringSync(examData)
} catch (e) {
console.info(judgeTag, JSON.stringify(e))
}
console.info(judgeTag, '过程数据文件上传 start')
await uploadExamProgressData({
time,
carId,
examinationRoomId,
examData: examDataBase64,
type: 1,
cardNo: idCard,
examStartTime: startFullTime,
examEndTime: endTime,
2024-01-05 11:11:15 +08:00
})
2024-07-02 10:42:53 +08:00
console.info(judgeTag, '过程数据文件上传 end')
}
//获取科目三的评判初始化配置
getKm3JudgeInitConfig = async () => {
const {judgeUI,getModelData} = this;
const {carinfoArrr,mapPointArr,mapPointItemArr,systemparmArr} = judgeUI;
return {
carinfo: carinfoArrr,
map_point: mapPointArr,
systemparm: systemparmArr,
map_point_item: mapPointItemArr,
//科目三暂时为空
iteminfo: [],
roads: getModelData('km3/Roads.txt'),
sharps: getModelData('km3/Sharps.txt')
}
}
// 处理udp plc信号
handleUdp = async (msg) => {
console.info('plc信号', msg)
const {fileLog,getPlcData} = this
const stachArr = msg.split(',')
const {isEnd} = this;
if (stachArr[0] != '#DN_GD' || isEnd) {
return
}
const plcData = await getPlcData(msg);
// 4.过程数据
await fileLog.setExamJudgeData(plcData)
await examJudgeRealExam(plcData)
const udpIndex = globalThis.udpIndex;
if (udpIndex % 5 === 0) {
const judgeUdp = globalThis.judgeUdp
const bytes = await this.getMessageHeartbeat();
judgeUdp.send(bytes)
}
globalThis.udpIndex += 1
}
// 处理特殊参数配置
handleSEP = async (code: number) => {
const {judgeUI:{
judgeConfigObj
},avPlayer} = this;
const {examSubject} = globalThis.carInfo;
2024-01-31 14:42:14 +08:00
2024-07-02 10:42:53 +08:00
switch (code) {
//结束考试方式
case 306:
if (judgeConfigObj[code] == 5) {
//靠边停车
avPlayer.playAudio(['voice/406001.mp3'])
}
break;
2024-01-05 11:11:15 +08:00
2024-02-21 14:53:53 +08:00
2024-01-05 11:11:15 +08:00
}
2024-07-02 10:42:53 +08:00
}
public plcStr: string
private judgeUI
// 更改考试状态
goVoiceAnnounce = async (event, xmdm, kf, xmjs) => {
const {projectsObj,judgeConfigObj} = this.judgeUI;
2024-01-31 14:42:14 +08:00
2024-07-02 10:42:53 +08:00
const {beginProject,pointsDedute,endProject,avPlayer,uploadProgressPhoto,judgeTask,handEndExam} = this;
const xmhg = xmjs.xmhg
const kfLen = kf.length
2024-01-05 11:11:15 +08:00
2024-07-02 10:42:53 +08:00
//不报语音的项目列表
const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',')
switch (event) {
2024-05-15 16:22:48 +08:00
2024-07-02 10:42:53 +08:00
// 项目开始
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;
2024-01-05 11:11:15 +08:00
2024-07-02 10:42:53 +08:00
// 项目结束
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;
2024-07-02 10:02:22 +08:00
2024-07-02 10:42:53 +08:00
// 扣分
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;
2024-07-02 10:02:22 +08:00
2024-07-02 10:42:53 +08:00
// 考车状态
case 4:
break
2024-07-02 10:02:22 +08:00
2024-07-02 10:42:53 +08:00
// 考试结束
case 5:
clearInterval(globalThis.judgeTimer)
await judgeTask.addTask(async () => {
console.info(judgeTag, '考试结束 start')
await handEndExam()
})
break
default:
break
2024-01-05 11:11:15 +08:00
}
}
2024-07-02 10:42:53 +08:00
private fileLog
private totalScore: number
private folderPath: string
private modelPath: string
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
private xmdm: string | number
private xmxh: string
private fileModel: FileModel
private filePhoto: FilePhoto
private usbService: UsbService
//是否是考试模式
private isExam: boolean
//考试是否结束了
private isEnd: boolean
//UDP服务序列号
private serialIndex: number
private fileUtil: FileUtil
private judgeTask: JudgeTask
private tempData: any
private performInfo: any
private ksjs: {
// 累计前进距离
qjjl: number,
// 累计倒车距离
dcjl: number
}
private kfArr: {
//项目名称
xmmcStr: string,
xmdm: string | number,
//扣分描述
desc: string,
//扣分
score: string
//无锡所扣分代码
markcatalog: string
markserial: string
kfxh: string
}[]
private plcData: any
// 获取plc数据
getPlcData = async (plc: string) => {
const {fileLog,mndgStr,rmndg,wav} = this;
await fileLog.setPlcProgressData(plc)
//plc字符串转化成评判初始化数据
const tempData = await plcStrToJson(plc);
//模拟灯光回放时刻
tempData.sensor.rmndg = rmndg;
//模拟灯光单个灯光结束时刻
tempData.sensor.wav = wav;
//模拟灯灯光灯光项目
tempData.sensor.mndg = mndgStr;
//plc字符串转化成无锡所过程数据
const wuXiDataStr = await plcStrToWXJson(plc)
this.plcData = tempData
await fileLog.setExamJudgeWuxiProgressData(wuXiDataStr)
this.tempData = tempData
this.plcStr = plc;
this.mndgStr = '';
this.rmndg = 0;
this.wav = 0;
globalThis.msgStr = plc
2024-01-05 11:11:15 +08:00
2024-07-02 10:42:53 +08:00
return tempData
}
// 处理轨迹plc信号
handleTrajectoryUdp = async (strArr) => {
const {fileLog} = this;
let num = 2;
const {usbService} = this;
const judgeTimer = setInterval(async () => {
const msg = JSON.parse(strArr[num]);
await fileLog.setExamJudgeData(msg)
if (!msg) {
console.info(judgeTag, '模拟数据考试结束')
examJudgeEndExam();
globalThis.windowClass.setWindowSystemBarEnable(['navigation'])
clearInterval(judgeTimer)
return
}
// 4.过程数据
this.tempData = msg
this.plcData = msg
globalThis.msgStr = ''
const str = await senorToWXDataStr(msg);
//检测到有无锡所设备接入,需要发送特定的数据,供检测
if (usbService.isWXUSBDevice) {
usbService.sendUSB(str)
}
await examJudgeRealExam(msg)
num++
}, 200)
globalThis.judgeTimer = judgeTimer;
2024-01-05 11:11:15 +08:00
}
2024-07-02 10:42:53 +08:00
private km2ItemsStatus: any[]
//所有的科目考试项目(大车&小车)
private testKmItems: any
2024-01-05 11:11:15 +08:00
//处理评判过程回调
2024-07-02 10:42:53 +08:00
handleRealExam = async (strData, callBack) => {
2024-01-05 11:11:15 +08:00
// console.log('过程数据:' + strData);
2024-07-02 10:42:53 +08:00
let examData: EXAMDATA = JSON.parse(strData);
2024-05-15 16:22:48 +08:00
const {getDqxmStr,getKfStr,goJudgeVoice,setMndg,judgeUI} = this;
const {carzt,xmks,kf,event,xmjs,ksjs,sound,mndg} = examData
2024-01-31 14:35:16 +08:00
2024-01-05 11:11:15 +08:00
//获取项目结束、项目开始代码
2024-01-31 14:35:16 +08:00
const xmdm = event == 2 ? xmjs.xmdm : xmks.xmdm
const xmxh = event == 2 ? xmjs.xmxh : xmks.xmxh;
2024-01-05 11:11:15 +08:00
2024-07-02 10:42:53 +08:00
switch (event) {
2024-01-05 11:11:15 +08:00
//项目开始
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;
2024-05-15 16:22:48 +08:00
this.testKmItems[xmmcCode].status = 2;
2024-01-05 11:11:15 +08:00
this.xmmcStr = xmmcStr;
this.xmmcCode = xmmcCode;
this.xmmcSingleCode = xmmcSingleCode
this.xmdm = xmdm;
2024-01-31 14:35:16 +08:00
this.xmxh = xmxh;
2024-05-15 16:22:48 +08:00
2024-01-05 11:11:15 +08:00
break;
//项目结束
case 2:
2024-01-31 14:35:16 +08:00
judgeUI.projectsObj[xmdm].type = (xmjs.xmhg === 0 ? '4' : '3');
2024-01-05 11:11:15 +08:00
this.xmmcStr = '无';
this.xmmcCode = '';
this.xmmcSingleCode = 0;
this.xmdm = '';
break;
//扣分
case 3:
const thisKf = getKfStr(`${kf.xmdm}_${kf.kfdm}`)
2024-07-02 10:42:53 +08:00
//扣分信息
2024-01-05 11:11:15 +08:00
this.kfArr.push({
//扣分项目名称
2024-07-02 10:42:53 +08:00
xmmcStr: getDqxmStr(kf.xmdm),
xmdm: kf.xmdm,
2024-01-05 11:11:15 +08:00
//扣分描述
2024-07-02 10:42:53 +08:00
desc: thisKf.desc,
2024-01-05 11:11:15 +08:00
//扣分分数
2024-07-02 10:42:53 +08:00
score: thisKf.score,
2024-01-05 11:11:15 +08:00
// 扣分无锡所代码
2024-07-02 10:42:53 +08:00
markcatalog: thisKf.markcatalog,
markserial: thisKf.markserial,
kfxh: thisKf.kfxh
2024-01-05 11:11:15 +08:00
})
2024-07-02 10:42:53 +08:00
this.judgeUI.totalScore += thisKf.score * 1;
2024-01-05 11:11:15 +08:00
break;
//考车状态
2024-07-02 10:42:53 +08:00
case 4:
this.carztStr = getCarStatus(carzt);
break;
2024-01-05 11:11:15 +08:00
//考试结束
2024-07-02 10:42:53 +08:00
case 5:
this.ksjs = ksjs;
break;
2024-05-15 16:22:48 +08:00
//项目取消
2024-07-02 10:42:53 +08:00
case 6:
break;
2024-05-15 16:22:48 +08:00
//语音播放和提示
case 7:
goJudgeVoice(sound)
break;
//模拟灯光事件
case 8:
setMndg(mndg)
2024-07-02 10:42:53 +08:00
break;
2024-05-15 16:22:48 +08:00
2024-07-02 10:42:53 +08:00
default:
;break;
2024-05-15 16:22:48 +08:00
2024-01-05 11:11:15 +08:00
}
2024-05-15 16:22:48 +08:00
2024-01-05 11:11:15 +08:00
const {xmmcStr,carztStr,kfArr} = this;
2024-05-15 16:22:48 +08:00
2024-01-05 11:11:15 +08:00
await callBack({
//项目名称 考车状态 扣分arr
2024-07-02 10:42:53 +08:00
xmmcStr, carztStr, kfArr
2024-01-05 11:11:15 +08:00
});
2024-01-31 14:42:14 +08:00
//语音播报
2024-07-02 10:42:53 +08:00
this.goVoiceAnnounce(event, xmdm, this.kfArr, xmjs)
2024-05-15 16:22:48 +08:00
//更新UI
2024-07-02 10:42:53 +08:00
if (event == 1 || event == 2 || event == 3) {
2024-05-15 16:22:48 +08:00
const copyProjectsObj = this.judgeUI.projectsObj;
judgeUI.projectsObj = deepClone(copyProjectsObj)
}
}
2024-07-02 10:42:53 +08:00
//当前科目二的考试项目
private currentKm2ItemsObj: any
//本地轨迹回放地址
private trajectoryPath: string
private isTrajectoryOpen: boolean;
// 调代理接口是否断网了
private isJudgeDisConnect: boolean;
2024-01-05 11:11:15 +08:00
// 项目开始接口同步
2024-07-02 10:42:53 +08:00
beginProject = async (ksxm) => {
2024-01-05 11:11:15 +08:00
const carInfo = globalThis.carInfo;
const { examSubject,plateNo } = carInfo;
2024-01-31 14:35:16 +08:00
const {judgeUI,fileLog,getSbbm,xmxh} = this;
2024-01-05 11:11:15 +08:00
const {lsh,idCard,serialNumber,projectsObj,ksdd,kslx} = judgeUI
const time = await getCurrentTime();
const project = projectsObj[ksxm]
2024-07-02 10:42:53 +08:00
const sbxh = getSbbm(ksxm, xmxh)
2024-01-05 11:11:15 +08:00
const data = {
2024-02-21 14:53:53 +08:00
//系统类别 接口序列号 接口标识
2024-07-02 10:42:53 +08:00
xtlb: '17', jkxlh: serialNumber, jkid: '17C52',
drvexam: {
2024-02-21 14:53:53 +08:00
// 考试科目 身份证号码
2024-07-02 10:42:53 +08:00
lsh,
kskm: examSubject,
sfzmhm: idCard,
ksxm: project.projectCodeCenter,
sbxh,
kchp: encodeURI(plateNo),
2024-02-21 14:53:53 +08:00
// 开始时间
2024-07-02 10:42:53 +08:00
ksdd: encodeURI(ksdd),
ksxl: encodeURI(kslx) || '',
kssj: time
2024-01-05 11:11:15 +08:00
}
}
const code = await writeObjectOut(data)
2024-05-15 16:22:48 +08:00
// console.info(judgeTag,'项目开始 end')
2024-07-02 10:42:53 +08:00
if (code === 2300007) {
this.isJudgeDisConnect = true;
}
2024-01-31 14:35:16 +08:00
const isJudgeDisConnect = this.isJudgeDisConnect
isJudgeDisConnect ? fileLog.setExamJudgeDisWuxiProgressData(data) : fileLog.setExamJudgeWuxiData(data)
2024-07-02 10:42:53 +08:00
promptWxCode('17C52', code)
2024-01-05 11:11:15 +08:00
}
// 项目结束接口同步
2024-07-02 10:42:53 +08:00
endProject = async (ksxm) => {
2024-01-05 11:11:15 +08:00
const carInfo = globalThis.carInfo;
const deviceNo = globalThis.deviceNo;
const { examSubject,plateNo,carNo } = carInfo;
2024-01-31 14:35:16 +08:00
const {judgeUI,fileLog,getSbxh,xmxh,getSbbm} = this;
2024-01-05 11:11:15 +08:00
const {lsh,idCard,serialNumber,projectsObj,cdsbInfoObj,ksdd,kslx} = judgeUI
const time = await getCurrentTime();
const project = projectsObj[ksxm]
2024-07-02 10:42:53 +08:00
const sbxh = getSbbm(ksxm, xmxh)
2024-01-05 11:11:15 +08:00
const data = {
2024-07-02 10:42:53 +08:00
xtlb: '17', jkxlh: serialNumber, jkid: '17C55',
drvexam: {
lsh,
kskm: examSubject,
sfzmhm: idCard,
ksxm: project.projectCodeCenter,
2024-01-05 11:11:15 +08:00
sbxh,
//操作类型 1:正常 0:撤销该考试记录
2024-07-02 10:42:53 +08:00
czlx: '1',
kchp: encodeURI(plateNo),
ksdd: encodeURI(ksdd),
ksxl: encodeURI(kslx) || '',
jssj: time
2024-01-05 11:11:15 +08:00
}
}
const code = await writeObjectOut(data)
2024-07-02 10:42:53 +08:00
if (code === 2300007) {
this.isJudgeDisConnect = true;
}
2024-01-31 14:35:16 +08:00
const isJudgeDisConnect = this.isJudgeDisConnect
isJudgeDisConnect ? fileLog.setExamJudgeDisWuxiProgressData(data) : fileLog.setExamJudgeWuxiData(data)
2024-05-15 16:22:48 +08:00
// console.info(judgeTag,'项目结束 end')
2024-07-02 10:42:53 +08:00
promptWxCode('17C55', code)
}
// 考试扣分
pointsDedute = async (ksxm, kf) => {
const carInfo = globalThis.carInfo;
const deviceNo = globalThis.deviceNo;
const { examSubject,plateNo,carNo } = carInfo;
const {judgeUI,getProjectInfo,fileLog} = this;
const {lsh,idCard,serialNumber,ksdd} = judgeUI
const time = await getCurrentTime();
const project = getProjectInfo(ksxm);
const data = {
xtlb: '17', jkxlh: serialNumber, jkid: '17C53',
drvexam: {
lsh,
kskm: examSubject,
// 通用评判科二10000科三30000
ksxm: project ? project.projectCodeCenter : 10000,
kfxm: kf.markcatalog,
kfxmmx: `${ksxm},${kf.markserial}`,
sfzmhm: idCard,
kchp: encodeURI(carInfo.plateNo),
//1:自动 2:人工
kffs: 1,
ksdd: encodeURI(ksdd),
kfsj: time
}
}
const code = await writeObjectOut(data);
if (code === 2300007) {
this.isJudgeDisConnect = true
}
const isJudgeDisConnect = this.isJudgeDisConnect
isJudgeDisConnect ? fileLog.setExamJudgeDisWuxiProgressData(data) : fileLog.setExamJudgeWuxiData(data)
console.info(judgeTag, '项目扣分 end')
promptWxCode('17C53', code)
}
// 考试过程照片
uploadProgressPhoto = async (ksxm) => {
const time = await getCurrentTime();
const {judgeUI,plcData,getPhoto,fileLog} = this;
const photoBase64 = await getPhoto();
const carInfo = globalThis.carInfo;
const { examSubject,plateNo,carNo } = carInfo;
const {lsh,idCard,serialNumber,projectsObj,ksdd} = judgeUI;
const {sensor,gps} = plcData
const project = projectsObj[ksxm]
const data = {
xtlb: '17', jkxlh: serialNumber, jkid: '17C54',
drvexam: {
lsh,
kskm: examSubject,
ksxm: project.projectCodeCenter,
sfzmhm: idCard,
kchp: encodeURI(plateNo),
zpsj: time,
//@ts-ignore
zp: encodeURIComponent(photoBase64),
cs: Math.ceil(gps.sd * 1.852),
ksdd: encodeURI(ksdd)
}
};
const code = await writeObjectOut(data);
if (code === 2300007) {
this.isJudgeDisConnect = true
}
promptWxCode('17C54', code)
fileLog.setExamJudgeWuxiData(data)
console.info(judgeTag, '上传照片 end')
}
constructor(judgeUI) {
this.serialIndex = 1;
this.judgeUI = judgeUI
//语音播放工具
this.avPlayer = new VoiceAnnounce();
new SimulateLights(this.avPlayer)
//模型工具
this.fileModel = new FileModel(judgeUI.context);
//文件工具
this.fileUtil = new FileUtil(judgeUI.context)
this.judgeTask = new JudgeTask()
const mediaTest = new FilePhoto(judgeUI.context);
this.usbService = new UsbService();
this.filePhoto = mediaTest
this.kfArr = judgeUI.kfArr
this.xmmcStr = '';
this.xmmcCode = '';
this.carztStr = '';
this.testKmItems = {};
// 考试回放配置
const {isTrajectoryOpen,modelPath,trajectoryPath} = judgeConfig
this.isTrajectoryOpen = isTrajectoryOpen;
this.modelPath = modelPath;
this.trajectoryPath = trajectoryPath;
this.isExam = !globalThis.singlePlay;
const {projectsCenterObj} = judgeUI
//科目三待修改
testKmItems.forEach(item => {
this.testKmItems[item.code] = item;
//考试项目存在
if (projectsCenterObj[item.code]) {
this.testKmItems[item.code] = {
code: item.code, status: 1
}
}
})
this.isEnd = false;
}
public async onJudgeFn(fn: Function) {
await this.judging(fn)
2024-01-05 11:11:15 +08:00
}
2024-07-02 10:42:53 +08:00
// 评判语音提示
goJudgeVoice = async (sound: SOUND) => {
const {avPlayer} = this;
const {xmdm,code} = sound;
//判断是不是模拟灯光语音
const isLight = code.slice(0, 3) === '417';
if (isLight) {
console.info(judgeTag, '模拟灯光开始播放:' + code)
}
avPlayer.playAudio([`voice/${code}.mp3`], true, () => {
if (isLight) {
console.info(judgeTag, '播放结束:' + code)
setTimeout(() => {
this.wav = 1;
})
}
})
}
// 处理考试结束
public handEndExam = async (isManual?: Boolean) => {
const {isExam,judgeUI,endExam,handleSEP,avPlayer} = this;
const {judgeConfigObj,totalScore} = judgeUI
if (judgeConfigObj['344'] == 1) {
Prompt.showToast({
message: '考试未结束,不允许手动退出!',
duration: 4000
});
return
}
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)
2024-01-05 11:11:15 +08:00
}
2024-07-02 10:42:53 +08:00
2024-01-05 11:11:15 +08:00
}
2024-07-02 10:42:53 +08:00
// 当前项目转换
getDqxmStr = (type) => {
const projectsObj = this.judgeUI.projectsObj
return projectsObj[type]?.abbreviation || '通用评判'
}
2024-01-05 11:11:15 +08:00
2024-07-02 10:42:53 +08:00
// 扣分项目转换
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
}
2024-01-05 11:11:15 +08:00
}
// 考试结束
2024-07-02 10:42:53 +08:00
public endExam = async (isManual?: Boolean) => {
2024-01-05 11:11:15 +08:00
const carInfo = globalThis.carInfo;
const deviceNo = globalThis.deviceNo;
const { examSubject ,plateNo} = carInfo;
2024-01-31 14:35:16 +08:00
const {judgeUI,fileLog,ksjs,getPhoto,uploadProgressData,uploadDisConnectData,avPlayer} = this;
const {lsh,idCard,serialNumber,kssycs,totalScore} = judgeUI
await uploadDisConnectData();
2024-01-05 11:11:15 +08:00
const time = await getCurrentTime();
const photoBase64 = await getPhoto();
2024-05-15 16:22:48 +08:00
2024-01-05 11:11:15 +08:00
const data = {
2024-07-02 10:42:53 +08:00
xtlb: '17', jkxlh: serialNumber, jkid: '17C56',
drvexam: {
lsh,
kchp: encodeURI(plateNo),
kskm: examSubject,
sfzmhm: idCard,
2024-01-31 14:35:16 +08:00
//@ts-ignore
2024-07-02 10:42:53 +08:00
zp: encodeURIComponent(photoBase64),
jssj: time,
kscj: (totalScore * 1) > 0 ? totalScore : 0,
kslc: (ksjs?.qjjl + ksjs?.dcjl) || 0,
dwlc: '',
2024-01-05 11:11:15 +08:00
}
}
const code = await writeObjectOut(data);
2024-07-02 10:42:53 +08:00
promptWxCode('17C56', code)
console.info(judgeTag, '考试结束 end')
if (!isManual) {
if (totalScore < 80) {
2024-01-31 14:35:16 +08:00
judgeUI.loadingPopupVisible = true
2024-07-02 10:42:53 +08:00
if (kssycs == 1) {
avPlayer.playAudio(['voice/unqualified_one.wav'], true)
} else {
avPlayer.playAudio(['voice/unqualified_two.wav'], true)
2024-01-31 14:35:16 +08:00
}
2024-07-02 10:42:53 +08:00
} else {
avPlayer.playAudio(['voice/qualified.mp3'], true)
2024-01-31 14:35:16 +08:00
}
}
2024-07-02 10:42:53 +08:00
console.info(judgeTag, `考试成绩:${totalScore}`)
2024-01-05 11:11:15 +08:00
fileLog.setExamJudgeWuxiData(data)
await uploadProgressData();
2024-07-02 10:42:53 +08:00
setTimeout(() => {
2024-01-05 11:11:15 +08:00
router.back();
2024-07-02 10:42:53 +08:00
}, 3000)
2024-05-15 16:22:48 +08:00
2024-01-05 11:11:15 +08:00
}
// 获取评判初始化数据
getJudgeInitData = async () => {
2024-05-15 16:22:48 +08:00
const {getModelData,getKm3JudgeInitConfig} = this
2024-01-05 11:11:15 +08:00
const carInfo = globalThis.carInfo;
2024-05-15 16:22:48 +08:00
const { examSubject,plateNo,carId } = carInfo;
2024-01-05 11:11:15 +08:00
const {fileLog} = this
const judgeUI = this.judgeUI
2024-01-31 14:35:16 +08:00
const {projectsObj,cdsbInfoObj,markRuleListObj,carType,carName} = judgeUI
2024-05-15 16:22:48 +08:00
2024-07-02 10:42:53 +08:00
const examType = examSubject == 2 ? 'km2' : 'km3'
2024-05-15 16:22:48 +08:00
let allitems = [];
2024-07-02 10:42:53 +08:00
if (examSubject == 2) {
allitems = Reflect.ownKeys(cdsbInfoObj).map(cdsbKey => {
2024-05-15 16:22:48 +08:00
const cdsb = cdsbInfoObj[cdsbKey];
const {xmdm,xmxh,modelKey} = cdsb
return {
2024-07-02 10:42:53 +08:00
xmdm, xmxh, model: getModelData(`${examType}/${modelKey}.txt`)
2024-05-15 16:22:48 +08:00
}
})
}
2024-01-05 11:11:15 +08:00
const initInfo = {
2024-07-02 10:42:53 +08:00
kskm: examSubject * 1,
kchp: plateNo,
kchm: carId * 1,
kscx: carType,
cxcode: '1',
name: carName,
carmodel: getModelData(`${examType}/${carType}.txt`),
2024-05-15 16:22:48 +08:00
allitems,
2024-07-02 10:42:53 +08:00
mark: Reflect.ownKeys(markRuleListObj).map(ruleKey => (markRuleListObj[ruleKey])) || testMarkRules,
sysset: judgeUI.judgeConfig,
2024-01-05 11:11:15 +08:00
};
2024-05-15 16:22:48 +08:00
let km3Config = {}
2024-07-02 10:42:53 +08:00
if (examSubject) {
km3Config = await getKm3JudgeInitConfig();
2024-05-15 16:22:48 +08:00
}
// 获取科目三的评判配置
2024-07-02 10:42:53 +08:00
console.info(judgeTag, '3.获取评判初始化数据完成')
2024-05-15 16:22:48 +08:00
return {
...initInfo,
...km3Config,
}
}
2024-01-31 14:35:16 +08:00
// 消息心跳发送
2024-07-02 10:42:53 +08:00
getMessageHeartbeat = async (isEnd?: Boolean) => {
2024-06-27 20:53:36 +08:00
console.log('kkkkkkmmm')
2024-01-31 14:35:16 +08:00
const carInfo = globalThis.carInfo;
const { examSubject,plateNo,ksyh } = carInfo;
2024-06-27 20:53:36 +08:00
// const ksyh='0000000000000'
// const ksyh=globalThis.ksyh ||'0000000000000'
2024-07-02 10:42:53 +08:00
const {
judgeUI,
isExam,
serialIndex,
tempData,
xmmcCode,
xmxh,
xmmcSingleCode,
xmdm,
performInfo,
kfArr,
getTranslateProject,
getSbxh
} = this;
2024-01-31 14:35:16 +08:00
const {lsh,startHourTime,totalScore} = judgeUI;
2024-07-02 10:42:53 +08:00
const examType = isExam ? examSubject : 0;
2024-01-31 14:35:16 +08:00
const {sensor,gps} = tempData;
const {zfxd,yfxd,shtd,ygd,jgd,skd,dh1,dh2,lhq,jsc,ssc,fsc,lb,mkg,aqd,ygq,cs,fdjzs} = sensor
const {jd,wd, hxj, fyj, hbg,} = gps
const translateProject = getTranslateProject();
2024-07-02 10:42:53 +08:00
const sbxh = getSbxh(xmdm, xmxh)
console.log('sbxhsbxh', sbxh)
2024-05-15 16:22:48 +08:00
const {carzt,dcjl,qjjl,dxjl,bxjl} = performInfo;
2024-07-02 10:42:53 +08:00
console.log('performInfo', JSON.stringify(performInfo))
2024-06-27 20:53:36 +08:00
// const asclshArr = stringToASC(lsh);
const asclshArr = stringToASC(fillZero('0000000000000' || 0, 13));
2024-01-31 14:35:16 +08:00
//13不足要补0
2024-07-02 10:42:53 +08:00
const ascksyhArr = stringToASC(fillZero(ksyh || 0, 13))
2024-01-31 14:35:16 +08:00
const ascsbxhArr = stringToASC(sbxh)
const translateSignals = getTranslateSignals(
2024-07-02 10:42:53 +08:00
[zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, 0, 0, 0, 0].concat(getCarStatusType(carzt)).concat([ygq, sensor.wd, 0])
2024-01-31 14:35:16 +08:00
)
2024-06-27 20:53:36 +08:00
console.log('jinweidu111jdwd0')
2024-01-31 14:35:16 +08:00
//@ts-ignore
2024-07-02 10:42:53 +08:00
const translateJd = convertGpsCoord2(wd).toFixed(7) * Math.pow(10, 7);
2024-01-31 14:35:16 +08:00
//@ts-ignore
2024-06-27 20:53:36 +08:00
const translateWd = convertGpsCoord2(jd).toFixed(7) * Math.pow(10, 7)
console.log('jinweidu111jdwd')
2024-01-31 14:35:16 +08:00
//@ts-ignore
2024-06-27 20:53:36 +08:00
const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0])
2024-01-31 14:35:16 +08:00
//@ts-ignore
2024-06-27 20:53:36 +08:00
// const translateProjects= translateProject.map(num => string2Bytes(p,8)[0])
2024-07-02 10:42:53 +08:00
console.log('jinweidu2222', `${examType}${startHourTime}`)
2024-01-31 14:35:16 +08:00
const arr = [
2024-05-15 16:22:48 +08:00
//考生号 TODO 考试员号
2024-07-02 10:42:53 +08:00
asclshArr.map(lsh => string2Bytes(lsh, 8)[0]),
2024-06-27 20:53:36 +08:00
//考试员号
2024-07-02 10:42:53 +08:00
ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]),
2024-01-31 14:35:16 +08:00
//科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间
2024-07-02 10:42:53 +08:00
string2Bytes(`${examType}${startHourTime}`, 4 * 8),
2024-01-31 14:35:16 +08:00
// TODO 消息序号从1开始0结束
2024-07-02 10:42:53 +08:00
string2Bytes(isEnd ? 0 : serialIndex, 2 * 8),
2024-01-31 14:35:16 +08:00
/*左向灯 右向灯 双跳灯 远光灯 近光灯 视宽灯 点火1 点火2 离合器 脚刹 手刹 副刹 喇叭 门开关 安全带 档位 车辆状态 雨刮器 雾灯 0*/
translateSignals,
//速度 发动机转速 GPS纬度 GPS经度 主天线位置
//@ts-ignore
2024-07-02 10:42:53 +08:00
string2Bytes(cs, 2 * 8), string2Bytes(fdjzs / 60, 8), string2Bytes(translateJd, 4 * 8), string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8),
2024-01-31 14:35:16 +08:00
//GPS东向距离
2024-07-02 10:42:53 +08:00
string2Bytes(dxjl < 0 ? (dxjl + 4294967296) : dxjl, 4 * 8),
2024-01-31 14:35:16 +08:00
//GPS北向距离
2024-07-02 10:42:53 +08:00
string2Bytes(bxjl < 0 ? (bxjl + 4294967296) : bxjl, 4 * 8),
2024-01-31 14:35:16 +08:00
//航向角 俯仰角 高程(海拔)
2024-07-02 10:42:53 +08:00
string2Bytes((hxj + 90) * 100, 2 * 8), string2Bytes(fyj * 100, 2 * 8), string2Bytes(hbg * 100, 4 * 8),
2024-01-31 14:35:16 +08:00
//项目状态 parseInt('01010010',2) 二进制转成10进制
translateProjects,
//当前项目编号
2024-07-02 10:42:53 +08:00
string2Bytes(xmmcSingleCode ? (xmmcSingleCode * 1 + 1) : 0, 8),
2024-01-31 14:35:16 +08:00
//场地设备编号
2024-07-02 10:42:53 +08:00
ascsbxhArr.map(sbxh => string2Bytes(sbxh, 8)[0]),
2024-01-31 14:35:16 +08:00
//本次考试行驶距离
2024-07-02 10:42:53 +08:00
string2Bytes(Math.floor((dcjl + qjjl) / 100), 2 * 8),
2024-01-31 14:35:16 +08:00
//扣分
2024-07-02 10:42:53 +08:00
string2Bytes(100 - Math.abs(totalScore), 2 * 8),
2024-06-27 20:53:36 +08:00
//扣分数
//todo扣分值/扣分项
string2Bytes(0, 2 * 8),
2024-01-31 14:35:16 +08:00
//扣分项数量
2024-07-02 10:42:53 +08:00
string2Bytes(kfArr.length, 8),
2024-01-31 14:35:16 +08:00
//n个扣分序号
2024-06-27 20:53:36 +08:00
2024-07-02 10:42:53 +08:00
kfArr.map(kf => string2Bytes(kf.kfxh, 8)[0])
2024-01-31 14:35:16 +08:00
]
let tempArr = [];
2024-07-02 10:42:53 +08:00
arr.forEach(itemArr => {
tempArr = tempArr.concat(itemArr)
})
2024-01-31 14:35:16 +08:00
this.serialIndex += 1;
return Array2Byte(tempArr)
}
2024-01-05 11:11:15 +08:00
// 获取开始考试数据
getJudgeBeginData = async () => {
const {code,name:examinerName} = globalThis.examinerInfo;
2024-05-15 16:22:48 +08:00
const {isExam,isTrajectoryOpen} = this;
2024-07-02 10:42:53 +08:00
const judgeUI = this.judgeUI
2024-01-31 14:35:16 +08:00
const {projects,carType,isDdxk,ddxkTime,projectsCenterObj,ddxkKsxmArr,ddxkKfArr} = judgeUI;
2024-01-05 11:11:15 +08:00
const beginInfo = {
2024-07-02 10:42:53 +08:00
kgid: '012',
kgxm: decodeURI(examinerName || ''),
exam: isExam ? 1 : 0,
2024-05-15 16:22:48 +08:00
//是否回放
2024-07-02 10:42:53 +08:00
replay: 0,
2024-01-05 11:11:15 +08:00
//生成的轨迹文件
2024-07-02 10:42:53 +08:00
track: '',
xm: judgeUI.name,
sex: 0,
kslsh: judgeUI.lsh,
sfzmhm: judgeUI.idCard,
ksyy: '',
kscx: carType,
kkcs: 1,
sfyk: 0,
ykkkcs: 1,
2024-05-15 16:22:48 +08:00
//TODO 考试路线待修改
2024-07-02 10:42:53 +08:00
wayno: 3,
czlx: 0,
kskssj: await systemTime.getCurrentTime(),
ksxm: projects.map(project => {
2024-01-05 11:11:15 +08:00
return {
2024-07-02 10:42:53 +08:00
xmdm: project.projectCode * 1,
xmxh: '',
2024-01-05 11:11:15 +08:00
}
}),
//断点续考
2024-07-02 10:42:53 +08:00
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(',')
2024-01-31 14:35:16 +08:00
return {
2024-07-02 10:42:53 +08:00
xmdm: xmdm * 1,
2024-01-31 14:35:16 +08:00
kfdm
}
2024-07-02 10:42:53 +08:00
})) : [],
yklc: 0,
special: [],
2024-05-15 16:22:48 +08:00
//TODO 科目三参数临时写死
2024-07-02 10:42:53 +08:00
sczb: 0,
sczbkf: [],
dmndg: false,
nitem1: false,
nitem41: false,
mfxx: false,
mfxxn: false
2024-01-05 11:11:15 +08:00
}
2024-07-02 10:42:53 +08:00
console.info(judgeTag, '5.获取开始考试数据完成')
2024-01-05 11:11:15 +08:00
return beginInfo
}
//获取场地序号
2024-07-02 10:42:53 +08:00
getSbxh = (ksxm, xmxh) => {
2024-01-05 11:11:15 +08:00
const {judgeUI} = this;
const {cdsbInfoObj,projectsObj} = judgeUI;
const project = projectsObj[ksxm]
2024-07-02 10:42:53 +08:00
if (project === undefined) {
2024-06-27 20:53:36 +08:00
return '00000000'
2024-01-05 11:11:15 +08:00
}
const projectType = project.sbxh;
2024-01-31 14:35:16 +08:00
const projectKey = `${ksxm}_${xmxh}`;
2024-01-05 11:11:15 +08:00
const currentCdsb = cdsbInfoObj[projectKey] || {};
2024-06-27 20:53:36 +08:00
const sbxh = currentCdsb.sbbh || '00000000'
2024-01-05 11:11:15 +08:00
return sbxh
}
2024-07-02 10:42:53 +08:00
getSbbm = (ksxm, xmxh) => {
2024-01-05 11:11:15 +08:00
const {judgeUI} = this;
const {cdsbInfoObj,projectsObj} = judgeUI;
const project = projectsObj[ksxm]
2024-07-02 10:42:53 +08:00
if (project === undefined) {
2024-01-05 11:11:15 +08:00
return '00000000'
}
2024-01-31 14:35:16 +08:00
const projectKey = `${ksxm}_${xmxh}`;
2024-01-05 11:11:15 +08:00
const currentCdsb = cdsbInfoObj[projectKey] || {};
const sbxh = currentCdsb.sbbm || '00000000'
return sbxh
}
// 中心所有项目转换
2024-07-02 10:42:53 +08:00
getTranslateProject = () => {
2024-06-27 20:53:36 +08:00
// const {testKmItems} = this;
2024-07-02 10:42:53 +08:00
const tempItems = testKmItems.map(item => {
2024-06-27 20:53:36 +08:00
const current = this.testKmItems[item.code];
2024-01-05 11:11:15 +08:00
return {
2024-07-02 10:42:53 +08:00
code: item.code,
status: getCenterProjectStatus(current.status)
2024-01-05 11:11:15 +08:00
}
})
2024-06-27 20:53:36 +08:00
const len = Math.floor(tempItems.length / 8);
2024-01-05 11:11:15 +08:00
const arr = [];
2024-07-02 10:42:53 +08:00
for (let i = 0; i <= len; i++) {
const temp = tempItems.slice(i * 8, (i + 1) * 8);
2024-01-05 11:11:15 +08:00
let tempArr = temp.map(item => item.status)
2024-07-02 10:42:53 +08:00
if (i === 4) {
tempArr = tempArr.concat(['00', '00'])
2024-01-05 11:11:15 +08:00
}
arr.push(tempArr.join(''));
}
2024-07-02 10:42:53 +08:00
return arr.map(numStr => parseInt(numStr, 2));
2024-01-05 11:11:15 +08:00
}
2024-01-31 14:35:16 +08:00
// 获取考试项目详情
2024-01-05 11:11:15 +08:00
getProjectInfo = (projectCode) => {
const judgeUI = this.judgeUI;
return judgeUI.projectsObj[projectCode]
}
// 获取模型数据
getModelData = (modelName) => {
const modelPath = this.modelPath
const fileModel = this.fileModel;
2024-07-02 10:42:53 +08:00
const modelData = fileModel.getModelContent(modelPath, modelName);
2024-01-05 11:11:15 +08:00
return modelData
}
2024-07-02 10:42:53 +08:00
//开始评判
private async judging(callBack: Function) {
const {judgeUI} = this;
const { name, lsh, idCard} = judgeUI;
const fileLog = new FileLog(judgeUI.context);
const filePath = await fileLog.initFileLogo({
name, lsh, idCard
});
this.fileLog = fileLog;
2024-05-15 16:22:48 +08:00
2024-07-02 10:42:53 +08:00
const {getJudgeBeginData,handleUdp,fileUtil,handleTrajectoryUdp,isTrajectoryOpen,trajectoryPath,avPlayer} = this;
const isJudgeInitBool = globalThis.isJudgeInitBool;
let strArr = [];
if (isTrajectoryOpen) {
const folderPath = await this.fileUtil.initFolder(trajectoryPath);
const str = await fileUtil.readFile(folderPath)
strArr = str.split('\n')
2024-05-15 16:22:48 +08:00
}
2024-07-02 10:42:53 +08:00
//日志回调
console.info(judgeTag, '1.进入评判入口')
await examJudgeSetLogCallback(3, async (level, info, len) => {
console.log('评判日志:' + info)
await fileLog.setExamJudgeLogData(info);
})
console.info(judgeTag, '2.注册日志回调完成')
let initInfo = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData();
//相关评判初始化只做一次
if (!isJudgeInitBool) {
await fileLog.setExamJudgeData(initInfo)
const tempJudge = await examJudgeInit(initInfo);
globalThis.isJudgeInitBool = true
console.info(judgeTag, '4.评判初始化完成')
} else {
await fileLog.setExamJudgeData(initInfo)
2024-05-15 16:22:48 +08:00
}
2024-07-02 10:42:53 +08:00
globalThis.isJudge = true
// 2.评判过程回调
await examJudgeSetRealExamCallback(async (strData, len) => {
await fileLog.setExamJudgeCallbackData(strData)
console.info('评判回调数据', strData)
this.handleRealExam(strData, callBack)
})
2024-05-15 16:22:48 +08:00
2024-07-02 10:42:53 +08:00
await examJudgeSetPerformCallback(async (info) => {
console.info('评判实时数据', info)
const performInfo = JSON.parse(info)
this.performInfo = performInfo
this.judgeUI.jl = Math.ceil((performInfo.qjjl + performInfo.dcjl) / 100)
})
// 3.开始考试
let beginExamInfo = isTrajectoryOpen ? {
...JSON.parse(strArr[1]),
replay: 1
} : await getJudgeBeginData()
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
2024-05-15 16:22:48 +08:00
2024-07-02 10:42:53 +08:00
this.judgeUI.draw = true
2024-05-15 16:22:48 +08:00
2024-07-02 10:42:53 +08:00
// 处理轨迹plc信息
if (isTrajectoryOpen) {
handleTrajectoryUdp(strArr);
return
2024-05-15 16:22:48 +08:00
}
2024-01-05 11:11:15 +08:00
2024-07-02 10:42:53 +08:00
// 处理实时udp里的plc信号
globalThis.udpClient.onMessage(async (msg) => {
handleUdp(msg)
})
}
2024-01-05 11:11:15 +08:00
}