tcp独立进程

This commit is contained in:
lixiao 2025-05-17 14:59:49 +08:00
parent 14760e2c37
commit 54925cad67
4 changed files with 37 additions and 55 deletions

View File

@ -39,6 +39,7 @@ export async function getTCP(flag = false) {
let now = new Date() let now = new Date()
if (now.getTime() - lastTime.getTime() > (1000 * 6)) { if (now.getTime() - lastTime.getTime() > (1000 * 6)) {
console.log("差分tcp信号丢失") console.log("差分tcp信号丢失")
clearInterval(tick)
getTCP(true) getTCP(true)
return return
} }
@ -47,6 +48,7 @@ export async function getTCP(flag = false) {
} }
}, 1000 * 1.5) }, 1000 * 1.5)
tcpClient?.onError(() => { tcpClient?.onError(() => {
clearInterval(tick)
getTCP(true) getTCP(true)
}) })
tcpClient?.onMessage((val) => { tcpClient?.onMessage((val) => {

View File

@ -74,6 +74,7 @@ export default class TcpClient {
this.tcpSendNum++ this.tcpSendNum++
if (this.tcpSendNum > 10) { if (this.tcpSendNum > 10) {
getTCP(true) getTCP(true)
this.tcpSendNum = 0
} }
}) })
} }

View File

