Compare commits

..

No commits in common. "e65c48f1ebecb9ce14b84f185882deea3cba20f7" and "b9a69d2d84d1bb421853fbbf73d679e683c4c24f" have entirely different histories.

15 changed files with 316 additions and 381 deletions

View File

@ -260,77 +260,46 @@ export async function takePhotoFn(context) {
let fd let fd
const devPath="/dev/ttyS3" const devPath="/dev/ttyS3"
function openChuankouFn() { function openChuankouFn() {
console.log('SerialOpen in indexservice, path=' + devPath)
fd = testNapi.SerialOpen(devPath); fd = testNapi.SerialOpen(devPath);
globalThis.num=0
globalThis.fd=fd globalThis.fd=fd
console.log('fdfd1111',globalThis.fd) console.log('fdfd1111',globalThis.fd)
let parity = 0x4e; // 'N' let parity = 0x4e; // 'N'
let ret = testNapi.SerialSet(globalThis.fd, 115200, 0, 8, 1, parity); let ret = testNapi.SerialSet(globalThis.fd, 115200, 0, 8, 1, parity);
} }
function getChuankouFnMsg() { function getChuankouFnMsg() {
let timeout = 50000; // 2秒超时 let timeout = 50000; // 2秒超时
let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE
console.log('fdfd',globalThis.fd) console.log('fdfd',globalThis.fd)
console.log('zzc 1 try send msg') let ret = testNapi.SerialSend(globalThis.fd, databuff);
testNapi.SerialSendAsync(globalThis.fd, databuff,(ret)=>{ console.log('mmmm',ret)
console.log('zzc 2 send finished') let revTestInfo = testNapi?.SerialRecv(globalThis.fd, timeout);
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)
const message = revTestInfo?.recevedBuf?.toString() console.log('revTestInfo',revTestInfo.recevedBuf.length)
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){
} else if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { 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.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(){ export async function getChuankouFn(){
if(globalThis.fd){ if(globalThis.fd){
return return
} }
openChuankouFn() openChuankouFn()
// clearInterval(chuankou) setInterval(()=>{
// chuankou=setInterval(()=>{ getChuankouFnMsg()
getChuankouFnMsg() },1000)
// },1000)
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -68,6 +68,7 @@ export default class UdpClientByCenter {
}); });
} }
initHeartSendMsg(param,context){ initHeartSendMsg(param,context){
console.log('1111param',JSON.stringify(param))
this.initParam=param this.initParam=param
this.context=context this.context=context
} }
@ -198,16 +199,7 @@ export default class UdpClientByCenter {
callback({id,length,body:list,sendId:this.sendId}) 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) { closeUdp(callback) {
this.udp.close(err=>{ this.udp.close(err=>{
if(err){ if(err){

View File

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

View File

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

View File

@ -1,3 +1,5 @@
import UdpClient from '../common/utils/UdpClient';
import FileLog from './judgeSDK/utils/file-log';
import signDisplayCom from './compontents/signDisplayCom'; import signDisplayCom from './compontents/signDisplayCom';
@Entry @Entry
@ -5,54 +7,50 @@ import signDisplayCom from './compontents/signDisplayCom';
export default struct Index { export default struct Index {
@State signArr: Array<any> = [] @State signArr: Array<any> = []
@State sjxhColum: Array<any> = [ @State sjxhColum: Array<any> = [
{ key: '左方向灯', value: '0' }, { key: '左方向灯', value: '0' }, { key: '右方向灯', value: '0' }, {
{ key: '右方向灯', value: '0' }, key: '喇叭',
{ key: '喇叭', value: '0' }, value: '0'
{ key: '点火1', value: '0' }, }, { key: '点火1', value: '0' }, { key: '点火2', value: '0' }, { key: '近光灯', value: '0' }, {
{ key: '点火2', value: '0' }, key: '远光灯',
{ key: '近光灯', value: '0' }, value: '0'
{ key: '远光灯', value: '0' }, }, { key: '示廓灯', value: '0' }, { key: '雾灯', value: '0' }, { key: '雨刮器', value: '0' }, {
{ key: '示廓灯', value: '0' }, key: '脚刹',
{ key: '雾灯', value: '0' }, value: '0'
{ key: '雨刮器', value: '0' }, }, { key: '手刹', value: '0' }, { key: '主驾驶门', value: '0' }, { key: '离合', value: '0' }, {
{ key: '脚刹', value: '0' }, key: '副刹车',
{ key: '手刹', value: '0' }, value: '0'
{ key: '主驾驶门', value: '0' }, }, {
{ key: '离合', value: '0' }, key: '安全带',
{ key: '副刹车', value: '0' }, value: '0'
{ key: '安全带', value: '0' }, }, { key: '双跳灯', value: '0' }, { key: '车速', value: '0' }, { key: '档位', value: '0' }, {
{ key: '双跳灯', value: '0' }, key: '超声波1',
{ key: '车速', value: '0' }, value: '0'
{ key: '档位', value: '0' }, }, {
{ key: '超声波1', value: '0' }, key: '超声波2',
{ key: '超声波2', value: '0' }, value: '0'
{ key: 'NC', value: '0' }, }, {
{ key: 'SA15', value: '0' }, key: 'NC',
{ key: '其他门', value: '0' }, value: '0'
{ key: '转速过高', value: '0' }, }, { key: 'SA15', value: '0' }, { key: '其他门', value: '0' }, { key: '转速过高', value: '0' }, {
{ key: '累计脉冲', value: '0' }, key: '累计脉冲',
{ key: '熄火次数', value: '0' }, value: '0'
{ key: '发动机转速', value: '0' }, }, { key: '熄火次数', value: '0' }, { key: '发动机转速', value: '0' }, { key: '方向盘角度', value: '0' }, {
{ key: '方向盘角度', value: '0' }, key: '超声波3',
{ key: '超声波3', value: '0' }, value: '0'
{ key: '超声波4', value: '0' }, }, { key: '超声波4', value: '0' }, { key: '触摸1', value: '0' }, { key: '触摸2', value: '0' }, {
{ key: '触摸1', value: '0' }, key: '触摸3',
{ key: '触摸2', value: '0' }, value: '0'
{ key: '触摸3', value: '0' }, }, { key: 'SCIO', value: '0' }
{ key: 'SCIO', value: '0' }, , { key: 'SC1A_C', value: '0' }, { key: 'SC1B_C', value: '0' }, { key: 'SC2A_C', value: '0' }, {
{ key: 'SC1A_C', value: '0' }, key: 'SC2B_C',
{ key: 'SC1B_C', value: '0' }, value: '0'
{ key: 'SC2A_C', value: '0' }, }, { key: 'SC3A_C', value: '0' }, { key: 'SC3B_C', value: '0' }, { key: 'SC4A_C', value: '0' }, {
{ key: 'SC2B_C', value: '0' }, key: 'SC4B_C',
{ key: 'SC3A_C', value: '0' }, value: '0'
{ key: 'SC3B_C', value: '0' }, }, { key: 'SC5A_C', value: '0' }, { key: 'SC5B_C', value: '0' }, { key: 'SC6A_C', value: '0' }, {
{ key: 'SC4A_C', value: '0' }, key: 'SC6B_C',
{ key: 'SC4B_C', value: '0' }, 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> = [ @State GPSColum: Array<any> = [
{ key: '状态', value: '0' }, { key: '状态', value: '0' },
{ key: '收星数', value: '0' }, { key: '收星数', value: '0' },
@ -76,6 +74,10 @@ export default struct Index {
@State msg: string = '' @State msg: string = ''
@State @Watch('outClick') outFlag: boolean = false; @State @Watch('outClick') outFlag: boolean = false;
@State url: string = '' @State url: string = ''
private timer = null
private udpClient: UdpClient = null
private FileLog: FileLog
private vocObj = null;
// @State gpsList: Array<any> = [] // @State gpsList: Array<any> = []
build() { build() {

View File

@ -2,12 +2,10 @@ import TopLogo from './compontents/topLogo';
import ethernet from '@ohos.net.ethernet'; import ethernet from '@ohos.net.ethernet';
import prompt from '@ohos.prompt'; import prompt from '@ohos.prompt';
import { getSyncData, upDateTableByArray } from '../common/service/initable'; import { getSyncData, upDateTableByArray } from '../common/service/initable';
import { getUDP, getUDP2 } from '../common/utils/GlobalUdp';
import { getTCP } from '../common/utils/GlobalTcp';
@Entry @Entry
@Component @Component
struct Index { export default struct Index {
@State textList1: string[] = ['差分服务器Ip', '响应端口', '中心服务器IP', '响应端口', '子网掩码', '默认网关', 'dns', '后置机IP ', '响应端口', '前置机IP', '本地端口', '平台服务器Ip', '响应端口'] @State textList1: string[] = ['差分服务器Ip', '响应端口', '中心服务器IP', '响应端口', '子网掩码', '默认网关', 'dns', '后置机IP ', '响应端口', '前置机IP', '本地端口', '平台服务器Ip', '响应端口']
// @State textList2: string[] = [] // @State textList2: string[] = []
@State ratio: number = 1700 / 960 @State ratio: number = 1700 / 960
@ -116,9 +114,6 @@ struct Index {
}); });
} }
}); });
getUDP(true)
getUDP2(true)
getTCP(true)
}) })
} }
.backgroundColor('#CCC4B8') .backgroundColor('#CCC4B8')

View File

@ -7,6 +7,7 @@ import USER from '../common/constants/USER';
import { dateFormat, getCurrentTime, string2Bytes } from '../common/utils/tools'; import { dateFormat, getCurrentTime, string2Bytes } from '../common/utils/tools';
import MA_SYSSET from '../common//constants/MA_SYSSET'; import MA_SYSSET from '../common//constants/MA_SYSSET';
import FaceCompare from './compontents/FaceCompareByhaikang'; import FaceCompare from './compontents/FaceCompareByhaikang';
// import { initJudgeUdp } from '../common/utils/UdpJudge'
import { writeObjectOut } from '../api/judge'; import { writeObjectOut } from '../api/judge';
import testNapi from '@ohos.idcard'; import testNapi from '@ohos.idcard';
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';

View File

@ -1,32 +1,31 @@
import TopLogo from './compontents/topLogo' import TopLogo from './compontents/topLogo';
import FileUtil from '../common/utils/File' import FileUtil from '../common/utils/File';
import { VideoConfig } from './interfaces' import { VideoConfig } from './interfaces';
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
import promptAction from '@ohos.promptAction' import promptAction from '@ohos.promptAction';
import { startRecordVideo, endRecordVideo,takePhoto } from '../common/service/videoService' import { endRecordVideo, startRecordVideo, takePhoto } from '../common/service/videoService';
import { GlobalConfig } from '../config/index' import { GlobalConfig } from '../config/index';
@Entry @Entry
@Component @Component
struct Index { export default struct Index {
@State ratio: number = 1700 / 960 @State ratio: number = 1700 / 960
@State videoSrc: string = 'rtsp://admin12345qwe@192.168.36.94:554/h264/ch3/main/av_stream' @State videoSrc: string = 'rtsp://admin12345qwe@192.168.36.94:554/h264/ch3/main/av_stream'
@State previewUri: Resource = $r('app.media.2_nor') @State previewUri: Resource = $r('app.media.2_nor')
@State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X
@State inputFontSize: number = 10 //12 @State inputFontSize: number = 10 //12
@State rocordHandleObj:any = { @State rocordHandleObj: any = {
rocord_handle1:0, rocord_handle1: 0,
rocord_handle2:0, rocord_handle2: 0,
rocord_handle3:0, rocord_handle3: 0,
rocord_handle4:0 rocord_handle4: 0
} }
@State isAutoPlay: boolean = true @State isAutoPlay: boolean = true
@State showFlag: boolean = false @State showFlag: boolean = false
private vocObj = null;
@State showControls: boolean = false @State showControls: boolean = false
private fileUtil: FileUtil
@State @Watch('outClick') outFlag: boolean = false; @State @Watch('outClick') outFlag: boolean = false;
@State oldParam: VideoConfig = { @State oldParam: VideoConfig = {
videoNum:'1', videoNum: '1',
spls: '1', spls: '1',
wz: '0,0', wz: '0,0',
faceFlag: false, faceFlag: false,
@ -51,14 +50,14 @@ struct Index {
dolt: '', dolt: '',
fontSize: '', fontSize: '',
rlls: '1', rlls: '1',
spzd4:false, spzd4: false,
spzd3:false, spzd3: false,
spzd2:false, spzd2: false,
spzd1:false, spzd1: false,
zdyz:'5', zdyz: '5',
} }
@State param: VideoConfig = { @State param: VideoConfig = {
videoNum:'1', videoNum: '1',
spls: '1', spls: '1',
wz: '0,0', wz: '0,0',
faceFlag: false, faceFlag: false,
@ -83,30 +82,31 @@ struct Index {
dolt: '', dolt: '',
fontSize: '', fontSize: '',
rlls: '1', rlls: '1',
spzd4:false, spzd4: false,
spzd3:false, spzd3: false,
spzd2:false, spzd2: false,
spzd1:false, spzd1: false,
zdyz:'5', zdyz: '5',
} }
@State openFlag: boolean = true @State openFlag: boolean = true
@State lsArr: Array<any> = [ @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 context = getContext(this) as common.UIAbilityContext;
private controller1: VideoController = new VideoController() private controller1: VideoController = new VideoController()
private controller2: VideoController = new VideoController() private controller2: VideoController = new VideoController()
private controller3: VideoController = new VideoController() private controller3: VideoController = new VideoController()
private controller4: VideoController = new VideoController() private controller4: VideoController = new VideoController()
@State videoArr: Array<any> = [ @State videoArr: Array<any> = [
{td:'td1',controller:this.controller1,src:''}, { td: 'td1', controller: this.controller1, src: '' },
{td:'td2',controller:this.controller2,src:''}, { td: 'td2', controller: this.controller2, src: '' },
{td:'td3',controller:this.controller3,src:''}, { td: 'td3', controller: this.controller3, src: '' },
{td:'td4',controller:this.controller4,src:''}, { td: 'td4', controller: this.controller4, src: '' },
] ]
private inputController: TextInputController = new TextInputController() private inputController: TextInputController = new TextInputController()
@ -114,8 +114,8 @@ struct Index {
Column() { Column() {
TopLogo({ outFlag: $outFlag }) TopLogo({ outFlag: $outFlag })
Flex({ justifyContent: FlexAlign.SpaceBetween }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) {
Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row}) { Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row }) {
ForEach(this.videoArr,(item,index)=>{ ForEach(this.videoArr, (item, index) => {
Video({ 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` : '', 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, currentProgressRate: this.curRate,
@ -128,7 +128,7 @@ struct Index {
.controls(this.showControls) .controls(this.showControls)
.margin(10 * this.ratio) .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() { Column() {
Image($r('app.media.shezhi')) Image($r('app.media.shezhi'))
@ -170,8 +170,9 @@ struct Index {
.margin({ bottom: 10 * this.ratio }) .margin({ bottom: 10 * this.ratio })
.onClick(() => { .onClick(() => {
for (let i = 1; i <= 4; i++) { 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]) { if (this.rocordHandleObj['rocord_handle'+i]) {
console.log('ttttt', i)
endRecordVideo(this.rocordHandleObj['rocord_handle'+i]) endRecordVideo(this.rocordHandleObj['rocord_handle'+i])
this.rocordHandleObj['rocord_handle'+i] = 0 this.rocordHandleObj['rocord_handle'+i] = 0
} }
@ -185,16 +186,16 @@ struct Index {
.width(215 * this.ratio) .width(215 * this.ratio)
.height(64 * this.ratio) .height(64 * this.ratio)
.onClick(async () => { .onClick(async () => {
const arr=['1','2','3','4'] const arr = ['1', '2', '3', '4']
if(!arr.includes(this.param.pztd)){ if (!arr.includes(this.param.pztd)) {
promptAction.showToast({ promptAction.showToast({
message: '请填写正确的拍照通道', message: '请填写正确的拍照通道',
duration: 3000 duration: 3000
}) })
return return
} }
try{ try {
await takePhoto(this.param,this.context,'pz/') await takePhoto(this.param, this.context, 'pz/')
promptAction.showToast({ promptAction.showToast({
message: '抓图完成', message: '抓图完成',
duration: 3000 duration: 3000
@ -203,8 +204,8 @@ struct Index {
// console.log('daihai err: ' + err) // console.log('daihai err: ' + err)
// }) // })
}catch (error){ } catch (error) {
console.log('daihai',error) console.log('daihai', error)
} }
}) })
@ -319,9 +320,10 @@ struct Index {
.width(34 * this.ratio) .width(34 * this.ratio)
.height(26 * this.ratio) .height(26 * this.ratio)
.fontSize(this.inputFontSize * this.ratio) .fontSize(this.inputFontSize * this.ratio)
.margin({ left: 10 * this.ratio, right: 15 * this.ratio }).onChange((value: string) => { .margin({ left: 10 * this.ratio, right: 15 * this.ratio })
this.param.zdyz = value .onChange((value: string) => {
}) this.param.zdyz = value
})
// Text('k').fontColor('#333333').fontSize(16 * this.ratio) // Text('k').fontColor('#333333').fontSize(16 * this.ratio)
// Text('链接类型').fontColor('#333333').fontSize(16 * this.ratio) // Text('链接类型').fontColor('#333333').fontSize(16 * this.ratio)
// TextInput({ text: this.param.ljlx, controller: this.inputController }) // TextInput({ text: this.param.ljlx, controller: this.inputController })
@ -339,6 +341,7 @@ struct Index {
Row() { Row() {
Row() { Row() {
}.width(70 * this.ratio) }.width(70 * this.ratio)
Text('IP地址') Text('IP地址')
.width(158 * this.ratio) .width(158 * this.ratio)
.fontSize(16 * this.ratio) .fontSize(16 * this.ratio)
@ -371,7 +374,7 @@ struct Index {
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
} }
ForEach(this.lsArr,(item,index)=>{ ForEach(this.lsArr, (item, index) => {
Row() { Row() {
Text(item.key) Text(item.key)
.width(70 * this.ratio) .width(70 * this.ratio)
@ -389,7 +392,7 @@ struct Index {
.onChange((value: string) => { .onChange((value: string) => {
this.param.ip = value 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) .type(InputType.Normal)
.borderRadius(2) .borderRadius(2)
.width(96 * this.ratio) .width(96 * this.ratio)
@ -398,7 +401,7 @@ struct Index {
.margin({ right: 10 * this.ratio }) .margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize * this.ratio) .fontSize(this.inputFontSize * this.ratio)
.onChange((value: string) => { .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 }) TextInput({ text: this.param.userName, controller: this.inputController })
.type(InputType.Normal) .type(InputType.Normal)
@ -498,7 +501,7 @@ struct Index {
.width(22 * this.ratio) .width(22 * this.ratio)
.height(22 * this.ratio) .height(22 * this.ratio)
.onChange((value: boolean) => { .onChange((value: boolean) => {
this.param.spzd1=value this.param.spzd1 = value
}) })
Text('一路').fontSize(16 * this.ratio).fontColor('#333333') Text('一路').fontSize(16 * this.ratio).fontColor('#333333')
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
@ -506,7 +509,7 @@ struct Index {
.width(22 * this.ratio) .width(22 * this.ratio)
.height(22 * this.ratio) .height(22 * this.ratio)
.onChange((value: boolean) => { .onChange((value: boolean) => {
this.param.spzd2=value this.param.spzd2 = value
}) })
Text('二路').fontSize(16 * this.ratio).fontColor('#333333') Text('二路').fontSize(16 * this.ratio).fontColor('#333333')
} }
@ -517,7 +520,7 @@ struct Index {
.width(22 * this.ratio) .width(22 * this.ratio)
.height(22 * this.ratio) .height(22 * this.ratio)
.onChange((value: boolean) => { .onChange((value: boolean) => {
this.param.spzd3=value this.param.spzd3 = value
}) })
Text('三路').fontSize(16 * this.ratio).fontColor('#333333') Text('三路').fontSize(16 * this.ratio).fontColor('#333333')
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
@ -525,7 +528,7 @@ struct Index {
.width(22 * this.ratio) .width(22 * this.ratio)
.height(22 * this.ratio) .height(22 * this.ratio)
.onChange((value: boolean) => { .onChange((value: boolean) => {
this.param.spzd4=value this.param.spzd4 = value
}) })
Text('四路').fontSize(16 * this.ratio).fontColor('#333333') Text('四路').fontSize(16 * this.ratio).fontColor('#333333')
} }
@ -620,27 +623,31 @@ struct Index {
this.fileUtil = fileUtil this.fileUtil = fileUtil
this.getVideoConfig() this.getVideoConfig()
} }
async getfilehandleCode(td){
const record_handle = await startRecordVideo(this.param,td,this.context,'lp') async getfilehandleCode(td) {
this.rocordHandleObj['rocord_handle'+td]=record_handle const record_handle = await startRecordVideo(this.param, td, this.context, 'lp')
this.rocordHandleObj['rocord_handle'+td] = record_handle
} }
outClick() { outClick() {
this.openFlag = false this.openFlag = false
} }
sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay)) sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
async onPageShow() { async onPageShow() {
} }
async getVideoConfig() { 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.oldParam = JSON.parse(data)
this.param = JSON.parse(data) this.param = JSON.parse(data)
} }
async writeConfig() { async writeConfig() {
this.oldParam = JSON.parse(JSON.stringify(this.param)) this.oldParam = JSON.parse(JSON.stringify(this.param))
this.videoArr=JSON.parse(JSON.stringify(this.videoArr)) this.videoArr = JSON.parse(JSON.stringify(this.videoArr))
console.log('kkkk',JSON.stringify(this.param)) console.log('kkkk', JSON.stringify(this.param))
const folderPath = await this.fileUtil.initFolder(`/config`); const folderPath = await this.fileUtil.initFolder(`/config`);
this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(this.param), 'overWrite') this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(this.param), 'overWrite')
this.showFlag = false 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 UdpClient from '../../common/utils/UdpClient';
import FileLog from '../judgeSDK/utils/file-log' import FileLog from '../judgeSDK/utils/file-log';
import { voiceService } from '../../common/service/voiceService' import SerialPortClient from '../../common/utils/SerialPortClient';
import prompt from '@ohos.prompt' import RealTime from '../compontents/judge/real-time';
import RealTime from '../compontents/judge/real-time'
@Component
struct SignDisplayCom {
constructor() {
super()
}
@Component
export default struct SignDisplayCom {
@State showBack: boolean = false @State showBack: boolean = false
@State scaleNum: number = 1 @State scaleNum: number = 1
@State msg: string = '' @State msg: string = ''
@State signArr: Array<any> = [] @State signArr: Array<any> = []
@State sjxhColum: Array<any> = [ @State sjxhColum: Array<any> = [
{ key: '左方向灯', value: '0' }, { key: '右方向灯', value: '0' }, { { key: "左方向灯", value: "0" },
key: '喇叭', { key: "右方向灯", value: "0" },
value: '0' { key: "喇叭", value: "0" },
}, { key: '点火1', value: '0' }, { key: '点火2', value: '0' }, { key: '近光灯', value: '0' }, { { key: "点火1", value: "0" },
key: '远光灯', { key: "点火2", value: "0" },
value: '0' { key: "近光灯", value: "0" },
}, { key: '示廓灯', value: '0' }, { key: '雾灯', value: '0' }, { key: '雨刮器', value: '0' }, { { key: "远光灯", value: "0" },
key: '脚刹', { key: "示廓灯", value: "0" },
value: '0' { key: "雾灯", value: "0" },
}, { key: '手刹', value: '0' }, { key: '主驾驶门', value: '0' }, { key: '离合', value: '0' }, { { key: "雨刮器", value: "0" },
key: '副刹车', { key: "脚刹", value: "0" },
value: '0' { key: "手刹", value: "0" },
}, { { key: "主驾驶门", value: "0" },
key: '安全带', { key: "离合", value: "0" },
value: '0' { key: "副刹车", value: "0" },
}, { key: '双跳灯', value: '0' }, { key: '车速', value: '0' }, { key: '档位', value: '0' }, { { key: "安全带", value: "0" },
key: '超声波1', { key: "双跳灯", value: "0" },
value: '0' { key: "车速", value: "0" },
}, { { key: "档位", value: "0" },
key: '超声波2', { key: "超声波1", value: "0" },
value: '0' { key: "超声波2", value: "0" },
}, { { key: "NC", value: "0" },
key: 'NC', { key: "SA15", value: "0" },
value: '0' { key: "其他门", value: "0" },
}, { key: 'SA15', value: '0' }, { key: '其他门', value: '0' }, { key: '转速过高', value: '0' }, { { key: "转速过高", value: "0" },
key: '累计脉冲', { key: "累计脉冲", value: "0" },
value: '0' { key: "熄火次数", value: "0" },
}, { key: '熄火次数', value: '0' }, { key: '发动机转速', value: '0' }, { key: '方向盘角度', value: '0' }, { { key: "发动机转速", value: "0" },
key: '超声波3', { key: "方向盘角度", value: "0" },
value: '0' { key: "超声波3", value: "0" },
}, { key: '超声波4', value: '0' }, { key: '触摸1', value: '0' }, { key: '触摸2', value: '0' }, { { key: "超声波4", value: "0" },
key: '触摸3', { key: "触摸1", value: "0" },
value: '0' { key: "触摸2", value: "0" },
}, { key: 'SCIO', value: '0' } { key: "触摸3", value: "0" },
, { key: 'SC1A_C', value: '0' }, { key: 'SC1B_C', value: '0' }, { key: 'SC2A_C', value: '0' }, { { key: "SCIO", value: "0" },
key: 'SC2B_C', { key: "SC1A_C", value: "0" },
value: '0' { key: "SC1B_C", value: "0" },
}, { key: 'SC3A_C', value: '0' }, { key: 'SC3B_C', value: '0' }, { key: 'SC4A_C', value: '0' }, { { key: "SC2A_C", value: "0" },
key: 'SC4B_C', { key: "SC2B_C", value: "0" },
value: '0' { key: "SC3A_C", value: "0" },
}, { key: 'SC5A_C', value: '0' }, { key: 'SC5B_C', value: '0' }, { key: 'SC6A_C', value: '0' }, { { key: "SC3B_C", value: "0" },
key: 'SC6B_C', { key: "SC4A_C", value: "0" },
value: '0' { key: "SC4B_C", value: "0" },
}] { key: "SC5A_C", value: "0" },
@State GPSColum:Array<any>=[ { 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: '收星数', value: '0' },
{ key: '海拔高', value: '0' }, { key: '海拔高', value: '0' },
@ -80,17 +80,21 @@ struct SignDisplayCom {
@State gpsActive: number = 1 @State gpsActive: number = 1
@Prop active: number = 0 @Prop active: number = 0
@State msgStr: string = '' @State msgStr: string = ''
@State interval: any='' @State interval: any = ''
@State @Watch('outClick') outFlag: boolean = false; @State @Watch('outClick') outFlag: boolean = false;
@State url: string = ''
private timer = null private timer = null
private udpClient: UdpClient = null private udpClient: UdpClient = null
private FileLog: FileLog private FileLog: FileLog
private vocObj = null; private vocObj = null;
@State url: string = ''
constructor() {
super()
}
// @State gpsList: Array<any> = [] // @State gpsList: Array<any> = []
build() { build() {
Column(){ Column() {
Column() { Column() {
// TopLogo({outFlag:$outFlag}) // TopLogo({outFlag:$outFlag})
Flex({ justifyContent: FlexAlign.SpaceBetween }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) {
@ -146,7 +150,7 @@ struct SignDisplayCom {
} }
Row() { Row() {
if(this.showBack){ if (this.showBack) {
Image($r('app.media.topB_back')).width('16.7%').height('12.2%') Image($r('app.media.topB_back')).width('16.7%').height('12.2%')
.onClick(() => { .onClick(() => {
router.back() router.back()
@ -288,8 +292,14 @@ struct SignDisplayCom {
Text('海拔高:' + this.signArr[85]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) 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[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[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[88])
Text('经度因子:' + this.signArr[89]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) .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[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[91]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio)
Text('航向角状态-收星数:' + this.signArr[92]) Text('航向角状态-收星数:' + this.signArr[92])
@ -322,10 +332,10 @@ struct SignDisplayCom {
Row() { Row() {
Text('GPS').fontColor(this.gpsActive == 0 ? '#2D3C5A' : '#fff') Text('GPS').fontColor(this.gpsActive == 0 ? '#2D3C5A' : '#fff')
} }
.width(316*this.ratio) .width(316 * this.ratio)
.height(24*this.ratio) .height(24 * this.ratio)
.backgroundColor(this.gpsActive == 0 ? '#fff' : '#1A1A1A') .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) .justifyContent(FlexAlign.Center)
.onClick(() => { .onClick(() => {
this.gpsActive = 0 this.gpsActive = 0
@ -341,7 +351,8 @@ struct SignDisplayCom {
// .onClick(() => { // .onClick(() => {
// this.gpsActive = 1 // this.gpsActive = 1
// }) // })
}.margin({ top: 10*this.ratio }) }.margin({ top: 10 * this.ratio })
Flex({ direction: FlexDirection.Column }) { Flex({ direction: FlexDirection.Column }) {
ForEach(this.GPSColum, (item) => { ForEach(this.GPSColum, (item) => {
Column() { Column() {
@ -353,7 +364,7 @@ struct SignDisplayCom {
}) })
} }
} }
.width(168 *2* this.ratio) .width(168 * 2 * this.ratio)
.height(380 * this.ratio) .height(380 * this.ratio)
.backgroundColor('#282828') .backgroundColor('#282828')
.margin({ top: 6 * this.ratio, left: 10 * this.ratio }) .margin({ top: 6 * this.ratio, left: 10 * this.ratio })
@ -364,8 +375,8 @@ struct SignDisplayCom {
Row() { Row() {
RealTime({ RealTime({
width:Math.floor(550 * this.ratio), width: Math.floor(550 * this.ratio),
height:Math.floor(380 * this.ratio), height: Math.floor(380 * this.ratio),
}) })
} }
.width(550 * this.ratio) .width(550 * this.ratio)
@ -391,33 +402,47 @@ struct SignDisplayCom {
aboutToDisappear() { aboutToDisappear() {
clearInterval(this.interval) clearInterval(this.interval)
} }
aboutToAppear(){
aboutToAppear() {
this.ratio = this.ratio * (this.scaleNum || 1); this.ratio = this.ratio * (this.scaleNum || 1);
const that = this const that = this
const {showBack,getSignal} = this const {showBack,getSignal} = this
const serialPortClient = new SerialPortClient()
if(showBack){ 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) {
globalThis.udpClient.onMessage((msg) => { globalThis.udpClient.onMessage((msg) => {
console.log('msgmsg',msg) console.log('msgmsg', msg)
if(msg){ if (msg) {
getSignal(msg) getSignal(msg)
} }
}) })
}else{ } else {
clearInterval(globalThis.signalTimer) clearInterval(globalThis.signalTimer)
globalThis.signalTimer = setInterval(()=>{ globalThis.signalTimer = setInterval(() => {
const msgStr = globalThis.msgStr const msgStr = globalThis.msgStr
if(msgStr){ if (msgStr) {
getSignal(msgStr) getSignal(msgStr)
} }
},200) }, 200)
} }
} }
onPageShow() { onPageShow() {
console.info('SURENJUN',123) console.info('SURENJUN', 123)
// this.vocObj = new voiceService(async (status, val) => { // this.vocObj = new voiceService(async (status, val) => {
// if (status == 'idle') { // if (status == 'idle') {
// if (this.url == 'back') { // if (this.url == 'back') {
@ -427,21 +452,34 @@ struct SignDisplayCom {
// } // }
// } // }
// }); // });
const serialPortClient = new SerialPortClient()
serialPortClient.openSerial()
serialPortClient.SerialSet()
const getSignal = this.getSignal; 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 that = this
const showBack = this.showBack; const showBack = this.showBack;
if(showBack){ if (showBack) {
globalThis.udpClient.onMessage((msg) => { globalThis.udpClient.onMessage((msg) => {
getSignal(msg) getSignal(msg)
}) })
}else{ } else {
clearInterval(globalThis.signalTimer) clearInterval(globalThis.signalTimer)
globalThis.signalTimer = setInterval(()=>{ globalThis.signalTimer = setInterval(() => {
//TODO 临时方案 //TODO 临时方案
const msgStr = globalThis.msgStr const msgStr = globalThis.msgStr
getSignal(msgStr) getSignal(msgStr)
},200) }, 200)
} }
// this.getDeviceNo(); // this.getDeviceNo();
// this.initTime(); // this.initTime();
@ -450,17 +488,17 @@ struct SignDisplayCom {
// globalThis.isRegist = false; //是否已经注册 // globalThis.isRegist = false; //是否已经注册
} }
getSignal= (msg)=> { getSignal = (msg) => {
console.log('msgmsgmsg',msg) console.log('msgmsgmsg', msg)
const that = this; const that = this;
that.msg = msg that.msg = msg
const strachArr=msg.split(',') const strachArr = msg.split(',')
if (strachArr[0] != '#DN_GD') { if (strachArr[0] != '#DN_GD') {
return return
} }
this.signArr = strachArr 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] this.sjxhColum[i].value = this.signArr[i+2]
} }
@ -469,7 +507,7 @@ struct SignDisplayCom {
this.sjxhColum[15].value = this.signArr[19] this.sjxhColum[15].value = this.signArr[19]
this.sjxhColum[16].value = this.signArr[20] this.sjxhColum[16].value = this.signArr[20]
this.sjxhColum[17].value = this.signArr[23] //车速 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[19].value = this.signArr[29]
this.sjxhColum[20].value = this.signArr[30] this.sjxhColum[20].value = this.signArr[30]
this.sjxhColum[21].value = this.signArr[15] //NC this.sjxhColum[21].value = this.signArr[15] //NC
@ -485,11 +523,11 @@ struct SignDisplayCom {
this.sjxhColum[31].value = this.signArr[33] this.sjxhColum[31].value = this.signArr[33]
this.sjxhColum[32].value = this.signArr[34] this.sjxhColum[32].value = this.signArr[34]
this.sjxhColum[33].value = this.signArr[35] 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] this.sjxhColum[i].value = this.signArr[i+2]
} }
let t=0 let t = 0
for (let i = 83;i <= 97; i++) { for (let i = 83; i <= 97; i++) {
this.GPSColum[t].value = this.signArr[i] this.GPSColum[t].value = this.signArr[i]
t++ t++
} }
@ -497,6 +535,7 @@ struct SignDisplayCom {
that.signArr = JSON.parse(JSON.stringify((this.signArr))) that.signArr = JSON.parse(JSON.stringify((this.signArr)))
that.GPSColum = JSON.parse(JSON.stringify((this.GPSColum))) that.GPSColum = JSON.parse(JSON.stringify((this.GPSColum)))
} }
outClick() { outClick() {
} }
@ -504,6 +543,7 @@ struct SignDisplayCom {
// this.FileLog.initFileLogo('d .0ateLog') // this.FileLog.initFileLogo('d .0ateLog')
// this.FileLog.createFile('123') // this.FileLog.createFile('123')
} }
// getDeviceNo() { // getDeviceNo() {
// globalThis.deviceNo = 'FE-FC-FE-7C-5C-72'; //设备号 // globalThis.deviceNo = 'FE-FC-FE-7C-5C-72'; //设备号
// } // }
@ -521,4 +561,3 @@ struct SignDisplayCom {
// } // }
} }
export default SignDisplayCom