fix: 隐藏部分快速打印
This commit is contained in:
		
							parent
							
								
									883807298b
								
							
						
					
					
						commit
						78be17b13b
					
				| @ -165,6 +165,10 @@ export interface EnvironmentConfigurationType { | ||||
|   isOpenFiniteDifference?: string | ||||
|   //   是否开启调试模式 | ||||
|   isOpenDebugger?: string | ||||
|   //   外壳版本 | ||||
|   version?: string | ||||
|   //   评判版本 | ||||
|   judgeVersion?: string | ||||
| } | ||||
| 
 | ||||
| //全局配置 | ||||
|  | ||||
| @ -1229,7 +1229,7 @@ struct UserInfoPage { | ||||
|         FaceCompare({ | ||||
|           sfzh: this.currentUser.sfzmhm, | ||||
|           firstImage: this.currentUser.kszp, | ||||
|           faceCompareSucess: $faceCompareSucess, | ||||
|           faceCompareSuccess: $faceCompareSucess, | ||||
|           getqkFlag: $getqkFlag, | ||||
|           faceCatchImg: $faceCatchImg, | ||||
|           showFaceCompare: $showFaceCompare, | ||||
|  | ||||
| @ -12,12 +12,6 @@ import { takePhoto, takePhotoParam } from '../../utils/Video'; | ||||
| import { voiceService } from '../../utils/Voice'; | ||||
| import { dConsole } from '../../utils/LogWorker'; | ||||
| 
 | ||||
| interface ParamType { | ||||
|   id?: number; | ||||
|   list?: number[]; | ||||
|   carNo?: string | undefined; | ||||
|   placeId?: string | undefined; | ||||
| } | ||||
| 
 | ||||
| @Component | ||||
| export default struct FaceCompare { | ||||
| @ -26,7 +20,7 @@ export default struct FaceCompare { | ||||
|   @Prop sfzh: string; | ||||
|   @Prop lsh: string; | ||||
|   @Prop firstImage: string; | ||||
|   @Link faceCompareSucess: number; | ||||
|   @Link faceCompareSuccess: number; | ||||
|   @Link showFaceCompare: boolean; | ||||
|   @Link getqkFlag: boolean; | ||||
|   @Link faceCatchImg: string; | ||||
| @ -48,14 +42,172 @@ export default struct FaceCompare { | ||||
|   private interval: number = -1 | ||||
|   private context = getContext(this) as common.UIAbilityContext; | ||||
| 
 | ||||
|   constructor() { | ||||
|     super() | ||||
|   async aboutToAppear() { | ||||
|     const fileUtil = new FileUtils(this.context) | ||||
|     this.carInfo = AppStorage.get<CarInfoType>('carInfo')! | ||||
|     this.fileUtil = fileUtil | ||||
|     this.getVideoConfig() | ||||
|   } | ||||
| 
 | ||||
|   clearIntervalFn() { | ||||
|     this.callBackFlag = false | ||||
|     clearInterval(this.interval) | ||||
|     this.vocObj && this.vocObj.releasePlayer() | ||||
|   } | ||||
| 
 | ||||
|   async faceCompareFn() { | ||||
|     dConsole.log('mmmmm0', 2) | ||||
|     this.param.pztd = this.param.rlls | ||||
|     const data: takePhotoParam = await takePhoto(this.param, this.context, 'jt/', 1,) | ||||
|     this.base64 = this.imageBase64 + (data?.base64 || "") | ||||
|     dConsole.log('mmmmt', this.base64) | ||||
|     faceCompare({ | ||||
|       sfzh: this.sfzh.toString(), | ||||
|       firstImage: this.firstImage.substr(22), | ||||
|       secondImage: data?.base64 || "", | ||||
|       type: "2", | ||||
|       verifyType: "1" | ||||
|     }) | ||||
|       .then(res => { | ||||
|         dConsole.log('mmmmm8', JSON.stringify(res)) | ||||
|         if (res.imageCompareRsp?.head?.resultCode == '0') { | ||||
|           this.controller.stop() | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|           this.faceCompareSuccess = 1; | ||||
|           // this.faceCatchImg = result | ||||
|           this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'yzcg.wav' | ||||
|           }) | ||||
|         } else { | ||||
|           this.times++; | ||||
|           //3s后开始语音提示 | ||||
|           this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'face_fail.mp3' | ||||
|           }) | ||||
| 
 | ||||
|         } | ||||
|       }) | ||||
|     dConsole.log('mmmmm8', 9) | ||||
|   } | ||||
| 
 | ||||
|   async heartMsg() { | ||||
|     let tmpList: number[] = [] | ||||
|     const str = this.lsh | ||||
|     dConsole.log('this.lshbitbit', this.lsh, this.carInfo.carNo, this.carInfo.examinationRoomId) | ||||
|     for (let i = 0; i < str.length; i++) { | ||||
|       if (str && str.charCodeAt(i) !== undefined) { | ||||
|         tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0]); | ||||
|       } | ||||
|     } | ||||
|     const param: UDPParamType = { | ||||
|       id: 46, | ||||
|       list: tmpList, | ||||
|       carNo: this.carInfo.carNo || "", | ||||
|       placeId: this.carInfo.examinationRoomId || "", | ||||
|       sendCallback: () => { | ||||
|         this.callBackFlag = true | ||||
|       } | ||||
|     } | ||||
|     CenterUDPBusinessInstance.sendData(param) | ||||
|     // UDP缺失 | ||||
|     // globalThis.udpClient2 && globalThis.udpClient2.sendMsgExt(param, this.context) | ||||
|     clearInterval(this.interval) | ||||
|     this.interval = setInterval(() => { | ||||
|       if (this.callBackFlag) { | ||||
|         const param2: UDPParamType = { | ||||
|           id: 47, | ||||
|           list: tmpList, | ||||
|           carNo: this.carInfo.carNo || "", | ||||
|           placeId: this.carInfo.examinationRoomId || "", | ||||
|         } | ||||
|         CenterUDPBusinessInstance.sendData(param2) | ||||
|       } | ||||
|     }, 1000) | ||||
|     CenterUDPBusinessInstance.onMsg((val) => { | ||||
|       if (AppStorage.get('statue') != 3) { | ||||
|         return | ||||
|       } | ||||
|       if (val.id == 48) { | ||||
|         if (val.body[13] == 1) { | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.vocObj && this.vocObj.releasePlayer() | ||||
|           this.faceCompareSuccess = 1 | ||||
|           clearInterval(this.interval) | ||||
|         } else if (val.body[13] == 1 && this.callBackFlag) { | ||||
|           AppStorage.setOrCreate('statue', 2) | ||||
|           this.vocObj && this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'face_chekc_fail.wav' | ||||
|           }) | ||||
|         } | ||||
|       } | ||||
|     }) | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   async getVideoConfig() { | ||||
|     dConsole.log('faceEnterIn') | ||||
|     this.vocObj = new voiceService(async (status: string, val?: string) => { | ||||
|       if (status == 'idle') { | ||||
|         if (val === 'face_check.mp3' || val === 'face_fail.mp3') { | ||||
|           if (this.times >= 3) { | ||||
|             AppStorage.setOrCreate('statue', 3); | ||||
|             this.faceCompareSuccess = -1; | ||||
|             this.vocObj && this.vocObj.playAudio({ | ||||
|               type: 1, | ||||
|               name: 'face_checking.wav', | ||||
|             }); | ||||
|             this.heartMsg(); | ||||
|           } else { | ||||
|             setTimeout(() => { | ||||
|               this.faceCompareFn(); | ||||
|             }, 2000); | ||||
|           } | ||||
|         } else if (val === 'yzcg.wav') { | ||||
|           this.showFaceCompare = !this.showFaceCompare; | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag; | ||||
|           AppStorage.setOrCreate('statue', 4); | ||||
|           this.faceCompareSuccess = 1; | ||||
|           this.vocObj && this.vocObj.releasePlayer(); | ||||
|         } else if (val === 'face_chekc_fail.wav') { | ||||
|           this.vocObj && this.vocObj.releasePlayer(); | ||||
|           this.faceCompareSuccess = -1; | ||||
|           this.showFaceCompare = !this.showFaceCompare; | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag; | ||||
|         } | ||||
|       } | ||||
|     }, this.context); | ||||
| 
 | ||||
|     const data = await this.fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/config3.txt'); | ||||
|     dConsole.log('faceEnterIn,data', data) | ||||
| 
 | ||||
|     setTimeout(() => { | ||||
|       this.vocObj && this.vocObj.playAudio({ | ||||
|         type: 1, | ||||
|         name: 'face_check.mp3' | ||||
|       }) | ||||
|     }, 1000) | ||||
|     this.param = JSON.parse(data) | ||||
|     this.param.userName = JSON.parse(data).userName | ||||
|     this.param.ip = this.param.ip | ||||
|     this.param.pwd = this.param.pwd | ||||
|     this.param.port = this.param.port | ||||
|     this.param.rlls = this.param.rlls | ||||
|     this.controller.start() | ||||
|   } | ||||
| 
 | ||||