@ -57,7 +57,7 @@ export default struct Index {
} }
}); });
let routParam: any = router.getParams(); let routParam: any = router.getParams();
this.fromIndex=routParam?.fromIndex || false this.fromIndex = routParam?.fromIndex || false
this.carConfigurationInfoFn() this.carConfigurationInfoFn()
} }
@ -109,30 +109,10 @@ export default struct Index {
this.stachValue = JSON.parse(JSON.stringify(StackValueData)) this.stachValue = JSON.parse(JSON.stringify(StackValueData))
this.warnFlag = JSON.parse(JSON.stringify(WarnFlagData)) this.warnFlag = JSON.parse(JSON.stringify(WarnFlagData))
this.passArray = JSON.parse(JSON.stringify(PassData)) this.passArray = JSON.parse(JSON.stringify(PassData))
// clearInterval(this.interval)
} }
// //
carConfigurationInfoFn() { carConfigurationInfoFn() {
// const fileUtil = new FileUtil(context)
// const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt');
// if (data === '' || data === undefined) {
// promptAction.showToast({
// message: `请先进行设备注册`,
// duration: 3000
// });
// globalThis.type='1'
// globalThis.title=decodeURIComponent('请先进行设备注册')
// globalThis.errorDialog.open()
// resolve('')
// } else {
// const fileData=JSON.parse(data)
// globalThis.deviceNo = fileData.deviceName
// console.log('globalThis.deviceNo', globalThis.deviceNo)
// // getCarInfo()
// resolve(fileData.deviceName)
// }
if (globalThis.singlePlay) { if (globalThis.singlePlay) {
const str = "1:5;2:5;3:5;4:5;5:5;6:5;7:5;8:5;9:5;10:5;11:5;12:5;13:5;14:5;15:5;16:5;17:5;18:5;19:5;20:5;21:5;22:2;23:5;24:5" const str = "1:5;2:5;3:5;4:5;5:5;6:5;7:5;8:5;9:5;10:5;11:5;12:5;13:5;14:5;15:5;16:5;17:5;18:5;19:5;20:5;21:5;22:2;23:5;24:5"
const data = str.split(';') const data = str.split(';')
@ -295,7 +275,7 @@ export default struct Index {
flag: flag ? 'N' : 'Y', flag: flag ? 'N' : 'Y',
condition: flag ? '自检不通过' : '自检通过' condition: flag ? '自检不通过' : '自检通过'
} }
if(!flag&&this.fromIndex||true){ if (!flag && this.fromIndex || true) {
router.pushUrl({ router.pushUrl({
url: 'pages/ExaminerLogin', url: 'pages/ExaminerLogin',
}, router.RouterMode.Single); }, router.RouterMode.Single);
@ -306,41 +286,43 @@ export default struct Index {
} }
}, parseInt(this.checkListCopy[0].time) * 1000) }, parseInt(this.checkListCopy[0].time) * 1000)
} }
initfackCheck(index){
const that=this
setTimeout(()=>{
console.log('indexindex',index)
if(index>=3){
this.getCheckList()
return
}
console.log('this.index',index,) initfackCheck(index) {
that.passArray[index]=true const that = this
if(index==2){ setTimeout(() => {
let flag=false console.log('indexindex', index)
console.log('globalThis.spzd[key]',globalThis.spzd) if (index >= 3) {
this.getCheckList()
return
}
for(let key in globalThis.spzd){ console.log('this.index', index,)
console.log('globalThis.spzd[key]',globalThis.spzd[key]) that.passArray[index] = true
if(globalThis.spzd[key]){ if (index == 2) {
that.warnFlag[index]='1' let flag = false
flag=true console.log('globalThis.spzd[key]', globalThis.spzd)
}
for (let key in globalThis.spzd) {
console.log('globalThis.spzd[key]', globalThis.spzd[key])
if (globalThis.spzd[key]) {
that.warnFlag[index] = '1'
flag = true
} }
if(!flag){
that.warnFlag[index]='2'
}
}else{
that.warnFlag[index]='2'
} }
that.passArray=JSON.parse(JSON.stringify(that.passArray)) if (!flag) {
that.warnFlag=JSON.parse(JSON.stringify(that.warnFlag)) that.warnFlag[index] = '2'
index++ }
this.initfackCheck(index) } else {
},1000) that.warnFlag[index] = '2'
}
that.passArray = JSON.parse(JSON.stringify(that.passArray))
that.warnFlag = JSON.parse(JSON.stringify(that.warnFlag))
index++
this.initfackCheck(index)
}, 1000)
} }
async getCheckList() { async getCheckList() {
this.index = this.checkListCopy[0].key this.index = this.checkListCopy[0].key
this.passArray[this.index] = true this.passArray[this.index] = true

View File

@ -248,7 +248,6 @@ export default class Judge {
const str = await senorToWXDataStr(msg); const str = await senorToWXDataStr(msg);
usbService.sendUSB(str) usbService.sendUSB(str)
} }
// this.judgeUI.isDwztRight = (plcData.gps.dwzt == 4 && plcData.gps.jdzt == 3);
const param350 = judgeUI.judgeConfigObj['350'] const param350 = judgeUI.judgeConfigObj['350']
//@ts-ignore //@ts-ignore
this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + '' this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + ''
@ -486,7 +485,7 @@ export default class Judge {
} }
// 处理轨迹plc信号 // 处理轨迹plc信号
handleTrajectoryUdp = async (strArr) => { handleTrajectoryUdp = async (strArr) => {
const {fileLog,setJudgeItem,setJudgeMark,endExam} = this; const {setJudgeItem} = this;
let num = 2; let num = 2;
const judgeTimer = setInterval(async () => { const judgeTimer = setInterval(async () => {
const msgStr = strArr[num]; const msgStr = strArr[num];
@ -504,7 +503,6 @@ export default class Judge {
this.judgeUI.sd = Math.floor(msg?.gps?.sd * 1.852) + ''; this.judgeUI.sd = Math.floor(msg?.gps?.sd * 1.852) + '';
this.judgeUI.dw = Math.floor(msg?.sensor?.dw) + '' this.judgeUI.dw = Math.floor(msg?.sensor?.dw) + ''
this.plcData = msg this.plcData = msg
// this.judgeUI.isDwztRight = msg.gps.dwzt == 4;
globalThis.msgStr = '' globalThis.msgStr = ''
if (msg.method === 'examJudgeArtificialItem') { if (msg.method === 'examJudgeArtificialItem') {
setJudgeItem(msg.itemno, msg.type) setJudgeItem(msg.itemno, msg.type)
@ -1730,7 +1728,6 @@ export default class Judge {
// 检测差分状态 // 检测差分状态
checkDwzt = async (type) => { checkDwzt = async (type) => {
const {avPlayer} = this; const {avPlayer} = this;
const judgeConfig = this.judgeUI.judgeConfig;
switch (type) { switch (type) {
case 0: case 0:
this.judgeUI.isDwztRight = true; this.judgeUI.isDwztRight = true;