fix: 过程数据问题
This commit is contained in:
parent
0f400c7467
commit
8cf68ea6fb
@ -226,9 +226,10 @@ export struct JudgePage {
|
|||||||
async aboutToDisappear() {
|
async aboutToDisappear() {
|
||||||
this.generateExamRecordsDialogController.close()
|
this.generateExamRecordsDialogController.close()
|
||||||
this.signalTrajectoryDialogController.close()
|
this.signalTrajectoryDialogController.close()
|
||||||
// this.judgeBusiness.close()
|
this.judgeBusiness.close()
|
||||||
clearInterval(this.mileageTimer)
|
clearInterval(this.mileageTimer)
|
||||||
DifferentialAndSignal.offMsg(this.onCenterMsg)
|
DifferentialAndSignal.offMsg(this.onCenterMsg)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化相关数据库表
|
//初始化相关数据库表
|
||||||
@ -802,19 +803,19 @@ export struct JudgePage {
|
|||||||
private onCenterMsg = (msg: string) => {
|
private onCenterMsg = (msg: string) => {
|
||||||
let result: WorkerBackMessage = JSON.parse(msg)
|
let result: WorkerBackMessage = JSON.parse(msg)
|
||||||
if (result.type === WorkerBackMessageType.RemoteEndExam) {
|
if (result.type === WorkerBackMessageType.RemoteEndExam) {
|
||||||
dConsole.info("lixiao", msg)
|
dConsole.info(JudgeTag, msg)
|
||||||
this.judgeBusiness.JudgeEnd(true)
|
this.judgeBusiness.JudgeEnd(true)
|
||||||
} else if (result.type === WorkerBackMessageType.RemoteKf) {
|
} else if (result.type === WorkerBackMessageType.RemoteKf) {
|
||||||
let data = result.data as number[]
|
let data = result.data as number[]
|
||||||
const config810 = this.judgeConfigObj.param_810
|
const config810 = this.judgeConfigObj.param_810
|
||||||
dConsole.info("lixiao", '评判收到远程扣分项目内容:' + `kfxh=>${data[1]}; directives=>${data[0]}`)
|
dConsole.info(JudgeTag, '评判收到远程扣分项目内容:' + `kfxh=>${data[1]}; directives=>${data[0]}`)
|
||||||
let currentKf = this.markRules.filter(item => {
|
let currentKf = this.markRules.filter(item => {
|
||||||
return item.kfxh === data[1].toString() && (config810 === "1" || Number(item.markserial) > 99)
|
return item.kfxh === data[1].toString() && (config810 === "1" || Number(item.markserial) > 99)
|
||||||
})[0]
|
})[0]
|
||||||
if (!currentKf) {
|
if (!currentKf) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dConsole.info("lixiao", '远程扣分项目:', currentKf)
|
dConsole.info(JudgeTag, '远程扣分项目:', currentKf)
|
||||||
this.judgeBusiness.setJudgeMark(currentKf.itemno!, currentKf.markserial!, 2)
|
this.judgeBusiness.setJudgeMark(currentKf.itemno!, currentKf.markserial!, 2)
|
||||||
DifferentialAndSignal.sendMsg({
|
DifferentialAndSignal.sendMsg({
|
||||||
type: WorkerMessageDataType.JudgeSend,
|
type: WorkerMessageDataType.JudgeSend,
|
||||||
|
|||||||
@ -519,7 +519,7 @@ export class BaseJudge {
|
|||||||
}
|
}
|
||||||
//日志回调
|
//日志回调
|
||||||
dConsole.info(JudgeTag, '1.进入评判入口')
|
dConsole.info(JudgeTag, '1.进入评判入口')
|
||||||
await examJudgeSetLogCallback(1, async (level: number, info: string, len: number) => {
|
await examJudgeSetLogCallback(3, async (level: number, info: string, len: number) => {
|
||||||
dConsole.log(JudgeTag, '评判日志:' + info)
|
dConsole.log(JudgeTag, '评判日志:' + info)
|
||||||
dConsole.writeProcessData(ProcessDataEnumType.JudgeLogData, info)
|
dConsole.writeProcessData(ProcessDataEnumType.JudgeLogData, info)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import {
|
|||||||
JudgeKSJS,
|
JudgeKSJS,
|
||||||
JudgePerformInfo,
|
JudgePerformInfo,
|
||||||
LANE,
|
LANE,
|
||||||
MarkRule,
|
|
||||||
PLCType,
|
PLCType,
|
||||||
ProcessDataEnumType,
|
ProcessDataEnumType,
|
||||||
RecordHandleType,
|
RecordHandleType,
|
||||||
@ -121,7 +120,7 @@ export default class JudgeBusiness {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 人工扣分
|
// 人工扣分
|
||||||
public async setJudgeMark(itemno: number,markserial: string, type: number) {
|
public async setJudgeMark(itemno: number, markserial: string, type: number) {
|
||||||
await examJudgeArtificialMark(itemno, markserial, type)
|
await examJudgeArtificialMark(itemno, markserial, type)
|
||||||
// TODO 写扣分轨迹日志
|
// TODO 写扣分轨迹日志
|
||||||
}
|
}
|
||||||
@ -133,7 +132,7 @@ export default class JudgeBusiness {
|
|||||||
|
|
||||||
// 结束考试
|
// 结束考试
|
||||||
public JudgeEnd(isManual?: boolean) {
|
public JudgeEnd(isManual?: boolean) {
|
||||||
dConsole.info("lixiao", '收到远程结束考试消息1')
|
dConsole.info(JudgeTag, '收到远程结束考试消息1')
|
||||||
this.judgeBusiness.JudgeEnd(this.judgeUI, this, isManual)
|
this.judgeBusiness.JudgeEnd(this.judgeUI, this, isManual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -101,6 +101,7 @@ export class ProcessDataTaskPool {
|
|||||||
jkid: taskData.jkid,
|
jkid: taskData.jkid,
|
||||||
drvexam: drvexam,
|
drvexam: drvexam,
|
||||||
};
|
};
|
||||||
|
|
||||||
dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(obj));
|
dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(obj));
|
||||||
|
|
||||||
await this.processSingleTaskWithRetries(taskData, callback);
|
await this.processSingleTaskWithRetries(taskData, callback);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import dayTs from './Date';
|
import dayTs from './Date';
|
||||||
import fs from '@ohos.file.fs';
|
import fs from '@ohos.file.fs';
|
||||||
import { BusinessError } from '@ohos.base';
|
import { BusinessError } from '@ohos.base';
|
||||||
import { CommonFileTag, JudgeConfig, JudgeTag } from '../config';
|
import { CommonFileTag, JudgeConfig, JudgeTag, LogTag } from '../config';
|
||||||
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
||||||
import Prompt from '@system.prompt';
|
import Prompt from '@system.prompt';
|
||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
@ -272,9 +272,11 @@ export function CloseFile(fd: number): Promise<boolean> {
|
|||||||
export function EditFile(fd: number, data: string): Promise<boolean> {
|
export function EditFile(fd: number, data: string): Promise<boolean> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
|
console.log(LogTag, "写入数据:" + data)
|
||||||
fs.writeSync(fd, data + "\n")
|
fs.writeSync(fd, data + "\n")
|
||||||
resolve(true)
|
resolve(true)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.error(LogTag, "写入数据失败", data)
|
||||||
reject(false)
|
reject(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -75,6 +75,7 @@ class logWorker {
|
|||||||
|
|
||||||
// 过程数据写入
|
// 过程数据写入
|
||||||
writeProcessData(type: ProcessDataEnumType, data: string) {
|
writeProcessData(type: ProcessDataEnumType, data: string) {
|
||||||
|
dConsole.log(LogTag, "传入过程数据", data)
|
||||||
let params: LogWorkerMessage = {
|
let params: LogWorkerMessage = {
|
||||||
type: WorkerMessageType.WriteProcessData,
|
type: WorkerMessageType.WriteProcessData,
|
||||||
data,
|
data,
|
||||||
|
|||||||
@ -94,7 +94,7 @@ class differentialAndSignal {
|
|||||||
getMessage() {
|
getMessage() {
|
||||||
this.workerInstance.onmessage = (e: MessageEvents): void => {
|
this.workerInstance.onmessage = (e: MessageEvents): void => {
|
||||||
if (e.data) {
|
if (e.data) {
|
||||||
console.log(WorkerTag, "lixiao", "Worker 收到消息: " + e.data);
|
// console.log(WorkerTag, "Worker 收到消息: " + e.data);
|
||||||
this.events.forEach((callback) => {
|
this.events.forEach((callback) => {
|
||||||
callback(e.data);
|
callback(e.data);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import {
|
|||||||
UDPParamType
|
UDPParamType
|
||||||
} from '../../model';
|
} from '../../model';
|
||||||
|
|
||||||
import { JudgeConfig } from '../../config';
|
import { JudgeConfig, JudgeTag } from '../../config';
|
||||||
import { FillZero, NumberToByteArray, StringToASCII } from '../Common';
|
import { FillZero, NumberToByteArray, StringToASCII } from '../Common';
|
||||||
import UdpClient, { MsgExt } from '../UdpUtils';
|
import UdpClient, { MsgExt } from '../UdpUtils';
|
||||||
import systemTime from '@ohos.systemDateTime';
|
import systemTime from '@ohos.systemDateTime';
|
||||||
@ -46,7 +46,7 @@ class JudgeUdpBusiness {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getMessageHeartbeat(msg: string): Promise<number[]> {
|
async getMessageHeartbeat(msg: string): Promise<number[]> {
|
||||||
dConsole.info(Tag, msg, this.lsh)
|
// dConsole.info(Tag, msg, this.lsh)
|
||||||
if (!this.business || !this.performInfo) {
|
if (!this.business || !this.performInfo) {
|
||||||
return this.getOBDMessageHeart(msg)
|
return this.getOBDMessageHeart(msg)
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ class JudgeUdpBusiness {
|
|||||||
carNo: this.carInfo.carNo!,
|
carNo: this.carInfo.carNo!,
|
||||||
placeId: this.carInfo!.examinationRoomId!,
|
placeId: this.carInfo!.examinationRoomId!,
|
||||||
}
|
}
|
||||||
dConsole.info(Tag, "发送小红球数据", data)
|
// dConsole.info(Tag, "发送小红球数据", data)
|
||||||
this.udp.sendMsgExt(data, udpLsh)
|
this.udp.sendMsgExt(data, udpLsh)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ class JudgeUdpBusiness {
|
|||||||
this.carInfo = carInfo
|
this.carInfo = carInfo
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
dConsole.info("lixiao udp", config.udplocalIp!, '8080', carInfo.udpAddress!, carInfo.hintPort!)
|
dConsole.info(JudgeTag, "udp", config.udplocalIp!, '8080', carInfo.udpAddress!, carInfo.hintPort!)
|
||||||
this.udp.create(config.udplocalIp!, '8080', carInfo.udpAddress!, carInfo.hintPort!).then(resolve).catch(reject)
|
this.udp.create(config.udplocalIp!, '8080', carInfo.udpAddress!, carInfo.hintPort!).then(resolve).catch(reject)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(e)
|
reject(e)
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import { DifferentialSignal } from '../utils/business/DifferentialSignal';
|
|||||||
import { JudgeUdpBusinessInstance } from '../utils/business/JudgeUdpBusiness';
|
import { JudgeUdpBusinessInstance } from '../utils/business/JudgeUdpBusiness';
|
||||||
import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness';
|
import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness';
|
||||||
import { SerialPortService } from '../utils/business/SerialPortService';
|
import { SerialPortService } from '../utils/business/SerialPortService';
|
||||||
import { dConsole } from '../utils/LogWorker';
|
|
||||||
import dayTs from '../utils/Date';
|
import dayTs from '../utils/Date';
|
||||||
import { NumberToByteArray } from '../utils/Common';
|
import { NumberToByteArray } from '../utils/Common';
|
||||||
|
|
||||||
@ -141,7 +140,7 @@ function getDataFn(config: EnvironmentConfigurationType) {
|
|||||||
JudgeUdpBusinessInstance.sendData(byte, udpLsh)
|
JudgeUdpBusinessInstance.sendData(byte, udpLsh)
|
||||||
}
|
}
|
||||||
udpIndex++
|
udpIndex++
|
||||||
console.log(SerialPortTag, "后置机消息", data)
|
// console.log(SerialPortTag, "后置机消息", data)
|
||||||
workerPort.postMessage(
|
workerPort.postMessage(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: WorkerBackMessageType.ObtainUdpData,
|
type: WorkerBackMessageType.ObtainUdpData,
|
||||||
@ -154,7 +153,6 @@ function getDataFn(config: EnvironmentConfigurationType) {
|
|||||||
// TODO
|
// TODO
|
||||||
// 需要观察
|
// 需要观察
|
||||||
checkLsh()
|
checkLsh()
|
||||||
dConsole.info("lixiao", data)
|
|
||||||
switch (Number(data.id)) {
|
switch (Number(data.id)) {
|
||||||
case 32:
|
case 32:
|
||||||
signNum = data.body![1]
|
signNum = data.body![1]
|
||||||
@ -170,7 +168,6 @@ function getDataFn(config: EnvironmentConfigurationType) {
|
|||||||
} as WorkerBackMessage)
|
} as WorkerBackMessage)
|
||||||
)
|
)
|
||||||
} else if (Number(data.body![0]) === 12) {
|
} else if (Number(data.body![0]) === 12) {
|
||||||
dConsole.info("lixiao", 12, data)
|
|
||||||
workerPort.postMessage(
|
workerPort.postMessage(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: WorkerBackMessageType.RemoteEndExam
|
type: WorkerBackMessageType.RemoteEndExam
|
||||||
|
|||||||
@ -29,6 +29,7 @@ workerPort.onmessage = (e: MessageEvents) => {
|
|||||||
}
|
}
|
||||||
// 写过程数据
|
// 写过程数据
|
||||||
if (result.type === WorkerMessageType.WriteProcessData && result.processDataType) {
|
if (result.type === WorkerMessageType.WriteProcessData && result.processDataType) {
|
||||||
|
console.log(LogTag, "work收到过程数据")
|
||||||
WriteProcessData(result.processDataType, result.data || "")
|
WriteProcessData(result.processDataType, result.data || "")
|
||||||
}
|
}
|
||||||
// 关闭过程数据
|
// 关闭过程数据
|
||||||
@ -82,21 +83,23 @@ async function InitExam(dirName: string) {
|
|||||||
await CreateDir(path);
|
await CreateDir(path);
|
||||||
}
|
}
|
||||||
// 创建几个文件
|
// 创建几个文件
|
||||||
fileNameArr.forEach(async (item: string, index: number) => {
|
fileNameArr.forEach(async (item: string) => {
|
||||||
let filePath = path + "/" + item
|
let filePath = path + "/" + item
|
||||||
console.log(LogTag, "创建文件", filePath)
|
console.log(LogTag, "创建文件", filePath)
|
||||||
let result = await CreateFile(filePath)
|
let result = await CreateFile(filePath)
|
||||||
fileFdArr[index] = result
|
// fileFdArr[index] = result
|
||||||
|
fileFdArr.push(result)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写过程数据
|
// 写过程数据
|
||||||
async function WriteProcessData(type: ProcessDataEnumType, data: string) {
|
async function WriteProcessData(type: ProcessDataEnumType, data: string) {
|
||||||
// if (type === ProcessDataEnumType.WuxiExam) {
|
console.log(LogTag, "推入过程数据", type, data)
|
||||||
// writeQueue.push({ type, data });
|
if (fileFdArr.length === 0) {
|
||||||
// } else {
|
return
|
||||||
|
}
|
||||||
writeQueue.push({ type, data });
|
writeQueue.push({ type, data });
|
||||||
// }
|
|
||||||
if (!isProcessing) {
|
if (!isProcessing) {
|
||||||
processQueue();
|
processQueue();
|
||||||
}
|
}
|
||||||
@ -104,23 +107,34 @@ async function WriteProcessData(type: ProcessDataEnumType, data: string) {
|
|||||||
|
|
||||||
async function processQueue() {
|
async function processQueue() {
|
||||||
isProcessing = true;
|
isProcessing = true;
|
||||||
while (writeQueue.length > 0) {
|
while (writeQueue.length > 0 && isProcessing) {
|
||||||
|
console.log(LogTag, "处理过程数据")
|
||||||
const item = writeQueue.shift()!;
|
const item = writeQueue.shift()!;
|
||||||
const index = Number(item.type);
|
const index = Number(item.type);
|
||||||
await EditFile(fileFdArr[index], item.data);
|
try {
|
||||||
|
await EditFile(fileFdArr[index], item.data);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(LogTag, "写过程数据错误", JSON.stringify(e))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
isProcessing = false;
|
isProcessing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭过程数据
|
// 关闭过程数据
|
||||||
function CloseProcessData() {
|
function CloseProcessData() {
|
||||||
|
writeQueue = []
|
||||||
|
isProcessing = false
|
||||||
if (fileFdArr.length > 0) {
|
if (fileFdArr.length > 0) {
|
||||||
console.log(LogTag, "有文件需要 关闭过程数据")
|
console.log(LogTag, "有文件需要 关闭过程数据", fileFdArr)
|
||||||
fileFdArr.forEach((item: number) => {
|
fileFdArr.forEach((item: number) => {
|
||||||
fs.closeSync(item)
|
try {
|
||||||
|
fs.closeSync(item)
|
||||||
|
} catch (e) {
|
||||||
|
console.error(LogTag, JSON.stringify(e))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
fileFdArr = []
|
|
||||||
}
|
}
|
||||||
|
fileFdArr = []
|
||||||
}
|
}
|
||||||
|
|
||||||
workerPort.onmessageerror = (e: MessageEvents) => {
|
workerPort.onmessageerror = (e: MessageEvents) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user