|   async aboutToDisappear() { | ||||
|     clearInterval(this.interval) | ||||
|   } | ||||
| 
 | ||||
|   build() { | ||||
|     Column() { | ||||
|       Column() { | ||||
|         Text('照片比对')// .lineHeight('16%') | ||||
|         Text('照片比对') | ||||
|           .height('16%') | ||||
|           .fontWeight(FontWeight.Bold) | ||||
|           .fontSize(24) | ||||
| @ -122,7 +274,7 @@ export default struct FaceCompare { | ||||
|               this.vocObj && this.vocObj.releasePlayer() | ||||
|               this.showFaceCompare = !this.showFaceCompare | ||||
|               this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|               this.faceCompareSucess = -1 | ||||
|               this.faceCompareSuccess = -1 | ||||
|               AppStorage.setOrCreate('statue', 2) | ||||
|             }) | ||||
|           } | ||||
| @ -159,10 +311,8 @@ export default struct FaceCompare { | ||||
|         this.vocObj && this.vocObj.releasePlayer() | ||||
|         this.showFaceCompare = !this.showFaceCompare | ||||
|         this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|         this.faceCompareSucess = -1 | ||||
|         this.faceCompareSuccess = -1 | ||||
|         AppStorage.setOrCreate('statue', 2) | ||||
| 
 | ||||
| 
 | ||||
|       }) | ||||
|     } | ||||
|     .width('100%') | ||||
| @ -170,172 +320,5 @@ export default struct FaceCompare { | ||||
|     .backgroundColor('rgba(0, 0, 0, 0.8)') | ||||
|     .position({ x: 0, y: 0 }) | ||||
|   } | ||||
| 
 | ||||
