wangzhongjie #12

Merged
wangzhongjie merged 3 commits from wangzhongjie into main 2024-06-04 11:24:53 +08:00
13 changed files with 386 additions and 332 deletions
Showing only changes of commit da6a85f02a - Show all commits

View File

@ -260,46 +260,77 @@ export async function takePhotoFn(context) {
let fd
const devPath="/dev/ttyS3"
function openChuankouFn() {
console.log('SerialOpen in indexservice, path=' + devPath)
fd = testNapi.SerialOpen(devPath);
globalThis.num=0
globalThis.fd=fd
console.log('fdfd1111',globalThis.fd)
let parity = 0x4e; // 'N'
let ret = testNapi.SerialSet(globalThis.fd, 115200, 0, 8, 1, parity);
}
function getChuankouFnMsg() {
let timeout = 50000; // 2秒超时
let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE
console.log('fdfd',globalThis.fd)
let ret = testNapi.SerialSend(globalThis.fd, databuff);
console.log('mmmm',ret)
let revTestInfo = testNapi?.SerialRecv(globalThis.fd, timeout);
console.log('zzc 1 try send msg')
testNapi.SerialSendAsync(globalThis.fd, databuff,(ret)=>{
console.log('zzc 2 send finished')
console.log('zzc 3 try receive msg')
testNapi.SerialRecvAsync(globalThis.fd, timeout, (revTestInfo) => {
console.log('zzc 4 received msg')
console.log('revTestInfo',revTestInfo.recevedBuf.length)
console.log('revTestInfo',revTestInfo.recevedBuf.length)
const message = revTestInfo?.recevedBuf?.toString()
console.log('chuankou',message)
if (message == '') {
console.log('zzc error msg is emptry')
globalThis.num=1
console.log('zzc 9 num=3 close serial')
// clearInterval(chuankou)
testNapi.SerialClose(globalThis.fd);
globalThis.fd=null
getChuankouFn()
return
}
const msg = message?.split(',')
if(!msg?.length){
const message = revTestInfo?.recevedBuf?.toString()
console.log('chuankou',message)
if (message == '') {
return
}
const msg = message?.split(',')
if(!msg?.length){
return
}
if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) {
return
}
globalThis.chuankoMsg=msg[9]
} else if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) {
} else if(msg.length<12){
} else {
globalThis.chuankoMsg=msg[9]
}
console.log('zzc 5 sleep 1s')
setTimeout(()=>{
console.log(`x=${globalThis.num}`)
console.log('zzc 7 send next msg')
getChuankouFnMsg()
},1000)
// hilog.info(0x0000, 'testTag', 'Test NAPI SerialRecvAsync callback in');
// hilog.info(0x0000, 'testTag', 'Test NAPI SerialRecvAsync recevedLen = %{public}d', revTestInfo.recevedLen);
// hilog.info(0x0000, 'testTag', 'Test NAPI SerialRecvAsync recevedBuf = %{public}s', revTestInfo.recevedBuf.toString());
});
});
// let revTestInfo = testNapi?.SerialRecv(globalThis.fd, timeout);
}
let chuankou
export async function getChuankouFn(){
if(globalThis.fd){
return
}
openChuankouFn()
setInterval(()=>{
getChuankouFnMsg()
},1000)
// clearInterval(chuankou)
// chuankou=setInterval(()=>{
getChuankouFnMsg()
// },1000)
}

View File

@ -40,6 +40,7 @@ export async function getCarInfo() {
// }, router.RouterMode.Single);
}else {
globalThis.carInfo=res.obtainCarExamInfoRsp.body
console.log('globalThis.carInfo',JSON.stringify(globalThis.carInfo));
// globalThis.carInfo.carId=res.obtainCarExamInfoRsp.body.carId
globalThis.carInfo.plateNo = decodeURIComponent(globalThis.carInfo.plateNo)
}

View File

