Compare commits
3 Commits
39bfed3beb
...
9696924932
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9696924932 | ||
|
|
30a7c3842d | ||
|
|
46c9b8bd63 |
@ -31,6 +31,7 @@ export enum WorkerBackMessageType {
|
|||||||
export interface LogWorkerMessage {
|
export interface LogWorkerMessage {
|
||||||
type: WorkerMessageType;
|
type: WorkerMessageType;
|
||||||
data?: string;
|
data?: string;
|
||||||
|
studentDirName?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
//枚举
|
//枚举
|
||||||
@ -45,7 +46,8 @@ export enum WorkerMessageType {
|
|||||||
ProcessDataInit = 'processDataInit',
|
ProcessDataInit = 'processDataInit',
|
||||||
// 打开过程数据文件
|
// 打开过程数据文件
|
||||||
OpenProcessDataFile = 'openProcessDataFile',
|
OpenProcessDataFile = 'openProcessDataFile',
|
||||||
|
// 初始化考试过程
|
||||||
|
ExamProcessInit = 'examProcessInit'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LogPathType {
|
export interface LogPathType {
|
||||||
|
|||||||
@ -230,6 +230,91 @@ export default class Judge {
|
|||||||
dConsole.info(JudgeTag, '过程数据文件上传 end')
|
dConsole.info(JudgeTag, '过程数据文件上传 end')
|
||||||
}
|
}
|
||||||
private judgeTask: JudgeTask
|
private judgeTask: JudgeTask
|
||||||
|
// 处理udp plc信号
|
||||||
|
handleUdp = async (msg: string) => {
|
||||||
|
const stachArr = msg.split(',')
|
||||||
|
if (stachArr[0] != '#DN_GD' || this.isUdpEnd) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const plcData = await this.getPlcData(msg);
|
||||||
|
// 4.过程数据
|
||||||
|
await this.fileLog?.setExamJudgeData(JSON.stringify(plcData))
|
||||||
|
//检测到有无锡所设备接入,需要发送特定的数据,供检测
|
||||||
|
// if (this.usbService.isWXUSBDevice) {
|
||||||
|
// const str = await senorToWXDataStr(msg);
|
||||||
|
// this.usbService.sendUSB(str)
|
||||||
|
// }
|
||||||
|
const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350')
|
||||||
|
this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + ''
|
||||||
|
this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + ''
|
||||||
|
//TODO 暂时关闭差分检测异常
|
||||||
|
// await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt);
|
||||||
|
if (!this.isExamEnd) {
|
||||||
|
await examJudgeRealExam(plcData)
|
||||||
|
}
|
||||||
|
// let udpIndex = AppStorage.get<number>('udpIndex') || 0;
|
||||||
|
// if (udpIndex % 5 === 0 && !this.isUdpEnd) {
|
||||||
|
// TODO UPD缺失
|
||||||
|
// const judgeUdp = globalThis.judgeUdp
|
||||||
|
// const bytes = await this.getMessageHeartbeat(this.isExamEnd);
|
||||||
|
// judgeUdp.send(bytes)
|
||||||
|
// }
|
||||||
|
// AppStorage.setOrCreate('udpIndex', udpIndex++)
|
||||||
|
}
|
||||||
|
// 检测扣分、结束项目时该项目是否开始
|
||||||
|
checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: MarkRule) => {
|
||||||
|
if (xmdm == 20) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
const judgeUI = this.judgeUI;
|
||||||
|
const judgeTask = this.judgeTask;
|
||||||
|
const projectsObj: object = this.judgeUI.projectsObj
|
||||||
|
const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm)
|
||||||
|
const isUpload = currentProject.isUpload
|
||||||
|
|
||||||
|
//如果项目没有开始
|
||||||
|
dConsole.info(JudgeTag, 'surenjun isUpload=>', isUpload)
|
||||||
|
if (!isUpload) {
|
||||||
|
dConsole.info(JudgeTag, '项目补传开始')
|
||||||
|
//项目开始补传
|
||||||
|
judgeTask.addTask(async () => {
|
||||||
|
await this.beginProject(xmdm)
|
||||||
|
}, {
|
||||||
|
isDelay: true
|
||||||
|
})
|
||||||
|
judgeTask.addTask(async () => {
|
||||||
|
await this.uploadProgressPhoto(xmdm)
|
||||||
|
}, {
|
||||||
|
isDelay: true
|
||||||
|
})
|
||||||
|
currentProject.isUpload = true;
|
||||||
|
Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject)
|
||||||
|
//扣分补传
|
||||||
|
if (currentType == 2) {
|
||||||
|
judgeTask.addTask(async () => {
|
||||||
|
await this.pointsDedute(xmdm, kf!)
|
||||||
|
}, {
|
||||||
|
isDelay: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//扣分补传判断是否合格 不合格补传项目结束
|
||||||
|
if (currentType == 1 || (currentType == 2 && this.totalScore < judgeUI.passingScore)) {
|
||||||
|
judgeTask.addTask(async () => {
|
||||||
|
await this.endProject(xmdm)
|
||||||
|
}, {
|
||||||
|
isDelay: true
|
||||||
|
})
|
||||||
|
currentProject.isEnd = true;
|
||||||
|
Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject)
|
||||||
|
}
|
||||||
|
judgeTask.addTask(async () => {
|
||||||
|
this.checkExamIsEnd()
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
private tempData?: PLCType
|
private tempData?: PLCType
|
||||||
//实时计算gps经纬度距离
|
//实时计算gps经纬度距离
|
||||||
handDistance = async () => {
|
handDistance = async () => {
|
||||||
@ -253,11 +338,9 @@ export default class Judge {
|
|||||||
this.prevWd = tWD;
|
this.prevWd = tWD;
|
||||||
}
|
}
|
||||||
private performInfo?: JudgePerformInfo
|
private performInfo?: JudgePerformInfo
|
||||||
private isEndTip: boolean = false;
|
|
||||||
private deductedPopShowTimer: number = 0;
|
|
||||||
// 校验考试是否结束
|
// 校验考试是否结束
|
||||||
checkExamIsEnd =
|
checkExamIsEnd = async (isManual?: boolean) => {
|
||||||
async (isManual?: boolean) => {
|
dConsole.log(JudgeTag, "校验考试是否结束")
|
||||||
const judgeUI = this.judgeUI
|
const judgeUI = this.judgeUI
|
||||||
const avPlayer = this.avPlayer
|
const avPlayer = this.avPlayer
|
||||||
const isExamEnd = this.isExamEnd
|
const isExamEnd = this.isExamEnd
|
||||||
@ -268,10 +351,11 @@ export default class Judge {
|
|||||||
const totalScore = Number(judgeUI.totalScore)
|
const totalScore = Number(judgeUI.totalScore)
|
||||||
const judgeConfigObj = judgeUI.judgeConfigObj
|
const judgeConfigObj = judgeUI.judgeConfigObj
|
||||||
const examMileage = Number(judgeUI.examMileage)
|
const examMileage = Number(judgeUI.examMileage)
|
||||||
const passingScore = Number(judgeUI.examMileage)
|
const passingScore = Number(judgeUI.passingScore)
|
||||||
const jl = judgeUI.jl
|
const jl = judgeUI.jl
|
||||||
|
|
||||||
if (isExamEnd) {
|
if (isExamEnd) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//及格分
|
//及格分
|
||||||
@ -318,6 +402,7 @@ export default class Judge {
|
|||||||
this.isExamEnd = true
|
this.isExamEnd = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//成绩不合格
|
//成绩不合格
|
||||||
if (totalScore < passingGrade) {
|
if (totalScore < passingGrade) {
|
||||||
//科目三不合格报靠边停车
|
//科目三不合格报靠边停车
|
||||||
@ -393,37 +478,7 @@ export default class Judge {
|
|||||||
AppStorage.setOrCreate('msgStr', plc)
|
AppStorage.setOrCreate('msgStr', plc)
|
||||||
return tempData
|
return tempData
|
||||||
}
|
}
|
||||||
// 处理udp plc信号
|
private isEndTip: boolean = false;
|
||||||
handleUdp = async (msg: string) => {
|
|
||||||
const stachArr = msg.split(',')
|
|
||||||
if (stachArr[0] != '#DN_GD' || this.isUdpEnd) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const plcData = await this.getPlcData(msg);
|
|
||||||
// 4.过程数据
|
|
||||||
await this.fileLog?.setExamJudgeData(JSON.stringify(plcData))
|
|
||||||
//检测到有无锡所设备接入,需要发送特定的数据,供检测
|
|
||||||
// if (this.usbService.isWXUSBDevice) {
|
|
||||||
// const str = await senorToWXDataStr(msg);
|
|
||||||
// this.usbService.sendUSB(str)
|
|
||||||
// }
|
|
||||||
const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350')
|
|
||||||
this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + ''
|
|
||||||
this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + ''
|
|
||||||
//TODO 暂时关闭差分检测异常
|
|
||||||
// await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt);
|
|
||||||
if (!this.isExamEnd) {
|
|
||||||
await examJudgeRealExam(plcData)
|
|
||||||
}
|
|
||||||
// let udpIndex = AppStorage.get<number>('udpIndex') || 0;
|
|
||||||
// if (udpIndex % 5 === 0 && !this.isUdpEnd) {
|
|
||||||
// TODO UPD缺失
|
|
||||||
// const judgeUdp = globalThis.judgeUdp
|
|
||||||
// const bytes = await this.getMessageHeartbeat(this.isExamEnd);
|
|
||||||
// judgeUdp.send(bytes)
|
|
||||||
// }
|
|
||||||
// AppStorage.setOrCreate('udpIndex', udpIndex++)
|
|
||||||
}
|
|
||||||
// 处理轨迹plc信号
|
// 处理轨迹plc信号
|
||||||
handleTrajectoryUdp = async (strArr: string[]) => {
|
handleTrajectoryUdp = async (strArr: string[]) => {
|
||||||
let num = 2;
|
let num = 2;
|
||||||
@ -581,60 +636,7 @@ export default class Judge {
|
|||||||
UploadRegulatoryCodeConversion('17C54', temp.code || 0)
|
UploadRegulatoryCodeConversion('17C54', temp.code || 0)
|
||||||
dConsole.info(JudgeTag, '上传照片 end')
|
dConsole.info(JudgeTag, '上传照片 end')
|
||||||
}
|
}
|
||||||
// 检测扣分、结束项目时该项目是否开始
|
private deductedPopShowTimer: number = 0;
|
||||||
checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: MarkRule) => {
|
|
||||||
if (xmdm == 20) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
const judgeUI = this.judgeUI;
|
|
||||||
const judgeTask = this.judgeTask;
|
|
||||||
const projectsObj: object = this.judgeUI.projectsObj
|
|
||||||
const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm)
|
|
||||||
const isUpload = currentProject.isUpload
|
|
||||||
|
|
||||||
//如果项目没有开始
|
|
||||||
dConsole.info(JudgeTag, 'surenjun isUpload=>', isUpload)
|
|
||||||
if (!isUpload) {
|
|
||||||
dConsole.info(JudgeTag, '项目补传开始')
|
|
||||||
//项目开始补传
|
|
||||||
judgeTask.addTask(async () => {
|
|
||||||
await this.beginProject(xmdm)
|
|
||||||
}, {
|
|
||||||
isDelay: true
|
|
||||||
})
|
|
||||||
judgeTask.addTask(async () => {
|
|
||||||
await this.uploadProgressPhoto(xmdm)
|
|
||||||
}, {
|
|
||||||
isDelay: true
|
|
||||||
})
|
|
||||||
currentProject.isUpload = true;
|
|
||||||
Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject)
|
|
||||||
//扣分补传
|
|
||||||
if (currentType == 2) {
|
|
||||||
judgeTask.addTask(async () => {
|
|
||||||
await this.pointsDedute(xmdm, kf!)
|
|
||||||
}, {
|
|
||||||
isDelay: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//扣分补传判断是否合格 不合格补传项目结束
|
|
||||||
if (currentType == 1 || (currentType == 2 && this.totalScore < judgeUI.passingScore)) {
|
|
||||||
judgeTask.addTask(async () => {
|
|
||||||
await this.endProject(xmdm)
|
|
||||||
}, {
|
|
||||||
isDelay: true
|
|
||||||
})
|
|
||||||
currentProject.isEnd = true;
|
|
||||||
Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject)
|
|
||||||
}
|
|
||||||
judgeTask.addTask(async () => {
|
|
||||||
this.checkExamIsEnd()
|
|
||||||
})
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11]
|
private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11]
|
||||||
private lane: LANE = {
|
private lane: LANE = {
|
||||||
road: '', num: 0, count: 0
|
road: '', num: 0, count: 0
|
||||||
@ -1059,8 +1061,7 @@ export default class Judge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 更改考试状态
|
// 更改考试状态
|
||||||
goVoiceAnnounce =
|
goVoiceAnnounce = async (event: number, xmdm: number, kf: MarkRule[], xmjs: JudgeXMJS, ksjs: JudgeKSJS, xmxh: string) => {
|
||||||
async (event: number, xmdm: number, kf: MarkRule[], xmjs: JudgeXMJS, ksjs: JudgeKSJS, xmxh: string) => {
|
|
||||||
|
|
||||||
const beginProject = this.beginProject
|
const beginProject = this.beginProject
|
||||||
const pointsDedute = this.pointsDedute
|
const pointsDedute = this.pointsDedute
|
||||||
@ -1907,7 +1908,7 @@ export default class Judge {
|
|||||||
// 2.评判过程回调
|
// 2.评判过程回调
|
||||||
await examJudgeSetRealExamCallback(async (strData: string, len: number) => {
|
await examJudgeSetRealExamCallback(async (strData: string, len: number) => {
|
||||||
// 评判回调日志
|
// 评判回调日志
|
||||||
// await fileLog?.setExamJudgeCallbackData(strData)
|
await fileLog?.setExamJudgeCallbackData(strData)
|
||||||
dConsole.info(JudgeTag, '评判回调数据', strData)
|
dConsole.info(JudgeTag, '评判回调数据', strData)
|
||||||
await this.handleRealExam(strData, callBack)
|
await this.handleRealExam(strData, callBack)
|
||||||
})
|
})
|
||||||
@ -1963,7 +1964,6 @@ export default class Judge {
|
|||||||
}
|
}
|
||||||
// 处理实时udp里的plc信号
|
// 处理实时udp里的plc信号
|
||||||
DifferentialAndSignal.onMsg((data: string) => {
|
DifferentialAndSignal.onMsg((data: string) => {
|
||||||
dConsole.info(JudgeTag, 'socketTag[PLC.UdpClient]', '收到udp回调数据')
|
|
||||||
const result: WorkerBackMessage = JSON.parse(data)
|
const result: WorkerBackMessage = JSON.parse(data)
|
||||||
if (result.type === WorkerBackMessageType.ObtainUdpData) {
|
if (result.type === WorkerBackMessageType.ObtainUdpData) {
|
||||||
handleUdp(result.data as string)
|
handleUdp(result.data as string)
|
||||||
|
|||||||
@ -217,6 +217,17 @@ export function CreateDir(path: string): Promise<boolean> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建文件
|
||||||
|
* @params path 文件具体路径
|
||||||
|
* @return 返回一个Promise
|
||||||
|
*/
|
||||||
|
export function CreateFile(path: string): Promise<boolean> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 将秒数转换为灵活的时间格式(HH:MM:SS)
|
* 将秒数转换为灵活的时间格式(HH:MM:SS)
|
||||||
* @param seconds 要转换的秒数
|
* @param seconds 要转换的秒数
|
||||||
|
|||||||
@ -16,15 +16,18 @@ workerPort.onmessage = (e: MessageEvents) => {
|
|||||||
let logFileFd: LogFileFd = {}
|
let logFileFd: LogFileFd = {}
|
||||||
const result: LogWorkerMessage = JSON.parse(e.data);
|
const result: LogWorkerMessage = JSON.parse(e.data);
|
||||||
if (result.type === WorkerMessageType.Init) {
|
if (result.type === WorkerMessageType.Init) {
|
||||||
Init()
|
InitLog()
|
||||||
}
|
}
|
||||||
if (result.type === WorkerMessageType.OpenProcessDataFile) {
|
if (result.type === WorkerMessageType.OpenProcessDataFile) {
|
||||||
OpenProcessDataFile(logPaths, logFileFd, result.data || "")
|
OpenProcessDataFile(logPaths, logFileFd, result.data || "")
|
||||||
}
|
}
|
||||||
|
if (result.type === WorkerMessageType.ExamProcessInit && result.studentDirName) {
|
||||||
|
InitExam(result.studentDirName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化
|
// 初始化日志
|
||||||
async function Init() {
|
async function InitLog() {
|
||||||
// /mnt/hmdfs/100/account/device_view/local/files/duolun/logs/2024_10_12
|
// /mnt/hmdfs/100/account/device_view/local/files/duolun/logs/2024_10_12
|
||||||
// 创建duolun文件夹 /mnt/hmdfs/100/account/device_view/local/files/duolun
|
// 创建duolun文件夹 /mnt/hmdfs/100/account/device_view/local/files/duolun
|
||||||
const basePath = GlobalConfig.commonFileWriteAddress;
|
const basePath = GlobalConfig.commonFileWriteAddress;
|
||||||
@ -57,6 +60,19 @@ async function Init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化学员过程数据目录
|
||||||
|
async function InitExam(dirName: string) {
|
||||||
|
let date = dayTs().format("YYYY_MM_DD")
|
||||||
|
const path = `${GlobalConfig.commonFileWriteAddress}/logs/${date}/${dirName}`
|
||||||
|
const nameDirIsExit = await IsExit(path)
|
||||||
|
if (!nameDirIsExit) {
|
||||||
|
await CreateDir(path);
|
||||||
|
}
|
||||||
|
// 创建几个文件
|
||||||
|
let fileNameArr: string[] = ["four_one_log_byte_data.text", "four_one_log_data.txt", "judge_exam_data.txt", "judge_log_data.txt", "judge_progress_callback_data.txt", "plc_data.txt", "wuxi_exam_data.txt", "wuxi_progress_data.txt"]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function OpenProcessDataFile(logPaths: LogPathType, logFileFd: LogFileFd, name: string) {
|
function OpenProcessDataFile(logPaths: LogPathType, logFileFd: LogFileFd, name: string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user