Compare commits
	
		
			6 Commits
		
	
	
		
			ee4d54e8d7
			...
			beb6ba1b60
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | beb6ba1b60 | ||
|  | 2321052cc1 | ||
|  | 19d409cf54 | ||
|  | 7e7900a124 | ||
|  | d64d951f1e | ||
|  | e6a75028c5 | 
| @ -145,4 +145,5 @@ export async function initCarParameter(params: object) { | ||||
|     method: http.RequestMethod.POST, | ||||
|     xml: false, | ||||
|   }) | ||||
| } | ||||
| } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										94
									
								
								entry/src/main/ets/api/networkCamera.ets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								entry/src/main/ets/api/networkCamera.ets
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,94 @@ | ||||
| import http from '@ohos.net.http'; | ||||
| import buffer from '@ohos.buffer'; | ||||
| import image from '@ohos.multimedia.image'; | ||||
| 
 | ||||
| const TAG = 'CameraService'; | ||||
| 
 | ||||
| export async function ObtainNetworkCameraImages(): Promise<string | null> { | ||||
|   const url = "http://192.168.1.125/snapshot.cgi?stream=1&username=admin&password=123456"; | ||||
|   let httpRequest = http.createHttp(); | ||||
| 
 | ||||
|   try { | ||||
|     console.info(TAG, 'Starting image request...'); | ||||
|     const response = await httpRequest.request(url, { | ||||
|       method: http.RequestMethod.GET, | ||||
|       connectTimeout: 10000, | ||||
|       readTimeout: 10000, | ||||
|       expectDataType: http.HttpDataType.ARRAY_BUFFER, | ||||
|     }); | ||||
| 
 | ||||
|     if (response.responseCode === 200) { | ||||
|       let arrayBuffer = response.result as ArrayBuffer; | ||||
| 
 | ||||
|       // 裁剪左半部分 | ||||
|       const croppedBase64 = await cropLeftHalf(arrayBuffer); | ||||
| 
 | ||||
|       return croppedBase64; | ||||
|     } else { | ||||
|       console.error(TAG, `HTTP Error: ${response.responseCode}`); | ||||
|       return null; | ||||
|     } | ||||
|   } catch (error) { | ||||
|     console.error(TAG, 'An error occurred while fetching the image.', JSON.stringify(error)); | ||||
|     return null; | ||||
|   } finally { | ||||
|     httpRequest.destroy(); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| async function cropLeftHalf(arrayBuffer: ArrayBuffer): Promise<string> { | ||||
|   let imageSource: image.ImageSource | null = null; | ||||
|   let pixelMap: image.PixelMap | null = null; | ||||
| 
 | ||||
|   try { | ||||
|     // 1. 创建ImageSource | ||||
|     imageSource = image.createImageSource(arrayBuffer); | ||||
| 
 | ||||
|     // 2. 获取图片信息 | ||||
|     const imageInfo = await imageSource.getImageInfo(); | ||||
|     console.info(TAG, `Original image size: ${imageInfo.size.width}x${imageInfo.size.height}`); | ||||
| 
 | ||||
|     // 3. 计算并定义左半部分的裁剪区域 | ||||
|     const leftHalfWidth = Math.floor(imageInfo.size.width / 2); | ||||
|     const cropRegion: image.Region = { | ||||
|       size: { | ||||
|         width: leftHalfWidth, | ||||
|         height: imageInfo.size.height | ||||
|       }, | ||||
|       x: 0, | ||||
|       y: 0 | ||||
|     }; | ||||
| 
 | ||||
|     // 创建解码选项,并将裁剪区域放入其中 | ||||
|     const decodingOptions: image.DecodingOptions = { | ||||
|       desiredRegion: cropRegion | ||||
|     }; | ||||
| 
 | ||||
|     // 4. 创建像素映射并进行裁剪 | ||||
|     pixelMap = await imageSource.createPixelMap(decodingOptions); | ||||
| 
 | ||||
|     // 5. 将裁剪后的PixelMap转换为ArrayBuffer | ||||
|     const imagePacker = image.createImagePacker(); | ||||
|     const packedData = await imagePacker.packing(pixelMap, { | ||||
|       format: "image/jpeg", | ||||
|       quality: 90 | ||||
|     }); | ||||
| 
 | ||||
|     // 6. 转换为Base64 | ||||
|     const buf = buffer.from(packedData); | ||||
|     const base64 = buf.toString('base64'); | ||||
| 
 | ||||
|     const result = `data:image/jpeg;base64,${base64}`; | ||||
|     console.info(TAG, `Left half cropped successfully. Size: ${leftHalfWidth}x${imageInfo.size.height}`); | ||||
| 
 | ||||
|     return result; | ||||
| 
 | ||||
|   } catch (error) { | ||||
|     console.error(TAG, 'Image cropping failed:', JSON.stringify(error)); | ||||
|     return ""; | ||||
|   } finally { | ||||
|     // 7. 在 finally 块中安全地释放资源 | ||||
|     imageSource?.release(); | ||||
|     pixelMap?.release(); | ||||
|   } | ||||
| } | ||||
| @ -26,7 +26,7 @@ export const JudgeConfig: JudgeConfigType = { | ||||
|   // 本地模型地址 | ||||
|   modelPath: 'models/model_enc', | ||||
|   // 济南科目三 | ||||
|   trajectoryPath: 'logs/2024_10_12/2024_10_12_11_50_10_9999427676823_744299437502336256_隋统/judge_exam_data.txt', | ||||
|   trajectoryPath: 'logs/2025_08_22/2025_08_22_17_09_49_9999245520855_654211778346526080_杜兰曼/judge_exam_data.txt', | ||||
|   //四合一画面配置 | ||||
|   fourInOneScreen: { | ||||
|     //gps位数 | ||||
|  | ||||
| @ -169,6 +169,8 @@ export interface EnvironmentConfigurationType { | ||||
|   version?: string | ||||
|   //   评判版本 | ||||
|   judgeVersion?: string | ||||
|   //   是否使用网络摄像头 | ||||
|   isUseNetworkCamera?: string | ||||
| } | ||||
| 
 | ||||
| //全局配置 | ||||
|  | ||||
| @ -19,6 +19,7 @@ import Prompt from '@system.prompt'; | ||||
| import { DifferentialAndSignal } from '../utils/business/DifferentialAndSignalWorker'; | ||||
| import { dConsole } from '../utils/LogWorker'; | ||||
| import CarLoadingComponent from './Index/Loading'; | ||||
| import { ObtainNetworkCameraImages } from '../api/networkCamera'; | ||||
| 
 | ||||
| @Entry | ||||
| @Component | ||||
| @ -40,6 +41,7 @@ struct Index { | ||||
|   @State isPlay: boolean = false; | ||||
|   @State initWork: boolean = false | ||||
|   @State status: string = "开始" | ||||
|   @State base64Img: string = "" | ||||
|   // 请求网络表等待弹窗 | ||||
|   customDialogController: CustomDialogController = new CustomDialogController({ | ||||
|     builder: CarLoadingComponent(), | ||||
| @ -62,6 +64,7 @@ struct Index { | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     dConsole.log("权限首页 aboutToAppear") | ||||
|     this.base64Img = await ObtainNetworkCameraImages() || "" | ||||
|     this.ratio = AppStorage.get<BaseInfoType>('baseInfo')?.ratio || 1.4 | ||||
|     this.angle = 0 | ||||
|     AppStorage.set('lsh', '1111111111111') | ||||
| @ -217,7 +220,7 @@ struct Index { | ||||
|       HeaderComponent({ | ||||
|         shortLogo: false | ||||
|       }) | ||||
| 
 | ||||
|      | ||||
|       CardComponent({ | ||||
|         isSingle: this.singlePlay, | ||||
|         singleClick: () => { | ||||
|  | ||||
| @ -37,20 +37,21 @@ export default struct SignalTrajectoryDialog { | ||||
|         }) | ||||
|       } | ||||
| 
 | ||||
|       Scroll() { | ||||
|         Column() { | ||||
|           if (this.active !== 2) { | ||||
|             SignalDisplayComponent({ | ||||
|               active: this.active, | ||||
|             }) | ||||
|           } else { | ||||
|             TrajectoryViewComponent({ | ||||
|               laneSignal: this.laneSignal | ||||
|             }) | ||||
|           } | ||||
|       // Scroll() { | ||||
|       Column() { | ||||
|         if (this.active !== 2) { | ||||
|           SignalDisplayComponent({ | ||||
|             active: this.active, | ||||
|             heightNum: 1500 | ||||
|           }) | ||||
|         } else { | ||||
|           TrajectoryViewComponent({ | ||||
|             laneSignal: this.laneSignal | ||||
|           }) | ||||
|         } | ||||
| 
 | ||||
|         }.height(890) | ||||
|       }.width("100%") | ||||
|       }.height(890) | ||||
|       // }.width("100%") | ||||
|       .height(700) | ||||
|     }.width(1500) | ||||
| 
 | ||||
|  | ||||
| @ -6,11 +6,9 @@ import { | ||||
|   DefaultJudgeConfigObj, | ||||
|   ExtendType, | ||||
|   Gps, | ||||
|   JudgeSound, | ||||
|   LANE, | ||||
|   MarkRule, | ||||
|   PLCType, | ||||
|   ProcessDataEnumType, | ||||
|   ProjectInfo, | ||||
|   ProjectInfos, | ||||
|   ProjectRoads, | ||||
| @ -21,7 +19,6 @@ import { ArrayToByteArray, NumberToByteArray } from '../../utils/Common'; | ||||
| import dayTs from '../../utils/Date'; | ||||
| import { dConsole } from '../../utils/LogWorker'; | ||||
| import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements'; | ||||
| import { examJudgeSoundEnd } from './JudgeSDKUtils'; | ||||
| 
 | ||||
| 
 | ||||
| // 中心信号转换 | ||||
| @ -863,23 +860,23 @@ export const CurrentProjectConversion = (code: number, projectsObj: object): str | ||||
|  * @param sound - 评判音频对象 | ||||
|  * @param avPlayer - 语音播放器实例 | ||||
|  */ | ||||
| export function PlayJudgeVoice(sound: JudgeSound, avPlayer: VoiceAnnounce) { | ||||
|   if (sound.type == 1) { | ||||
|     avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`], false, () => { | ||||
|       examJudgeSoundEnd({ | ||||
|         xmdm: sound.xmdm, code: sound.code[0], type: sound.type | ||||
|       }); | ||||
|       dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({ | ||||
|         method: 'examJudgeSoundEnd', | ||||
|         itemno: sound.xmdm, | ||||
|         code: sound.code[0], | ||||
|         type: sound.type, | ||||
|       })); | ||||
|     }); | ||||
|   } else { | ||||
|     avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`]); | ||||
|   } | ||||
| } | ||||
| // export function PlayJudgeVoice(sound: JudgeSound, avPlayer: VoiceAnnounce) { | ||||
| //   if (sound.type == 1) { | ||||
| //     avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`], false, () => { | ||||
| //       examJudgeSoundEnd({ | ||||
| //         xmdm: sound.xmdm, code: sound.code[0], type: sound.type | ||||
| //       }); | ||||
| //       dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({ | ||||
| //         method: 'examJudgeSoundEnd', | ||||
| //         itemno: sound.xmdm, | ||||
| //         code: sound.code[0], | ||||
| //         type: sound.type, | ||||
| //       })); | ||||
| //     }); | ||||
| //   } else { | ||||
| //     avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`]); | ||||
| //   } | ||||
| // } | ||||
| 
 | ||||
| /** | ||||
|  * 检查差分 | ||||
|  | ||||
| @ -7,14 +7,15 @@ import ethernet from '@ohos.net.ethernet'; | ||||
| import { BusinessError } from '@ohos.base'; | ||||
| import Prompt from '@system.prompt'; | ||||
| import { dConsole } from '../utils/LogWorker'; | ||||
| import window from '@ohos.window'; | ||||
| 
 | ||||
| @Entry | ||||
| @Component | ||||
| struct TerminalInfoPage { | ||||
|   @State config: EnvironmentConfigurationType = {} | ||||
|   @State isProcessing: boolean = false; | ||||
|   private fileUtil!: FileUtils | ||||
|   private context = getContext(this) as common.UIAbilityContext; | ||||
|   @State isProcessing: boolean = false; | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     this.fileUtil = new FileUtils(this.context) | ||||
| @ -186,6 +187,14 @@ struct TerminalInfoPage { | ||||
|                   this.config.isOpenFiniteDifference = value; | ||||
|                 } | ||||
|               }) | ||||
|               blockComponent({ | ||||
|                 label: "开启网络摄像头", | ||||
|                 type: 7, | ||||
|                 value: this.config.isUseNetworkCamera, | ||||
|                 change: (value: string) => { | ||||
|                   this.config.isUseNetworkCamera = value; | ||||
|                 } | ||||
|               }) | ||||
|               blockComponent({ | ||||
|                 label: "是否开启日志", | ||||
|                 type: 2, | ||||
| @ -203,15 +212,20 @@ struct TerminalInfoPage { | ||||
|                 } | ||||
|               }) | ||||
|               blockComponent({ | ||||
|                 label: "开启调试(重启APP)", | ||||
|                 label: "开启调试", | ||||
|                 type: 6, | ||||
|                 value: this.config.isOpenDebugger, | ||||
|                 change: (value: string) => { | ||||
|                 change: async (value: string) => { | ||||
|                   this.config.isOpenDebugger = value; | ||||
|                   const win = await window.getLastWindow(this.context); | ||||
|                   if (value === "1") { | ||||
|                     win.setWindowSystemBarEnable(['status', 'navigation']) | ||||
|                   } else { | ||||
|                     win.setWindowSystemBarEnable([]) | ||||
|                   } | ||||
|                 } | ||||
|               }) | ||||
|             }.margin(20) | ||||
| 
 | ||||
|           } | ||||
|           .height(650) | ||||
|           .width("100%") | ||||
| @ -222,7 +236,6 @@ struct TerminalInfoPage { | ||||
|             top: 10 | ||||
|           }) | ||||
| 
 | ||||
| 
 | ||||
|           Row() { | ||||
|             Image($r('app.media.bc')).height(80).objectFit(ImageFit.Contain).onClick(() => { | ||||
|               if (this.isProcessing) { | ||||
| @ -396,7 +409,7 @@ struct blockComponent { | ||||
|             }) | ||||
|         } else { | ||||
|           ForEach(this.type === 1 ? this.rearMachineModelList : | ||||
|             this.type === 2 || this.type === 5 || this.type === 6 ? this.logList : | ||||
|             this.type === 2 || this.type === 5 || this.type === 6 || this.type === 7 ? this.logList : | ||||
|               this.type === 3 ? this.boardList : this.carTypeList, (item: CommonListType, index) => { | ||||
|             Radio({ value: item.label, group: 'terRadioGroup' + this.type }) | ||||
|               .borderColor('#E5CBA1') | ||||
|  | ||||
| @ -2,19 +2,19 @@ | ||||
| export default struct BlockComponent { | ||||
|   @State label: string = "发送次数" | ||||
|   @Prop value: string = "1" | ||||
|   @State widthNum: number = 130 | ||||
|   @State widthNum: number = 150 | ||||
|   @State heightNum: number = 70 | ||||
|   @State color: string = "#FDF5E7" | ||||
| 
 | ||||
|   build() { | ||||
|     Row() { | ||||
|       Row() { | ||||
|         Text(this.label + ":").fontColor(this.color).fontSize(14) | ||||
|         Text(this.label + ":").fontColor(this.color).fontSize(20) | ||||
|       }.width(this.widthNum).justifyContent(FlexAlign.End) | ||||
| 
 | ||||
|       Row() { | ||||
|         Text(this.value).fontColor(this.color) | ||||
|       }.width(80).justifyContent(FlexAlign.Start).margin({ | ||||
|         Text(this.value).fontColor(this.color).fontSize(24) | ||||
|       }.width(150).justifyContent(FlexAlign.Start).margin({ | ||||
|         left: 20 | ||||
|       }) | ||||
|     } | ||||
|  | ||||
| @ -10,11 +10,13 @@ export default struct CoordinateComponent { | ||||
|   build() { | ||||
|     Flex({ | ||||
|       direction: FlexDirection.Column, | ||||
|       alignItems: ItemAlign.Center | ||||
|       alignItems: ItemAlign.Center, | ||||
|       justifyContent: FlexAlign.Center | ||||
|     }) { | ||||
|       Text("GPS坐标").fontColor("#FFB433").fontSize(20).margin({ | ||||
|         top: 10 | ||||
|       }) | ||||
|       Row() { | ||||
|         Text("GPS坐标").fontColor("#FFB433").fontSize(20) | ||||
|       }.height(70) | ||||
| 
 | ||||
|       Flex({ | ||||
|         wrap: FlexWrap.Wrap, | ||||
|         direction: this.isItHorizontal ? FlexDirection.Row : FlexDirection.Column | ||||
| @ -30,7 +32,10 @@ export default struct CoordinateComponent { | ||||
|       }.width("100%") | ||||
|     } | ||||
|     .width("100%") | ||||
|     .height(this.isItHorizontal ? 210 : "100%") | ||||
|     .height(this.isItHorizontal ? 280 : "100%") | ||||
|     .backgroundColor("#1A1A1A") | ||||
|     .margin({ | ||||
|       bottom: 20 | ||||
|     }) | ||||
|   } | ||||
| } | ||||
| @ -20,6 +20,7 @@ export default struct SignalDisplayComponent { | ||||
|   @Prop active: number = 0 | ||||
|   // 原始数据 | ||||
|   @State rawData: string = "$GPS,,,,,,,,,,,,,,,,,,,,,,,,,,,,," | ||||
|   @State heightNum: number = 1200 | ||||
| 
 | ||||
|   aboutToAppear(): void { | ||||
|     DifferentialAndSignal.onMsg(this.getMsg) | ||||
| @ -47,7 +48,6 @@ export default struct SignalDisplayComponent { | ||||
|     for (let i = 0; i <= 12; i++) { | ||||
|       this.vehicleSignal[i].value = this.signArr[i+2] | ||||
|     } | ||||
| 
 | ||||
|     this.vehicleSignal[13].value = this.signArr[17] | ||||
|     this.vehicleSignal[14].value = this.signArr[18] | ||||
|     this.vehicleSignal[15].value = this.signArr[19] | ||||
| @ -85,11 +85,12 @@ export default struct SignalDisplayComponent { | ||||
|       this.signArr[93] = str2 + str1 + str0 | ||||
|     } | ||||
|     this.GPSColum[10].value = this.signArr[93] | ||||
| 
 | ||||
|     // this.signArr[53]=192.168.7.170' | ||||
|     this.vehicleSignal = JSON.parse(JSON.stringify((this.vehicleSignal))) | ||||
|     this.signArr = JSON.parse(JSON.stringify((this.signArr))) | ||||
|     this.GPSColum = JSON.parse(JSON.stringify((this.GPSColum))) | ||||
|     // this.vehicleSignal = this.vehicleSignal.slice() | ||||
|     // this.signArr = this.signArr.slice() | ||||
|     // this.GPSColum = this.GPSColum.slice() | ||||
|   } | ||||
| 
 | ||||
|   build() { | ||||
| @ -97,26 +98,28 @@ export default struct SignalDisplayComponent { | ||||
|       Flex({ | ||||
|         direction: FlexDirection.Column, | ||||
|       }) { | ||||
|         // 信号查看 | ||||
|         if (this.active === 0) { | ||||
|           // GPS信号展示 | ||||
|           GPSComponent({ | ||||
|             data: this.signArr | ||||
|           }) | ||||
|           //   车载信号以及车载坐标 | ||||
|           CarComponent({ | ||||
|             data: this.vehicleSignal | ||||
|           }) | ||||
|           CoordinateComponent({ | ||||
|             data: this.GPSColum | ||||
|           }) | ||||
| 
 | ||||
|         } else if (this.active === 1) { | ||||
|           // 原始数据 | ||||
|           Column() { | ||||
|             Text(this.rawData).fontSize(20).fontColor("#fff") | ||||
|           }.backgroundColor("#282828").width("100%").height("100%") | ||||
|         } | ||||
|         Scroll() { | ||||
|           // 信号查看 | ||||
|           if (this.active === 0) { | ||||
|             Column() { | ||||
|               //   车载信号以及车载坐标 | ||||
|               CarComponent({ | ||||
|                 data: this.vehicleSignal, | ||||
|                 GPSData: this.signArr | ||||
|               }) | ||||
|               CoordinateComponent({ | ||||
|                 data: this.GPSColum | ||||
|               }) | ||||
|             }.height(this.heightNum).padding({ | ||||
|               bottom: 20 | ||||
|             }) | ||||
|           } else if (this.active === 1) { | ||||
|             // 原始数据 | ||||
|             Column() { | ||||
|               Text(this.rawData).fontSize(20).fontColor("#fff") | ||||
|             }.backgroundColor("#282828").width("100%").height("100%") | ||||
|           } | ||||
|         }.height("100%").backgroundColor("#1A1A1A") | ||||
|       } | ||||
|       .width("100%") | ||||
|       .height("100%") | ||||
| @ -129,8 +132,9 @@ export default struct SignalDisplayComponent { | ||||
| 
 | ||||
| 
 | ||||
| @Component | ||||
| struct GPSComponent { | ||||
|   @Prop data: Array<string> | ||||
| struct CarComponent { | ||||
|   @Prop data: Array<SignalDataType> | ||||
|   @Prop GPSData: Array<string> | ||||
|   @State ip: string = "" | ||||
| 
 | ||||
|   aboutToAppear(): void { | ||||
| @ -147,35 +151,36 @@ struct GPSComponent { | ||||
| 
 | ||||
|   build() { | ||||
|     Flex({ | ||||
|       wrap: FlexWrap.Wrap | ||||
|       wrap: FlexWrap.Wrap, | ||||
|       justifyContent: FlexAlign.Center | ||||
|     }) { | ||||
|       BlockComponent({ | ||||
|         label: "发送次数", | ||||
|         value: this.data[49] || "-" | ||||
|         value: this.GPSData[49] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "固件版本", | ||||
|         value: this.data[54] || "-" | ||||
|         value: this.GPSData[54] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "方向盘类型", | ||||
|         value: this.data[50] || "-" | ||||
|         value: this.GPSData[50] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "按键数值", | ||||
|         value: this.data[55] || "-" | ||||
|         value: this.GPSData[55] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "GPS错误次数", | ||||
|         value: this.data[60] || "-" | ||||
|         value: this.GPSData[60] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "汽车类型", | ||||
|         value: this.data[51] || "-" | ||||
|         value: this.GPSData[51] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "GPS板卡类型", | ||||
|         value: this.data[56] || "-" | ||||
|         value: this.GPSData[56] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "本机IP", | ||||
| @ -183,47 +188,35 @@ struct GPSComponent { | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "接口心跳", | ||||
|         value: this.data[52] || "-" | ||||
|         value: this.GPSData[52] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "GPS板卡软件版本", | ||||
|         value: this.data[57] || "-" | ||||
|         value: this.GPSData[57] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "改正数次数/改正数大小", | ||||
|         value: this.data[58] || "-" | ||||
|         value: this.GPSData[58] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "已工作时长/设定工作时长", | ||||
|         value: this.data[61] || "-" | ||||
|         value: this.GPSData[61] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "GPS数据次数/数据长度", | ||||
|         value: this.data[59] || "-" | ||||
|         value: this.GPSData[59] || "-" | ||||
|       }) | ||||
|       BlockComponent({ | ||||
|         label: "改正数据长度*数据长度-基准站RTCM改正数类型", | ||||
|         value: this.data[62] || "-" | ||||
|         value: this.GPSData[62] || "-" | ||||
|       }) | ||||
|     }.backgroundColor("#282828").width("100%").height(140) | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| @Component | ||||
| struct CarComponent { | ||||
|   @Prop data: Array<SignalDataType> | ||||
| 
 | ||||
|   build() { | ||||
|     Flex({ | ||||
|       wrap: FlexWrap.Wrap | ||||
|     }) { | ||||
|       ForEach(this.data, (item: SignalDataType) => { | ||||
|         BlockComponent({ | ||||
|           label: item.key, | ||||
|           value: item.value | ||||
|         }) | ||||
|       }) | ||||
|     }.width("100%").backgroundColor("#282828").height(490) | ||||
|     }.width("100%").backgroundColor("#282828") | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -168,48 +168,6 @@ export default class Judge { | ||||
|   private isExamEnd: boolean | ||||
|   // 是否发送udp | ||||
|   private isUdpEnd: boolean = false | ||||
|   // 处理udp plc信号 | ||||
|   handleUdp = async (msg: string) => { | ||||
|     const stachArr = msg.split(',') | ||||
|     if (stachArr[0] != '#DN_GD' || this.isUdpEnd) { | ||||
|       return | ||||
|     } | ||||
|     const gpsPart = msg.split("#END$GPS,")[1]; | ||||
|     const gpsStatus = gpsPart.split(",")[0]; | ||||
|     if (gpsStatus === "4") { | ||||
|       dConsole.log(JudgeTag, "差分状态正常", gpsStatus) | ||||
|       this.judgeUI.isDwztRight = true | ||||
|     } else { | ||||
|       dConsole.log(JudgeTag, "差分状态异常", gpsStatus) | ||||
|       this.judgeUI.isDwztRight = false | ||||
|     } | ||||
|     this.judgeUI.isDwztRight | ||||
|     const plcData = await this.getPlcData(msg); | ||||
|     // 4.过程数据 | ||||
|     // await this.fileLog?.setExamJudgeData(JSON.stringify(plcData)) | ||||
|     dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify(plcData)) | ||||
|     //检测到有无锡所设备接入,需要发送特定的数据,供检测 | ||||
|     // if (this.usbService.isWXUSBDevice) { | ||||
|     //   const str = await senorToWXDataStr(msg); | ||||
|     //   this.usbService.sendUSB(str) | ||||
|     // } | ||||
|     const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350') | ||||
|     this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + '' | ||||
|     this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + '' | ||||
|     //TODO 暂时关闭差分检测异常 | ||||
|     // await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt); | ||||
|     if (!this.isExamEnd) { | ||||
|       await examJudgeRealExam(plcData) | ||||
|     } | ||||
|     // let udpIndex = AppStorage.get<number>('udpIndex') || 0; | ||||
|     // if (udpIndex % 5 === 0 && !this.isUdpEnd) { | ||||
|     // TODO UPD缺失 | ||||
|     // const judgeUdp = globalThis.judgeUdp | ||||
|     // const bytes = await this.getMessageHeartbeat(this.isExamEnd); | ||||
|     // judgeUdp.send(bytes) | ||||
|     // } | ||||
|     // AppStorage.setOrCreate('udpIndex', udpIndex++) | ||||
|   } | ||||
|   //是否手动结束考试 | ||||
|   private isManual: boolean = false | ||||
|   //UDP服务序列号 | ||||
| @ -254,60 +212,6 @@ export default class Judge { | ||||
|     dConsole.info(JudgeTag, '过程数据文件上传 end') | ||||
|   } | ||||
|   private judgeTask: JudgeTask | ||||
|   // 检测扣分、结束项目时该项目是否开始 | ||||
|   checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: MarkRule) => { | ||||
|     if (xmdm == 20) { | ||||
|       return true | ||||
|     } | ||||
|     const judgeUI = this.judgeUI; | ||||
|     const judgeTask = this.judgeTask; | ||||
|     const projectsObj: object = this.judgeUI.projectsObj | ||||
|     const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) | ||||
|     const isUpload = currentProject.isUpload | ||||
| 
 | ||||
|     //如果项目没有开始 | ||||
|     dConsole.info(JudgeTag, 'surenjun isUpload=>', isUpload) | ||||
|     if (!isUpload) { | ||||
|       dConsole.info(JudgeTag, '项目补传开始') | ||||
|       //项目开始补传 | ||||
|       judgeTask.addTask(async () => { | ||||
|         await this.beginProject(xmdm) | ||||
|       }, { | ||||
|         isDelay: true | ||||
|       }) | ||||
|       judgeTask.addTask(async () => { | ||||
|         await this.uploadProgressPhoto(xmdm) | ||||
|       }, { | ||||
|         isDelay: true | ||||
|       }) | ||||
|       currentProject.isUpload = true; | ||||
|       Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) | ||||
|       //扣分补传 | ||||
|       if (currentType == 2) { | ||||
|         judgeTask.addTask(async () => { | ||||
|           await this.pointsDedute(xmdm, kf!) | ||||
|         }, { | ||||
|           isDelay: true | ||||
|         }) | ||||
|       } | ||||
|       //扣分补传判断是否合格 不合格补传项目结束 | ||||
|       if (currentType == 1 || (currentType == 2 && this.totalScore < judgeUI.passingScore)) { | ||||
|         judgeTask.addTask(async () => { | ||||
|           await this.endProject(xmdm) | ||||
|         }, { | ||||
|           isDelay: true | ||||
|         }) | ||||
|         currentProject.isEnd = true; | ||||
|         Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) | ||||
|       } | ||||
|       judgeTask.addTask(async () => { | ||||
|         this.checkExamIsEnd() | ||||
|       }) | ||||
|       return false; | ||||
|     } else { | ||||
|       return true | ||||
|     } | ||||
|   } | ||||
|   private tempData?: PLCType | ||||
|   //实时计算gps经纬度距离 | ||||
|   handDistance = async () => { | ||||
| @ -358,40 +262,47 @@ export default class Judge { | ||||
|     AppStorage.setOrCreate('msgStr', plc) | ||||
|     return tempData | ||||
|   } | ||||
|   // 处理轨迹plc信号 | ||||
|   handleTrajectoryUdp = async (strArr: string[]) => { | ||||
|     let num = 2; | ||||
|     const judgeTimer = setInterval(async () => { | ||||
|       const msgStr = strArr[num]; | ||||
|       if (msgStr == '') { | ||||
|         dConsole.info(JudgeTag, '模拟数据考试结束') | ||||
|         clearInterval(judgeTimer) | ||||
|         this.checkExamIsEnd(true) | ||||
|         return | ||||
|       } | ||||
|       const msg: PLCType = JSON.parse(strArr[num]); | ||||
|       num++ | ||||
|       // 4.过程数据 | ||||
|       this.tempData = msg | ||||
|       // this.judgeUI.isDwztRight = (msg?.gps?.dwzt == 4 && msg?.gps?.jdzt == 3); | ||||
|       this.judgeUI.sd = Math.floor(msg?.gps?.sd * 1.852) + ''; | ||||
|       this.judgeUI.dw = Math.floor(msg?.sensor?.dw) + '' | ||||
|       this.plcData = msg | ||||
|       // this.judgeUI.isDwztRight = msg.gps.dwzt == 4; | ||||
|       AppStorage.setOrCreate('msgStr', '') | ||||
|       if (msg.method === 'examJudgeArtificialItem') { | ||||
|         this.setJudgeItem(msg.itemno, msg.type) | ||||
|       } | ||||
|       if (msg.method === 'examJudgeArtificialMark') { | ||||
|         this.setJudgeItem(msg.itemno, msg.serial) | ||||
|       } | ||||
|       await examJudgeRealExam(msg) | ||||
|       // const bytes = await this.getMessageHeartbeat(); | ||||
|       // bytes && globalThis.judgeUdp.send(bytes) | ||||
| 
 | ||||
|     }, 200) | ||||
|     // TODO 定时器缺失 | ||||
|     // globalThis.judgeTimer = judgeTimer; | ||||
|   // 处理udp plc信号 | ||||
|   handleUdp = async (msg: string) => { | ||||
|     const stachArr = msg.split(',') | ||||
|     if (stachArr[0] != '#DN_GD' || this.isUdpEnd) { | ||||
|       return | ||||
|     } | ||||
|     const gpsPart = msg.split("#END$GPS,")[1]; | ||||
|     const gpsStatus = gpsPart.split(",")[0]; | ||||
|     if (gpsStatus === "4") { | ||||
|       dConsole.log(JudgeTag, "差分状态正常", gpsStatus) | ||||
|       this.judgeUI.isDwztRight = true | ||||
|     } else { | ||||
|       dConsole.log(JudgeTag, "差分状态异常", gpsStatus) | ||||
|       this.judgeUI.isDwztRight = false | ||||
|     } | ||||
|     this.judgeUI.isDwztRight | ||||
|     const plcData = await this.getPlcData(msg); | ||||
|     // 4.过程数据 | ||||
|     // await this.fileLog?.setExamJudgeData(JSON.stringify(plcData)) | ||||
|     dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify(plcData)) | ||||
|     //检测到有无锡所设备接入,需要发送特定的数据,供检测 | ||||
|     // if (this.usbService.isWXUSBDevice) { | ||||
|     //   const str = await senorToWXDataStr(msg); | ||||
|     //   this.usbService.sendUSB(str) | ||||
|     // } | ||||
|     const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350') | ||||
|     this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + '' | ||||
|     this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + '' | ||||
|     //TODO 暂时关闭差分检测异常 | ||||
|     // await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt); | ||||
|     if (!this.isExamEnd) { | ||||
|       await examJudgeRealExam(plcData) | ||||
|     } | ||||
|     // let udpIndex = AppStorage.get<number>('udpIndex') || 0; | ||||
|     // if (udpIndex % 5 === 0 && !this.isUdpEnd) { | ||||
|     // TODO UPD缺失 | ||||
|     // const judgeUdp = globalThis.judgeUdp | ||||
|     // const bytes = await this.getMessageHeartbeat(this.isExamEnd); | ||||
|     // judgeUdp.send(bytes) | ||||
|     // } | ||||
|     // AppStorage.setOrCreate('udpIndex', udpIndex++) | ||||
|   } | ||||
|   private isEndTip: boolean = false; | ||||
|   //本地轨迹回放地址 | ||||
| @ -411,6 +322,32 @@ export default class Judge { | ||||
|       const code = await writeObjectOut(JSON.parse(examDataStr), "", this.context); | ||||
|     } | ||||
|   } | ||||
|   private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] | ||||
|   private lane: LANE = { | ||||
|     road: '', num: 0, count: 0 | ||||
|   } | ||||
|   private disConnectNum: number = 0; | ||||
|   //调用监管接口 | ||||
|   sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => { | ||||
|     const temp = await writeObjectOut(data, filePath, this.context); | ||||
|     dConsole.log(JudgeTag, "wzj", JSON.stringify(temp)) | ||||
|     //断网&网络超时次数计算 | ||||
|     if (temp.code == 2300007 || temp.code == 2300028) { | ||||
|       this.disConnectNum += 1; | ||||
|       if (this.disConnectNum < 5) { | ||||
|         return await this.sendWriteObjectOut(data, filePath) | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     if (this.disConnectNum >= 5) { | ||||
|       dConsole.info('surenjun', '123') | ||||
|       this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!'; | ||||
|       this.judgeUI.disConnectErrorOpen = true | ||||
|     } | ||||
| 
 | ||||
|     this.disConnectNum = 0 | ||||
|     return temp | ||||
|   } | ||||
|   // 项目开始接口同步 | ||||
|   beginProject = async (ksxm: number) => { | ||||
|     const carInfo = AppStorage.get<CarInfoType>('carInfo'); | ||||
| @ -514,32 +451,6 @@ export default class Judge { | ||||
|     UploadRegulatoryCodeConversion('17C54', temp.code || 0) | ||||
|     dConsole.info(JudgeTag, '上传照片 end') | ||||
|   } | ||||
|   private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] | ||||
|   private lane: LANE = { | ||||
|     road: '', num: 0, count: 0 | ||||
|   } | ||||
|   private disConnectNum: number = 0; | ||||
|   //调用监管接口 | ||||
|   sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => { | ||||
|     const temp = await writeObjectOut(data, filePath, this.context); | ||||
|     dConsole.log(JudgeTag, "wzj", JSON.stringify(temp)) | ||||
|     //断网&网络超时次数计算 | ||||
|     if (temp.code == 2300007 || temp.code == 2300028) { | ||||
|       this.disConnectNum += 1; | ||||
|       if (this.disConnectNum < 5) { | ||||
|         return await this.sendWriteObjectOut(data, filePath) | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     if (this.disConnectNum >= 5) { | ||||
|       dConsole.info('surenjun', '123') | ||||
|       this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!'; | ||||
|       this.judgeUI.disConnectErrorOpen = true | ||||
|     } | ||||
| 
 | ||||
|     this.disConnectNum = 0 | ||||
|     return temp | ||||
|   } | ||||
|   private videoData?: RecordHandleType | ||||
|   //当前科目二的考试项目 | ||||
|   private deductedPopShowTimer: number = 0; | ||||
| @ -653,6 +564,95 @@ export default class Judge { | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   // 检测扣分、结束项目时该项目是否开始 | ||||
|   checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: MarkRule) => { | ||||
|     if (xmdm == 20) { | ||||
|       return true | ||||
|     } | ||||
|     const judgeUI = this.judgeUI; | ||||
|     const judgeTask = this.judgeTask; | ||||
|     const projectsObj: object = this.judgeUI.projectsObj | ||||
|     const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) | ||||
|     const isUpload = currentProject.isUpload | ||||
| 
 | ||||
|     //如果项目没有开始 | ||||
|     dConsole.info(JudgeTag, 'surenjun isUpload=>', isUpload) | ||||
|     if (!isUpload) { | ||||
|       dConsole.info(JudgeTag, '项目补传开始') | ||||
|       //项目开始补传 | ||||
|       judgeTask.addTask(async () => { | ||||
|         await this.beginProject(xmdm) | ||||
|       }, { | ||||
|         isDelay: true | ||||
|       }) | ||||
|       judgeTask.addTask(async () => { | ||||
|         await this.uploadProgressPhoto(xmdm) | ||||
|       }, { | ||||
|         isDelay: true | ||||
|       }) | ||||
|       currentProject.isUpload = true; | ||||
|       Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) | ||||
|       //扣分补传 | ||||
|       if (currentType == 2) { | ||||
|         judgeTask.addTask(async () => { | ||||
|           await this.pointsDedute(xmdm, kf!) | ||||
|         }, { | ||||
|           isDelay: true | ||||
|         }) | ||||
|       } | ||||
|       //扣分补传判断是否合格 不合格补传项目结束 | ||||
|       if (currentType == 1 || (currentType == 2 && this.totalScore < judgeUI.passingScore)) { | ||||
|         judgeTask.addTask(async () => { | ||||
|           await this.endProject(xmdm) | ||||
|         }, { | ||||
|           isDelay: true | ||||
|         }) | ||||
|         currentProject.isEnd = true; | ||||
|         Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) | ||||
|       } | ||||
|       judgeTask.addTask(async () => { | ||||
|         this.checkExamIsEnd() | ||||
|       }) | ||||
|       return false; | ||||
|     } else { | ||||
|       return true | ||||
|     } | ||||
|   } | ||||
|   // 处理轨迹plc信号 | ||||
|   handleTrajectoryUdp = async (strArr: string[]) => { | ||||
|     let num = 2; | ||||
|     const judgeTimer = setInterval(async () => { | ||||
|       const msgStr = strArr[num]; | ||||
|       if (msgStr == '') { | ||||
|         dConsole.info(JudgeTag, '模拟数据考试结束') | ||||
|         clearInterval(judgeTimer) | ||||
|         this.checkExamIsEnd(true) | ||||
|         return | ||||
|       } | ||||
|       const msg: PLCType = JSON.parse(strArr[num]); | ||||
|       num++ | ||||
|       // 4.过程数据 | ||||
|       this.tempData = msg | ||||
|       // this.judgeUI.isDwztRight = (msg?.gps?.dwzt == 4 && msg?.gps?.jdzt == 3); | ||||
|       this.judgeUI.sd = Math.floor(msg?.gps?.sd * 1.852) + ''; | ||||
|       this.judgeUI.dw = Math.floor(msg?.sensor?.dw) + '' | ||||
|       this.plcData = msg | ||||
|       // this.judgeUI.isDwztRight = msg.gps.dwzt == 4; | ||||
|       AppStorage.setOrCreate('msgStr', '') | ||||
|       if (msg.method === 'examJudgeArtificialItem') { | ||||
|         this.setJudgeItem(msg.itemno, msg.type) | ||||
|       } | ||||
|       if (msg.method === 'examJudgeArtificialMark') { | ||||
|         this.setJudgeItem(msg.itemno, msg.serial) | ||||
|       } | ||||
|       await examJudgeRealExam(msg) | ||||
|       // const bytes = await this.getMessageHeartbeat(); | ||||
|       // bytes && globalThis.judgeUdp.send(bytes) | ||||
| 
 | ||||
|     }, 200) | ||||
|     // TODO 定时器缺失 | ||||
|     // globalThis.judgeTimer = judgeTimer; | ||||
|   } | ||||
| 
 | ||||
|   constructor(judgeUI: JudgeUI) { | ||||
|     this.serialIndex = 1; | ||||
| @ -894,6 +894,7 @@ export default class Judge { | ||||
|     //项目结束 | ||||
|       case 2: { | ||||
|         const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) | ||||
|         dConsole.log(JudgeTag, "项目结束判定", xmdm, project) | ||||
|         const xmmcCode = project.projectCodeCenter || ""; | ||||
|         project.type = (xmjs.xmhg === 0 ? '4' : '3') | ||||
| 
 | ||||
| @ -1628,6 +1629,7 @@ export default class Judge { | ||||
|   } | ||||
|   // 统计必考项目、所有项目、已考数量 | ||||
|   setCountItems = async () => { | ||||
|     dConsole.log(JudgeTag, "项目结束判定,统计考试项目") | ||||
|     const projectsObj: object = this.judgeUI.projectsObj; | ||||
|     //必考项目数量       必考项目已考数量 | ||||
|     let projectNum = 0, endProjectsNum = 0; | ||||
| @ -1723,7 +1725,7 @@ export default class Judge { | ||||
|     dConsole.info(JudgeTag, '2.注册日志回调完成') | ||||
| 
 | ||||
|     let initInfo: JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData(); | ||||
|     // await fileLog?.setExamJudgeData(JSON.stringify(initInfo)) | ||||
|     dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify(initInfo)) | ||||
|     //相关评判初始化只做一次 | ||||
|     if (!isJudgeInitBool) { | ||||
|       dConsole.log(JudgeTag, "评判初始化参数", initInfo) | ||||
| @ -1767,6 +1769,7 @@ export default class Judge { | ||||
|     } else { | ||||
|       beginExamInfo = await getJudgeBeginData() | ||||
|     } | ||||
|     dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify(beginExamInfo)) | ||||
|     if (beginExamInfo) { | ||||
|       await examJudgeBeginExam(beginExamInfo); | ||||
|     } | ||||
|  | ||||
| @ -72,6 +72,10 @@ class serialPortService { | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   offMsg() { | ||||
|     this.events = []; | ||||
|   } | ||||
| 
 | ||||
|   async closed() { | ||||
|     const res = await CancelReceiveSerialPortData(this.fd); | ||||
|     this.events = []; | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| // 处理worker线程的消息tcp拿差分改正数,udp给后置机 | ||||
| import worker, { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope } from '@ohos.worker'; | ||||
| import { WorkerTag } from '../config'; | ||||
| import { SerialPortTag, WorkerTag } from '../config'; | ||||
| import { | ||||
|   CenterCallBackMsgType, | ||||
|   EnvironmentConfigurationType, | ||||
| @ -68,7 +68,7 @@ function getDataFn(config: EnvironmentConfigurationType) { | ||||
|     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(","); | ||||
| @ -76,7 +76,7 @@ function getDataFn(config: EnvironmentConfigurationType) { | ||||
|         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