|   onPageShow() { | ||||
|   } | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     const fileUtil = new FileUtils(this.context) | ||||
|     this.carInfo = AppStorage.get<CarInfoType>('carInfo')! | ||||
|     this.fileUtil = fileUtil | ||||
|     this.getVideoConfig() | ||||
|   } | ||||
| 
 | ||||
|   clearIntervalFn() { | ||||
|     this.callBackFlag = false | ||||
|     clearInterval(this.interval) | ||||
|     this.vocObj && this.vocObj.releasePlayer() | ||||
|   } | ||||
| 
 | ||||
|   async faceComparFn() { | ||||
|     dConsole.log('mmmmm0', 2) | ||||
|     this.param.pztd = this.param.rlls | ||||
|     const data: takePhotoParam = await takePhoto(this.param, this.context, 'jt/', 1,) | ||||
|     this.base64 = this.imageBase64 + (data?.base64 || "") | ||||
|     dConsole.log('mmmmt', this.base64) | ||||
|     faceCompare({ | ||||
|       sfzh: this.sfzh.toString(), | ||||
|       firstImage: this.firstImage.substr(22), | ||||
|       secondImage: data?.base64 || "", | ||||
|       type: "2", | ||||
|       verifyType: "1" | ||||
|     }) | ||||
|       .then(res => { | ||||
|         dConsole.log('mmmmm8', JSON.stringify(res)) | ||||
|         if (res.imageCompareRsp?.head?.resultCode == '0') { | ||||
|           this.controller.stop() | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|           this.faceCompareSucess = 1; | ||||
|           // this.faceCatchImg = result | ||||
|           this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'yzcg.wav' | ||||
|           }) | ||||
|         } else { | ||||
|           this.times++; | ||||
|           //3s后开始语音提示 | ||||
|           this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'face_fail.mp3' | ||||
|           }) | ||||
| 
 | ||||
