From 6b6a2ba6691c1b49ab3d5b02a2193250797ca6fc Mon Sep 17 00:00:00 2001 From: lv <1344032923@qq.com> Date: Mon, 28 Apr 2025 16:50:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E8=BF=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/utils/GlobalTcp.ts | 16 ++++++++++++---- entry/src/main/ets/common/utils/TcpClient.ts | 3 ++- entry/src/main/ets/entryability/EntryAbility.ets | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/entry/src/main/ets/common/utils/GlobalTcp.ts b/entry/src/main/ets/common/utils/GlobalTcp.ts index 04485318..93212af6 100644 --- a/entry/src/main/ets/common/utils/GlobalTcp.ts +++ b/entry/src/main/ets/common/utils/GlobalTcp.ts @@ -28,10 +28,14 @@ export async function getTCP(flag=false) { console.log('ttttttt00') clearInterval(globalThis.intervalSendmsg) - globalThis.intervalSendmsg=setInterval(()=>{ + globalThis.intervalSendmsg=setInterval(async ()=>{ console.log('getCloseTcp',globalThis.carInfo.carNo) if(!globalThis.getCloseTcp){ - globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002 + await globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002 + globalThis.tcpStep+=1 + if(globalThis.tcpStep>10){ + getTCP() + } } },1000/3) globalThis.TcpClient.onError((val) => { @@ -63,10 +67,14 @@ export async function getTCP(flag=false) { console.log('ttttttt12') clearInterval(globalThis.intervalSendmsg) - globalThis.intervalSendmsg=setInterval(()=>{ + globalThis.intervalSendmsg=setInterval(async ()=>{ // console.log('getCloseTcp',globalThis.getCloseTcp) if(!globalThis.getCloseTcp){ - globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002 + await globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002 + globalThis.tcpStep+=1 + if(globalThis.tcpStep>10){ + getTCP() + } } },1000/3) globalThis.TcpClient.onError((val) => { diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index bf4cd943..2f100c4b 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -156,7 +156,7 @@ export default class TcpClient { // time:dateFormat(new Date()), // message: `${TAG} TCPsend error ${JSON.stringify(err)}`, // }) - reslove(false) + reject(false) }); }) } @@ -167,6 +167,7 @@ export default class TcpClient { // time:dateFormat(new Date()), // PLC:`${TAG} Tcponmessage`, // }) + globalThis.tcpStep=0 globalThis.tcpUdpError = false // console.log('messageLengt',,value.message.length)) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index be84f0b0..1d86efc0 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -56,7 +56,7 @@ export default class EntryAbility extends UIAbility { globalThis.judgeVersion = GlobalConfig.version.jn.km3[1]; globalThis.tcpSendNum = 0 globalThis.videoVersion = '1.0' - + globalThis.tcpStep=0 //视频遮挡 globalThis.spzd = { spzd1: false,