Compare commits
No commits in common. "be462d6877178d385a21514fe9934aa93051e5ed" and "0f400c7467043aca77d3b91cf3dc9620e438acc4" have entirely different histories.
be462d6877
...
0f400c7467
@ -112,22 +112,22 @@ export enum WorkerMessageType {
|
|||||||
|
|
||||||
// 过程数据枚举
|
// 过程数据枚举
|
||||||
export enum ProcessDataEnumType {
|
export enum ProcessDataEnumType {
|
||||||
// //four_one_log_byte_data
|
//four_one_log_byte_data
|
||||||
// FourOneLogByteData = "0",
|
FourOneLogByteData = "0",
|
||||||
// //four_one_log_data
|
//four_one_log_data
|
||||||
// FourOneLogData = "1",
|
FourOneLogData = "1",
|
||||||
//judge_exam_data
|
//judge_exam_data
|
||||||
JudgeExamData = "0",
|
JudgeExamData = "2",
|
||||||
//judge_log_data
|
//judge_log_data
|
||||||
JudgeLogData = "1",
|
JudgeLogData = "3",
|
||||||
//judge_progress_callback_data
|
//judge_progress_callback_data
|
||||||
JudgeProgressCallbackData = "2",
|
JudgeProgressCallbackData = "4",
|
||||||
//plc_data
|
//plc_data
|
||||||
PlcData = "3",
|
PlcData = "5",
|
||||||
//wuxi_exam_data
|
//wuxi_exam_data
|
||||||
WuxiExam = "4",
|
WuxiExam = "6",
|
||||||
//wuxi_progress_data
|
//wuxi_progress_data
|
||||||
WuxiProgressData = "5"
|
WuxiProgressData = "7"
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FileQueueType {
|
export interface FileQueueType {
|
||||||
|
|||||||
@ -226,10 +226,9 @@ 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)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化相关数据库表
|
//初始化相关数据库表
|
||||||
@ -803,19 +802,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(JudgeTag, msg)
|
dConsole.info("lixiao", 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(JudgeTag, '评判收到远程扣分项目内容:' + `kfxh=>${data[1]}; directives=>${data[0]}`)
|
dConsole.info("lixiao", '评判收到远程扣分项目内容:' + `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(JudgeTag, '远程扣分项目:', currentKf)
|
dConsole.info("lixiao", '远程扣分项目:', 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(3, async (level: number, info: string, len: number) => {
|
await examJudgeSetLogCallback(1, 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)
|
||||||
})
|
})
|
||||||
@ -533,7 +533,6 @@ export class BaseJudge {
|
|||||||
AppStorage.setOrCreate('isJudgeInitBool', true)
|
AppStorage.setOrCreate('isJudgeInitBool', true)
|
||||||
dConsole.info(JudgeTag, '4.评判初始化完成')
|
dConsole.info(JudgeTag, '4.评判初始化完成')
|
||||||
}
|
}
|
||||||
dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify(initInfo))
|
|
||||||
AppStorage.setOrCreate('isJudge', true)
|
AppStorage.setOrCreate('isJudge', true)
|
||||||
// 2.评判过程回调
|
// 2.评判过程回调
|
||||||
await examJudgeSetRealExamCallback(async (strData: string, len: number) => {
|
await examJudgeSetRealExamCallback(async (strData: string, len: number) => {
|
||||||
@ -556,7 +555,6 @@ export class BaseJudge {
|
|||||||
// 3.开始考试
|
// 3.开始考试
|
||||||
if (beginExamInfo) {
|
if (beginExamInfo) {
|
||||||
await examJudgeBeginExam(beginExamInfo);
|
await examJudgeBeginExam(beginExamInfo);
|
||||||
dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify(beginExamInfo))
|
|
||||||
}
|
}
|
||||||
dConsole.info(JudgeTag, '6.开始考试注册完成')
|
dConsole.info(JudgeTag, '6.开始考试注册完成')
|
||||||
that.avPlayer?.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3'])
|
that.avPlayer?.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3'])
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import {
|
|||||||
JudgeKSJS,
|
JudgeKSJS,
|
||||||
JudgePerformInfo,
|
JudgePerformInfo,
|
||||||
LANE,
|
LANE,
|
||||||
|
MarkRule,
|
||||||
PLCType,
|
PLCType,
|
||||||
ProcessDataEnumType,
|
ProcessDataEnumType,
|
||||||
RecordHandleType,
|
RecordHandleType,
|
||||||
@ -120,7 +121,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 写扣分轨迹日志
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ export default class JudgeBusiness {
|
|||||||
|
|
||||||
// 结束考试
|
// 结束考试
|
||||||
public JudgeEnd(isManual?: boolean) {
|
public JudgeEnd(isManual?: boolean) {
|
||||||
dConsole.info(JudgeTag, '收到远程结束考试消息1')
|
dConsole.info("lixiao", '收到远程结束考试消息1')
|
||||||
this.judgeBusiness.JudgeEnd(this.judgeUI, this, isManual)
|
this.judgeBusiness.JudgeEnd(this.judgeUI, this, isManual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -101,7 +101,6 @@ 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, LogTag } from '../config';
|
import { CommonFileTag, JudgeConfig, JudgeTag } 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,11 +272,9 @@ 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,7 +75,6 @@ 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, "Worker 收到消息: " + e.data);
|
console.log(WorkerTag, "lixiao", "Worker 收到消息: " + e.data);
|
||||||
this.events.forEach((callback) => {
|
this.events.forEach((callback) => {
|
||||||
callback(e.data);
|
callback(e.data);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,16 +10,6 @@ export default class GetDistance {
|
|||||||
public totalTime: number
|
public totalTime: number
|
||||||
public date: string
|
public date: string
|
||||||
public fd: number
|
public fd: number
|
||||||
//上传行驶里程数据
|
|
||||||
uploadData = async () => {
|
|
||||||
// setInterval(() => {
|
|
||||||
// // const { carId } = AppStorage.get<CarInfoType>('carInfo');
|
|
||||||
// // const { date, timeStr, totalDistance } = this;
|
|
||||||
// return
|
|
||||||
// //"carid":"1001","startTime":"2024-08-24 08:09:01","time":"111233", "mileage":"1222"
|
|
||||||
//
|
|
||||||
// }, 5000)
|
|
||||||
}
|
|
||||||
//后续文件路径待替换
|
//后续文件路径待替换
|
||||||
private fileUtil: FileUtils
|
private fileUtil: FileUtils
|
||||||
// 设置文件夹
|
// 设置文件夹
|
||||||
@ -45,6 +35,7 @@ export default class GetDistance {
|
|||||||
this.fileUtil = fileUtil;
|
this.fileUtil = fileUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 过程文件数据
|
// 过程文件数据
|
||||||
public setTimeData = async (str: number) => {
|
public setTimeData = async (str: number) => {
|
||||||
console.log('folderPath', this.folderPath)
|
console.log('folderPath', this.folderPath)
|
||||||
@ -64,4 +55,14 @@ export default class GetDistance {
|
|||||||
// `${folderPath}/${date}.txt`,contentArr.join('\n')
|
// `${folderPath}/${date}.txt`,contentArr.join('\n')
|
||||||
// );
|
// );
|
||||||
}
|
}
|
||||||
|
//上传行驶里程数据
|
||||||
|
uploadData = async () => {
|
||||||
|
setInterval(() => {
|
||||||
|
// const { carId } = AppStorage.get<CarInfoType>('carInfo');
|
||||||
|
// const { date, timeStr, totalDistance } = this;
|
||||||
|
return
|
||||||
|
//"carid":"1001","startTime":"2024-08-24 08:09:01","time":"111233", "mileage":"1222"
|
||||||
|
|
||||||
|
}, 5000)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import {
|
|||||||
UDPParamType
|
UDPParamType
|
||||||
} from '../../model';
|
} from '../../model';
|
||||||
|
|
||||||
import { JudgeConfig, JudgeTag } from '../../config';
|
import { JudgeConfig } 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(JudgeTag, "udp", config.udplocalIp!, '8080', carInfo.udpAddress!, carInfo.hintPort!)
|
dConsole.info("lixiao 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,6 +19,7 @@ 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';
|
||||||
|
|
||||||
@ -140,7 +141,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,
|
||||||
@ -153,6 +154,7 @@ 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]
|
||||||
@ -168,6 +170,7 @@ 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
|
||||||
|
|||||||
@ -7,8 +7,7 @@ import fs from '@ohos.file.fs';
|
|||||||
|
|
||||||
const workerPort: ThreadWorkerGlobalScope = worker.workerPort;
|
const workerPort: ThreadWorkerGlobalScope = worker.workerPort;
|
||||||
// 过程数据文件
|
// 过程数据文件
|
||||||
// "four_one_log_byte_data.txt", "four_one_log_data.txt",
|
const fileNameArr: string[] = ["four_one_log_byte_data.txt", "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"]
|
||||||
const fileNameArr: string[] = ["judge_exam_data.txt", "judge_log_data.txt", "judge_progress_callback_data.txt", "plc_data.txt", "wuxi_exam_data.txt", "wuxi_progress_data.txt"]
|
|
||||||
// 过程数据fd
|
// 过程数据fd
|
||||||
let fileFdArr: number[] = []
|
let fileFdArr: number[] = []
|
||||||
let writeQueue: Array<FileQueueType> = [];
|
let writeQueue: Array<FileQueueType> = [];
|
||||||
@ -30,7 +29,6 @@ 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 || "")
|
||||||
}
|
}
|
||||||
// 关闭过程数据
|
// 关闭过程数据
|
||||||
@ -84,23 +82,21 @@ async function InitExam(dirName: string) {
|
|||||||
await CreateDir(path);
|
await CreateDir(path);
|
||||||
}
|
}
|
||||||
// 创建几个文件
|
// 创建几个文件
|
||||||
fileNameArr.forEach(async (item: string) => {
|
fileNameArr.forEach(async (item: string, index: number) => {
|
||||||
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) {
|
||||||
console.log(LogTag, "推入过程数据", type, data)
|
// if (type === ProcessDataEnumType.WuxiExam) {
|
||||||
if (fileFdArr.length === 0) {
|
// writeQueue.push({ type, data });
|
||||||
return
|
// } else {
|
||||||
}
|
|
||||||
writeQueue.push({ type, data });
|
writeQueue.push({ type, data });
|
||||||
|
// }
|
||||||
if (!isProcessing) {
|
if (!isProcessing) {
|
||||||
processQueue();
|
processQueue();
|
||||||
}
|
}
|
||||||
@ -108,34 +104,23 @@ async function WriteProcessData(type: ProcessDataEnumType, data: string) {
|
|||||||
|
|
||||||
async function processQueue() {
|
async function processQueue() {
|
||||||
isProcessing = true;
|
isProcessing = true;
|
||||||
while (writeQueue.length > 0 && isProcessing) {
|
while (writeQueue.length > 0) {
|
||||||
console.log(LogTag, "处理过程数据")
|
|
||||||
const item = writeQueue.shift()!;
|
const item = writeQueue.shift()!;
|
||||||
const index = Number(item.type);
|
const index = Number(item.type);
|
||||||
try {
|
await EditFile(fileFdArr[index], item.data);
|
||||||
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, "有文件需要 关闭过程数据", fileFdArr)
|
console.log(LogTag, "有文件需要 关闭过程数据")
|
||||||
fileFdArr.forEach((item: number) => {
|
fileFdArr.forEach((item: number) => {
|
||||||
try {
|
fs.closeSync(item)
|
||||||
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