cpp
This commit is contained in:
		
							parent
							
								
									e5eb8eb7b7
								
							
						
					
					
						commit
						7e69ada2d2
					
				| @ -87,6 +87,10 @@ struct Index { | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     try { | ||||
|       await this.initWireControlUDP() | ||||
|       await this.initPlatformUDP() | ||||
|       await this.initAudioPlayer() | ||||
|       await this.initBackMachineUDP() | ||||
|       await getConfigFile().then(([fieldModel, carModel, line, lib, teachPoint, teachPointParams, basePoint]) => { | ||||
|         this.fieldModel = fieldModel | ||||
|         this.carModel = carModel | ||||
| @ -102,7 +106,27 @@ struct Index { | ||||
|       await nativeLogCallback((message: string, _: number) => { | ||||
|         LogHelper.I("NativeSDK", "[Log Callback]: ", message) | ||||
|       }) | ||||
|       await registerControlCallback(() => { | ||||
|       await registerControlCallback((fxp: number, move: number) => { | ||||
|         if (fxp > 0) { | ||||
|           this.outWireControl.rightWheel(fxp) | ||||
|         } else { | ||||
|           this.outWireControl.leftWheel(fxp) | ||||
|         } | ||||
|         switch (move) { | ||||
|           case -1000: | ||||
|             break; | ||||
|           case -1: | ||||
|             this.outWireControl.moveDown() | ||||
|             break; | ||||
|           case 0: | ||||
|             this.outWireControl.moveStop() | ||||
|             break; | ||||
|           case 1: | ||||
|             this.outWireControl.moveUp() | ||||
|             break; | ||||
|           default: | ||||
|             break; | ||||
|         } | ||||
|         LogHelper.I("NativeSDK", "[Control Callback]: ") | ||||
|       }) | ||||
|       await registerSoundCallback(() => { | ||||
| @ -110,11 +134,6 @@ struct Index { | ||||
|       }) | ||||
|       await setImageSize(500, 300) | ||||
|       await setConfigFile(this.basePoint, this.fieldModel, this.teachPoint, this.teachPointParams, this.carModel, this.line, this.lib) | ||||
|       this.outWireControl = new OutWireControl() | ||||
|       await this.outWireControl.init("192.168.7.181", 30021) | ||||
|       await this.initPlatformUDP() | ||||
|       await this.initAudioPlayer() | ||||
|       await this.initBackMachineUDP() | ||||
|     } catch (err) { | ||||
|       promptAction.showToast({ | ||||
|         message: JSON.stringify(err?.message || err), | ||||
| @ -145,9 +164,9 @@ struct Index { | ||||
|     try { | ||||
|       await this.simulatorUdpClient.bindUdp() | ||||
|       // this.simulatorUdpClient.heart() | ||||
|       setInterval(() => { | ||||
|         this.simulatorUdpClient.uploadPosition(new GpsInfo(), new CarInfo()) | ||||
|       }, 1000) | ||||
|       // setInterval(() => { | ||||
|       //   this.simulatorUdpClient.uploadPosition(new GpsInfo(), new CarInfo()) | ||||
|       // }, 1000) | ||||
|       this.simulatorUdpClient.onMessage(({type, data = [] }: MessageCallBackParams) => { | ||||
|         if (type === CommandType.Start) { | ||||
|           let path = this.paths.findIndex(item => { | ||||
| @ -194,6 +213,12 @@ struct Index { | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // 初始化车机控制UDP | ||||
|   async initWireControlUDP() { | ||||
|     this.outWireControl = new OutWireControl() | ||||
|     await this.outWireControl.init("192.168.7.181", 30021) | ||||
|   } | ||||
| 
 | ||||
|   // 上方按钮点击 | ||||
|   onConfirm() { | ||||
|     if (this.status === Status.Idle) { | ||||
| @ -202,9 +227,12 @@ struct Index { | ||||
|       this.simulatorUdpClient?.sendPID26(CommandType.Start) | ||||
|       selectLineAndLib(this.paths[this.currentPath].properties.id, this.libraries[this.currentLibrary].properties.id) | ||||
|       this.status = Status.Running | ||||
|       this.outWireControl.apaStart() | ||||
|     } else { | ||||
|       this.simulatorUdpClient?.sendPID26(CommandType.Stop) | ||||
|       this.status = Status.Idle | ||||
|       this.outWireControl.moveStop() | ||||
|       this.outWireControl.apaStop() | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user