@ -132,10 +132,10 @@ export async function takePhoto(param, context,dir,flag=1,callback?) {
}
export async function deleteAllFileByPiC(dirName) {
//type:1 是图片 2是视频
export async function deleteAllFileByPiC(dirName,type=1) {
// const fileHelper = new FileHelper();
fileHelper.deleteFileOfAlbum(dirName,1);
fileHelper.deleteFileOfAlbum(dirName,type);
}
export async function deleteAllVideos(context,type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise<void> {

View File

@ -1,36 +1,58 @@
import TcpClient from './TcpClient';
import { getSyncData} from '../service/initable'
import hilog from '@ohos.hilog';
export async function getTCP() {
export async function getTCP(flag=false) {
getSyncData('IpConfigTable').then(async (result:Array<any>)=>{
console.log('result222',JSON.stringify(result))
if(result.length){
if(globalThis.TcpClient&&globalThis.TcpClient.closeTcp){
if(!flag){
return
}
globalThis.TcpClient.closeTcp(async ()=>{
// const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
// globalThis.TcpClient = tcpClient
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()
await globalThis.TcpClient.sendMsg(globalThis.carInfo?.carNo||'402')//1002
await globalThis.TcpClient.onMessage((val)=>{
hilog.info(0x0000, 'testTag', "valvalval1" + JSON.stringify(val));
// console.log('valvalval',val)
setTimeout(()=>{
globalThis.TcpClient.sendMsg('1002')//1002
if(val){
globalThis.TcpClient.sendMsg(globalThis.carInfo?.carNo||'402')//1002
if(val&&globalThis.udpClient&&globalThis.udpClient.sendMsg){
// const msg=val.substring(5,val.length-1)
globalThis.udpClient?.sendMsg(val)
}
},1000)
})
globalThis.TcpClient.onError(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(globalThis.carInfo?.carNo||'402')//1002
await globalThis.TcpClient.onMessage((val)=>{
hilog.info(0x0000, 'testTag', "valvalval1" + JSON.stringify(val));
// console.log('valvalval',val)
setTimeout(()=>{
globalThis.TcpClient.sendMsg(globalThis.carInfo?.carNo||'402')//1002
if(val&&globalThis.udpClient&&globalThis.udpClient.sendMsg){
// const msg=val.substring(5,val.length-1)
globalThis.udpClient?.sendMsg(val)
}
},1000)
})
})
})
}else{
}
else{
// prompt.showToast({
// message:'初始化localIp'+ result[0].localIp+ result[0].localIpPort+'oppositeIp'+result[0].oppositeIp+result[0].oppositeIpPort,
// duration: 1000
@ -39,23 +61,39 @@ export async function getTCP() {
globalThis.TcpClient = tcpClient
await globalThis.TcpClient.bindTcp()
await globalThis.TcpClient.connectTcp()
await globalThis.TcpClient.sendMsg('1002')//1002
// setInterval(()=>{
// globalThis.TcpClient.sendMsg('1002')//1002
//
// },2000)
globalThis.TcpClient.onError()
await globalThis.TcpClient.sendMsg(globalThis.carInfo?.carNo||'402')//1002
await globalThis.TcpClient.onMessage((val)=>{
hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val));
setTimeout(()=>{
globalThis.TcpClient.sendMsg('1002')//1002
if(val){
globalThis.TcpClient.sendMsg(globalThis.carInfo?.carNo||'402')//1002
if(val&&globalThis.udpClient&&globalThis.udpClient.sendMsg){
// const msg=val.substring(5,val.length-1)
globalThis.udpClient?.sendMsg(val)
}
},1000)
})
globalThis.TcpClient.onError(async()=>{
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(globalThis.carInfo?.carNo||'402')//1002
await globalThis.TcpClient.onMessage((val)=>{
hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val));
setTimeout(()=>{
globalThis.TcpClient.sendMsg(globalThis.carInfo?.carNo||'402')//1002
if(val&&globalThis.udpClient&&globalThis.udpClient.sendMsg){
// const msg=val.substring(5,val.length-1)
globalThis.udpClient?.sendMsg(val)
}
},1000)
})
})
}
// globalThis.udpClient = new UdpClient(result[0].localIp, result[0].localIpPort,result[0].oppositeIp,result[0].oppositeIpPort)

View File

@ -8,14 +8,19 @@ import {string2Bytes} from '../../common/utils/tools'
export async function sendMsg(val){
// globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val)
}
export async function getUDP() {
export async function getUDP(flag:Boolean=false) {
getSyncData('IpConfigTable').then((result:Array<any>)=>{
if(result.length){
if(!flag){
return
}
if(globalThis.udpClient&&globalThis.udpClient.closeUdp){
globalThis.udpClient.closeUdp(()=>{
globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort)
globalThis.udpClient.sendMsg('111')
globalThis.host=`http://${result[0].centerIp}:${result[0].centerPort}`
globalThis.udpClient.onError(globalThis.udpClient.onMessage?globalThis.udpClient.onMessage:()=>{})
})
}else{
@ -24,6 +29,8 @@ export async function getUDP() {
udpClient.sendMsg('111')
globalThis.udpClient = udpClient
globalThis.host=`http://${result[0].centerIp}:${result[0].centerPort}`
globalThis.udpClient.onError(globalThis.udpClient.onMessage?globalThis.udpClient.onMessage:()=>{})
}
}else{
@ -34,14 +41,18 @@ export async function getUDP() {
})
}
export async function getUDP2() {
export async function getUDP2(flag:Boolean=false) {
getSyncData('IpConfigTable').then(async (result:Array<any>)=>{
if(result.length){
if(globalThis.udpClient2&&globalThis.udpClient2.closeUdp){
if(!flag){
return
}
globalThis.udpClient2.closeUdp(async ()=>{
globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort)
globalThis.udpClient2.onMessage((val)=>{
})
globalThis.udpClient2.onError()
globalThis.udpClient2.setMsgCallBack=()=>{}
})
@ -49,6 +60,7 @@ export async function getUDP2() {
const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort)
globalThis.udpClient2 = udpClient
globalThis.udpClient2.bindUdp()
globalThis.udpClient2.onError()
globalThis.udpClient2.onMessage((val)=>{
if(val.id=='32'){
globalThis.signNum=val.body[1]

View File

@ -24,8 +24,7 @@ export default class TcpClient {
onError(callback?){
this.tcp.on('error', err => {
hilog.info(0x0000, 'testTag', "on error, err:" + JSON.stringify(err));
this.bindTcp()
this.connectTcp()
callback()
// this.closeUdp(()=>{
// this.bindUdp()
// })
@ -56,13 +55,17 @@ export default class TcpClient {
}
bindTcp() {
console.log('tcpoppositeIp',this.oppositeIp,'localIp',this.localIp)
return new Promise((resolve,reject)=>{
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => {
if (err) {
console.log('testTag tcp bind faile');
hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err));
resolve(true)
return
}
console.log('bind success');
console.log('testTag tcp bind success');
resolve(false)
})
})
@ -77,10 +80,13 @@ export default class TcpClient {
}
connectTcp(){
console.log('testTagtcpoppositeIp',this.oppositeIp,'localIp',this.localIp)
console.log('22323')
return new Promise((resolve,reject)=>{
let promise = this.tcp.connect({ address: {address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1} , timeout: 6000});
promise.then(() => {
console.log('testTagbindSuccess')
this.tcp.setExtraOptions({
keepAlive: true,
// OOBInline: true,
@ -97,13 +103,15 @@ export default class TcpClient {
});
resolve(true)
}).catch(err => {
console.log('testTagconnect,error')
resolve(false)
});
})
}
sendMsg(msg: string) {console.log('oppositeIp',this.oppositeIp)
sendMsg(msg: string) {
console.log('oppositeIp',this.oppositeIp)
return new Promise((reslove,reject)=>{
let promise = this.tcp.send({
data:msg
@ -135,19 +143,19 @@ export default class TcpClient {
// });
}
onMessage(callback) {
onMessage(callback?) {
this.tcp.on('message', value => {
// console.log('messageLengt',,value.message.length))
console.log('tcpmsg')
// console.log("on message, message:" + value.message+ ", remoteInfo:" )
if (value) {
let dataView = new DataView(value.message)
// const Arraybuffer=buffer.from(value.message, 5, dataView?.byteLength);
const Arraybuffer=value.message.slice(5, dataView?.byteLength);
callback(Arraybuffer)
callback&&callback(Arraybuffer)
}else{
callback('')
callback&&callback('')
}
// callback(value.message)
});

View File

@ -64,9 +64,9 @@ export default class UdpClient {
hilog.info(0x0000, 'udpCLient', 'bind'+ this.localIp+this.localIpPort);
let promise = this.udp.bind({
// address: '192.168.7.170', port: 20122, family: 1
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
// address: this.localIp, port: parseInt(this.localIpPort), family: 1
});
promise.then(() => {
console.log(`${TAG}udpCLient udp bind success`);
@ -78,19 +78,20 @@ export default class UdpClient {
setMsgCallBack(callback){
// this.stashFn=callback?callback:()=>{}
}
sendMsg(msg: string) {
sendMsg(msg) {
console.log('sendsnd01')
hilog.info(0x0000, 'udpCLient', 'send');
console.log('udpdiushisend')
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),
address: '192.168.7.124',
port: 20022,
// address: this.oppositeIp,
// port: parseInt(this.oppositeIpPort),
family: 1
}
});
@ -101,18 +102,25 @@ export default class UdpClient {
});
}
onError(callback?){
this.udp.on('error', err => {
hilog.info(0x0000, 'udpCLient', 'error'+ JSON.stringify(err));
this.udp.on('error',async err => {
console.log('udpdiushierroring')
hilog.info(0x0000, 'udpCLientonerror', 'error'+ JSON.stringify(err));
console.log("on error, err:" + JSON.stringify(err))
await this.bindUdp()
await this.sendMsg('111')
await this.onMessage(callback)
// callback&&callback()
// this.closeUdp(()=>{
// this.bindUdp()
// })
});
}
onMessage(callback) {
onMessage(callback?) {
this.udp.on('message', value => {
console.log('udpdiushimsg')
// 收到的是ArrayBuffer 需要进行转换解析
hilog.info(0x0000, 'udpCLient', 'onmessage');
@ -134,15 +142,16 @@ export default class UdpClient {
if (strachArr[0] != '#DN_GD') {
return
}
strachArr[28]=globalThis.chuankoMsg
console.log(`${TAG} udp222 on message array buffer:${str}`);
strachArr[28]=globalThis.chuankoMsg||'0'
// this.stashFn(str)
const newArr=JSON.parse(JSON.stringify(strachArr))
console.log('22222',strachArr[28],newArr)
// this.stashFn=()=>{}
callback(newArr.toString())
callback&&callback(newArr.toString())
} else {
callback('')
callback&&callback('')
}
console.log('messageTimeEnd')

View File

@ -68,7 +68,6 @@ export default class UdpClientByCenter {
});
}
initHeartSendMsg(param,context){
console.log('1111param',JSON.stringify(param))
this.initParam=param
this.context=context
}
@ -199,7 +198,16 @@ export default class UdpClientByCenter {
callback({id,length,body:list,sendId:this.sendId})
});
}
onError(callback?){
this.udp.on('error', err => {
console.log('udpbycenterdiushierroring')
hilog.info(0x0000, 'udpCLientBycenteronerror', 'error'+ JSON.stringify(err));
console.log("on error, err:" + JSON.stringify(err))
// this.closeUdp(()=>{
// this.bindUdp()
// })
});
}
closeUdp(callback) {
this.udp.close(err=>{
if(err){

View File

@ -223,6 +223,8 @@ export default struct Index {
}
openChuankouFn() {
console.log('SerialOpen in carcheck, path=' + this.devPath)
this.fd = testNapi.SerialOpen(this.devPath);
let parity = 0x4e; // 'N'
let ret = testNapi.SerialSet(this.fd, 115200, 0, 8, 1, parity);

View File

@ -256,7 +256,7 @@ struct Index {
getliushuiNum()
this.heartMsg()
}, 1000)
takePhotoFn(this.context)
// takePhotoFn(this.context)
//
getTCP()

View File

@ -1,64 +1,70 @@
import TopLogo from './compontents/topLogo';
import ethernet from '@ohos.net.ethernet';
import prompt from '@ohos.prompt';
import { getSyncData, upDateTableByArray } from '../common/service/initable';
import router from '@ohos.router'
import TopLogo from './compontents/topLogo'
import ethernet from '@ohos.net.ethernet';
import prompt from '@ohos.prompt'
import { upDateTableByArray} from '../common/service/initable'
import { getSyncData} from '../common/service/initable'
import { voiceService } from '../common/service/voiceService'
import { GlobalConfig } from '../config/index'
import { getUDP, getUDP2 } from '../common/utils/GlobleUdp';
import { getTCP } from '../common/utils/GlobleTcp';
@Entry
@Component
export default struct Index {
@State textList1: string[] = ['差分服务器Ip', '响应端口', '中心服务器IP', '响应端口', '子网掩码', '默认网关', 'dns', '后置机IP ', '响应端口', '前置机IP', '本地端口', '平台服务器Ip', '响应端口']
struct Index {
@State textList1: string[] = ['差分服务器Ip','响应端口','中心服务器IP','响应端口', '子网掩码','默认网关','dns','后置机IP ', '响应端口','前置机IP','本地端口','平台服务器Ip','响应端口']
// @State textList2: string[] = []
@State ratio: number = 1700 / 960
@State inputFontSize: number = 12 //12
@State inputFontSize:number=12 //12
//
// @State inputTextList1: string[] = ['192.168.7.170','8084','192.168.7.170','20122','255.255.255.0','192.168.7.1','','','114.114.114.114','112.80.35.83','11055' +
// '',]
// @State inputTextList2: string[] = ['192.168.7.124','20022']
@State inputTextList1: string[] = ['112.80.35.83', '11055', '112.80.35.83', '11052', '255.255.255.0', '192.168.7.1', '114.114.114.114', '192.168.7.124', '20022', '192.168.7.170', '20122', '112.80.35.83', '11050']
@State inputTextList1: string[] = ['112.80.35.83','11055','112.80.35.83','11052','255.255.255.0','192.168.7.1','114.114.114.114','192.168.7.124','20022','192.168.7.170','20122','112.80.35.83','11050']
// @State inputTextList2: string[] = []
// 112.80.35.83 11052
// @State inputTextList1: string[] = ['192.168.36.2','8084','192.168.36.200','20122','255.255.255.0','192.168.36.1','','','114.114.114.114','192.168.36.139','8000']
// @State inputTextList2: string[] = ['192.168.36.139','20022']
@State @Watch('outClick') outFlag: boolean = false;
scroller: Scroller = new Scroller()
private vocObj = null;
@State @Watch('outClick') outFlag: boolean = false;
private vocObj = null;
scroller: Scroller = new Scroller()
build() {
Column() {
TopLogo({ outFlag: $outFlag })
TopLogo({outFlag:$outFlag})
Column() {
Column() {
Scroll(this.scroller) {
Flex({ 'wrap': FlexWrap.Wrap }) {
ForEach(this.textList1, (item: string, index: number) => {
Scroll(this.scroller){
Flex({'wrap':FlexWrap.Wrap}) {
ForEach(this.textList1, (item:string, index:number) => {
Row() {
Text(item)
.width('40%')
.height('100%')
.fontColor('#E5CBA1')
.padding({ 'left': '35px' })
.fontSize(this.inputFontSize * this.ratio)
TextInput({ 'text': this.inputTextList1[index] ? this.inputTextList1[index] : '' })
.padding({'left': '35px'})
.fontSize(this.inputFontSize*this.ratio)
TextInput({'text':this.inputTextList1[index]?this.inputTextList1[index]: ''})
.width('50%')
.height('60%')
.fontColor('#fff')
.borderColor('#E6E0D8')
.borderRadius('10px')
.borderWidth('2px')
.fontSize(this.inputFontSize * this.ratio)
.padding({ top: 0, bottom: 0 })
.fontSize(this.inputFontSize*this.ratio)
.padding({top:0,bottom:0})
.linearGradient({
angle: 0,
colors: [[0x403C36, 0.0], [0x4D473D, 0.34], [0x3D3A34, 1.0]]
})
.onChange((value: string) => {
this.inputTextList1[index] = value
}).onChange((value: string) => {
this.inputTextList1[index]=value
})
})
}
.width('50%')
.height('16.7%')
@ -68,43 +74,28 @@ export default struct Index {
}
.width('95%')
.height('90%')
.margin({ 'top': '2%' })
.margin({'top': '2%'})
.backgroundColor('#282828')
.borderRadius('15px')
}
.width('100%')
.height('80%')
.borderRadius('25px')
Column() {
Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(() => {
upDateTableByArray('IpConfigTable', [{
udplocalIp: this.inputTextList1[9],
udplocalIpPort: this.inputTextList1[10],
udpOppositeIp: this.inputTextList1[7],
udpOppositeIpPort: this.inputTextList1[8],
tcplocalIp: this.inputTextList1[9],
tcplocalIpPort: '8088',
tcpOppositeIp: this.inputTextList1[0],
tcpOppositePort: this.inputTextList1[1],
netMask: this.inputTextList1[4],
gateway: this.inputTextList1[5],
dnsServers: this.inputTextList1[6],
centerIp: this.inputTextList1[2],
centerPort: this.inputTextList1[3]
}])
Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(()=>{
upDateTableByArray('IpConfigTable',[{udplocalIp:this.inputTextList1[9],udplocalIpPort:this.inputTextList1[10],udpOppositeIp:this.inputTextList1[7],udpOppositeIpPort:this.inputTextList1[8],tcplocalIp:this.inputTextList1[9],tcplocalIpPort:'8088',tcpOppositeIp:this.inputTextList1[0],tcpOppositePort:this.inputTextList1[1],netMask:this.inputTextList1[4],gateway:this.inputTextList1[5],dnsServers:this.inputTextList1[6],centerIp:this.inputTextList1[2],centerPort:this.inputTextList1[3]}])
ethernet.setIfaceConfig("eth0", {
mode: 0,
ipAddr: this.inputTextList1[9],
ipAddr:this.inputTextList1[9],
route: "0.0.0.0",
gateway: this.inputTextList1[5], //value.gateway网关
netMask: this.inputTextList1[4], //value.netMask网络掩码
gateway: this.inputTextList1[5],//value.gateway网关
netMask: this.inputTextList1[4],//value.netMask网络掩码
dnsServers: this.inputTextList1[6],
// domain: ""
}, (error) => {
if (error) {
prompt.showToast({
message: '设置失败' + JSON.stringify(error),
message: '设置失败'+JSON.stringify(error),
duration: 3000
});
} else {
@ -114,48 +105,50 @@ export default struct Index {
});
}
});
getUDP(true)
getUDP2(true)
getTCP(true)
})
}
.backgroundColor('#CCC4B8')
.width('100%')
.height('20%')
.borderRadius({ 'bottomLeft': '25px', 'bottomRight': '25px' })
.borderRadius({'bottomLeft':'25px','bottomRight':'25px'})
.justifyContent(FlexAlign.SpaceAround)
}
.width('75%')
.height('69.4%')
.backgroundColor('#E6E3DF')
.borderRadius('25px')
.margin({ 'top': '7%' })
.margin({'top':'7%'})
.justifyContent(FlexAlign.SpaceAround)
}
.width('100%')
.height('100%')
.backgroundImagePosition({ x: 0, y: 0 })
.backgroundImagePosition({x: 0, y: 0})
.backgroundImage($r('app.media.index_bg'))
.backgroundImageSize({ width: '100%', height: '100%' })
}
aboutToAppear() {
getSyncData('IpConfigTable').then((result: Array<any>) => {
console.log('result222', JSON.stringify(result))
if (result.length) {
console.log('tagtag', JSON.stringify(result))
this.inputTextList1[9] = result[0].udplocalIp
this.inputTextList1[10] = result[0].udplocalIpPort
this.inputTextList1[7] = result[0].udpOppositeIp
this.inputTextList1[8] = result[0].udpOppositeIpPort
getSyncData('IpConfigTable').then((result:Array<any>)=>{
console.log('result222',JSON.stringify(result))
if(result.length){
console.log('tagtag',JSON.stringify(result))
this.inputTextList1[9]=result[0].udplocalIp
this.inputTextList1[10]=result[0].udplocalIpPort
this.inputTextList1[7]=result[0].udpOppositeIp
this.inputTextList1[8]=result[0].udpOppositeIpPort
// this.inputTextList1[0]=result[0].tcplocalIp
// this.inputTextList1[13]=result[0].tcplocalIpPort
this.inputTextList1[0] = result[0].tcpOppositeIp
this.inputTextList1[1] = result[0].tcpOppositePort
this.inputTextList1[5] = result[0].gateway
this.inputTextList1[4] = result[0].netMask
this.inputTextList1[6] = result[0].dnsServers
this.inputTextList1[2] = result[0].centerIp
this.inputTextList1[3] = result[0].centerPort
this.inputTextList1[0]=result[0].tcpOppositeIp
this.inputTextList1[1]=result[0].tcpOppositePort
this.inputTextList1[5]=result[0].gateway
this.inputTextList1[4]=result[0].netMask
this.inputTextList1[6]=result[0].dnsServers
this.inputTextList1[2]=result[0].centerIp
this.inputTextList1[3]=result[0].centerPort
}
})
ethernet.getIfaceConfig("eth0", (error, value) => {
@ -173,12 +166,10 @@ export default struct Index {
})
}
onPageShow() {
console.info('Index onPageShow');
}
outClick() {
outClick(){
}
}

View File

@ -1,31 +1,32 @@
import TopLogo from './compontents/topLogo';
import FileUtil from '../common/utils/File';
import { VideoConfig } from './interfaces';
import TopLogo from './compontents/topLogo'
import FileUtil from '../common/utils/File'
import { VideoConfig } from './interfaces'
import common from '@ohos.app.ability.common';
import promptAction from '@ohos.promptAction';
import { endRecordVideo, startRecordVideo, takePhoto } from '../common/service/videoService';
import { GlobalConfig } from '../config/index';
import promptAction from '@ohos.promptAction'
import { startRecordVideo, endRecordVideo,takePhoto } from '../common/service/videoService'
import { GlobalConfig } from '../config/index'
@Entry
@Component
export default struct Index {
struct Index {
@State ratio: number = 1700 / 960
@State videoSrc: string = 'rtsp://admin12345qwe@192.168.36.94:554/h264/ch3/main/av_stream'
@State previewUri: Resource = $r('app.media.2_nor')
@State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X
@State inputFontSize: number = 10 //12
@State rocordHandleObj: any = {
rocord_handle1: 0,
rocord_handle2: 0,
rocord_handle3: 0,
rocord_handle4: 0
@State rocordHandleObj:any = {
rocord_handle1:0,
rocord_handle2:0,
rocord_handle3:0,
rocord_handle4:0
}
@State isAutoPlay: boolean = true
@State showFlag: boolean = false
private vocObj = null;
@State showControls: boolean = false
private fileUtil: FileUtil
@State @Watch('outClick') outFlag: boolean = false;
@State oldParam: VideoConfig = {
videoNum: '1',
videoNum:'1',
spls: '1',
wz: '0,0',
faceFlag: false,
@ -50,14 +51,14 @@ export default struct Index {
dolt: '',
fontSize: '',
rlls: '1',
spzd4: false,
spzd3: false,
spzd2: false,
spzd1: false,
zdyz: '5',
spzd4:false,
spzd3:false,
spzd2:false,
spzd1:false,
zdyz:'5',
}
@State param: VideoConfig = {
videoNum: '1',
videoNum:'1',
spls: '1',
wz: '0,0',
faceFlag: false,
@ -82,31 +83,30 @@ export default struct Index {
dolt: '',
fontSize: '',
rlls: '1',
spzd4: false,
spzd3: false,
spzd2: false,
spzd1: false,
zdyz: '5',
spzd4:false,
spzd3:false,
spzd2:false,
spzd1:false,
zdyz:'5',
}
@State openFlag: boolean = true
@State lsArr: Array<any> = [
{ key: '第一路' },
{ key: '第二路' },
{ key: '第三路' },
{ key: '第四路' },
{key:'第一路'},
{key:'第二路'},
{key:'第三路'},
{key:'第四路'},
]
private vocObj = null;
private fileUtil: FileUtil
private context = getContext(this) as common.UIAbilityContext;
private controller1: VideoController = new VideoController()
private controller2: VideoController = new VideoController()
private controller3: VideoController = new VideoController()
private controller4: VideoController = new VideoController()
@State videoArr: Array<any> = [
{ td: 'td1', controller: this.controller1, src: '' },
{ td: 'td2', controller: this.controller2, src: '' },
{ td: 'td3', controller: this.controller3, src: '' },
{ td: 'td4', controller: this.controller4, src: '' },
{td:'td1',controller:this.controller1,src:''},
{td:'td2',controller:this.controller2,src:''},
{td:'td3',controller:this.controller3,src:''},
{td:'td4',controller:this.controller4,src:''},
]
private inputController: TextInputController = new TextInputController()
@ -114,8 +114,8 @@ export default struct Index {
Column() {
TopLogo({ outFlag: $outFlag })
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row }) {
ForEach(this.videoArr, (item, index) => {
Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row}) {
ForEach(this.videoArr,(item,index)=>{
Video({
src: this.openFlag ? `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param[item.td]}/main/av_stream` : '',
currentProgressRate: this.curRate,
@ -128,7 +128,7 @@ export default struct Index {
.controls(this.showControls)
.margin(10 * this.ratio)
})
}.margin({ top: 37 * this.ratio, left: 30 * this.ratio }).width(600 * this.ratio).height(600 * this.ratio)
}.margin({ top: 37 * this.ratio, left: 30 * this.ratio }).width(600*this.ratio).height(600*this.ratio)
Column() {
Image($r('app.media.shezhi'))
@ -170,9 +170,8 @@ export default struct Index {
.margin({ bottom: 10 * this.ratio })
.onClick(() => {
for (let i = 1; i <= 4; i++) {
console.log('rocord_handle', i, JSON.stringify(this.rocordHandleObj))
console.log('rocord_handle',i,JSON.stringify(this.rocordHandleObj))
if (this.rocordHandleObj['rocord_handle'+i]) {
console.log('ttttt', i)
endRecordVideo(this.rocordHandleObj['rocord_handle'+i])
this.rocordHandleObj['rocord_handle'+i] = 0
}
@ -186,16 +185,16 @@ export default struct Index {
.width(215 * this.ratio)
.height(64 * this.ratio)
.onClick(async () => {
const arr = ['1', '2', '3', '4']
if (!arr.includes(this.param.pztd)) {
const arr=['1','2','3','4']
if(!arr.includes(this.param.pztd)){
promptAction.showToast({
message: '请填写正确的拍照通道',
duration: 3000
})
return
}
try {
await takePhoto(this.param, this.context, 'pz/')
try{
await takePhoto(this.param,this.context,'pz/')
promptAction.showToast({
message: '抓图完成',
duration: 3000
@ -204,8 +203,8 @@ export default struct Index {
// console.log('daihai err: ' + err)
// })
} catch (error) {
console.log('daihai', error)
}catch (error){
console.log('daihai',error)
}
})
@ -320,10 +319,9 @@ export default struct Index {
.width(34 * this.ratio)
.height(26 * this.ratio)
.fontSize(this.inputFontSize * this.ratio)
.margin({ left: 10 * this.ratio, right: 15 * this.ratio })
.onChange((value: string) => {
this.param.zdyz = value
})
.margin({ left: 10 * this.ratio, right: 15 * this.ratio }).onChange((value: string) => {
this.param.zdyz = value
})
// Text('k').fontColor('#333333').fontSize(16 * this.ratio)
// Text('链接类型').fontColor('#333333').fontSize(16 * this.ratio)
// TextInput({ text: this.param.ljlx, controller: this.inputController })
@ -341,7 +339,6 @@ export default struct Index {
Row() {
Row() {
}.width(70 * this.ratio)
Text('IP地址')
.width(158 * this.ratio)
.fontSize(16 * this.ratio)
@ -374,7 +371,7 @@ export default struct Index {
.textAlign(TextAlign.Center)
}
ForEach(this.lsArr, (item, index) => {
ForEach(this.lsArr,(item,index)=>{
Row() {
Text(item.key)
.width(70 * this.ratio)
@ -392,7 +389,7 @@ export default struct Index {
.onChange((value: string) => {
this.param.ip = value
})
TextInput({ text: this.param['td'+(Number(index) + 1)], controller: this.inputController })
TextInput({ text: this.param['td'+(Number(index)+1)], controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(96 * this.ratio)
@ -401,7 +398,7 @@ export default struct Index {
.margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize * this.ratio)
.onChange((value: string) => {
this.param['td'+(Number(index) + 1)] = value
this.param['td'+(Number(index)+1)] = value
})
TextInput({ text: this.param.userName, controller: this.inputController })
.type(InputType.Normal)
@ -501,7 +498,7 @@ export default struct Index {
.width(22 * this.ratio)
.height(22 * this.ratio)
.onChange((value: boolean) => {
this.param.spzd1 = value
this.param.spzd1=value
})
Text('一路').fontSize(16 * this.ratio).fontColor('#333333')
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
@ -509,7 +506,7 @@ export default struct Index {
.width(22 * this.ratio)
.height(22 * this.ratio)
.onChange((value: boolean) => {
this.param.spzd2 = value
this.param.spzd2=value
})
Text('二路').fontSize(16 * this.ratio).fontColor('#333333')
}
@ -520,7 +517,7 @@ export default struct Index {
.width(22 * this.ratio)
.height(22 * this.ratio)
.onChange((value: boolean) => {
this.param.spzd3 = value
this.param.spzd3=value
})
Text('三路').fontSize(16 * this.ratio).fontColor('#333333')
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
@ -528,7 +525,7 @@ export default struct Index {
.width(22 * this.ratio)
.height(22 * this.ratio)
.onChange((value: boolean) => {
this.param.spzd4 = value
this.param.spzd4=value
})
Text('四路').fontSize(16 * this.ratio).fontColor('#333333')
}
@ -623,31 +620,27 @@ export default struct Index {
this.fileUtil = fileUtil
this.getVideoConfig()
}
async getfilehandleCode(td) {
const record_handle = await startRecordVideo(this.param, td, this.context, 'lp')
this.rocordHandleObj['rocord_handle'+td] = record_handle
async getfilehandleCode(td){
const record_handle = await startRecordVideo(this.param,td,this.context,'lp')
this.rocordHandleObj['rocord_handle'+td]=record_handle
}
outClick() {
this.openFlag = false
}
sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
async onPageShow() {
}
async getVideoConfig() {
const data = await this.fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt');
const data = await this.fileUtil.readFile(GlobalConfig.comoonfileWriteAddress+'/config/config3.txt');
this.oldParam = JSON.parse(data)
this.param = JSON.parse(data)
}
async writeConfig() {
this.oldParam = JSON.parse(JSON.stringify(this.param))
this.videoArr = JSON.parse(JSON.stringify(this.videoArr))
console.log('kkkk', JSON.stringify(this.param))
this.videoArr=JSON.parse(JSON.stringify(this.videoArr))
console.log('kkkk',JSON.stringify(this.param))
const folderPath = await this.fileUtil.initFolder(`/config`);
this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(this.param), 'overWrite')
this.showFlag = false

View File

@ -1,65 +1,65 @@
import router from '@ohos.router';
import router from '@ohos.router'
import UdpClient from '../../common/utils/UdpClient';
import FileLog from '../judgeSDK/utils/file-log';
import SerialPortClient from '../../common/utils/SerialPortClient';
import RealTime from '../compontents/judge/real-time';
import FileLog from '../judgeSDK/utils/file-log'
import { voiceService } from '../../common/service/voiceService'
import prompt from '@ohos.prompt'
import RealTime from '../compontents/judge/real-time'
@Component
export default struct SignDisplayCom {
struct SignDisplayCom {
constructor() {
super()
}
@State showBack: boolean = false
@State scaleNum: number = 1
@State msg: string = ''
@State signArr: Array<any> = []
@State sjxhColum: Array<any> = [
{ key: "左方向灯", value: "0" },
{ key: "右方向灯", value: "0" },
{ key: "喇叭", value: "0" },
{ key: "点火1", value: "0" },
{ key: "点火2", value: "0" },
{ key: "近光灯", value: "0" },
{ key: "远光灯", value: "0" },
{ key: "示廓灯", value: "0" },
{ key: "雾灯", value: "0" },
{ key: "雨刮器", value: "0" },
{ key: "脚刹", value: "0" },
{ key: "手刹", value: "0" },
{ key: "主驾驶门", value: "0" },
{ key: "离合", value: "0" },
{ key: "副刹车", value: "0" },
{ key: "安全带", value: "0" },
{ key: "双跳灯", value: "0" },
{ key: "车速", value: "0" },
{ key: "档位", value: "0" },
{ key: "超声波1", value: "0" },
{ key: "超声波2", value: "0" },
{ key: "NC", value: "0" },
{ key: "SA15", value: "0" },
{ key: "其他门", value: "0" },
{ key: "转速过高", value: "0" },
{ key: "累计脉冲", value: "0" },
{ key: "熄火次数", value: "0" },
{ key: "发动机转速", value: "0" },
{ key: "方向盘角度", value: "0" },
{ key: "超声波3", value: "0" },
{ key: "超声波4", value: "0" },
{ key: "触摸1", value: "0" },
{ key: "触摸2", value: "0" },
{ key: "触摸3", value: "0" },
{ key: "SCIO", value: "0" },
{ key: "SC1A_C", value: "0" },
{ key: "SC1B_C", value: "0" },
{ key: "SC2A_C", value: "0" },
{ key: "SC2B_C", value: "0" },
{ key: "SC3A_C", value: "0" },
{ key: "SC3B_C", value: "0" },
{ key: "SC4A_C", value: "0" },
{ key: "SC4B_C", value: "0" },
{ key: "SC5A_C", value: "0" },
{ key: "SC5B_C", value: "0" },
{ key: "SC6A_C", value: "0" },
{ key: "SC6B_C", value: "0" },
]
@State GPSColum: Array<any> = [
{ key: '左方向灯', value: '0' }, { key: '右方向灯', value: '0' }, {
key: '喇叭',
value: '0'
}, { key: '点火1', value: '0' }, { key: '点火2', value: '0' }, { key: '近光灯', value: '0' }, {
key: '远光灯',
value: '0'
}, { key: '示廓灯', value: '0' }, { key: '雾灯', value: '0' }, { key: '雨刮器', value: '0' }, {
key: '脚刹',
value: '0'
}, { key: '手刹', value: '0' }, { key: '主驾驶门', value: '0' }, { key: '离合', value: '0' }, {
key: '副刹车',
value: '0'
}, {
key: '安全带',
value: '0'
}, { key: '双跳灯', value: '0' }, { key: '车速', value: '0' }, { key: '档位', value: '0' }, {
key: '超声波1',
value: '0'
}, {
key: '超声波2',
value: '0'
}, {
key: 'NC',
value: '0'
}, { key: 'SA15', value: '0' }, { key: '其他门', value: '0' }, { key: '转速过高', value: '0' }, {
key: '累计脉冲',
value: '0'
}, { key: '熄火次数', value: '0' }, { key: '发动机转速', value: '0' }, { key: '方向盘角度', value: '0' }, {
key: '超声波3',
value: '0'
}, { key: '超声波4', value: '0' }, { key: '触摸1', value: '0' }, { key: '触摸2', value: '0' }, {
key: '触摸3',
value: '0'
}, { key: 'SCIO', value: '0' }
, { key: 'SC1A_C', value: '0' }, { key: 'SC1B_C', value: '0' }, { key: 'SC2A_C', value: '0' }, {
key: 'SC2B_C',
value: '0'
}, { key: 'SC3A_C', value: '0' }, { key: 'SC3B_C', value: '0' }, { key: 'SC4A_C', value: '0' }, {
key: 'SC4B_C',
value: '0'
}, { key: 'SC5A_C', value: '0' }, { key: 'SC5B_C', value: '0' }, { key: 'SC6A_C', value: '0' }, {
key: 'SC6B_C',
value: '0'
}]
@State GPSColum:Array<any>=[
{ key: '状态', value: '0' },
{ key: '收星数', value: '0' },
{ key: '海拔高', value: '0' },
@ -80,21 +80,17 @@ export default struct SignDisplayCom {
@State gpsActive: number = 1
@Prop active: number = 0
@State msgStr: string = ''
@State interval: any = ''
@State interval: any=''
@State @Watch('outClick') outFlag: boolean = false;
@State url: string = ''
private timer = null
private udpClient: UdpClient = null
private FileLog: FileLog
private vocObj = null;
constructor() {
super()
}
@State url: string = ''
// @State gpsList: Array<any> = []
build() {
Column() {
Column(){
Column() {
// TopLogo({outFlag:$outFlag})
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
@ -150,7 +146,7 @@ export default struct SignDisplayCom {
}
Row() {
if (this.showBack) {
if(this.showBack){
Image($r('app.media.topB_back')).width('16.7%').height('12.2%')
.onClick(() => {
router.back()
@ -292,14 +288,8 @@ export default struct SignDisplayCom {
Text('海拔高:' + this.signArr[85]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio)
Text('高度差:' + this.signArr[86]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio)
Text('龄期:' + this.signArr[87]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio)
Text('维度因子:' + this.signArr[88])
.fontColor('#FFB433')
.fontSize(14 * this.ratio)
.height(18 * this.ratio)
Text('经度因子:' + this.signArr[89])
.fontColor('#FFB433')
.fontSize(14 * this.ratio)
.height(18 * this.ratio)
Text('维度因子:' + this.signArr[88]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio)
Text('经度因子:' + this.signArr[89]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio)
Text('航向角:' + this.signArr[90]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio)
Text('俯仰角:' + this.signArr[91]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio)
Text('航向角状态-收星数:' + this.signArr[92])
@ -332,10 +322,10 @@ export default struct SignDisplayCom {
Row() {
Text('GPS').fontColor(this.gpsActive == 0 ? '#2D3C5A' : '#fff')
}
.width(316 * this.ratio)
.height(24 * this.ratio)
.width(316*this.ratio)
.height(24*this.ratio)
.backgroundColor(this.gpsActive == 0 ? '#fff' : '#1A1A1A')
.margin({ left: 10 * this.ratio, right: 10 * this.ratio })
.margin({ left: 10*this.ratio, right: 10*this.ratio })
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.gpsActive = 0
@ -351,8 +341,7 @@ export default struct SignDisplayCom {
// .onClick(() => {
// this.gpsActive = 1
// })
}.margin({ top: 10 * this.ratio })
}.margin({ top: 10*this.ratio })
Flex({ direction: FlexDirection.Column }) {
ForEach(this.GPSColum, (item) => {
Column() {
@ -364,7 +353,7 @@ export default struct SignDisplayCom {
})
}
}
.width(168 * 2 * this.ratio)
.width(168 *2* this.ratio)
.height(380 * this.ratio)
.backgroundColor('#282828')
.margin({ top: 6 * this.ratio, left: 10 * this.ratio })
@ -375,8 +364,8 @@ export default struct SignDisplayCom {
Row() {
RealTime({
width: Math.floor(550 * this.ratio),
height: Math.floor(380 * this.ratio),
width:Math.floor(550 * this.ratio),
height:Math.floor(380 * this.ratio),
})
}
.width(550 * this.ratio)
@ -402,47 +391,33 @@ export default struct SignDisplayCom {
aboutToDisappear() {
clearInterval(this.interval)
}
aboutToAppear() {
aboutToAppear(){
this.ratio = this.ratio * (this.scaleNum || 1);
const that = this
const {showBack,getSignal} = this
const serialPortClient = new SerialPortClient()
serialPortClient.openSerial()
serialPortClient.SerialSet()
this.interval = setInterval(() => {
serialPortClient.SerialSend()
const data = serialPortClient.SerialRecv()
// if (data?.recevedLen) {
// const msg = data.msg.split(',')
// if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) {
// return
// }
// this.sjxhColum[18].value = msg[9]
// }
}, 1000)
if (showBack) {
if(showBack){
globalThis.udpClient.onMessage((msg) => {
console.log('msgmsg', msg)
if (msg) {
console.log('msgmsg',msg)
if(msg){
getSignal(msg)
}
})
} else {
}else{
clearInterval(globalThis.signalTimer)
globalThis.signalTimer = setInterval(() => {
globalThis.signalTimer = setInterval(()=>{
const msgStr = globalThis.msgStr
if (msgStr) {
if(msgStr){
getSignal(msgStr)
}
}, 200)
},200)
}
}
onPageShow() {
console.info('SURENJUN', 123)
console.info('SURENJUN',123)
// this.vocObj = new voiceService(async (status, val) => {
// if (status == 'idle') {
// if (this.url == 'back') {
@ -452,34 +427,21 @@ export default struct SignDisplayCom {
// }
// }
// });
const serialPortClient = new SerialPortClient()
serialPortClient.openSerial()
serialPortClient.SerialSet()
const getSignal = this.getSignal;
this.interval = setInterval(() => {
serialPortClient.SerialSend()
const data = serialPortClient.SerialRecv()
// if (data.recevedLen) {
// const msg = data.msg.split(',')
// if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) {
// return
// }
// this.sjxhColum[18].value = msg[9]
// }
}, 1000)
const that = this
const showBack = this.showBack;
if (showBack) {
if(showBack){
globalThis.udpClient.onMessage((msg) => {
getSignal(msg)
})
} else {
}else{
clearInterval(globalThis.signalTimer)
globalThis.signalTimer = setInterval(() => {
globalThis.signalTimer = setInterval(()=>{
//TODO 临时方案
const msgStr = globalThis.msgStr
getSignal(msgStr)
}, 200)
},200)
}
// this.getDeviceNo();
// this.initTime();
@ -488,17 +450,17 @@ export default struct SignDisplayCom {
// globalThis.isRegist = false; //是否已经注册
}
getSignal = (msg) => {
console.log('msgmsgmsg', msg)
getSignal= (msg)=> {
console.log('msgmsgmsg',msg)
const that = this;
that.msg = msg
const strachArr = msg.split(',')
const strachArr=msg.split(',')
if (strachArr[0] != '#DN_GD') {
return
}
this.signArr = strachArr
for (let i = 0; i <= 12; i++) {
for (let i = 0;i <= 12; i++) {
this.sjxhColum[i].value = this.signArr[i+2]
}
@ -507,7 +469,7 @@ export default struct SignDisplayCom {
this.sjxhColum[15].value = this.signArr[19]
this.sjxhColum[16].value = this.signArr[20]
this.sjxhColum[17].value = this.signArr[23] //车速
this.sjxhColum[18].value = this.signArr[28]
this.sjxhColum[18].value=this.signArr[28]
this.sjxhColum[19].value = this.signArr[29]
this.sjxhColum[20].value = this.signArr[30]
this.sjxhColum[21].value = this.signArr[15] //NC
@ -523,11 +485,11 @@ export default struct SignDisplayCom {
this.sjxhColum[31].value = this.signArr[33]
this.sjxhColum[32].value = this.signArr[34]
this.sjxhColum[33].value = this.signArr[35]
for (let i = 34; i <= 46; i++) {
for (let i = 34;i <= 46; i++) {
this.sjxhColum[i].value = this.signArr[i+2]
}
let t = 0
for (let i = 83; i <= 97; i++) {
let t=0
for (let i = 83;i <= 97; i++) {
this.GPSColum[t].value = this.signArr[i]
t++
}
@ -535,7 +497,6 @@ export default struct SignDisplayCom {
that.signArr = JSON.parse(JSON.stringify((this.signArr)))
that.GPSColum = JSON.parse(JSON.stringify((this.GPSColum)))
}
outClick() {
}
@ -543,7 +504,6 @@ export default struct SignDisplayCom {
// this.FileLog.initFileLogo('d .0ateLog')
// this.FileLog.createFile('123')
}
// getDeviceNo() {
// globalThis.deviceNo = 'FE-FC-FE-7C-5C-72'; //设备号
// }
@ -561,3 +521,4 @@ export default struct SignDisplayCom {
// }
}
export default SignDisplayCom