fix: 重构配置设置页面以及UDP需要注意的地方
This commit is contained in:
		
							parent
							
								
									3999e1d32b
								
							
						
					
					
						commit
						8589d0ac76
					
				| @ -3,7 +3,8 @@ | |||||||
|   "buildOption": { |   "buildOption": { | ||||||
|     sourceOption: { |     sourceOption: { | ||||||
|       "workers": [ |       "workers": [ | ||||||
|         './src/main/ets/workers/DifferentialCorrection.ets' |         './src/main/ets/workers/DifferentialCorrection.ets', | ||||||
|  |         './src/main/ets/workers/Log.ets' | ||||||
|       ] |       ] | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|  | |||||||
| @ -143,6 +143,12 @@ export interface EnvironmentConfigurationType { | |||||||
|   centerIp?: string, |   centerIp?: string, | ||||||
|   centerPort?: string, |   centerPort?: string, | ||||||
|   terType?: string |   terType?: string | ||||||
|  |   //   几代机1 | 2 | 3 | 4 | ||||||
|  |   rearMachineModel?: string | ||||||
|  |   //   是否开启日志 | ||||||
|  |   isOpenLog?: string | ||||||
|  |   //   板卡类型 1|2 | ||||||
|  |   boardType?: string | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //全局配置 | //全局配置 | ||||||
| @ -195,3 +201,4 @@ interface FourInOneScreenType { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| interface SystemParamConfigType {} | interface SystemParamConfigType {} | ||||||
|  | 
 | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import CardComponent from './Index/Card'; | |||||||
| import BottomMessageComponent from './Index/BottomMessage'; | import BottomMessageComponent from './Index/BottomMessage'; | ||||||
| import LoadingComponent from './Index/Loading'; | import LoadingComponent from './Index/Loading'; | ||||||
| import Prompt from '@system.prompt'; | import Prompt from '@system.prompt'; | ||||||
| import { DifferentialAndSignal } from '../utils/business/DifferentialAndSignal'; | import { DifferentialAndSignal } from '../utils/business/DifferentialAndSignalWorker'; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @Entry | @Entry | ||||||
|  | |||||||
| @ -41,7 +41,7 @@ struct Index { | |||||||
|             //   type: 1, |             //   type: 1, | ||||||
|             //   name: 'button_media.wav' |             //   name: 'button_media.wav' | ||||||
|             // }) |             // }) | ||||||
|             this.url = 'pages/TerminalInfos' |             this.url = 'pages/TerminalInfo' | ||||||
|             router.pushUrl({ |             router.pushUrl({ | ||||||
|               url: this.url, |               url: this.url, | ||||||
|             }, router.RouterMode.Single); |             }, router.RouterMode.Single); | ||||||
|  | |||||||
							
								
								
									
										291
									
								
								entry/src/main/ets/pages/TerminalInfo.ets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										291
									
								
								entry/src/main/ets/pages/TerminalInfo.ets
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,291 @@ | |||||||
|  | import HeaderComponent from './compontents/Header'; | ||||||
|  | import { EnvironmentConfigurationType } from '../model'; | ||||||
|  | import common from '@ohos.app.ability.common'; | ||||||
|  | import FileUtils from '../utils/FileUtils'; | ||||||
|  | import { GlobalConfig } from '../config'; | ||||||
|  | import ethernet from '@ohos.net.ethernet'; | ||||||
|  | import { BusinessError } from '@ohos.base'; | ||||||
|  | import Prompt from '@system.prompt'; | ||||||
|  | 
 | ||||||
|  | @Entry | ||||||
|  | @Component | ||||||
|  | struct TerminalInfoPage { | ||||||
|  |   @State config: EnvironmentConfigurationType = {} | ||||||
|  |   private fileUtil!: FileUtils | ||||||
|  |   private context = getContext(this) as common.UIAbilityContext; | ||||||
|  | 
 | ||||||
|  |   async aboutToAppear() { | ||||||
|  |     this.fileUtil = new FileUtils(this.context) | ||||||
|  |     const data = await this.fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt'); | ||||||
|  |     console.log("data", data) | ||||||
|  |     if (data) { | ||||||
|  |       this.config = JSON.parse(data) | ||||||
|  |       AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", this.config) | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   build() { | ||||||
|  |     Flex({ | ||||||
|  |       justifyContent: FlexAlign.Center, | ||||||
|  |       direction: FlexDirection.Column, | ||||||
|  |       alignItems: ItemAlign.Center, | ||||||
|  |     }) { | ||||||
|  |       HeaderComponent({ | ||||||
|  |         shortLogo: true, | ||||||
|  |         shouBackArea: true | ||||||
|  |       }) | ||||||
|  |       // TODO | ||||||
|  |       // 差分是否开启 | ||||||
|  |       // 车型 | ||||||
|  |       // 大车需要UDP两个端口 | ||||||
|  |       Column() { | ||||||
|  |         Column() { | ||||||
|  |           Flex({ | ||||||
|  |             wrap: FlexWrap.Wrap, | ||||||
|  |           }) { | ||||||
|  |             blockComponent({ | ||||||
|  |               value: this.config.tcpOppositeIp, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.tcpOppositeIp = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "响应端口", | ||||||
|  |               value: this.config.tcpOppositePort, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.tcpOppositePort = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "中心服务器IP", | ||||||
|  |               value: this.config.centerIp, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.centerIp = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "响应端口", | ||||||
|  |               value: this.config.centerPort, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.centerPort = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "后置机IP", | ||||||
|  |               value: this.config.udpOppositeIp, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.udpOppositeIp = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "响应端口", | ||||||
|  |               value: this.config.udpOppositeIpPort, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.udpOppositeIpPort = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "前置机IP", | ||||||
|  |               value: this.config.udplocalIp, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.udplocalIp = value; | ||||||
|  |                 this.config.tcplocalIp = value | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "后置机UDP本地端口", | ||||||
|  |               value: this.config.udplocalIpPort, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.udplocalIpPort = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             // blockComponent({ | ||||||
|  |             //   label: "TCP本地端口", | ||||||
|  |             //   value: this.config.tcplocalIpPort, | ||||||
|  |             //   change: (value: string) => { | ||||||
|  |             //     this.config.tcplocalIpPort = value; | ||||||
|  |             //   } | ||||||
|  |             // }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "子网掩码", | ||||||
|  |               value: this.config.netMask, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.netMask = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "默认网关", | ||||||
|  |               value: this.config.gateway, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.gateway = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "DNS", | ||||||
|  |               value: this.config.dnsServers, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.dnsServers = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "后置机类型", | ||||||
|  |               type: 1, | ||||||
|  |               value: (Number(this.config.rearMachineModel) - 1).toString(), | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.rearMachineModel = (Number(value) + 1).toString(); | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "是否开启日志", | ||||||
|  |               type: 2, | ||||||
|  |               value: this.config.isOpenLog, | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.isOpenLog = value; | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             blockComponent({ | ||||||
|  |               label: "板卡类型", | ||||||
|  |               type: 3, | ||||||
|  |               value: (Number(this.config.boardType) - 1).toString(), | ||||||
|  |               change: (value: string) => { | ||||||
|  |                 this.config.boardType = (Number(value) + 1).toString(); | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |           } | ||||||
|  |           .backgroundColor("#282828") | ||||||
|  |           .height(500) | ||||||
|  |           .borderRadius(20) | ||||||
|  |           .margin(20) | ||||||
|  |           .padding({ | ||||||
|  |             top: 10 | ||||||
|  |           }) | ||||||
|  | 
 | ||||||
|  |           Row() { | ||||||
|  |             Image($r('app.media.bc')).height(80).objectFit(ImageFit.Contain).onClick(() => { | ||||||
|  |               console.log("保存配置", JSON.stringify(this.config)) | ||||||
|  |               AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", this.config) | ||||||
|  |               this.fileUtil.addFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt', JSON.stringify(this.config)) | ||||||
|  |               ethernet.setIfaceConfig("eth0", { | ||||||
|  |                 mode: ethernet.IPSetMode.STATIC, | ||||||
|  |                 ipAddr: this.config.udplocalIp, | ||||||
|  |                 route: "0.0.0.0", | ||||||
|  |                 gateway: this.config.gateway, //value.gateway网关 | ||||||
|  |                 netMask: this.config.netMask, //value.netMask网络掩码 | ||||||
|  |                 dnsServers: this.config.dnsServers, | ||||||
|  |                 domain: "" | ||||||
|  |               }, (error: BusinessError) => { | ||||||
|  |                 if (error) { | ||||||
|  |                   Prompt.showToast({ | ||||||
|  |                     message: '设置失败' + JSON.stringify(error), | ||||||
|  |                     duration: 3000 | ||||||
|  |                   }); | ||||||
|  |                 } else { | ||||||
|  |                   Prompt.showToast({ | ||||||
|  |                     message: '设置成功', | ||||||
|  |                     duration: 3000 | ||||||
|  |                   }); | ||||||
|  |                 } | ||||||
|  |               }); | ||||||
|  |             }) | ||||||
|  |           } | ||||||
|  |           .width("100%") | ||||||
|  |           .height(120) | ||||||
|  |           .backgroundColor("#CAC4B8") | ||||||
|  |           .justifyContent(FlexAlign.Center) | ||||||
|  |           .alignItems(VerticalAlign.Center) | ||||||
|  |           .borderRadius({ | ||||||
|  |             bottomLeft: 20, | ||||||
|  |             bottomRight: 20 | ||||||
|  |           }) | ||||||
|  |         } | ||||||
|  |         .width(1500) | ||||||
|  |         .height(660) | ||||||
|  |         .backgroundColor("#fff") | ||||||
|  |         .borderRadius(20) | ||||||
|  |       } | ||||||
|  |       .width("100%") | ||||||
|  |       .height("100%") | ||||||
|  |       .alignItems(HorizontalAlign.Center) | ||||||
|  |       .justifyContent(FlexAlign.Center) | ||||||
|  |     }.width("100%") | ||||||
|  |     .height("100%") | ||||||
|  |     .backgroundImage($r('app.media.index_bg')) | ||||||
|  |     .backgroundImageSize({ | ||||||
|  |       width: "100%", | ||||||
|  |       height: "100%" | ||||||
|  |     }) | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | @Component | ||||||
|  | struct blockComponent { | ||||||
|  |   @State label: string = "差分服务器IP" | ||||||
|  |   @Prop value: string | ||||||
|  |   change?: (value: string) => void | ||||||
|  |   // 0 -输入框,1 -后置机类型,2 -日志开关,3 -板卡类型 | ||||||
|  |   @State type: number = 0 | ||||||
|  |   // '一型机', '二型机', '三型机', '一体机' | ||||||
|  |   @State rearMachineModelList: string[] = ['一型机', '二型机', '三型机', '一体机'] | ||||||
|  |   @State boardList: string[] = ['北云', '天宝MB2'] | ||||||
|  |   @State logList: string[] = ['关', '开'] | ||||||
|  | 
 | ||||||
|  |   build() { | ||||||
|  |     Row() { | ||||||
|  |       Row() { | ||||||
|  |         Text(this.label + ":").fontSize(20).fontColor("#E5CBA1") | ||||||
|  |       }.width("40%").padding({ | ||||||
|  |         left: 15 | ||||||
|  |       }) | ||||||
|  | 
 | ||||||
|  |       Row() { | ||||||
|  |         // 输入框 | ||||||
|  |         if (this.type === 0) { | ||||||
|  |           TextInput({ | ||||||
|  |             text: this.value, | ||||||
|  |           }) | ||||||
|  |             .type(InputType.Normal) | ||||||
|  |             .borderRadius(0) | ||||||
|  |             .fontSize(20) | ||||||
|  |             .height(50) | ||||||
|  |             .backgroundColor("#4C473E") | ||||||
|  |             .fontColor("#FFF5E5") | ||||||
|  |             .border({ | ||||||
|  |               width: 1, | ||||||
|  |               color: "#E6E0D8" | ||||||
|  |             }) | ||||||
|  |             .margin({ left: 15, right: 15 }) | ||||||
|  |             .onChange((value) => { | ||||||
|  |               this.value = value; | ||||||
|  |               this.change?.(value); | ||||||
|  |             }) | ||||||
|  |         } else { | ||||||
|  |           ForEach(this.type === 1 ? this.rearMachineModelList : | ||||||
|  |             this.type === 2 ? this.logList : | ||||||
|  |             this.boardList, (item: string, index) => { | ||||||
|  |             Radio({ value: item, group: 'terRadioGroup' + this.type }) | ||||||
|  |               .borderColor('#E5CBA1') | ||||||
|  |               .checked(index.toString() === this.value ? true : false) | ||||||
|  |               .onChange((value: boolean) => { | ||||||
|  |                 if (value) { | ||||||
|  |                   this.value = index.toString(); | ||||||
|  |                   this.change?.(index.toString()); | ||||||
|  |                 } | ||||||
|  |               }) | ||||||
|  |             Text(item).fontSize(20).fontColor('#FFF') | ||||||
|  |           }) | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |       }.width("60%").padding({ | ||||||
|  |         right: 15 | ||||||
|  |       }) | ||||||
|  |     } | ||||||
|  |     .width("50%") | ||||||
|  |     .height(50) | ||||||
|  |     .justifyContent(FlexAlign.Center) | ||||||
|  |     .alignItems(VerticalAlign.Center) | ||||||
|  |     .margin({ | ||||||
|  |       top: 10, | ||||||
|  |       bottom: 10 | ||||||
|  |     }) | ||||||
|  |   } | ||||||
|  | } | ||||||
| @ -1,186 +0,0 @@ | |||||||
| import TopLogo from './compontents/TopLogo'; |  | ||||||
| import ethernet from '@ohos.net.ethernet'; |  | ||||||
| 
 |  | ||||||
| import common from '@ohos.app.ability.common'; |  | ||||||
| import { GlobalConfig } from '../config'; |  | ||||||
| import Prompt from '@system.prompt'; |  | ||||||
| import FileUtils from '../utils/FileUtils'; |  | ||||||
| import { EnvironmentConfigurationType } from '../model/Common'; |  | ||||||
| import { BusinessError } from '@ohos.base'; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| @Entry |  | ||||||
| @Component |  | ||||||
| struct Index { |  | ||||||
|   @State textList1: string[] = |  | ||||||
|     ['差分服务器Ip', '响应端口', '中心服务器IP', '响应端口', '子网掩码', '默认网关', 'dns', '后置机IP ', '响应端口', |  | ||||||
|       '前置机IP', '本地端口'] |  | ||||||
|   @State ratio: number = 1700 / 960 |  | ||||||
|   @State inputFontSize: number = 12 |  | ||||||
|   @State inputTextList1: string[] = |  | ||||||
|     ['172.37.55.191', '18782', '172.37.55.191', '8082', '255.255.255.0', '192.168.7.1', '114.114.114.114', |  | ||||||
|       '192.168.7.124', '20022', '192.168.7.170', '20122'] |  | ||||||
|   @State @Watch('outClick') outFlag: boolean = false; |  | ||||||
|   scroller: Scroller = new Scroller() |  | ||||||
|   private fileUtil!: FileUtils |  | ||||||
|   private context = getContext(this) as common.UIAbilityContext; |  | ||||||
| 
 |  | ||||||
|   build() { |  | ||||||
|     Column() { |  | ||||||
|       TopLogo({ outFlag: $outFlag }) |  | ||||||
|       Column() { |  | ||||||
|         Column() { |  | ||||||
|           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] : '' }) |  | ||||||
|                     .width('50%') |  | ||||||
|                     .height('60%') |  | ||||||
|                     .fontColor('#fff') |  | ||||||
|                     .borderColor('#E6E0D8') |  | ||||||
|                     .borderRadius('10px') |  | ||||||
|                     .borderWidth('2px') |  | ||||||
|                     .defaultFocus(false) |  | ||||||
|                     .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 |  | ||||||
| 
 |  | ||||||
|                     }) |  | ||||||
|                 } |  | ||||||
|                 .width('50%') |  | ||||||
|                 .height('16.7%') |  | ||||||
|               }) |  | ||||||
| 
 |  | ||||||
|             } |  | ||||||
|           } |  | ||||||
|           .width('95%') |  | ||||||
|           .height('90%') |  | ||||||
|           .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(async () => { |  | ||||||
|             const folderPath = await this.fileUtil.initFolder(`/config`); |  | ||||||
|             const param: EnvironmentConfigurationType = { |  | ||||||
|               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] |  | ||||||
|             } |  | ||||||
|             console.log("保存参数", JSON.stringify(param)) |  | ||||||
|             this.fileUtil.addFile(`${folderPath}/ipConfig.txt`, JSON.stringify(param)) |  | ||||||
|             AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", param) |  | ||||||
|             const host = `http://${param.centerIp}:${param.centerPort}` |  | ||||||
|             console.log("中心host", host) |  | ||||||
|             AppStorage.setOrCreate<string>("host", host) |  | ||||||
|             ethernet.setIfaceConfig("eth0", { |  | ||||||
|               mode: ethernet.IPSetMode.STATIC, |  | ||||||
|               ipAddr: this.inputTextList1[9], |  | ||||||
|               route: "0.0.0.0", |  | ||||||
|               gateway: this.inputTextList1[5], //value.gateway网关 |  | ||||||
|               netMask: this.inputTextList1[4], //value.netMask网络掩码 |  | ||||||
|               dnsServers: this.inputTextList1[6], |  | ||||||
|               domain: "" |  | ||||||
|             }, (error: BusinessError) => { |  | ||||||
|               if (error) { |  | ||||||
|                 Prompt.showToast({ |  | ||||||
|                   message: '设置失败' + JSON.stringify(error), |  | ||||||
|                   duration: 3000 |  | ||||||
|                 }); |  | ||||||
|               } else { |  | ||||||
|                 Prompt.showToast({ |  | ||||||
|                   message: '设置成功', |  | ||||||
|                   duration: 3000 |  | ||||||
|                 }); |  | ||||||
|               } |  | ||||||
|             }); |  | ||||||
| 
 |  | ||||||
|           }) |  | ||||||
|         } |  | ||||||
|         .backgroundColor('#CCC4B8') |  | ||||||
|         .width('100%') |  | ||||||
|         .height('20%') |  | ||||||
|         .borderRadius({ 'bottomLeft': '25px', 'bottomRight': '25px' }) |  | ||||||
|         .justifyContent(FlexAlign.SpaceAround) |  | ||||||
|       } |  | ||||||
|       .width('75%') |  | ||||||
|       .height('69.4%') |  | ||||||
|       .backgroundColor('#E6E3DF') |  | ||||||
|       .borderRadius('25px') |  | ||||||
|       .margin({ 'top': '7%' }) |  | ||||||
|       .justifyContent(FlexAlign.SpaceAround) |  | ||||||
| 
 |  | ||||||
|     } |  | ||||||
|     .width('100%') |  | ||||||
|     .height('100%') |  | ||||||
|     .backgroundImagePosition({ x: 0, y: 0 }) |  | ||||||
|     .backgroundImage($r('app.media.index_bg')) |  | ||||||
|     .backgroundImageSize({ width: '100%', height: '100%' }) |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   async aboutToAppear() { |  | ||||||
|     this.fileUtil = new FileUtils(this.context) |  | ||||||
|     const data = await this.fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt'); |  | ||||||
|     if (data === '' || data === undefined) { |  | ||||||
|     } else { |  | ||||||
|       const result: EnvironmentConfigurationType = JSON.parse(data) |  | ||||||
|       AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", result) |  | ||||||
|       this.inputTextList1[9] = result.udplocalIp ?? '' |  | ||||||
|       this.inputTextList1[10] = result.udplocalIpPort ?? '' |  | ||||||
|       this.inputTextList1[7] = result.udpOppositeIp ?? '' |  | ||||||
|       this.inputTextList1[8] = result.udpOppositeIpPort ?? '' |  | ||||||
|       this.inputTextList1[0] = result.tcpOppositeIp ?? '' |  | ||||||
|       this.inputTextList1[1] = result.tcpOppositePort ?? '' |  | ||||||
|       this.inputTextList1[5] = result.gateway ?? '' |  | ||||||
|       this.inputTextList1[4] = result.netMask ?? '' |  | ||||||
|       this.inputTextList1[6] = result.dnsServers ?? '' |  | ||||||
|       this.inputTextList1[2] = result.centerIp ?? '' |  | ||||||
|       this.inputTextList1[3] = result.centerPort ?? '' |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     ethernet.getIfaceConfig("eth0").then(value => { |  | ||||||
|       console.log("boot_up getIp_new callback ipAddr = " + JSON.stringify(value.ipAddr)); // |  | ||||||
|       console.log(" boot_up getIp_new callback mode = " + JSON.stringify(value.mode)); |  | ||||||
|       console.log("boot_up getIp_new callback route = " + JSON.stringify(value.route)); |  | ||||||
|       console.log("boot_up getIp_new callback gateway = " + JSON.stringify(value.gateway)); |  | ||||||
|       console.log("boot_up getIp_new callback netMask = " + JSON.stringify(value.netMask)); |  | ||||||
|       console.log("boot_up getIp_new callback dnsServers = " + JSON.stringify(value.dnsServers)); |  | ||||||
|     }).catch((error: BusinessError) => { |  | ||||||
|       console.log("boot_up getIp_new  callback error = " + JSON.stringify(error)); |  | ||||||
|     }) |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   onPageShow() { |  | ||||||
|     console.info('Index onPageShow'); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   outClick() { |  | ||||||
| 
 |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| @ -3,7 +3,8 @@ import RealTime from '../compontents/judge/RealTime'; | |||||||
| import { GPSData, SignalData } from '../../mock'; | import { GPSData, SignalData } from '../../mock'; | ||||||
| import { SignalDataType, WorkerBackMessage } from '../../model'; | import { SignalDataType, WorkerBackMessage } from '../../model'; | ||||||
| import { ObtainUdpBusinessInstance } from '../../utils/business/ObtainUdpBusiness'; | import { ObtainUdpBusinessInstance } from '../../utils/business/ObtainUdpBusiness'; | ||||||
| import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignal'; | import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker'; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| @Component | @Component | ||||||
| export default struct SignDisplayCom { | export default struct SignDisplayCom { | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| import router from '@ohos.router' | import router from '@ohos.router' | ||||||
| import { GPSData, InitialPerLane, SignalData } from '../../mock' | import { GPSData, InitialPerLane, SignalData } from '../../mock' | ||||||
| import { EnvironmentConfigurationType, PerLane, RoadDataType, SignalDataType, WorkerBackMessage } from '../../model' | import { EnvironmentConfigurationType, PerLane, RoadDataType, SignalDataType, WorkerBackMessage } from '../../model' | ||||||
| import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignal' |  | ||||||
| import apiJudgeSdk from 'libJudgeSdk.so' | import apiJudgeSdk from 'libJudgeSdk.so' | ||||||
| import { examJudgeMapSetScaling } from '../judgeSDK/api' | import { examJudgeMapSetScaling } from '../judgeSDK/api' | ||||||
|  | import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker' | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @Component | @Component | ||||||
|  | |||||||
| @ -79,6 +79,8 @@ export default class TcpClient { | |||||||
|     this.tcp.on("message", value => { |     this.tcp.on("message", value => { | ||||||
|       let data = new DataView(value.message) |       let data = new DataView(value.message) | ||||||
|       this.events.forEach(cb => { |       this.events.forEach(cb => { | ||||||
|  |         // TODO | ||||||
|  |         // 一体机不需要截取 | ||||||
|         cb(value.message.slice(5, data.byteLength)) |         cb(value.message.slice(5, data.byteLength)) | ||||||
|       }) |       }) | ||||||
|     }) |     }) | ||||||
|  | |||||||
							
								
								
									
										23
									
								
								entry/src/main/ets/utils/business/LogWorker.ets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								entry/src/main/ets/utils/business/LogWorker.ets
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | |||||||
|  | class logWorker { | ||||||
|  |   // 正常日志 | ||||||
|  |   log(msg: string) { | ||||||
|  |     console.log(msg) | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   // 信息日志 | ||||||
|  |   info(msg: string) { | ||||||
|  |     console.info(msg) | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   // 调试日志 | ||||||
|  |   warn(msg: string) { | ||||||
|  |     console.warn(msg) | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   // 错误日志 | ||||||
|  |   error(msg: string) { | ||||||
|  |     console.error(msg) | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export const dConsole = new logWorker(); | ||||||
| @ -39,7 +39,6 @@ function initFn(result: WorkerMessage) { | |||||||
|   CenterUDPBusinessInstance.startHeartBeat() |   CenterUDPBusinessInstance.startHeartBeat() | ||||||
|   // 初始化考试过程UDP |   // 初始化考试过程UDP | ||||||
|   // JudgeUdpBusinessInstance.init(result.config, result.carInfo, result?.singlePlay || false, result.otherMessage.lsh) |   // JudgeUdpBusinessInstance.init(result.config, result.carInfo, result?.singlePlay || false, result.otherMessage.lsh) | ||||||
| 
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getDataFn() { | function getDataFn() { | ||||||
| @ -47,7 +46,7 @@ function getDataFn() { | |||||||
|   DifferentialSignal.getData((data: ArrayBuffer) => { |   DifferentialSignal.getData((data: ArrayBuffer) => { | ||||||
|     console.log(WorkerTag, "Received differential signal data:", data.byteLength, "bytes") |     console.log(WorkerTag, "Received differential signal data:", data.byteLength, "bytes") | ||||||
|     // TCP拿到差分改正数发给后置机 |     // TCP拿到差分改正数发给后置机 | ||||||
|     // ObtainUdpBusinessInstance.sendData(data) |     ObtainUdpBusinessInstance.sendData(data) | ||||||
|   }) |   }) | ||||||
|   // 后置机回执PLC和GPS |   // 后置机回执PLC和GPS | ||||||
|   ObtainUdpBusinessInstance.onMsg((data: string) => { |   ObtainUdpBusinessInstance.onMsg((data: string) => { | ||||||
|  | |||||||
							
								
								
									
										30
									
								
								entry/src/main/ets/workers/Log.ets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								entry/src/main/ets/workers/Log.ets
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | |||||||
|  | import worker, { ThreadWorkerGlobalScope, MessageEvents, ErrorEvent } from '@ohos.worker'; | ||||||
|  | 
 | ||||||
|  | const workerPort: ThreadWorkerGlobalScope = worker.workerPort; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Defines the event handler to be called when the worker thread receives a message sent by the host thread. | ||||||
|  |  * The event handler is executed in the worker thread. | ||||||
|  |  * | ||||||
|  |  * @param e message data | ||||||
|  |  */ | ||||||
|  | workerPort.onmessage = (e: MessageEvents) => { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Defines the event handler to be called when the worker receives a message that cannot be deserialized. | ||||||
|  |  * The event handler is executed in the worker thread. | ||||||
|  |  * | ||||||
|  |  * @param e message data | ||||||
|  |  */ | ||||||
|  | workerPort.onmessageerror = (e: MessageEvents) => { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Defines the event handler to be called when an exception occurs during worker execution. | ||||||
|  |  * The event handler is executed in the worker thread. | ||||||
|  |  * | ||||||
|  |  * @param e error message | ||||||
|  |  */ | ||||||
|  | workerPort.onerror = (e: ErrorEvent) => { | ||||||
|  | } | ||||||
| @ -6,7 +6,7 @@ | |||||||
|     "pages/UserInfo", |     "pages/UserInfo", | ||||||
|     "pages/Register", |     "pages/Register", | ||||||
|     "pages/Settings", |     "pages/Settings", | ||||||
|     "pages/TerminalInfos", |     "pages/TerminalInfo", | ||||||
|     "pages/VideoConfig", |     "pages/VideoConfig", | ||||||
|     "pages/SignDisplay", |     "pages/SignDisplay", | ||||||
|     "pages/Roads", |     "pages/Roads", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user