牵引车第二导航仪新udp增加
This commit is contained in:
parent
7ff283169c
commit
f299e6fe17
Binary file not shown.
@ -85,68 +85,6 @@ export async function getTCP(flag=false) {
|
||||
}
|
||||
}
|
||||
return
|
||||
getSyncData('IpConfigTable').then(async (result: Array<any>) => {
|
||||
|
||||
console.log('result222', JSON.stringify(result))
|
||||
if (result.length) {
|
||||
if (globalThis.TcpClient && globalThis.TcpClient.closeTcp) {
|
||||
globalThis.TcpClient.closeTcp(async () => {
|
||||
// const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
|
||||
// globalThis.TcpClient = tcpClient
|
||||
setTimeout(async () => {
|
||||
await globalThis.TcpClient.rebindTcp(result[0].tcplocalIp, result[0].tcplocalIpPort, result[0].tcpOppositeIp, result[0].tcpOppositePort)
|
||||
await globalThis.TcpClient.connectTcp()
|
||||
await globalThis.TcpClient.sendMsg('1002') //1002
|
||||
globalThis.TcpClient.onError((val) => {
|
||||
setTimeout(() => {
|
||||
getTCP()
|
||||
}, 1000)
|
||||
})
|
||||
await globalThis.TcpClient.onMessage((val) => {
|
||||
setTimeout(() => {
|
||||
globalThis.TcpClient.sendMsg('1002') //1002
|
||||
if (val) {
|
||||
// const msg=val.substring(5,val.length-1)
|
||||
console.log('socketTag[PLC.UdpClient] status:', globalThis.udpClient.getStatus())
|
||||
globalThis.udpClient?.sendMsg(val)
|
||||
}
|
||||
}, 1000)
|
||||
|
||||
})
|
||||
}, 2000)
|
||||
})
|
||||
|
||||
}
|
||||
else {
|
||||
const tcpClient: TcpClient = new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort, result[0].tcpOppositeIp, result[0].tcpOppositePort)
|
||||
globalThis.TcpClient = tcpClient
|
||||
await globalThis.TcpClient.bindTcp()
|
||||
await globalThis.TcpClient.connectTcp()
|
||||
await globalThis.TcpClient.sendMsg('1002') //1002
|
||||
globalThis.TcpClient.onError((val) => {
|
||||
setTimeout(() => {
|
||||
getTCP()
|
||||
}, 1000)
|
||||
})
|
||||
await globalThis.TcpClient.onMessage((val) => {
|
||||
hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val));
|
||||
setTimeout(() => {
|
||||
globalThis.TcpClient.sendMsg('1002') //1002
|
||||
if (val && globalThis.udpClient?.sendMsg) {
|
||||
globalThis.udpClient?.sendMsg(val)
|
||||
}
|
||||
}, 1000)
|
||||
|
||||
})
|
||||
}
|
||||
// globalThis.udpClient = new UdpClient(result[0].localIp, result[0].localIpPort,result[0].oppositeIp,result[0].oppositeIpPort)
|
||||
|
||||
} else {
|
||||
globalThis.TcpClient = {}
|
||||
globalThis.TcpClient.onMessage = () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,28 +1,24 @@
|
||||
//import UdpClient from './UdpClient';
|
||||
import UdpClientByCenter from './UdpClientByCenter';
|
||||
import { getSyncData } from '../service/initable'
|
||||
import { getChuankouFn } from '../../common/service/indexService'
|
||||
import FileUtil from '../../common/utils/File'
|
||||
import { GlobalConfig } from '../../config/index'
|
||||
import {Array2Byte,fillZero,string2Bytes}from './tools'
|
||||
import emitter from '@ohos.events.emitter';
|
||||
import { Array2Byte, string2Bytes } from './tools'
|
||||
|
||||
export async function sendMsg(val) {
|
||||
// globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val)
|
||||
}
|
||||
|
||||
export async function getUDP(context,errorFlag?) {
|
||||
return new Promise(async (reslove,reject)=>{
|
||||
export async function getUDP(context, errorFlag?) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const fileUtil = new FileUtil(context)
|
||||
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
|
||||
console.log('ttttt',data)
|
||||
console.log('ttttt', data)
|
||||
if (data === '' || data === undefined) {
|
||||
console.log(` getUDP has no IPConfigTable `);
|
||||
globalThis.udpClient = {}
|
||||
globalThis.host = ''
|
||||
reslove('')
|
||||
resolve('')
|
||||
} else {
|
||||
const result=JSON.parse(data)
|
||||
const result = JSON.parse(data)
|
||||
console.log(` getUDP has IPConfigTable `);
|
||||
if (globalThis.udpClient && globalThis.udpClient.closeUdp) {
|
||||
console.log(` getUDP has udclent close and rebind `);
|
||||
@ -31,16 +27,15 @@ export async function getUDP(context,errorFlag?) {
|
||||
globalThis.udpClient.rebindUdp(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, result.udpOppositeIpPort)
|
||||
globalThis.udpClient.sendMsg('111', null)
|
||||
globalThis.host = `http://${result.centerIp}:${result.centerPort}`
|
||||
globalThis.udpClient.onError_Callback(()=>{
|
||||
globalThis.udpClient.onError_Callback(() => {
|
||||
console.log('getUDPgetUDPgetUDP')
|
||||
getUDP(context,true)
|
||||
if(errorFlag&&globalThis.udpClient&&globalThis.udpClient.onMessage_1){
|
||||
globalThis.udpClient.onMessage_1=globalThis.udpClient.onMessage_1
|
||||
getUDP(context, true)
|
||||
if (errorFlag && globalThis.udpClient && globalThis.udpClient.onMessage_1) {
|
||||
globalThis.udpClient.onMessage_1 = globalThis.udpClient.onMessage_1
|
||||
}
|
||||
})
|
||||
reslove(`http://${result.centerIp}:${result.centerPort}`)
|
||||
resolve(`http://${result.centerIp}:${result.centerPort}`)
|
||||
|
||||
// globalThis.udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
@ -48,117 +43,103 @@ export async function getUDP(context,errorFlag?) {
|
||||
else {
|
||||
// 未绑定
|
||||
console.log(` getUDP has no udclent and bind `);
|
||||
console.log('ttttttdata',JSON.stringify(result))
|
||||
console.log('ttttttdata', JSON.stringify(result))
|
||||
const udpClient: UdpClientByCenter = new UdpClientByCenter(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, result.udpOppositeIpPort)
|
||||
udpClient.bindUdp()
|
||||
udpClient.sendMsg('111')
|
||||
globalThis.host = `http://${result.centerIp}:${result.centerPort}`
|
||||
globalThis.udpClient = udpClient
|
||||
|
||||
globalThis.udpClient.onMessage_1(()=>{
|
||||
globalThis.udpClient.onMessage_1(() => {
|
||||
console.log('getUDPonMessage_1msgmsgByGloalUdp')
|
||||
|
||||
})
|
||||
globalThis.udpClient.onError_Callback(()=>{
|
||||
getUDP(context,true)
|
||||
if(errorFlag&&globalThis.udpClient&&globalThis.udpClient.onMessage_1){
|
||||
globalThis.udpClient.onMessage_1=globalThis.udpClient.onMessage_1
|
||||
globalThis.udpClient.onError_Callback(() => {
|
||||
getUDP(context, true)
|
||||
if (errorFlag && globalThis.udpClient && globalThis.udpClient.onMessage_1) {
|
||||
globalThis.udpClient.onMessage_1 = globalThis.udpClient.onMessage_1
|
||||
}
|
||||
})
|
||||
getChuankouFn()
|
||||
reslove(`http://${result.centerIp}:${result.centerPort}`)
|
||||
|
||||
resolve(`http://${result.centerIp}:${result.centerPort}`)
|
||||
}
|
||||
|
||||
}
|
||||
return
|
||||
getSyncData('IpConfigTable').then((result: Array<any>) => {
|
||||
if (result.length) {
|
||||
console.log(` getUDP has IPConfigTable `);
|
||||
if (globalThis.udpClient && globalThis.udpClient.closeUdp) {
|
||||
console.log(` getUDP has udclent close and rebind `);
|
||||
globalThis.udpClient.closeUdp(() => {
|
||||
setTimeout(() => {
|
||||
globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort, result[0].udpOppositeIp, result[0].udpOppositeIpPort)
|
||||
globalThis.udpClient.sendMsg('111', null)
|
||||
globalThis.host = `http://${result[0].centerIp}:${result[0].centerPort}`
|
||||
globalThis.udpClient.onError_Callback(()=>{
|
||||
console.log('getUDPgetUDPgetUDP')
|
||||
getUDP(true,context)
|
||||
if(errorFlag&&globalThis.udpClient&&globalThis.udpClient.onMessage_1){
|
||||
globalThis.udpClient.onMessage_1=globalThis.udpClient.onMessage_1
|
||||
}
|
||||
})
|
||||
reslove(`http://${result[0].centerIp}:${result[0].centerPort}`)
|
||||
|
||||
// globalThis.udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
}
|
||||
else {
|
||||
// 未绑定
|
||||
console.log(` getUDP has no udclent and bind `);
|
||||
const udpClient: UdpClientByCenter = new UdpClientByCenter(result[0].udplocalIp, result[0].udplocalIpPort, result[0].udpOppositeIp, result[0].udpOppositeIpPort)
|
||||
udpClient.bindUdp()
|
||||
udpClient.sendMsg('111')
|
||||
globalThis.host = `http://${result[0].centerIp}:${result[0].centerPort}`
|
||||
globalThis.udpClient = udpClient
|
||||
|
||||
globalThis.udpClient.onMessage_1(()=>{
|
||||
console.log('getUDPonMessage_1msgmsgByGloalUdp')
|
||||
|
||||
})
|
||||
globalThis.udpClient.onError_Callback(()=>{
|
||||
getUDP(true,context)
|
||||
if(errorFlag&&globalThis.udpClient&&globalThis.udpClient.onMessage_1){
|
||||
globalThis.udpClient.onMessage_1=globalThis.udpClient.onMessage_1
|
||||
}
|
||||
})
|
||||
// udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
|
||||
getChuankouFn()
|
||||
reslove(`http://${result[0].centerIp}:${result[0].centerPort}`)
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log(` getUDP has no IPConfigTable `);
|
||||
// if(globalThis.udpClient)
|
||||
// {
|
||||
// console.log(` getUDP2 has IPConfigTable ,has udpClient ,close it`);
|
||||
// globalThis.udpClient.closeUdp(async ()=>{ })
|
||||
// }
|
||||
globalThis.udpClient = {}
|
||||
// globalThis.udpClient.onMessage_1 = () => {}
|
||||
globalThis.host = ''
|
||||
reslove('')
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
export async function getUDP2(context,errorFlag?) {
|
||||
export async function getUDPGps2(context, errorFlag?) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const fileUtil = new FileUtil(context)
|
||||
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
|
||||
console.log('ttttt', data)
|
||||
if (data === '' || data === undefined) {
|
||||
globalThis.udpClientGps2 = {}
|
||||
resolve('')
|
||||
} else {
|
||||
const result = JSON.parse(data)
|
||||
if (globalThis.udpClientGps2 && globalThis.udpClientGps2.closeUdp) {
|
||||
console.log(` getUDPGPS2 has udclent close and rebind `);
|
||||
globalThis.udpClientGps2.closeUdp(() => {
|
||||
setTimeout(() => {
|
||||
globalThis.udpClientGps2.rebindUdp(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, Number(result.udpOppositeIpPort) + 1)
|
||||
globalThis.udpClientGps2.sendMsg('111', null)
|
||||
globalThis.udpClientGps2.onError_Callback(() => {
|
||||
console.log('getUDPGPS')
|
||||
getUDP(context, true)
|
||||
if (errorFlag && globalThis.udpClientGps2 && globalThis.udpClientGps2.onMessage_1) {
|
||||
globalThis.udpClientGps2.onMessage_1 = globalThis.udpClientGps2.onMessage_1
|
||||
}
|
||||
})
|
||||
resolve(`http://${result.centerIp}:${result.centerPort}`)
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
}
|
||||
else {
|
||||
// 未绑定
|
||||
console.log(` getUDPGPS2 has no udclent and bind `);
|
||||
const udpClient: UdpClientByCenter = new UdpClientByCenter(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, result.udpOppositeIpPort)
|
||||
udpClient.bindUdp()
|
||||
udpClient.sendMsg('111')
|
||||
globalThis.host = `http://${result.centerIp}:${result.centerPort}`
|
||||
globalThis.udpClientGps2 = udpClient
|
||||
|
||||
globalThis.udpClientGps2.onMessage_1(() => {
|
||||
console.log('getUDPGPS2 onMessage_1 MsgByGlobalUdpGPS2')
|
||||
})
|
||||
globalThis.udpClientGps2.onError_Callback(() => {
|
||||
getUDPGps2(context, true)
|
||||
if (errorFlag && globalThis.udpClientGps2 && globalThis.udpClientGps2.onMessage_1) {
|
||||
globalThis.udpClientGps2.onMessage_1 = globalThis.udpClientGps2.onMessage_1
|
||||
}
|
||||
})
|
||||
resolve(`http://${result.centerIp}:${result.centerPort}`)
|
||||
}
|
||||
}
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export async function getUDP2(context, errorFlag?) {
|
||||
const fileUtil = new FileUtil(context)
|
||||
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
|
||||
if (data === '' || data === undefined) {
|
||||
globalThis.udpClient2 = {}
|
||||
globalThis.udpClient2.setMsgCallBack = () => {
|
||||
}
|
||||
}else{
|
||||
const result=JSON.parse(data)
|
||||
} else {
|
||||
const result = JSON.parse(data)
|
||||
console.log(` getUDP2 has IPConfigTable `);
|
||||
if (globalThis.udpClient2 && globalThis.udpClient2.closeUdp) {
|
||||
console.log(` getUDP2 has udclent ,close and rebind `);
|
||||
globalThis.udpClient2.closeUdp(async () => {
|
||||
setTimeout(() => {
|
||||
globalThis.udpClient2.rebindUdp(result.udplocalIp, '8800', globalThis.carInfo?.udpAddress, globalThis.carInfo?.messagePort)
|
||||
globalThis.udpClient2.onError_Callback(()=>{
|
||||
getUDP2(context,true);
|
||||
if(errorFlag&&globalThis.udpClient2&&globalThis.udpClient2.onMessage_2){
|
||||
globalThis.udpClient2.onMessage_2=globalThis.udpClient2.onMessage_2
|
||||
globalThis.udpClient2.onError_Callback(() => {
|
||||
getUDP2(context, true);
|
||||
if (errorFlag && globalThis.udpClient2 && globalThis.udpClient2.onMessage_2) {
|
||||
globalThis.udpClient2.onMessage_2 = globalThis.udpClient2.onMessage_2
|
||||
}
|
||||
})
|
||||
}, 1000)
|
||||
@ -169,32 +150,33 @@ export async function getUDP2(context,errorFlag?) {
|
||||
console.log(` getUDP2 has no udclent and bind `);
|
||||
const udpClient2: UdpClientByCenter = new UdpClientByCenter(result.udplocalIp, '8800', globalThis.carInfo?.udpAddress, globalThis.carInfo?.messagePort)
|
||||
console.info('surenjun udp2=> ', globalThis.carInfo?.messagePort)
|
||||
await udpClient2.bindUdp()
|
||||
await udpClient2.onError_Callback(()=>{
|
||||
getUDP2(context,true);
|
||||
if(errorFlag&&globalThis.udpClient2&&globalThis.udpClient2.onMessage_2){
|
||||
globalThis.udpClient2.onMessage_2=globalThis.udpClient2.onMessage_2
|
||||
udpClient2.bindUdp()
|
||||
udpClient2.onError_Callback(() => {
|
||||
getUDP2(context, true);
|
||||
if (errorFlag && globalThis.udpClient2 && globalThis.udpClient2.onMessage_2) {
|
||||
globalThis.udpClient2.onMessage_2 = globalThis.udpClient2.onMessage_2
|
||||
}
|
||||
})
|
||||
if(!errorFlag){
|
||||
await udpClient2.onMessage_2((val) => {
|
||||
if (!errorFlag) {
|
||||
udpClient2.onMessage_2((val) => {
|
||||
if (val.id == '32') {
|
||||
globalThis.signNum = val.body[1]
|
||||
if(val.body[0] == 5){
|
||||
if (val.body[0] == 5) {
|
||||
console.info('surenjun', `接收到平台扣分请求,请求指令为:${val.body[1]}`)
|
||||
globalThis.udpEvent.sendOnKf(val.body[1])
|
||||
}
|
||||
if(val.body[0] == 11){
|
||||
console.info('surenjun','GlobalUdp收到beginExam事件')
|
||||
if (val.body[0] == 11) {
|
||||
console.info('surenjun', 'GlobalUdp收到beginExam事件')
|
||||
globalThis.udpEvent.sendBeginExam(val.body[1])
|
||||
}
|
||||
if(val.body[0] == 12){
|
||||
console.info('surenjun','GlobalUdp收到endExam事件')
|
||||
if (val.body[0] == 12) {
|
||||
console.info('surenjun', 'GlobalUdp收到endExam事件')
|
||||
globalThis.udpEvent.sendEndExam(val.body[1])
|
||||
}
|
||||
}if (val.id == '36'){
|
||||
}
|
||||
if (val.id == '36') {
|
||||
//获取远程扣分内容
|
||||
console.info('surenjun','考车收到远程扣分项目内容,扣分代码:' + val.body[0])
|
||||
console.info('surenjun', '考车收到远程扣分项目内容,扣分代码:' + val.body[0])
|
||||
globalThis.udpEvent.sendKfContent(val.body[0])
|
||||
} else if (val.id == '46') {
|
||||
let tmpList = []
|
||||
@ -217,65 +199,6 @@ export async function getUDP2(context,errorFlag?) {
|
||||
}
|
||||
}
|
||||
return
|
||||
console.log(` getUDP2 enter`);
|
||||
getSyncData('IpConfigTable').then(async (result: Array<any>) => {
|
||||
if (result.length) {
|
||||
console.log(` getUDP2 has IPConfigTable `);
|
||||
if (globalThis.udpClient2 && globalThis.udpClient2.closeUdp) {
|
||||
console.log(` getUDP2 has udclent ,close and rebind `);
|
||||
globalThis.udpClient2.closeUdp(async () => {
|
||||
setTimeout(() => {
|
||||
globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800', globalThis.carInfo?.udpAddress, globalThis.carInfo?.messagePort)
|
||||
globalThis.udpClient2.onError_Callback(()=>{
|
||||
getUDP2(true);
|
||||
if(errorFlag&&globalThis.udpClient2&&globalThis.udpClient2.onMessage_2){
|
||||
globalThis.udpClient2.onMessage_2=globalThis.udpClient2.onMessage_2
|
||||
}
|
||||
})
|
||||
}, 1000)
|
||||
})
|
||||
}
|
||||
else {
|
||||
// 未绑定
|
||||
console.log(` getUDP2 has no udclent and bind `);
|
||||
const udpClient2: UdpClientByCenter = new UdpClientByCenter(result[0].udplocalIp, '8800', globalThis.carInfo?.udpAddress, globalThis.carInfo?.messagePort)
|
||||
await udpClient2.bindUdp()
|
||||
await udpClient2.onError_Callback(()=>{
|
||||
getUDP2(true);
|
||||
if(errorFlag&&globalThis.udpClient2&&globalThis.udpClient2.onMessage_2){
|
||||
globalThis.udpClient2.onMessage_2=globalThis.udpClient2.onMessage_2
|
||||
}
|
||||
})
|
||||
if(!errorFlag){
|
||||
await udpClient2.onMessage_2((val) => {
|
||||
if (val.id == '32') {
|
||||
globalThis.signNum = val.body[1]
|
||||
|
||||
} else if (val.id == '46') {
|
||||
let tmpList = []
|
||||
const str = globalThis.lsh
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0])
|
||||
}
|
||||
const param = {
|
||||
id: 47,
|
||||
list: tmpList,
|
||||
carNo: globalThis.carInfo.carNo,
|
||||
placeId: globalThis.carInfo.examinationRoomId
|
||||
}
|
||||
globalThis.udpClient2.send(param)
|
||||
}
|
||||
})
|
||||
}
|
||||
globalThis.udpClient2 = udpClient2
|
||||
|
||||
}
|
||||
} else {
|
||||
globalThis.udpClient2 = {}
|
||||
globalThis.udpClient2.setMsgCallBack = () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function setTopLineUdp() {
|
||||
@ -283,7 +206,6 @@ export async function setTopLineUdp() {
|
||||
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
|
||||
const config = JSON.parse(data)
|
||||
|
||||
// const config = await getSyncData('IpConfigTable');
|
||||
if (config && config.udplocalIp) {
|
||||
const {udplocalIp,udpOppositeIp,udpOppositeIpPort} = config;
|
||||
const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '55509', udpOppositeIp, udpOppositeIpPort)
|
||||
@ -320,11 +242,13 @@ export async function setJudgeUdp() {
|
||||
globalThis.carInfo?.udpAddress,
|
||||
globalThis.carInfo?.hintPort
|
||||
)
|
||||
console.info('surenjun hintPort=> ',globalThis.carInfo?.hintPort)
|
||||
console.info('surenjun hintPort=> ', globalThis.carInfo?.hintPort)
|
||||
|
||||
await udpClientbyCenter.onError_Callback(()=>{})
|
||||
await udpClientbyCenter.bindUdp()
|
||||
await udpClientbyCenter.onMessage_2((val) => {})
|
||||
udpClientbyCenter.onError_Callback(() => {
|
||||
})
|
||||
udpClientbyCenter.bindUdp()
|
||||
udpClientbyCenter.onMessage_2((val) => {
|
||||
})
|
||||
|
||||
//远程监听开始考试、结束考试、扣分指令
|
||||
|
||||
@ -343,7 +267,7 @@ export async function setJudgeUdp() {
|
||||
},
|
||||
|
||||
//申请远程扣分查询
|
||||
askKf(directives){
|
||||
askKf(directives) {
|
||||
globalThis.udpClient2.sendMsgExt({
|
||||
id: 35,
|
||||
list: [directives],
|
||||
@ -354,10 +278,10 @@ export async function setJudgeUdp() {
|
||||
},
|
||||
|
||||
//确定远程扣分
|
||||
confirmKf(directives,code){
|
||||
confirmKf(directives, code) {
|
||||
globalThis.udpClient2.sendMsgExt({
|
||||
id: 37,
|
||||
list: Array2Byte([string2Bytes(directives,8),string2Bytes(code,8)]),
|
||||
list: Array2Byte([string2Bytes(directives, 8), string2Bytes(code, 8)]),
|
||||
carNo: globalThis.carInfo.carNo,
|
||||
placeId: globalThis.carInfo.examinationRoomId
|
||||
})
|
||||
@ -376,4 +300,4 @@ export async function setJudgeUdp() {
|
||||
}
|
||||
|
||||
}
|
||||
// globalThis.udpClient.bindUdp()
|
||||
|
||||
|
||||
@ -1,237 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import socket from '@ohos.net.socket';
|
||||
import { Array2Byte } from '../utils/tools'
|
||||
import {getChuankouFn} from '../../common/service/indexService'
|
||||
import {getUDP} from './GlobalUdp'
|
||||
const TAG = 'socketTag[PLC.UdpClient]'
|
||||
import prompt from '@ohos.prompt'
|
||||
|
||||
import hilog from '@ohos.hilog';
|
||||
let num=0
|
||||
export default class UdpClient {
|
||||
private localIp: string = ''
|
||||
private localIpPort: string = ''
|
||||
private oppositeIp: string = ''
|
||||
private oppositeIpPort: string = ''
|
||||
|
||||
private udp: any = null
|
||||
// private stashFn:StashFuncotionon
|
||||
|
||||
constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
|
||||
this.localIp = udplocalIp
|
||||
this.oppositeIp = udpOppositeIp
|
||||
this.localIpPort = udplocalIpPort
|
||||
this.oppositeIpPort = udpOppositeIpPort
|
||||
getChuankouFn()
|
||||
console.log(TAG,'newUdp')
|
||||
// this.stashFn=()=>{}
|
||||
this.udp = socket.constructUDPSocketInstance();
|
||||
}
|
||||
|
||||
rebindUdp(localIp: string, localIpPort: string, oppositeIp: string, oppositeIpPort: string) {
|
||||
console.log(TAG,'rebindUdp',this.localIp,this.localIpPort)
|
||||
|
||||
this.localIp = localIp
|
||||
this.oppositeIp = oppositeIp
|
||||
this.localIpPort = localIpPort
|
||||
this.oppositeIpPort = oppositeIpPort
|
||||
let promise = this.udp.bind({
|
||||
address: this.localIp, port: parseInt(this.localIpPort), family: 1
|
||||
});
|
||||
promise.then(() => {
|
||||
globalThis.closeUDPSocket=false
|
||||
|
||||
console.log(`${TAG},udpCLient udp rebind success`);
|
||||
}).catch(err => {
|
||||
globalThis.closeUDPSocket=true
|
||||
console.log(`${TAG},udpCLient udp rebind failed:${JSON.stringify(err)}`);
|
||||
});
|
||||
}
|
||||
|
||||
bindUdp() {
|
||||
console.log(TAG,'udpbind',this.localIp,this.localIpPort)
|
||||
let promise = this.udp.bind({
|
||||
// address: '192.168.7.170', port: 20122, family: 1
|
||||
// address: '192.168.7.170', port: 31013, family: 1
|
||||
address: this.localIp, port: parseInt(this.localIpPort), family: 1
|
||||
});
|
||||
promise.then(() => {
|
||||
globalThis.closeUDPSocket=false
|
||||
console.log(`${TAG}udpCLient udp bind success`);
|
||||
}).catch(err => {
|
||||
globalThis.closeUDPSocket=true
|
||||
console.log(`${TAG}udpCLient udp bind failed:${JSON.stringify(err)}`);
|
||||
});
|
||||
}
|
||||
setMsgCallBack(callback){
|
||||
// this.stashFn=callback?callback:()=>{}
|
||||
}
|
||||
sendMsg(msg) {
|
||||
console.log(TAG,'UdpSend1111',this.oppositeIp,this.oppositeIpPort)
|
||||
this.udp.getState((err, data) => {
|
||||
if (err) {
|
||||
|
||||
console.log('getState fail');
|
||||
return;
|
||||
} else {
|
||||
let promise = this.udp.send({
|
||||
data: msg,
|
||||
address: {
|
||||
// address: '192.168.7.124',
|
||||
// port: 30013,
|
||||
// address: '192.168.7.124',
|
||||
// port: 20022,
|
||||
address: this.oppositeIp,
|
||||
port: parseInt(this.oppositeIpPort),
|
||||
family: 1
|
||||
}
|
||||
});
|
||||
promise.then(() => {
|
||||
console.log(`${TAG}udpCLient udp send success:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`);
|
||||
}).catch(err => {
|
||||
console.log(`${TAG}udpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`);
|
||||
});
|
||||
}
|
||||
console.log('getState success:' + JSON.stringify(data));
|
||||
})
|
||||
|
||||
}
|
||||
onError(callback?){
|
||||
this.udp.on('error',async err => {
|
||||
globalThis.closeUDPSocket=true
|
||||
console.log(TAG,'udpError',JSON.stringify(err))
|
||||
await this.bindUdp()
|
||||
await this.sendMsg('111')
|
||||
await this.onMessage(callback)
|
||||
// callback&&callback()
|
||||
// this.closeUdp(()=>{
|
||||
// this.bindUdp()
|
||||
// })
|
||||
});
|
||||
}
|
||||
|
||||
onMessage(callback?) {
|
||||
console.info(TAG, '注册udp message监听事件')
|
||||
this.udp.on('message', value => {
|
||||
console.log(TAG,'udponmessage')
|
||||
// 收到的是ArrayBuffer 需要进行转换解析
|
||||
globalThis.plcUdpError = false
|
||||
if (value) {
|
||||
|
||||
let dataView = new DataView(value.message)
|
||||
// console.log(`${TAG} udp message length:${dataView?.byteLength}`);
|
||||
let str = ""
|
||||
for (let i = 0; i < dataView?.byteLength; ++i) {
|
||||
let c = String.fromCharCode(dataView?.getUint8(i))
|
||||
if (c !== "\n") {
|
||||
str += c
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`${TAG} udp on message array buffer:${str}`);
|
||||
let strachArr = str.split(',')
|
||||
if (strachArr[0] != '#DN_GD') {
|
||||
return
|
||||
}
|
||||
console.log(`${TAG} udp222 on message array buffer:${str}`);
|
||||
|
||||
strachArr[28]=globalThis.chuankoMsg||'0'
|
||||
// this.stashFn(str)
|
||||
const newArr=JSON.parse(JSON.stringify(strachArr))
|
||||
// this.stashFn=()=>{}
|
||||
callback&&callback(newArr.toString())
|
||||
|
||||
} else {
|
||||
callback&&callback('')
|
||||
}
|
||||
|
||||
});
|
||||
const arrRed = [0x55, 0xaa, 0x01, 0x01, 0x02, 0x00, 0x03, 0x00];
|
||||
const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00];
|
||||
const arrGreen = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x00, 0x03, 0x01];
|
||||
const arrBlueBuffer = Array2Byte(arrBlue).buffer
|
||||
const arrRedBuffer = Array2Byte(arrRed).buffer
|
||||
const arrGreenBugger = Array2Byte(arrGreen).buffer
|
||||
//监听udp是否断开
|
||||
clearInterval(globalThis.messageTimer)
|
||||
globalThis.messageTimer = setInterval(() => {
|
||||
const lightLineUdp = globalThis.lightLineUdp
|
||||
const isJudge = globalThis.isJudge
|
||||
setTimeout(async () => {
|
||||
//程序断开
|
||||
lightLineUdp?.send(globalThis.plcUdpError ? arrRedBuffer : (isJudge ? arrGreenBugger : arrBlueBuffer));
|
||||
if (globalThis.plcUdpError) {
|
||||
// num++
|
||||
console.log(TAG,'plc udp信号丢失')
|
||||
// if(num==3){
|
||||
getUDP(globalThis.context,true)
|
||||
// await this.bindUdp()
|
||||
// await this.sendMsg('111')
|
||||
// await this.onMessage(callback)
|
||||
// num=0
|
||||
// }
|
||||
prompt.showToast({
|
||||
message: 'plc udp信号丢失',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
globalThis.plcUdpError = true;
|
||||
}, 2000)
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
closeUdp(callback) {
|
||||
this.udp.close(err => {
|
||||
hilog.info(0x0000,TAG, 'udpCLient', 'close');
|
||||
|
||||
if (err) {
|
||||
hilog.info(0x0000,TAG, 'udpCLient', 'closeonerror');
|
||||
globalThis.closeUDPSocket=false
|
||||
|
||||
} else {
|
||||
globalThis.closeUDPSocket=true
|
||||
|
||||
this.udp.getState((err, data) => {
|
||||
if (err) {
|
||||
console.log('getState fail');
|
||||
return;
|
||||
} else {
|
||||
if (!data.isisClose) {
|
||||
setTimeout(() => {
|
||||
callback()
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
console.log('getState success:' + JSON.stringify(data));
|
||||
})
|
||||
// let promise = this.udp.getState({});
|
||||
// promise.then(data => {
|
||||
//
|
||||
// console.log('getState success:' + JSON.stringify(data));
|
||||
// }).catch(err => {
|
||||
// callback()
|
||||
// console.log('getState fail');
|
||||
// });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
interface StashFunction {
|
||||
(str: string)
|
||||
}
|
||||
@ -20,12 +20,10 @@ import FileUtil from '../../common/utils/File'
|
||||
import { fillZero, string2Bytes } from '../utils/tools'
|
||||
|
||||
const TAG = '[UdpDemo.UdpClient]'
|
||||
import hilog from '@ohos.hilog';
|
||||
import prompt from '@ohos.prompt'
|
||||
import promptAction from '@ohos.promptAction';
|
||||
import { getUDP } from './GlobalUdp';
|
||||
import { dateFormat } from '../utils/tools'
|
||||
import { getSyncData } from '../service/initable';
|
||||
|
||||
|
||||
export default class UdpClientByCenter {
|
||||
@ -43,15 +41,16 @@ export default class UdpClientByCenter {
|
||||
private context
|
||||
private folderPath
|
||||
private stashFn: StashFunction
|
||||
private errorStep: number=0
|
||||
private errorStep: number = 0
|
||||
private interval
|
||||
private headLenth: number = 9
|
||||
//消息头长度
|
||||
private isWorking: Boolean = false
|
||||
private plcUdpError = false;
|
||||
private initParam
|
||||
private onMessage_1Callback:Function = ()=>{}
|
||||
public currentValue:string = ''
|
||||
private onMessage_1Callback: Function = () => {
|
||||
}
|
||||
public currentValue: string = ''
|
||||
|
||||
constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
|
||||
this.localIp = udplocalIp
|
||||
@ -68,8 +67,7 @@ export default class UdpClientByCenter {
|
||||
return this.isWorking
|
||||
}
|
||||
|
||||
rebindUdp(localIp: string, localIpPort: string, oppositeIp: string, oppositeIpPort: string)
|
||||
{
|
||||
rebindUdp(localIp: string, localIpPort: string, oppositeIp: string, oppositeIpPort: string) {
|
||||
this.localIp = localIp
|
||||
this.oppositeIp = oppositeIp
|
||||
this.localIpPort = localIpPort
|
||||
@ -90,10 +88,10 @@ export default class UdpClientByCenter {
|
||||
}).catch(err => {
|
||||
//globalThis.closeHeartSocket=true
|
||||
this.isWorking = false
|
||||
// this.writeLog({
|
||||
// time:dateFormat(new Date()),
|
||||
// PLC:`${TAG} getUDPudp rebind failed:${JSON.stringify(err)}`,
|
||||
// })
|
||||
// this.writeLog({
|
||||
// time:dateFormat(new Date()),
|
||||
// PLC:`${TAG} getUDPudp rebind failed:${JSON.stringify(err)}`,
|
||||
// })
|
||||
console.log(`${TAG} getUDPudp rebind failed:${JSON.stringify(err)}`);
|
||||
});
|
||||
}
|
||||
@ -171,15 +169,14 @@ export default class UdpClientByCenter {
|
||||
console.log('getUDPsendHeadMsg exit')
|
||||
}
|
||||
|
||||
sendMsg(msg, sendCallback?)
|
||||
{
|
||||
if (!this.isWorking ) {
|
||||
sendMsg(msg, sendCallback?) {
|
||||
if (!this.isWorking) {
|
||||
// console.log(`${TAG}getUDPudpCLient sendMsg is closed return `);
|
||||
// this.writeLog({
|
||||
// time:dateFormat(new Date()),
|
||||
// PLC:`${TAG}getUDPudpCLient sendMsg is closed return oppositeIp:${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort:${this.localIpPort}`,
|
||||
// })
|
||||
if(sendCallback) {
|
||||
if (sendCallback) {
|
||||
sendCallback()
|
||||
}
|
||||
return;
|
||||
@ -205,8 +202,8 @@ export default class UdpClientByCenter {
|
||||
// PLC:`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}${JSON.stringify(err)}`,
|
||||
// })
|
||||
promptAction.showToast({
|
||||
message:`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`,
|
||||
duration:4000
|
||||
message: `${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`,
|
||||
duration: 4000
|
||||
})
|
||||
});
|
||||
}
|
||||
@ -243,6 +240,7 @@ export default class UdpClientByCenter {
|
||||
this.stashFn = callback ? callback : () => {
|
||||
}
|
||||
}
|
||||
|
||||
//中心udp回执
|
||||
onMessage_2(callback, type?) {
|
||||
this.udp.on('message', (value, remoteInfo) => {
|
||||
@ -268,7 +266,6 @@ export default class UdpClientByCenter {
|
||||
})
|
||||
|
||||
|
||||
|
||||
// this.interval=setInterval(()=>{
|
||||
//
|
||||
// },3000)
|
||||
@ -300,16 +297,16 @@ export default class UdpClientByCenter {
|
||||
//plc
|
||||
onMessage_1(callback?) {
|
||||
this.onMessage_1Callback = callback;
|
||||
this.udp&&this.udp.on('message', this.message_1Fn);
|
||||
this.udp && this.udp.on('message', this.message_1Fn);
|
||||
}
|
||||
|
||||
closeMessage_1(){
|
||||
closeMessage_1() {
|
||||
console.info('surenjun', 'getUDP关闭udp message监听事件')
|
||||
this.udp.off('message',this.message_1Fn);
|
||||
this.udp.off('message', this.message_1Fn);
|
||||
console.info('surenjun', 'getUDP关闭udp message监听事件 成功')
|
||||
}
|
||||
|
||||
message_1Fn = (value)=>{
|
||||
message_1Fn = (value) => {
|
||||
let callback = this.onMessage_1Callback
|
||||
// 收到的是ArrayBuffer 需要进行转换解析
|
||||
this.plcUdpError = false
|
||||
@ -336,15 +333,15 @@ export default class UdpClientByCenter {
|
||||
// time:dateFormat(new Date()),
|
||||
// PLC: JSON.stringify(newArr.toString()),
|
||||
// })
|
||||
if(strachArr[83]!='4'){
|
||||
console.log('差分状态异常',strachArr[83],strachArr[92])
|
||||
if (strachArr[83] != '4') {
|
||||
console.log('差分状态异常', strachArr[83], strachArr[92])
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
time: dateFormat(new Date()),
|
||||
PLC: `${TAG}差分状态异常,${strachArr[83]},${strachArr[92]}`,
|
||||
})
|
||||
}else{
|
||||
globalThis.dialogOpen=false
|
||||
this.chafenFlag=0
|
||||
} else {
|
||||
globalThis.dialogOpen = false
|
||||
this.chafenFlag = 0
|
||||
}
|
||||
callback && callback(newArr.toString())
|
||||
this.currentValue = newArr.toString();
|
||||
@ -354,15 +351,18 @@ export default class UdpClientByCenter {
|
||||
|
||||
this.testIfUdpConnetced(callback)
|
||||
}
|
||||
async writeLog(param){
|
||||
|
||||
async writeLog(param) {
|
||||
// const fileUtil = new FileUtil(globalThis.context)
|
||||
// fileUtil.editFile(`${this.folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`)
|
||||
}
|
||||
async initPath(){
|
||||
|
||||
async initPath() {
|
||||
// const fileUtil = new FileUtil(globalThis.context)
|
||||
// const date=dateFormat(new Date).split(' ')[0]
|
||||
// this.folderPath = await fileUtil.initFolder(`/PLC/${date}`);
|
||||
}
|
||||
|
||||
//获取当前UDP信号
|
||||
getCurrentMessage = () => {
|
||||
return this.currentValue
|
||||
@ -376,7 +376,7 @@ export default class UdpClientByCenter {
|
||||
const arrRedBuffer = Array2Byte(arrRed).buffer
|
||||
const arrGreenBugger = Array2Byte(arrGreen).buffer
|
||||
let num = 0
|
||||
globalThis.dialogOpen=false
|
||||
globalThis.dialogOpen = false
|
||||
|
||||
//监听udp是否断开
|
||||
clearInterval(globalThis.messageTimer)
|
||||
@ -389,15 +389,14 @@ export default class UdpClientByCenter {
|
||||
if (this.plcUdpError) {
|
||||
num++
|
||||
this.writeLog({
|
||||
time:dateFormat(new Date()),
|
||||
time: dateFormat(new Date()),
|
||||
PLC: 'plc udp信号丢失',
|
||||
})
|
||||
console.log(TAG, 'plc udp信号丢失')
|
||||
if (num == 3) {
|
||||
getUDP(globalThis.context,true)
|
||||
globalThis.title='plc udp信号丢失'
|
||||
globalThis.type='3'
|
||||
if(!globalThis.dialogOpen){
|
||||
getUDP(globalThis.context, true)
|
||||
globalThis.title = 'plc udp信号丢失'
|
||||
globalThis.type = '3'
|
||||
if (!globalThis.dialogOpen) {
|
||||
// AppStorage.SetOrCreate('errorCode', 1);
|
||||
// if(this.errorStep!=1){
|
||||
// console.log('sys.v_valuesys.v_valuesys.v_value11221')
|
||||
@ -425,7 +424,6 @@ export default class UdpClientByCenter {
|
||||
}
|
||||
num = 0
|
||||
}
|
||||
|
||||
prompt.showToast({
|
||||
message: 'plc udp信号丢失',
|
||||
duration: 2000
|
||||
|
||||
@ -6,7 +6,7 @@ import { getCurrentTime, string2Bytes } from '../common/utils/tools';
|
||||
import { FileHelper } from '../common/service/FileHelper';
|
||||
import { getEsCarModel, getSyncData, } from '../common/service/initable';
|
||||
import FileUtil from '../common/utils/File';
|
||||
import { getUDP, getUDP2 } from '../common/utils/GlobalUdp';
|
||||
import { getUDP, getUDP2, getUDPGps2 } from '../common/utils/GlobalUdp';
|
||||
import { initJudgeUdp } from '../common/utils/UdpJudge';
|
||||
import { judgeConfig } from './judgeSDK/utils/judgeConfig';
|
||||
import { getTCP } from '../common/utils/GlobalTcp';
|
||||
@ -580,6 +580,8 @@ struct Index {
|
||||
// deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/')
|
||||
//设置plc udp 同步requesthost
|
||||
await getUDP(this.context, false)
|
||||
// A2牵引车2号导航仪
|
||||
await getUDPGps2(this.context, false)
|
||||
this.loading = false
|
||||
await getDeviceInfo(this.context)
|
||||
|
||||
@ -611,15 +613,6 @@ struct Index {
|
||||
}
|
||||
}, 1000)
|
||||
this.createAlbum()
|
||||
// clearInterval(globalThis.demo)
|
||||
// globalThis.demo= setInterval(()=>{
|
||||
// const str= {"carId":"1062","examinationRoomId":"2","videoVersion":"1.0","judgeVersion":"2023.09.30.1","shellVersion":"2023.12.13.01","host":"http://172.37.55.191:8082"}
|
||||
// initialization(str)
|
||||
// },10000)
|
||||
//下载模型
|
||||
// await this.getModel()
|
||||
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
|
||||
// globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer)
|
||||
}
|
||||
|
||||
async getModel() {
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
import router from '@ohos.router';
|
||||
import UdpClient from '../../common/utils/UdpClient';
|
||||
import FileLog from '../judgeSDK/utils/fileLog';
|
||||
import RealTime from '../compontents/judge/RealTime';
|
||||
import { GPSData, SignalData } from '../../mock';
|
||||
import { SignalDataType } from '../../model';
|
||||
import FileUtil from '../../common/utils/File'
|
||||
import { GlobalConfig } from '../../config/index'
|
||||
@Component
|
||||
export default struct SignDisplayCom {
|
||||
@State showBack: boolean = false
|
||||
@ -23,10 +19,6 @@ export default struct SignDisplayCom {
|
||||
@State interval: number = 0
|
||||
@State @Watch('outClick') outFlag: boolean = false;
|
||||
@State url: string = ''
|
||||
private timer = null
|
||||
private udpClient: UdpClient = null
|
||||
private FileLog: FileLog
|
||||
private vocObj = null;
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
import router from '@ohos.router';
|
||||
import UdpClient from '../../common/utils/UdpClient';
|
||||
import FileLog from '../judgeSDK/utils/fileLog';
|
||||
import RealTime from '../compontents/judge/RealTime';
|
||||
import { GPSData, SignalData } from '../../mock';
|
||||
import { SignalDataType } from '../../model';
|
||||
@ -22,10 +20,6 @@ export default struct SignDisplayCom {
|
||||
@State interval: number = 0
|
||||
@State @Watch('outClick') outFlag: boolean = false;
|
||||
@State url: string = ''
|
||||
private timer = null
|
||||
private udpClient: UdpClient = null
|
||||
private FileLog: FileLog
|
||||
private vocObj = null;
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
@ -232,14 +232,14 @@ export default class Judge {
|
||||
}
|
||||
}
|
||||
// 处理udp plc信号
|
||||
handleUdp = async (msg) => {
|
||||
handleUdp = async (msg, gps2) => {
|
||||
console.info('plc信号', msg)
|
||||
const {fileLog,getPlcData,usbService,isUdpEnd,isExamEnd,judgeUI} = this
|
||||
const stachArr = msg.split(',')
|
||||
if (stachArr[0] != '#DN_GD' || isUdpEnd) {
|
||||
return
|
||||
}
|
||||
const plcData = await getPlcData(msg);
|
||||
const plcData = await getPlcData(msg, gps2);
|
||||
// 4.过程数据
|
||||
await fileLog.setExamJudgeData(plcData)
|
||||
//检测到有无锡所设备接入,需要发送特定的数据,供检测
|
||||
@ -461,11 +461,11 @@ export default class Judge {
|
||||
private testKmItems: any
|
||||
private plcData: any
|
||||
// 获取plc数据
|
||||
getPlcData = async (plc: string) => {
|
||||
getPlcData = async (plc: string, gps2: string) => {
|
||||
const {fileLog,mndgStr,rmndg} = this;
|
||||
await fileLog.setPlcProgressData(plc)
|
||||
//plc字符串转化成评判初始化数据
|
||||
const tempData = await plcStrToJson(plc);
|
||||
const tempData = await plcStrToJson(plc, gps2);
|
||||
//模拟灯光回放时刻
|
||||
tempData.sensor.rmndg = rmndg;
|
||||
//模拟灯灯光灯光项目
|
||||
@ -1856,10 +1856,14 @@ export default class Judge {
|
||||
return
|
||||
}
|
||||
// 处理实时udp里的plc信号
|
||||
// globalThis.udpClient.closeMessage_1();
|
||||
let gps2 = ""
|
||||
globalThis.udpClientGps2?.onMessage_1(msg => {
|
||||
console.info('socketTag[PLC.UdpClient]', '收到udp gps2回调数据')
|
||||
gps2 = msg
|
||||
})
|
||||
globalThis.udpClient.onMessage_1(async (msg) => {
|
||||
console.info('socketTag[PLC.UdpClient]', '收到udp回调数据')
|
||||
handleUdp(msg)
|
||||
handleUdp(msg, gps2)
|
||||
const udpIndex = globalThis.udpIndex;
|
||||
if (udpIndex % 5 === 0) {
|
||||
handDistance();
|
||||
|
||||
@ -458,16 +458,22 @@ export function promptWxCode(
|
||||
}
|
||||
|
||||
// 获取plc数据
|
||||
export const plcStrToJson = async (plc: string) => {
|
||||
|
||||
export const plcStrToJson = async (plc: string, gps2: string = "") => {
|
||||
const p = plc.split(',').map((val, key) => {
|
||||
if (key !== 27 && key !== 92) {
|
||||
//@ts-ignore
|
||||
return val * 1
|
||||
return Number(val)
|
||||
} else {
|
||||
return val
|
||||
}
|
||||
});
|
||||
const p2 = gps2.split(',').map((val, key) => {
|
||||
if (key !== 27 && key !== 92) {
|
||||
return Number(val)
|
||||
} else {
|
||||
return val
|
||||
}
|
||||
});
|
||||
|
||||
let data: any = testRealExam;
|
||||
const time = await systemTime.getCurrentTime()
|
||||
const tempData = {
|
||||
@ -544,27 +550,27 @@ export const plcStrToJson = async (plc: string) => {
|
||||
// gps2:data.gps,
|
||||
gps2: {
|
||||
//办卡类型 定位差分状态
|
||||
bklx: p[56],
|
||||
dwzt: p[83],
|
||||
bklx: p2[56],
|
||||
dwzt: p2[83],
|
||||
//@ts-ignore 角度差分状态
|
||||
jdzt: p[92].split('-')[0] * 1,
|
||||
jdzt: p2[92].split('-')[0] * 1,
|
||||
//gps数据
|
||||
//gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度
|
||||
sj: time,
|
||||
jd: p[96],
|
||||
wd: p[95],
|
||||
hxj: p[90],
|
||||
fyj: p[91],
|
||||
hbg: p[85],
|
||||
gdc: p[86],
|
||||
sd: p[97],
|
||||
jd: p2[96],
|
||||
wd: p2[95],
|
||||
hxj: p2[90],
|
||||
fyj: p2[91],
|
||||
hbg: p2[85],
|
||||
gdc: p2[86],
|
||||
sd: p2[97],
|
||||
//龄期 经度因子 纬度因子 定位搜星数
|
||||
age: p[87],
|
||||
jdyz: p[89],
|
||||
wdyz: p[88],
|
||||
dwsxs: p[84] || 0,
|
||||
age: p2[87],
|
||||
jdyz: p2[89],
|
||||
wdyz: p2[88],
|
||||
dwsxs: p2[84] || 0,
|
||||
//@ts-ignore 角度搜星数
|
||||
jdsxs: p[92].split('-')[1] * 1 || 0
|
||||
jdsxs: p2[92].split('-')[1] * 1 || 0
|
||||
},
|
||||
vision: data.vision,
|
||||
radar: data.radar,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user