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)
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){
return
}
if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) {
return
}
} 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(()=>{
// clearInterval(chuankou)
// chuankou=setInterval(()=>{
getChuankouFnMsg()
},1000)
// },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,27 +1,46 @@
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)
}
@ -30,7 +49,10 @@ export async function getTCP() {
})
})
}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,11 +1,17 @@
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 {
struct Index {
@State textList1: string[] = ['差分服务器Ip','响应端口','中心服务器IP','响应端口', '子网掩码','默认网关','dns','后置机IP ', '响应端口','前置机IP','本地端口','平台服务器Ip','响应端口']
// @State textList2: string[] = []
@State ratio: number = 1700 / 960
@ -23,10 +29,11 @@ export default struct Index {
// @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})
@ -54,8 +61,7 @@ export default struct Index {
.linearGradient({
angle: 0,
colors: [[0x403C36, 0.0], [0x4D473D, 0.34], [0x3D3A34, 1.0]]
})
.onChange((value: string) => {
}).onChange((value: string) => {
this.inputTextList1[index]=value
})
@ -75,24 +81,9 @@ export default struct Index {
.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]
}])
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],
@ -114,6 +105,9 @@ export default struct Index {
});
}
});
getUDP(true)
getUDP2(true)
getTCP(true)
})
}
.backgroundColor('#CCC4B8')
@ -136,7 +130,6 @@ export default struct Index {
.backgroundImage($r('app.media.index_bg'))
.backgroundImageSize({ width: '100%', height: '100%' })
}
aboutToAppear() {
getSyncData('IpConfigTable').then((result:Array<any>)=>{
console.log('result222',JSON.stringify(result))
@ -173,11 +166,9 @@ export default struct Index {
})
}
onPageShow() {
console.info('Index onPageShow');
}
outClick(){
}

View File

@ -1,14 +1,13 @@
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')
@ -22,7 +21,9 @@ export default struct Index {
}
@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',
@ -95,8 +96,7 @@ export default struct Index {
{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()
@ -172,7 +172,6 @@ export default struct Index {
for (let i = 1; i <= 4; i++) {
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
}
@ -320,8 +319,7 @@ 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) => {
.margin({ left: 10 * this.ratio, right: 15 * this.ratio }).onChange((value: string) => {
this.param.zdyz = value
})
// Text('k').fontColor('#333333').fontSize(16 * this.ratio)
@ -341,7 +339,6 @@ export default struct Index {
Row() {
Row() {
}.width(70 * this.ratio)
Text('IP地址')
.width(158 * this.ratio)
.fontSize(16 * this.ratio)
@ -623,18 +620,14 @@ 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
}
outClick() {
this.openFlag = false
}
sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
async onPageShow() {
}

View File

@ -1,64 +1,64 @@
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" },
]
{ 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' },
@ -81,17 +81,13 @@ export default struct SignDisplayCom {
@Prop active: number = 0
@State msgStr: string = ''
@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(){
@ -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])
@ -352,7 +342,6 @@ export default struct SignDisplayCom {
// this.gpsActive = 1
// })
}.margin({ top: 10*this.ratio })
Flex({ direction: FlexDirection.Column }) {
ForEach(this.GPSColum, (item) => {
Column() {
@ -402,26 +391,12 @@ export default struct SignDisplayCom {
aboutToDisappear() {
clearInterval(this.interval)
}
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){
globalThis.udpClient.onMessage((msg) => {
console.log('msgmsg',msg)
@ -452,21 +427,8 @@ 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){
@ -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