|         } | ||||
|       }) | ||||
|     dConsole.log('mmmmm8', 9) | ||||
| 
 | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   async heartMsg() { | ||||
|     let tmpList: number[] = [] | ||||
|     const str = this.lsh | ||||
|     dConsole.log('this.lshbitbit', this.lsh, this.carInfo.carNo, this.carInfo.examinationRoomId) | ||||
|     for (let i = 0; i < str.length; i++) { | ||||
|       if (str && str.charCodeAt(i) !== undefined) { | ||||
|         tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0]); | ||||
|       } | ||||
|     } | ||||
|     const param: UDPParamType = { | ||||
|       id: 46, | ||||
|       list: tmpList, | ||||
|       carNo: this.carInfo.carNo || "", | ||||
|       placeId: this.carInfo.examinationRoomId || "", | ||||
|       sendCallback: () => { | ||||
|         this.callBackFlag = true | ||||
|       } | ||||
|     } | ||||
|     CenterUDPBusinessInstance.sendData(param) | ||||
|     // UDP缺失 | ||||
|     // globalThis.udpClient2 && globalThis.udpClient2.sendMsgExt(param, this.context) | ||||
|     clearInterval(this.interval) | ||||
|     this.interval = setInterval(() => { | ||||
|       if (this.callBackFlag) { | ||||
|         const param2: UDPParamType = { | ||||
|           id: 47, | ||||
|           list: tmpList, | ||||
|           carNo: this.carInfo.carNo || "", | ||||
|           placeId: this.carInfo.examinationRoomId || "", | ||||
|         } | ||||
|         CenterUDPBusinessInstance.sendData(param2) | ||||
|       } | ||||
|     }, 1000) | ||||
|     CenterUDPBusinessInstance.onMsg((val) => { | ||||
|       if (AppStorage.get('statue') != 3) { | ||||
|         return | ||||
|       } | ||||
|       if (val.id == 48) { | ||||
|         if (val.body[13] == 1) { | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag | ||||
|           this.showFaceCompare = !this.showFaceCompare | ||||
|           this.vocObj && this.vocObj.releasePlayer() | ||||
|           this.faceCompareSucess = 1 | ||||
|           clearInterval(this.interval) | ||||
|         } else if (val.body[13] == 1 && this.callBackFlag) { | ||||
|           AppStorage.setOrCreate('statue', 2) | ||||
|           this.vocObj && this.vocObj.playAudio({ | ||||
|             type: 1, | ||||
|             name: 'face_chekc_fail.wav' | ||||
|           }) | ||||
|         } | ||||
|       } | ||||
|     }) | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   async getVideoConfig() { | ||||
|     dConsole.log('faceEnterIn') | ||||
|     this.vocObj = new voiceService(async (status: string, val?: string) => { | ||||
|       if (status == 'idle') { | ||||
|         if (val === 'face_check.mp3' || val === 'face_fail.mp3') { | ||||
|           if (this.times >= 3) { | ||||
|             AppStorage.setOrCreate('statue', 3); | ||||
|             this.faceCompareSucess = -1; | ||||
|             this.vocObj && this.vocObj.playAudio({ | ||||
|               type: 1, | ||||
|               name: 'face_checking.wav', | ||||
|             }); | ||||
|             this.heartMsg(); | ||||
|           } else { | ||||
|             setTimeout(() => { | ||||
|               this.faceComparFn(); | ||||
|             }, 2000); | ||||
|           } | ||||
|         } else if (val === 'yzcg.wav') { | ||||
|           this.showFaceCompare = !this.showFaceCompare; | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag; | ||||
|           AppStorage.setOrCreate('statue', 4); | ||||
|           this.faceCompareSucess = 1; | ||||
|           this.vocObj && this.vocObj.releasePlayer(); | ||||
|         } else if (val === 'face_chekc_fail.wav') { | ||||
|           this.vocObj && this.vocObj.releasePlayer(); | ||||
|           this.faceCompareSucess = -1; | ||||
|           this.showFaceCompare = !this.showFaceCompare; | ||||
|           this.showFaceCompareFlag = !this.showFaceCompareFlag; | ||||
|         } | ||||
|       } | ||||
|     }, this.context); | ||||
| 
 | ||||
|     const data = await this.fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/config3.txt'); | ||||
|     dConsole.log('faceEnterIn,data', data) | ||||
| 
 | ||||
|     setTimeout(() => { | ||||
|       this.vocObj && this.vocObj.playAudio({ | ||||
|         type: 1, | ||||
|         name: 'face_check.mp3' | ||||
|       }) | ||||
|     }, 1000) | ||||
|     this.param = JSON.parse(data) | ||||
|     this.param.userName = JSON.parse(data).userName | ||||
|     this.param.ip = this.param.ip | ||||
|     this.param.pwd = this.param.pwd | ||||
|     this.param.port = this.param.port | ||||
|     this.param.rlls = this.param.rlls | ||||
|     this.controller.start() | ||||
|   } | ||||
| 
 | ||||
