优化了部分代码

This commit is contained in:
wangzhongjie 2024-06-04 11:28:15 +08:00
parent da6a85f02a
commit e65c48f1eb
3 changed files with 116 additions and 105 deletions

View File

@ -1,5 +1,3 @@
import UdpClient from '../common/utils/UdpClient';
import FileLog from './judgeSDK/utils/file-log';
import signDisplayCom from './compontents/signDisplayCom';
@Entry
@ -7,50 +5,54 @@ import signDisplayCom from './compontents/signDisplayCom';
export default struct Index {
@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' },
@ -74,10 +76,6 @@ export default struct Index {
@State msg: string = ''
@State @Watch('outClick') outFlag: boolean = false;
@State url: string = ''
private timer = null
private udpClient: UdpClient = null
private FileLog: FileLog
private vocObj = null;
// @State gpsList: Array<any> = []
build() {

View File

@ -1,14 +1,10 @@
import router from '@ohos.router'
import TopLogo from './compontents/topLogo'
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';
import prompt from '@ohos.prompt';
import { getSyncData, upDateTableByArray } from '../common/service/initable';
import { getUDP, getUDP2 } from '../common/utils/GlobalUdp';
import { getTCP } from '../common/utils/GlobalTcp';
@Entry
@Component
struct Index {
@ -29,11 +25,10 @@ struct Index {
// @State inputTextList2: string[] = ['192.168.36.139','20022']
@State @Watch('outClick') outFlag: boolean = false;
private vocObj = null;
scroller: Scroller = new Scroller()
private vocObj = null;
build() {
Column() {
TopLogo({ outFlag: $outFlag })
@ -61,7 +56,8 @@ 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
})
@ -81,9 +77,24 @@ 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],
@ -130,6 +141,7 @@ 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))
@ -166,9 +178,11 @@ struct Index {
})
}
onPageShow() {
console.info('Index onPageShow');
}
outClick() {
}

View File

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