fix: 小红球udp

This commit is contained in:
wangzhongjie 2025-10-27 16:32:29 +08:00
parent a25ac61d58
commit 2ada59b81f
8 changed files with 45 additions and 41 deletions

View File

@ -204,7 +204,7 @@ 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)
} }

View File

@ -35,7 +35,6 @@ import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video'
import router from '@ohos.router' import router from '@ohos.router'
import { GetSyncData, UpdateTableByArray } from '../../utils/table/Operation' import { GetSyncData, UpdateTableByArray } from '../../utils/table/Operation'
import { CurrentProjectConversion, DeductionProjectConversion, DetectingDifferences, GetCarStatus } from './utils' import { CurrentProjectConversion, DeductionProjectConversion, DetectingDifferences, GetCarStatus } from './utils'
import { DifferentialSignal } from '../../utils/business/DifferentialSignal'
import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker' import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker'
@ -73,7 +72,11 @@ export const SetJudgeItem = async (itemno: string, type: 1 | 2) => {
} }
export class BaseJudge { export class BaseJudge {
protected isUdpEnd: boolean = false private isUdpEnd: boolean = false
getIsUdpEnd() {
return this.isUdpEnd
}
async goJudgeVoice(sound: JudgeSound, avPlayer: VoiceAnnounce) { async goJudgeVoice(sound: JudgeSound, avPlayer: VoiceAnnounce) {
dConsole.info(JudgeTag, 'surenjun code=>', JSON.stringify(sound.code)) dConsole.info(JudgeTag, 'surenjun code=>', JSON.stringify(sound.code))

View File

@ -22,9 +22,7 @@ import { examJudgeRealExam } from './JudgeSDKUtils'
import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker' import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker'
import { PlcStrToJson, PlcStrToWXJson } from './utils' import { PlcStrToJson, PlcStrToWXJson } from './utils'
import { BaseJudgeImpl, SetJudgeItem } from './BaseJudgeBussines' import { BaseJudgeImpl, SetJudgeItem } from './BaseJudgeBussines'
import { JudgePage } from '../Judge'; import { JudgePage } from '../Judge'
import { CenterUDPBusinessInstance } from '../../utils/business/CenterUdpBusiness'
import { ObtainUdpBusinessInstance } from '../../utils/business/ObtainUdpBusiness'
export default class JudgeBusiness { export default class JudgeBusiness {
public mndgStr: string | undefined public mndgStr: string | undefined
@ -63,13 +61,6 @@ export default class JudgeBusiness {
private tempData?: PLCType private tempData?: PLCType
// 是否发送udp // 是否发送udp
private judgeBusiness: BaseJudgeImpl private judgeBusiness: BaseJudgeImpl
private onObdCallback = (data: string) => {
const result: WorkerBackMessage = JSON.parse(data)
if (result.type === WorkerBackMessageType.ObtainUdpData) {
this.HandlePLCData(result.data as string)
dConsole.writeProcessData(ProcessDataEnumType.PlcData, result.data as string)
}
}
constructor(judgeUI: JudgePage) { constructor(judgeUI: JudgePage) {
this.judgeUI = judgeUI this.judgeUI = judgeUI
@ -138,10 +129,22 @@ export default class JudgeBusiness {
this.judgeBusiness.JudgeEnd(this.judgeUI, this, isManual) this.judgeBusiness.JudgeEnd(this.judgeUI, this, isManual)
} }
close() {
DifferentialAndSignal.offMsg(this.onObdCallback)
}
private onObdCallback = (data: string) => {
const result: WorkerBackMessage = JSON.parse(data)
if (result.type === WorkerBackMessageType.ObtainUdpData) {
this.HandlePLCData(result.data as string)
dConsole.writeProcessData(ProcessDataEnumType.PlcData, result.data as string)
}
}
// 处理PLC数据 // 处理PLC数据
private async HandlePLCData(msg: string) { private async HandlePLCData(msg: string) {
const plcArr = msg.split(',') const plcArr = msg.split(',')
if (plcArr[0] != '#DN_GD' || this.isExamEnd) { if (plcArr[0] != '#DN_GD' || this.judgeBusiness.getIsUdpEnd()) {
return return
} }
const gpsPart = msg.split("#END$GPS,")[1]; const gpsPart = msg.split("#END$GPS,")[1];
@ -172,6 +175,9 @@ export default class JudgeBusiness {
this.judgeUI.sd = ((param350 == 0 ? this.plcData.gps.sd : this.plcData.sensor.cs) as number * 1.852).toFixed(0) + '' this.judgeUI.sd = ((param350 == 0 ? this.plcData.gps.sd : this.plcData.sensor.cs) as number * 1.852).toFixed(0) + ''
this.judgeUI.dw = (Math.floor(this.plcData.sensor.dw as number) || 0) + '' this.judgeUI.dw = (Math.floor(this.plcData.sensor.dw as number) || 0) + ''
dConsole.info("小红球过程数据1", this.judgeBusiness.getIsUdpEnd(), this.judgeUI.kfArr)
DifferentialAndSignal.sendMsg({ DifferentialAndSignal.sendMsg({
type: WorkerMessageDataType.JudgeSend, data: { type: WorkerMessageDataType.JudgeSend, data: {
performInfo: this.performInfo, performInfo: this.performInfo,
@ -195,9 +201,5 @@ export default class JudgeBusiness {
await examJudgeRealExam(this.plcData) await examJudgeRealExam(this.plcData)
} }
} }
close() {
DifferentialAndSignal.offMsg(this.onObdCallback)
}
} }

View File

@ -40,8 +40,8 @@ export class LargeJudge extends BaseJudge implements BaseJudgeImpl {
private mockLight: boolean = false private mockLight: boolean = false
private mode: number = 1 private mode: number = 1
getIsUdpEnd() { getIsUdpEnd(): boolean {
return super.isUdpEnd return super.getIsUdpEnd()
} }
public async JudgeInit(judgeUI: JudgePage, that: JudgeBusiness): Promise<GetSysSetResult> { public async JudgeInit(judgeUI: JudgePage, that: JudgeBusiness): Promise<GetSysSetResult> {

View File

@ -36,10 +36,8 @@ import systemDateTime from '@ohos.systemDateTime';
import { testKm2Items, testKm3Items } from '../../mock/Judge'; import { testKm2Items, testKm3Items } from '../../mock/Judge';
export class SmallJudge extends BaseJudge implements BaseJudgeImpl { export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
getIsUdpEnd(): boolean {
return super.getIsUdpEnd()
getIsUdpEnd() {
return super.isUdpEnd
} }
public async GetJudgeBeginData(projects: Project[], carType: string, kssycs: string, isDdxk: boolean, ddxkTime: number, projectsCenterObj: Object, ddxkKsxmArr: string[], ddxkKfArr: string[], passingScore: number, wayno: number, name: string, lsh: string, idCard: string, isExam: boolean) { public async GetJudgeBeginData(projects: Project[], carType: string, kssycs: string, isDdxk: boolean, ddxkTime: number, projectsCenterObj: Object, ddxkKsxmArr: string[], ddxkKfArr: string[], passingScore: number, wayno: number, name: string, lsh: string, idCard: string, isExam: boolean) {

View File

@ -14,9 +14,8 @@ import {
} from '../../model'; } from '../../model';
import { JudgeConfig } from '../../config'; import { JudgeConfig } from '../../config';
import { FillZero, FormatTimeFlexible, NumberToByteArray, StringToASCII } from '../Common'; import { FillZero, NumberToByteArray, StringToASCII } from '../Common';
import UdpClient, { MsgExt } from '../UdpUtils'; import UdpClient, { MsgExt } from '../UdpUtils';
import { CenterUDPBusinessInstance } from './CenterUdpBusiness';
import systemTime from '@ohos.systemDateTime'; import systemTime from '@ohos.systemDateTime';
import { SerialNumberInstance } from '../SerialNumber'; import { SerialNumberInstance } from '../SerialNumber';
import { GetCenterProjectStatus, GetDwStatusType, GetTranslateSignals } from '../../pages/Judge/utils'; import { GetCenterProjectStatus, GetDwStatusType, GetTranslateSignals } from '../../pages/Judge/utils';
@ -28,15 +27,15 @@ const Tag = "JudgeUdpBusiness"
class JudgeUdpBusiness { class JudgeUdpBusiness {
private static instance: JudgeUdpBusiness private static instance: JudgeUdpBusiness
public business: JudgeUDPData | null = null
public performInfo: JudgePerformInfo | null = null
public isUDPEnd: boolean = false
public isExamEnd: boolean = false
private udp: UdpClient = new UdpClient() private udp: UdpClient = new UdpClient()
private carInfo: CarInfoType = {} private carInfo: CarInfoType = {}
private singlePlay: boolean = false private singlePlay: boolean = false
private lsh: string = "" private lsh: string = ""
private serialIndex: number = 1 private serialIndex: number = 1
public business: JudgeUDPData | null = null
public performInfo: JudgePerformInfo | null = null
public isUDPEnd: boolean = false
public isExamEnd: boolean = false
constructor() { constructor() {
if (!JudgeUdpBusiness.instance) { if (!JudgeUdpBusiness.instance) {
@ -75,8 +74,8 @@ class JudgeUdpBusiness {
let fyj = Number(plcData.gps.fyj.toFixed(2)) let fyj = Number(plcData.gps.fyj.toFixed(2))
fyj = Math.floor(fyj > 0 ? (fyj * 100) : (fyj * 100 + 65536)) fyj = Math.floor(fyj > 0 ? (fyj * 100) : (fyj * 100 + 65536))
let examType = this.carInfo.examSubject === "2" ? "2" : "3" let examType = this.carInfo.examSubject === "2" ? "2" : "3"
dConsole.info("小红球过程数据2", this.isExamEnd, this.business.kfArr)
dConsole.info("小红球过程数据", this.isExamEnd, this.business)
const arr: number[][] = [ const arr: number[][] = [
//考生号 //考生号
@ -112,7 +111,7 @@ class JudgeUdpBusiness {
//本次考试行驶距离 //本次考试行驶距离
NumberToByteArray(Math.floor(this.performInfo.dcjl! + this.performInfo.qjjl!) / 100, 2 * 8), NumberToByteArray(Math.floor(this.performInfo.dcjl! + this.performInfo.qjjl!) / 100, 2 * 8),
//扣分值 //扣分值
NumberToByteArray(100 - Math.abs(this.business.totalScore), 2 * 8), NumberToByteArray(100 - Math.abs(this.business.totalScore < 0 ? 0 : this.business.totalScore), 2 * 8),
//扣分数量 //扣分数量
NumberToByteArray(this.business.kfArr.length, 8), NumberToByteArray(this.business.kfArr.length, 8),
//n个扣分序号 //n个扣分序号

View File

@ -134,7 +134,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,

View File

@ -1,18 +1,20 @@
{ {
"lockfileVersion": 1, "lockfileVersion": 2,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": { "specifiers": {
"@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3", "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19",
"@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19" "@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3"
}, },
"packages": { "packages": {
"@ohos/crypto-js@2.0.3": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har",
"integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ=="
},
"@ohos/hypium@1.0.19": { "@ohos/hypium@1.0.19": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har", "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har",
"integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==" "integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==",
"registryType": "ohpm"
},
"@ohos/crypto-js@2.0.3": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har",
"integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ==",
"registryType": "ohpm"
} }
} }
} }