|   async aboutToDisappear() { | ||||
|     clearInterval(this.interval) | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -87,10 +87,12 @@ export default struct SignalDisplayComponent { | ||||
|       t++ | ||||
|     } | ||||
|     this.GPSColum[14].value = ((Number((this.signArr[97] || 0)) * 1.852).toFixed(2)).toString() | ||||
|     const str0 = this.signArr[93].slice(0, 2); | ||||
|     const str1 = this.signArr[93].slice(2, 4); | ||||
|     const str2 = this.signArr[93].slice(4); | ||||
|     this.signArr[93] = str2 + str1 + str0 | ||||
|     if (this.signArr.length > 93 && this.signArr[93]) { | ||||
|       const str0 = this.signArr[93].slice(0, 2); | ||||
|       const str1 = this.signArr[93].slice(2, 4); | ||||
|       const str2 = this.signArr[93].slice(4); | ||||
|       this.signArr[93] = str2 + str1 + str0 | ||||
|     } | ||||
|     this.GPSColum[10].value = this.signArr[93] | ||||
| 
 | ||||
|     // this.signArr[53]=192.168.7.170' | ||||
|  | ||||
| @ -62,7 +62,7 @@ class logWorker { | ||||
| 
 | ||||
|   // 通用日志方法 | ||||
|   private logWithLevel(level: 'log' | 'info' | 'error', ...args: ESObject[]): void { | ||||
|     console.log("当前环境查看", this.isLogEnabled, "日志级别:", level) | ||||
|     // console.log("当前环境查看", this.isLogEnabled, "日志级别:", level) | ||||
|     if (this.isLogEnabled === "1") { | ||||
|       const message = this.formatMessage(...args); | ||||
|       if (message.length > MAX_MESSAGE_LENGTH) { | ||||
|  | ||||
| @ -49,7 +49,7 @@ export const InitSerialPortData = | ||||
|   * @returns Promise<number> 成功返回发送的字节数,失败返回-1 | ||||
|  */ | ||||
| export const SendSerialPortData = (fd: number, data: number[]) => { | ||||
|   console.log(SerialPortTag, "wzj-----发送数据") | ||||
|   // console.log(SerialPortTag, "wzj-----发送数据") | ||||
|   return new Promise<number>((resolve, reject) => { | ||||
|     testNapi.SerialSendAsync(fd, data, (value: number) => { | ||||
|       if (value === -1) { | ||||
| @ -68,7 +68,7 @@ export const SendSerialPortData = (fd: number, data: number[]) => { | ||||
|   * @returns Promise<HiSerialSDK.receiveInfo> 成功返回接收到的数据,失败返回-1 | ||||
|  */ | ||||
| export const ReceiveSerialPortData = (fd: number, timeout: number,) => { | ||||
|   console.log(SerialPortTag, "wzj-----接受数据") | ||||
|   // console.log(SerialPortTag, "wzj-----接受数据") | ||||
|   return new Promise<HiSerialSDK.receiveInfo>((resolve) => { | ||||
|     testNapi.SerialRecvAsync(fd, timeout, (value: HiSerialSDK.receiveInfo) => { | ||||
|       resolve(value) | ||||
|  | ||||
| @ -79,7 +79,7 @@ export default class UdpClient { | ||||
|         address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1 | ||||
|       } | ||||
|     }).then(res => { | ||||
|       console.log(UDPTag, "udp发送成功", JSON.stringify(res)) | ||||
|       // console.log(UDPTag, "udp发送成功", JSON.stringify(res)) | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
| @ -139,7 +139,7 @@ export default class UdpClient { | ||||
|   private bindEvent() { | ||||
|     this.udp?.on("message", value => { | ||||
|       let result = this.dealMethod?.(value.message) | ||||
|       console.log(UDPTag, "中心返回消息", result) | ||||
|       // console.log(UDPTag, "中心返回消息", result) | ||||
|       this.messageEvents.forEach(cb => { | ||||
|         cb(result) | ||||
|       }) | ||||
|  | ||||
| @ -45,7 +45,7 @@ class CenterUDPBusiness { | ||||
|     this.timer = setInterval(() => { | ||||
|       // 生成流水号 | ||||
|       SerialNumberInstance.generate() | ||||
|       console.log(CenterUdpTag, "流水号生成") | ||||
|       // console.log(CenterUdpTag, "流水号生成") | ||||
|       // SetSerialNumber() | ||||
|       const arr = [this.signNum || 0, this.statue || 1] | ||||
|       let tmpList: number[] = []; | ||||
| @ -57,16 +57,16 @@ class CenterUDPBusiness { | ||||
|       for (let i = 0; i < str.length; i++) { | ||||
|         tmpList.push(NumberToByteArray(str.charCodeAt(i), 1 * 8)[0]) | ||||
|       } | ||||
|       console.log(CenterUdpTag, "学员流水号", JSON.stringify(tmpList)) | ||||
|       // console.log(CenterUdpTag, "学员流水号", JSON.stringify(tmpList)) | ||||
|       const data: UDPParamType = { | ||||
|         id: 31, | ||||
|         list: tmpList, | ||||
|         carNo: this.carInfo.carNo!, | ||||
|         placeId: this.carInfo.examinationRoomId! | ||||
|       } | ||||
|       console.log(CenterUdpTag, "查看生成的", JSON.stringify(data)) | ||||
|       // console.log(CenterUdpTag, "查看生成的", JSON.stringify(data)) | ||||
|       const param = this.setWholeMsg(data) | ||||
|       console.log(CenterUdpTag, "查看", JSON.stringify(param)) | ||||
|       // console.log(CenterUdpTag, "查看", JSON.stringify(param)) | ||||
|       this.udp.sendMsg(param); | ||||
|     }, 1000); | ||||
|   } | ||||
|  | ||||
| @ -67,7 +67,7 @@ class differentialAndSignal { | ||||
|   getMessage() { | ||||
|     this.workerInstance.onmessage = (e: MessageEvents): void => { | ||||
|       if (e.data) { | ||||
|         console.log(WorkerTag, "Worker 收到消息: " + e.data); | ||||
|         // console.log(WorkerTag, "Worker 收到消息: " + e.data); | ||||
|         this.events.forEach((callback) => { | ||||
|           callback(e.data); | ||||
|         }); | ||||
|  | ||||
| @ -41,7 +41,7 @@ class differentialSignal { | ||||
|   //   获取消息 | ||||
|   getData(callback: (data: ArrayBuffer) => void) { | ||||
|     this.differentialSignalTcp.onMsg((data: ArrayBuffer) => { | ||||
|       console.log(TCPTag, "获取", data); | ||||
|       // console.log(TCPTag, "获取", data); | ||||
|       callback(data); | ||||
|     }); | ||||
|   } | ||||
|  | ||||
| @ -135,6 +135,7 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl | ||||
|     if (!res || !res.head || res.head.resultCode === "1") { | ||||
|       resolve(false); | ||||
|     } | ||||
|     dConsole.log(InitTableTag, "插表操作开始"); | ||||
|     if (res && res.body) { | ||||
|       try { | ||||
|         const tableKeys = Object.keys(res.body); | ||||
| @ -145,9 +146,12 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl | ||||
| 
 | ||||
|           dConsole.log(InitTableTag, "-------------------表名-----------------------", newKey, isExit); | ||||
| 
 | ||||
|           if (!isExit) return false; | ||||
|           if (!isExit) { | ||||
|             dConsole.error(InitTableTag, newKey, "表不存在") | ||||
|             return false | ||||
|           } | ||||
| 
 | ||||
|           dConsole.log("可以插入的表", newKey, CenterMap.get(newKey)); | ||||
|           dConsole.log(InitTableTag, "可以插入的表", newKey, CenterMap.get(newKey)); | ||||
| 
 | ||||
|           let arrList: Array<RecordType> | RecordType = []; | ||||
|           const value: PublicInfoType = Reflect.get(res.body, key); | ||||
| @ -167,6 +171,7 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl | ||||
|           dConsole.log(InitTableTag, "插入表结果,表", newKey, "结果", result); | ||||
| 
 | ||||
|           if (!result) { | ||||
|             dConsole.log(InitTableTag, "初始化失败", newKey) | ||||
|             Prompt.showToast({ | ||||
|               message: `初始化表 ${newKey} 失败` | ||||
|             }); | ||||
|  | ||||
| @ -1,7 +1,13 @@ | ||||
| // 处理worker线程的消息tcp拿差分改正数,udp给后置机 | ||||
| import worker, { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope } from '@ohos.worker'; | ||||
| import { SerialPortTag, WorkerTag } from '../config'; | ||||
| import { CenterCallBackMsgType, WorkerBackMessage, WorkerBackMessageType, WorkerMessage } from '../model'; | ||||
| import { WorkerTag } from '../config'; | ||||
| import { | ||||
|   CenterCallBackMsgType, | ||||
|   EnvironmentConfigurationType, | ||||
|   WorkerBackMessage, | ||||
|   WorkerBackMessageType, | ||||
|   WorkerMessage | ||||
| } from '../model'; | ||||
| import { CenterUDPBusinessInstance } from '../utils/business/CenterUdpBusiness'; | ||||
| import { DifferentialSignal } from '../utils/business/DifferentialSignal'; | ||||
| import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness'; | ||||
| @ -23,7 +29,7 @@ workerPort.onmessage = (e: MessageEvents) => { | ||||
|   // if (result.centerUdpParam) { | ||||
|   //   CenterUDPBusinessInstance.sendData(result.centerUdpParam); | ||||
|   // } | ||||
|   getDataFn() | ||||
|   getDataFn(result.config) | ||||
|   // 必传环境配置 | ||||
|   if (result.close) { | ||||
|     closedFn(result) | ||||
| @ -50,19 +56,19 @@ function initFn(result: WorkerMessage) { | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| function getDataFn() { | ||||
| function getDataFn(config: EnvironmentConfigurationType) { | ||||
|   // 获取TCP差分改正数信号 | ||||
|   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拿到差分改正数发给后置机 | ||||
|     ObtainUdpBusinessInstance.sendData(data) | ||||
|   }) | ||||
|   // 后置机回执PLC和GPS | ||||
|   ObtainUdpBusinessInstance.onMsg(async (data: string) => { | ||||
|     if (data !== "") { | ||||
|     if (data !== "" && config.carType !== "2") { | ||||
|       // TODO | ||||
|       // 需要观察 | ||||
|       console.log(WorkerTag, "后置机消息", data) | ||||
|       // console.log(WorkerTag, "后置机消息", data) | ||||
|       const res = await SerialPortService.getData() | ||||
|       if (res.length > 0) { | ||||
|         const dataArray = data.split(","); | ||||
| @ -70,7 +76,7 @@ function getDataFn() { | ||||
|         dataArray[28] = res[9].toString(); | ||||
|         data = dataArray.join(","); | ||||
|       } | ||||
|       console.log(SerialPortTag, "处理完的档位信号", data) | ||||
|       // console.log(SerialPortTag, "处理完的档位信号", data) | ||||
|       workerPort.postMessage( | ||||
|         JSON.stringify({ | ||||
|           type: WorkerBackMessageType.ObtainUdpData, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user