fix: 重构轨迹查看
This commit is contained in:
		
							parent
							
								
									d938aa41ac
								
							
						
					
					
						commit
						084efe2e74
					
				| @ -1,4 +1,4 @@ | ||||
| import { AmplifyItem } from '../model' | ||||
| import { AmplifyItem, PerLane } from '../model'; | ||||
| 
 | ||||
| export const AmplifyArr: AmplifyItem[] = [ | ||||
|   { name: '直线', projectCode: '3', projectCodeCenter: '40300' }, | ||||
| @ -17,3 +17,32 @@ export const AmplifyImages = [ | ||||
|   'km_dtB.png', | ||||
|   'km_tcB.png', | ||||
| ] | ||||
| 
 | ||||
| export const InitialPerLane: PerLane = { | ||||
|   MapRoad_Code_No: "", | ||||
|   MapRoad_Name: "", | ||||
|   TouchLineType: 0, | ||||
|   TouchDir: 0, | ||||
|   TouchLineTypeCS: 0, | ||||
|   TouchLineDirCS: 0, | ||||
|   BasePointInLaneNo: 0, | ||||
|   BaseLaneCount: 0, | ||||
|   FrontPointLaneNo: 0, | ||||
|   FrontPointLaneCount: 0, | ||||
|   Body_LF_ToLeftEdge: 0, | ||||
|   Body_LB_ToLeftEdge: 0, | ||||
|   Body_RF_ToRightEdge: 0, | ||||
|   Body_RB_ToRightEdge: 0, | ||||
|   Wheel_RF_ToRightEdge: 0, | ||||
|   Wheel_RB_ToRightEdge: 0, | ||||
|   Wheel_RF_ToBaseLine: 0, | ||||
|   Wheel_LF_ToRightEdge: 0, | ||||
|   Wheel_LB_ToRightEdge: 0, | ||||
|   Wheel_LF_ToBaseLine: 0, | ||||
|   Wheel_LB_ToBaseLine: 0, | ||||
|   BasePointInLaneDir: "", | ||||
|   CrossLineAttr: 0, | ||||
|   InShapeAttr: 0, | ||||
|   ShapeNo: 0, | ||||
|   CrossPointNo: 0 | ||||
| }; | ||||
| @ -742,7 +742,7 @@ export interface JudgePerformInfo { | ||||
|   lane: PerLane | ||||
| } | ||||
| 
 | ||||
| interface PerLane { | ||||
| export  interface PerLane { | ||||
|   MapRoad_Code_No: string | ||||
|   MapRoad_Name: string | ||||
|   TouchLineType: number | ||||
|  | ||||
| @ -1,19 +1,36 @@ | ||||
| import router from '@ohos.router' | ||||
| import { GPSData, SignalData } from '../../mock' | ||||
| import { EnvironmentConfigurationType, SignalDataType, WorkerBackMessage } from '../../model' | ||||
| import { GPSData, InitialPerLane, SignalData } from '../../mock' | ||||
| import { EnvironmentConfigurationType, PerLane, RoadDataType, SignalDataType, WorkerBackMessage } from '../../model' | ||||
| import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignal' | ||||
| import apiJudgeSdk from 'libJudgeSdk.so' | ||||
| import { examJudgeMapSetScaling } from '../judgeSDK/api' | ||||
| 
 | ||||
| 
 | ||||
| @Component | ||||
| export default struct SignalDisplayComponent { | ||||
|   @State sjxhColum: Array<SignalDataType> = SignalData | ||||
|   // 车载信号 | ||||
|   @State vehicleSignal: Array<SignalDataType> = SignalData | ||||
|   // 信号数组 | ||||
|   @State signArr: Array<string> = [] | ||||
|   // GPS信号 | ||||
|   @State GPSColum: Array<SignalDataType> = GPSData | ||||
|   // tab选中 | ||||
|   @State active: number = 0 | ||||
|   // 原始数据 | ||||
|   @State rawData: string = "$GPS,,,,,,,,,,,,,,,,,,,,,,,,,,,,," | ||||
|   // 车道信息 | ||||
|   @State laneSignal: PerLane = InitialPerLane | ||||
|   // 是否显示返回 | ||||
|   @State isShowBack: boolean = true | ||||
|   onBackPress: () => void = () => { | ||||
|   } | ||||
| 
 | ||||
|   aboutToAppear(): void { | ||||
|     DifferentialAndSignal.onMsg((data: string) => { | ||||
|       const result: WorkerBackMessage = JSON.parse(data) | ||||
|       if (result.type === "centerUdpData") { | ||||
|         this.getSignal(result.data as string) | ||||
|         this.rawData = result.data as string | ||||
|       } | ||||
|     }) | ||||
|   } | ||||
| @ -26,32 +43,32 @@ export default struct SignalDisplayComponent { | ||||
|     this.signArr = strachArr | ||||
| 
 | ||||
|     for (let i = 0; i <= 12; i++) { | ||||
|       this.sjxhColum[i].value = this.signArr[i+2] | ||||
|       this.vehicleSignal[i].value = this.signArr[i+2] | ||||
|     } | ||||
| 
 | ||||
|     this.sjxhColum[13].value = this.signArr[17] | ||||
|     this.sjxhColum[14].value = this.signArr[18] | ||||
|     this.sjxhColum[15].value = this.signArr[19] | ||||
|     this.sjxhColum[16].value = this.signArr[20] | ||||
|     this.sjxhColum[17].value = this.signArr[23] //车速 | ||||
|     this.sjxhColum[18].value = this.signArr[28] | ||||
|     this.sjxhColum[19].value = this.signArr[29] | ||||
|     this.sjxhColum[20].value = this.signArr[30] | ||||
|     this.sjxhColum[21].value = this.signArr[15] //NC | ||||
|     this.sjxhColum[22].value = this.signArr[16] //SA15 | ||||
|     this.sjxhColum[23].value = this.signArr[21] | ||||
|     this.sjxhColum[24].value = this.signArr[22] | ||||
|     this.sjxhColum[25].value = this.signArr[24] | ||||
|     this.sjxhColum[26].value = this.signArr[26] | ||||
|     this.sjxhColum[27].value = this.signArr[25] | ||||
|     this.sjxhColum[28].value = this.signArr[27] | ||||
|     this.sjxhColum[29].value = this.signArr[31] | ||||
|     this.sjxhColum[30].value = this.signArr[32] | ||||
|     this.sjxhColum[31].value = this.signArr[33] | ||||
|     this.sjxhColum[32].value = this.signArr[34] | ||||
|     this.sjxhColum[33].value = this.signArr[35] | ||||
|     this.vehicleSignal[13].value = this.signArr[17] | ||||
|     this.vehicleSignal[14].value = this.signArr[18] | ||||
|     this.vehicleSignal[15].value = this.signArr[19] | ||||
|     this.vehicleSignal[16].value = this.signArr[20] | ||||
|     this.vehicleSignal[17].value = this.signArr[23] //车速 | ||||
|     this.vehicleSignal[18].value = this.signArr[28] | ||||
|     this.vehicleSignal[19].value = this.signArr[29] | ||||
|     this.vehicleSignal[20].value = this.signArr[30] | ||||
|     this.vehicleSignal[21].value = this.signArr[15] //NC | ||||
|     this.vehicleSignal[22].value = this.signArr[16] //SA15 | ||||
|     this.vehicleSignal[23].value = this.signArr[21] | ||||
|     this.vehicleSignal[24].value = this.signArr[22] | ||||
|     this.vehicleSignal[25].value = this.signArr[24] | ||||
|     this.vehicleSignal[26].value = this.signArr[26] | ||||
|     this.vehicleSignal[27].value = this.signArr[25] | ||||
|     this.vehicleSignal[28].value = this.signArr[27] | ||||
|     this.vehicleSignal[29].value = this.signArr[31] | ||||
|     this.vehicleSignal[30].value = this.signArr[32] | ||||
|     this.vehicleSignal[31].value = this.signArr[33] | ||||
|     this.vehicleSignal[32].value = this.signArr[34] | ||||
|     this.vehicleSignal[33].value = this.signArr[35] | ||||
|     for (let i = 34; i <= 46; i++) { | ||||
|       this.sjxhColum[i].value = this.signArr[i+2] | ||||
|       this.vehicleSignal[i].value = this.signArr[i+2] | ||||
|     } | ||||
|     let t = 0 | ||||
|     for (let i = 83; i <= 97; i++) { | ||||
| @ -66,7 +83,7 @@ export default struct SignalDisplayComponent { | ||||
|     this.GPSColum[10].value = this.signArr[93] | ||||
| 
 | ||||
|     // this.signArr[53]=192.168.7.170' | ||||
|     this.sjxhColum = JSON.parse(JSON.stringify((this.sjxhColum))) | ||||
|     this.vehicleSignal = JSON.parse(JSON.stringify((this.vehicleSignal))) | ||||
|     this.signArr = JSON.parse(JSON.stringify((this.signArr))) | ||||
|     this.GPSColum = JSON.parse(JSON.stringify((this.GPSColum))) | ||||
|   } | ||||
| @ -81,46 +98,261 @@ export default struct SignalDisplayComponent { | ||||
|         Row() { | ||||
|           // 短logo | ||||
|           Image($r('app.media.shortLogo')).height(100).width(150).objectFit(ImageFit.Contain).margin({ | ||||
|             left: 10 | ||||
|             left: 10, | ||||
|             right: 10 | ||||
|           }) | ||||
|           TabComponent({ | ||||
|             activeIndex: this.active, | ||||
|             onchange: (index: number) => { | ||||
|               this.active = index | ||||
|             } | ||||
|           }) | ||||
|         } | ||||
| 
 | ||||
|         Row() { | ||||
|           //   返回按钮 | ||||
|           Image($r('app.media.topB_back')).height(100).onClick(() => { | ||||
|             router.back() | ||||
|           }) | ||||
|           if (this.isShowBack) { | ||||
|             //   返回按钮 | ||||
|             Image($r('app.media.topB_back')).height(100).onClick(() => { | ||||
|               router.back() | ||||
|             }) | ||||
|           } else { | ||||
|             Image($rawfile('judge/close.png')).height(100).onClick(() => { | ||||
|               this.onBackPress() | ||||
|             }) | ||||
|           } | ||||
| 
 | ||||
|         } | ||||
|       }.width("100%").height(100) | ||||
| 
 | ||||
|       Column() { | ||||
|         // GPS信号展示 | ||||
|         GPSComponent({ | ||||
|           data: this.signArr | ||||
|         }) | ||||
|         //   车载信号以及车载坐标 | ||||
|         Column() { | ||||
|           CarComponent({ | ||||
|             data: this.sjxhColum | ||||
|         // 信号查看 | ||||
|         if (this.active === 0) { | ||||
|           // GPS信号展示 | ||||
|           GPSComponent({ | ||||
|             data: this.signArr | ||||
|           }) | ||||
|           CoordinateComponent({ | ||||
|             data: this.GPSColum | ||||
|           }) | ||||
|         }.margin({ | ||||
|           top: 5 | ||||
|         }).backgroundColor("#282828") | ||||
|           //   车载信号以及车载坐标 | ||||
|           Column() { | ||||
|             CarComponent({ | ||||
|               data: this.vehicleSignal | ||||
|             }) | ||||
|             CoordinateComponent({ | ||||
|               data: this.GPSColum | ||||
|             }) | ||||
|           }.margin({ | ||||
|             top: 5 | ||||
|           }).backgroundColor("#282828") | ||||
|         } else if (this.active === 1) { | ||||
|           // 原始数据 | ||||
|           Column() { | ||||
|             Text(this.rawData).fontSize(20).fontColor("#fff") | ||||
|           }.backgroundColor("#282828").width("100%").height("100%") | ||||
|         } else { | ||||
|           // 轨迹查看 | ||||
|           Flex() { | ||||
|             Column() { | ||||
|               CoordinateComponent({ | ||||
|                 isItHorizontal: false, | ||||
|                 heightNum: 40, | ||||
|               }) | ||||
|             }.width("20%") | ||||
| 
 | ||||
|             Column() { | ||||
|               LaneComponent({ | ||||
|                 laneSignal: this.laneSignal | ||||
|               }) | ||||
|             }.width("20%") | ||||
| 
 | ||||
|             Column() { | ||||
|               trajectoryComponent() | ||||
|             }.height("100%").width("60%") | ||||
| 
 | ||||
|           }.backgroundColor("#282828").width("100%").height("100%") | ||||
|         } | ||||
|       } | ||||
|       .width("100%") | ||||
|       .height("100%") | ||||
|       .backgroundColor("#fff") | ||||
|       .borderRadius(20) | ||||
|       .padding(20) | ||||
|       .margin(20) | ||||
|     }.width("100%").height("100%").backgroundColor("#222222") | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| @Component | ||||
| struct trajectoryComponent { | ||||
|   @State scaleNum: number = 100 | ||||
|   scaleFn = async (num: number) => { | ||||
|     const scaleNum = this.scaleNum | ||||
|     if (scaleNum > 0 && scaleNum < 5000) { | ||||
|       this.scaleNum += num; | ||||
|     } | ||||
|     if (scaleNum === 0 && num > 0) { | ||||
|       this.scaleNum += num; | ||||
|     } | ||||
|     if (scaleNum > 5000 && num < 0) { | ||||
|       this.scaleNum += num; | ||||
|     } | ||||
|     await examJudgeMapSetScaling(this.scaleNum); | ||||
|   } | ||||
|   getScaleNum = (): number => { | ||||
|     const scaleNum = this.scaleNum; | ||||
|     if (scaleNum < 200) return 10; | ||||
|     if (scaleNum < 400) return 30; | ||||
|     if (scaleNum < 600) return 50; | ||||
|     if (scaleNum < 800) return 70; | ||||
|     if (scaleNum < 1000) return 100; | ||||
|     if (scaleNum < 2000) return 500; | ||||
|     return 1000; | ||||
|   } | ||||
| 
 | ||||
|   build() { | ||||
|     Stack({ | ||||
|       alignContent: Alignment.TopStart | ||||
|     }) { | ||||
|       XComponent({ | ||||
|         id: 'duolun_plugin_id_draw', //显示轨迹窗口id名称,注意这个ID要和C++侧一致,不能变 | ||||
|         type: 'surface', | ||||
|         libraryname: 'JudgeSdk' | ||||
|         // libraryname: 'judgesdk' | ||||
|       }) | ||||
|         .width("100%") | ||||
|         .height("100%") | ||||
|         .onLoad(() => { | ||||
|           apiJudgeSdk.examJudgeMapSetDrawing(true); //停止绘制地图轨迹,false:表示结束绘制 | ||||
|         }) | ||||
|         .onDestroy(() => { | ||||
|           apiJudgeSdk.examJudgeMapSetDrawing(false); //停止绘制地图轨迹,false:表示结束绘制 | ||||
|           // clearInterval(globalThis.realTimer) | ||||
|         }) | ||||
|       Row() { | ||||
|         Image($rawfile('judge/big.png')).width(60).onClick(() => { | ||||
|           this.scaleFn(this.getScaleNum() - 1) | ||||
|         }) | ||||
|         Image($rawfile('judge/small.png')).width(60).onClick(() => { | ||||
|           this.scaleFn(this.getScaleNum()) | ||||
|         }).margin({ left: 20 }) | ||||
|       }.align(Alignment.TopEnd) | ||||
|     }.width("100%").height("100%") | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| @Component | ||||
| struct TabComponent { | ||||
|   @State activeIndex: number = 0 | ||||
|   onchange: (index: number) => void = () => { | ||||
|   } | ||||
| 
 | ||||
|   build() { | ||||
|     Row() { | ||||
|       TabItemComponent({ | ||||
|         active: this.activeIndex === 0, | ||||
|       }).onClick(() => { | ||||
|         this.activeIndex = 0 | ||||
|         this.onchange(0) | ||||
|       }) | ||||
|       TabItemComponent({ | ||||
|         label: "原始数据", | ||||
|         active: this.activeIndex === 1, | ||||
|       }).onClick(() => { | ||||
|         this.activeIndex = 1 | ||||
|         this.onchange(1) | ||||
|       }) | ||||
|       TabItemComponent({ | ||||
|         label: "轨迹查看", | ||||
|         active: this.activeIndex === 2, | ||||
|       }).onClick(() => { | ||||
|         console.log("轨迹查看") | ||||
|         this.activeIndex = 2 | ||||
|         this.onchange(2) | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| @Component | ||||
| struct LaneComponent { | ||||
|   @Prop laneSignal: PerLane | ||||
|   private RoadData: Array<RoadDataType> = [ | ||||
|     { name: '路段组号', key: 'MapRoad_Code_No' }, | ||||
|     { name: '路段编码', key: 'MapRoad_Name' }, | ||||
|     { name: '车轮压线', key: ['TouchLineType', 'TouchDir'] }, | ||||
|     { name: '车身碰线', key: ['TouchLineTypeCS', 'TouchLineDirCS'] }, | ||||
|     { name: '基准车道', key: ['BasePointInLaneNo', 'BaseLaneCount'] }, | ||||
|     { name: '前点车道', key: ['FrontPointLaneNo', 'FrontPointLaneCount'] }, | ||||
|     { name: '后车点道', key: ['BackPointLaneNo', 'BackPointLaneCount'] }, | ||||
|     { name: '左前/后车身距离', key: ['Body_LF_ToLeftEdge', 'Body_LB_ToLeftEdge'] }, | ||||
|     { name: '右前/后车身距离', key: ['Body_RF_ToRightEdge', 'Body_RB_ToRightEdge'] }, | ||||
|     { name: '右前/后车身边线', key: ['Body_RF_ToBaseLine', 'Body_RB_ToBaseLine'] }, | ||||
|     { name: '右前/后轮距离', key: ['Wheel_RF_ToRightEdge', 'Wheel_RB_ToRightEdge'] }, | ||||
|     { name: '右前/后轮边线', key: ['Wheel_RF_ToBaseLine', 'Wheel_RB_ToBaseLine'] }, | ||||
|     { name: '左前/后轮距离', key: ['Wheel_LF_ToRightEdge', 'Wheel_LB_ToRightEdge'] }, | ||||
|     { name: '左前/后轮边线', key: ['Wheel_LF_ToBaseLine', 'Wheel_LB_ToBaseLine'] }, | ||||
|     { name: '车道属性', key: ['BasePointInLaneDir', 'CrossLineAttr', 'DirInverse'] }, | ||||
|     { name: '形状', key: ['InShapeAttr', 'ShapeNo', 'ShapeNoWheel'] }, | ||||
|     { name: '路段点', key: ['CrossPointNo'] }, | ||||
|   ] | ||||
| 
 | ||||
|   getValues(roadColumn: RoadDataType) { | ||||
|     let key = roadColumn.key; | ||||
|     let str = '' | ||||
|     if (Array.isArray(key)) { | ||||
|       key.forEach((k, index) => { | ||||
|         str += (Reflect.get(this.laneSignal, k) === undefined ? '' : Reflect.get(this.laneSignal, k)) + (index == key.length - 1 ? '' : '/') | ||||
|       }) | ||||
|     } else { | ||||
|       str = Reflect.get(this.laneSignal, key) === undefined ? '' : Reflect.get(this.laneSignal, key) | ||||
|     } | ||||
|     return str | ||||
|   } | ||||
| 
 | ||||
|   build() { | ||||
|     Column() { | ||||
|       Text("车道信息").fontSize(20).fontColor("#FFB433").margin({ | ||||
|         top: 20 | ||||
|       }) | ||||
|       ForEach(this.RoadData, (item: RoadDataType) => { | ||||
|         blockComponent({ | ||||
|           color: "#FFB433", | ||||
|           heightNum: 40, | ||||
|           label: item.name, | ||||
|           value: this.getValues(item) | ||||
|         }) | ||||
|       }) | ||||
|     }.width("100%") | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| @Component | ||||
| struct TabItemComponent { | ||||
|   @State label: string = "信号查看" | ||||
|   @Prop active: boolean = false | ||||
| 
 | ||||
|   build() { | ||||
|     Row() { | ||||
|       Text(this.label).fontColor(this.active ? "#ECAD5C" : "#DDCBAC").fontSize(20).fontWeight(FontWeight.Bold) | ||||
|     } | ||||
|     .width(180) | ||||
|     .height(80) | ||||
|     .borderRadius({ | ||||
|       topLeft: 20, | ||||
|       topRight: 20, | ||||
|     }) | ||||
|     .border({ | ||||
|       width: { top: 1, left: 1, right: 1 }, | ||||
|       color: this.active ? "#ECAD5C" : "#DDCBAC" | ||||
|     }) | ||||
|     .justifyContent(FlexAlign.Center) | ||||
|     .alignItems(VerticalAlign.Center) | ||||
|     .margin({ | ||||
|       left: 10 | ||||
|     }) | ||||
|     .shadow({ | ||||
|       radius: 10, | ||||
|       color: this.active ? "#ECAD5C" : "", | ||||
|     }) | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| @Component | ||||
| struct GPSComponent { | ||||
| @ -136,7 +368,7 @@ struct GPSComponent { | ||||
|         tcpOppositeIp: "", | ||||
|         tcpOppositePort: "" | ||||
|       } | ||||
|     this.ip = config.tcplocalIp | ||||
|     this.ip = config.tcplocalIp || "" | ||||
|   } | ||||
| 
 | ||||
|   build() { | ||||
| @ -224,6 +456,8 @@ struct CarComponent { | ||||
| @Component | ||||
| struct CoordinateComponent { | ||||
|   @State data: Array<SignalDataType> = GPSData | ||||
|   @State isItHorizontal: boolean = true | ||||
|   @State heightNum: number = 65 | ||||
| 
 | ||||
|   build() { | ||||
|     Column() { | ||||
| @ -231,17 +465,23 @@ struct CoordinateComponent { | ||||
|         top: 20 | ||||
|       }) | ||||
|       Flex({ | ||||
|         wrap: FlexWrap.Wrap | ||||
|         wrap: FlexWrap.Wrap, | ||||
|         direction: this.isItHorizontal ? FlexDirection.Row : FlexDirection.Column | ||||
|       }) { | ||||
|         ForEach(this.data, (item: SignalDataType) => { | ||||
|           blockComponent({ | ||||
|             heightNum: this.heightNum, | ||||
|             color: "#FFB433", | ||||
|             label: item.key, | ||||
|             value: item.value | ||||
|           }) | ||||
|         }) | ||||
|       } | ||||
|     }.width("100%").backgroundColor("#1A1A1A").justifyContent(FlexAlign.Center) | ||||
|       }.height("100%").width("100%") | ||||
|     } | ||||
|     .width("100%") | ||||
|     .height("100%") | ||||
|     .backgroundColor("#1A1A1A") | ||||
|     .justifyContent(FlexAlign.Center) | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| @ -250,6 +490,7 @@ struct blockComponent { | ||||
|   @State label: string = "发送次数" | ||||
|   @State value: string = "1" | ||||
|   @State widthNum: number = 130 | ||||
|   @State heightNum: number = 65 | ||||
|   @State color: string = "#FDF5E7" | ||||
| 
 | ||||
|   build() { | ||||
| @ -263,6 +504,6 @@ struct blockComponent { | ||||
|       }.width(80).justifyContent(FlexAlign.Start).margin({ | ||||
|         left: 20 | ||||
|       }) | ||||
|     }.height(65).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center) | ||||
|     }.height(this.heightNum).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center) | ||||
|   } | ||||
| } | ||||
| @ -1,207 +1,161 @@ | ||||
| // import apiJudgeSdk from 'libJudgeSdk.so'; | ||||
| // import Judge from '../../judgeSDK/utils/judgeReal'; | ||||
| // import { MarkRule, Project, ProjectObj } from '../../judgeSDK/api/judgeSDK.d'; | ||||
| // import common from '@ohos.app.ability.common'; | ||||
| // import { | ||||
| //   examJudgeMapSetScaling | ||||
| // } from '../../judgeSDK/api' | ||||
| // | ||||
| // interface RoadDataType { | ||||
| //   name: string, | ||||
| //   key: string | string[] | ||||
| // } | ||||
| import apiJudgeSdk from 'libJudgeSdk.so'; | ||||
| import { examJudgeMapSetScaling } from '../../judgeSDK/api'; | ||||
| import { PerLane } from '../../../model'; | ||||
| import { InitialPerLane } from '../../../mock'; | ||||
| 
 | ||||
| interface RoadDataType { | ||||
|   name: string, | ||||
|   key: string | string[] | ||||
| } | ||||
| 
 | ||||
| @Component | ||||
| export default struct RealTime { | ||||
|   @State message: string = '开始绘制' | ||||
|   // 控制XComponent组件的创建和销毁 | ||||
|   @State draw: boolean = false | ||||
|   //模拟考试项目 | ||||
|   @State scaleNum: number = 100 | ||||
|   @State gpsActive: number = 1 | ||||
|   @State ratio: number = 1 | ||||
|   @State lane: PerLane = InitialPerLane | ||||
|   scaleFn = async (num: number) => { | ||||
|     const scaleNum = this.scaleNum | ||||
|     if (scaleNum > 0 && scaleNum < 5000) { | ||||
|       this.scaleNum += num; | ||||
|     } | ||||
|     if (scaleNum === 0 && num > 0) { | ||||
|       this.scaleNum += num; | ||||
|     } | ||||
|     if (scaleNum > 5000 && num < 0) { | ||||
|       this.scaleNum += num; | ||||
|     } | ||||
|     await examJudgeMapSetScaling(this.scaleNum); | ||||
|   } | ||||
|   private widthNumber: string | number | Resource = 0 | ||||
|   private heightNumber: string | number | Resource = 0 | ||||
|   private RoadData: Array<RoadDataType> = [ | ||||
|     { name: '路段组号', key: 'MapRoad_Code_No' }, | ||||
|     { name: '路段编码', key: 'MapRoad_Name' }, | ||||
|     { name: '车轮压线', key: ['TouchLineType', 'TouchDir'] }, | ||||
|     { name: '车身碰线', key: ['TouchLineTypeCS', 'TouchLineDirCS'] }, | ||||
|     { name: '基准车道', key: ['BasePointInLaneNo', 'BaseLaneCount'] }, | ||||
|     { name: '前点车道', key: ['FrontPointLaneNo', 'FrontPointLaneCount'] }, | ||||
|     { name: '后车点道', key: ['BackPointLaneNo', 'BackPointLaneCount'] }, | ||||
|     { name: '左前/后车身距离', key: ['Body_LF_ToLeftEdge', 'Body_LB_ToLeftEdge'] }, | ||||
|     { name: '右前/后车身距离', key: ['Body_RF_ToRightEdge', 'Body_RB_ToRightEdge'] }, | ||||
|     { name: '右前/后车身边线', key: ['Body_RF_ToBaseLine', 'Body_RB_ToBaseLine'] }, | ||||
|     { name: '右前/后轮距离', key: ['Wheel_RF_ToRightEdge', 'Wheel_RB_ToRightEdge'] }, | ||||
|     { name: '右前/后轮边线', key: ['Wheel_RF_ToBaseLine', 'Wheel_RB_ToBaseLine'] }, | ||||
|     { name: '左前/后轮距离', key: ['Wheel_LF_ToRightEdge', 'Wheel_LB_ToRightEdge'] }, | ||||
|     { name: '左前/后轮边线', key: ['Wheel_LF_ToBaseLine', 'Wheel_LB_ToBaseLine'] }, | ||||
|     { name: '车道属性', key: ['BasePointInLaneDir', 'CrossLineAttr', 'DirInverse'] }, | ||||
|     { name: '形状', key: ['InShapeAttr', 'ShapeNo', 'ShapeNoWheel'] }, | ||||
|     { name: '路段点', key: ['CrossPointNo'] }, | ||||
|   ] | ||||
| 
 | ||||
|   async aboutToDisappear() { | ||||
|     // clearInterval(this.timer) | ||||
|   } | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     // const judge = new Judge(this) | ||||
|     // let timer = setInterval(() => { | ||||
|     //   this.lane = globalThis.laneData; | ||||
|     // }, 1000) | ||||
|     // this.timer = timer | ||||
|   } | ||||
| 
 | ||||
|   getScaleNum = (): number => { | ||||
|     const scaleNum = this.scaleNum; | ||||
|     if (scaleNum < 200) return 10; | ||||
|     if (scaleNum < 400) return 30; | ||||
|     if (scaleNum < 600) return 50; | ||||
|     if (scaleNum < 800) return 70; | ||||
|     if (scaleNum < 1000) return 100; | ||||
|     if (scaleNum < 2000) return 500; | ||||
|     return 1000; | ||||
|   } | ||||
| 
 | ||||
|   getValues(roadColumn: RoadDataType) { | ||||
|     const lane = this.lane; | ||||
|     let key = roadColumn.key; | ||||
|     let str = '' | ||||
|     if (Array.isArray(key)) { | ||||
|       key.forEach((k, index) => { | ||||
|         str += (Reflect.get(lane, k) === undefined ? '' : Reflect.get(lane, k)) + (index == key.length - 1 ? '' : '/') | ||||
|       }) | ||||
|     } else { | ||||
|       str = Reflect.get(lane, key) === undefined ? '' : Reflect.get(lane, key) | ||||
|     } | ||||
|     return str | ||||
|   } | ||||
| 
 | ||||
|   build() { | ||||
|     Row() { | ||||
|       Column() { | ||||
|         Row() { | ||||
|           Text('车道信息').fontColor(this.gpsActive == 0 ? '#2D3C5A' : '#fff').fontSize(20) | ||||
|         } | ||||
|         .width('100%') | ||||
|         .height(37) | ||||
|         .backgroundColor(this.gpsActive == 0 ? '#fff' : '#1A1A1A') | ||||
|         .margin({ top: 10 * this.ratio, right: 10 }) | ||||
|         .justifyContent(FlexAlign.Center) | ||||
| 
 | ||||
|         Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start }) { | ||||
|           ForEach(this.RoadData, (item: RoadDataType) => { | ||||
|             Column() { | ||||
|               Text(`${item.name}:${this.getValues(item)}`) | ||||
|                 .fontSize(20) | ||||
|                 .lineHeight(30) | ||||
|                 .fontColor('#fff') | ||||
|             }.height(30).justifyContent(FlexAlign.Start).width('100%') | ||||
|           }) | ||||
|         }.margin({ top: 5 }) | ||||
| 
 | ||||
|       }.width(168 * 1.5) | ||||
|       .height(this.heightNumber) | ||||
|       .backgroundColor('#282828') | ||||
|       .margin({ top: 6 * this.ratio, }) | ||||
| 
 | ||||
|       Column() { | ||||
|         if (this.draw) { | ||||
|           XComponent({ | ||||
|             id: 'duolun_plugin_id_draw', //显示轨迹窗口id名称,注意这个ID要和C++侧一致,不能变 | ||||
|             type: 'surface', | ||||
|             libraryname: 'JudgeSdk' | ||||
|             // libraryname: 'judgesdk' | ||||
|           }) | ||||
|             .width(this.widthNumber) | ||||
|             .height(this.heightNumber) | ||||
|             .onLoad(() => { | ||||
|               apiJudgeSdk.examJudgeMapSetDrawing(true); //停止绘制地图轨迹,false:表示结束绘制 | ||||
|             }) | ||||
|             .onDestroy(() => { | ||||
|               apiJudgeSdk.examJudgeMapSetDrawing(false); //停止绘制地图轨迹,false:表示结束绘制 | ||||
|               this.draw = false; | ||||
|               // clearInterval(globalThis.realTimer) | ||||
|             }) | ||||
|         } else { | ||||
|           Column() { | ||||
|           } | ||||
|           .width(this.widthNumber) | ||||
|           .height(this.heightNumber) | ||||
|         } | ||||
|       } | ||||
|       .width('100%') | ||||
|       .backgroundColor('#fff') | ||||
| 
 | ||||
|       Row() { | ||||
|         Image($rawfile('judge/big.png')).width(60).onClick(() => { | ||||
|           this.scaleFn(this.getScaleNum() - 1) | ||||
|         }) | ||||
|         Image($rawfile('judge/small.png')).width(60).onClick(() => { | ||||
|           this.scaleFn(this.getScaleNum()) | ||||
|         }).margin({ left: 20 }) | ||||
|       }.position({ x: '32%', y: 60 }) | ||||
|     } | ||||
|     .height('100%') | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| // | ||||
| // @Component | ||||
| // export default struct RealTime { | ||||
| //   @State message: string = '开始绘制' | ||||
| //   // 控制XComponent组件的创建和销毁 | ||||
| //   @State draw: boolean = false | ||||
| //   //监管接口序列号 | ||||
| //   @State serialNumber: number = 0 | ||||
| //   //模拟考试项目 | ||||
| //   @State projects: Project[] = [] | ||||
| //   @State projectsObj: ProjectObj = {} | ||||
| //   @State markRuleListObj: MarkRule = {} | ||||
| //   @State scaleNum: number = 100 | ||||
| //   @State gpsActive: number = 1 | ||||
| //   private widthNumber: string | number | Resource = 0 | ||||
| //   private heightNumber: string | number | Resource = 0 | ||||
| //   private context = getContext(this) as common.UIAbilityContext; | ||||
| //   @State ratio: number = 1 | ||||
| //   @State lane: Object = {} | ||||
| //   @State timer:number = 0 | ||||
| // | ||||
| //   constructor() { | ||||
| //     super() | ||||
| //   } | ||||
| // | ||||
| //   // xcomponentController: XComponentController = new XComponentController() | ||||
| // | ||||
| //   build() { | ||||
| //     Row() { | ||||
| //       Column() { | ||||
| //         Row() { | ||||
| //           Text('车道信息').fontColor(this.gpsActive == 0 ? '#2D3C5A' : '#fff').fontSize(20) | ||||
| //         } | ||||
| //         .width('100%') | ||||
| //         .height(37) | ||||
| //         .backgroundColor(this.gpsActive == 0 ? '#fff' : '#1A1A1A') | ||||
| //         .margin({ top: 10 * this.ratio, right: 10 }) | ||||
| //         .justifyContent(FlexAlign.Center) | ||||
| // | ||||
| //         Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start }) { | ||||
| //           ForEach(this.RoadData, (item) => { | ||||
| //             Column() { | ||||
| //               Text(`${item.name}:${this.getValues(item)}`) | ||||
| //                 .fontSize(20) | ||||
| //                 .lineHeight(30) | ||||
| //                 .fontColor('#fff') | ||||
| //             }.height(30).justifyContent(FlexAlign.Start).width('100%') | ||||
| //           }) | ||||
| //         }.margin({top:5}) | ||||
| // | ||||
| //       }.width(168 * 1.5) | ||||
| //       .height(this.heightNumber) | ||||
| //       .backgroundColor('#282828') | ||||
| //       .margin({ top: 6 * this.ratio, }) | ||||
| // | ||||
| //       Column() { | ||||
| //         if (this.draw) { | ||||
| //           XComponent({ | ||||
| //             id: 'duolun_plugin_id_draw', //显示轨迹窗口id名称,注意这个ID要和C++侧一致,不能变 | ||||
| //             type: 'surface', | ||||
| //             libraryname: 'JudgeSdk' | ||||
| //             // libraryname: 'judgesdk' | ||||
| //           }) | ||||
| //             .width(this.widthNumber) | ||||
| //             .height(this.heightNumber) | ||||
| //             .onLoad(() => { | ||||
| //               apiJudgeSdk.examJudgeMapSetDrawing(true); //停止绘制地图轨迹,false:表示结束绘制 | ||||
| //             }) | ||||
| //             .onDestroy(() => { | ||||
| //               apiJudgeSdk.examJudgeMapSetDrawing(false); //停止绘制地图轨迹,false:表示结束绘制 | ||||
| //               this.draw = false; | ||||
| //             }) | ||||
| //         } else { | ||||
| //           Column() { | ||||
| //           } | ||||
| //           .width(this.widthNumber) | ||||
| //           .height(this.heightNumber) | ||||
| //         } | ||||
| //       } | ||||
| //       .width('100%') | ||||
| //       .backgroundColor('#fff') | ||||
| // | ||||
| //       Row(){ | ||||
| //         Image($rawfile('judge/big.png')).width(60).onClick(()=>{ | ||||
| //           this.scaleFn( -this.getScaleNum() ) | ||||
| //         }) | ||||
| //         Image($rawfile('judge/small.png')).width(60).onClick(()=>{ | ||||
| //           this.scaleFn( this.getScaleNum() ) | ||||
| //         }).margin({left:20}) | ||||
| //       }.position({x:'32%',y:60}) | ||||
| //     } | ||||
| //     .height('100%') | ||||
| //   } | ||||
| // | ||||
| //   async aboutToDisappear() { | ||||
| //     clearInterval(this.timer) | ||||
| //   } | ||||
| //   async aboutToAppear() { | ||||
| //     const judge = new Judge(this) | ||||
| //     let timer = setInterval(()=>{ | ||||
| //       this.lane = AppStorage.get('laneData'); | ||||
| //     },1000) | ||||
| //     this.timer = timer | ||||
| //   } | ||||
| // | ||||
| //   getScaleNum = ()=>{ | ||||
| //     const scaleNum = this.scaleNum; | ||||
| //     if(scaleNum < 200){ | ||||
| //       return 10 | ||||
| //     } | ||||
| //     if(scaleNum >= 200 && scaleNum < 400){ | ||||
| //       return 30 | ||||
| //     } | ||||
| // | ||||
| //     if(scaleNum >= 400 && scaleNum < 600){ | ||||
| //       return 50 | ||||
| //     } | ||||
| // | ||||
| //     if(scaleNum >= 600 && scaleNum < 800){ | ||||
| //       return 70 | ||||
| //     } | ||||
| // | ||||
| //     if(scaleNum >= 800 && scaleNum < 1000){ | ||||
| //       return 100 | ||||
| //     } | ||||
| // | ||||
| //     if(scaleNum >= 1000 && scaleNum < 2000){ | ||||
| //       return 500 | ||||
| //     } | ||||
| //     if(scaleNum >= 2000 && scaleNum <= 5000){ | ||||
| //       return 1000 | ||||
| //     } | ||||
| // | ||||
| //     return 1000 | ||||
| //   } | ||||
| // | ||||
| //   getValues(roadColumn) { | ||||
| //     const lane = this.lane || {}; | ||||
| //     let key = roadColumn.key; | ||||
| //     let str = '' | ||||
| //     if (Array.isArray(key)) { | ||||
| //       key.forEach((k, index) => { | ||||
| //         str += (lane[k] === undefined ? '' : lane[k]) + (index == key.length - 1 ? '' : '/') | ||||
| //       }) | ||||
| //     } else { | ||||
| //       str = lane[key] === undefined ? '' : lane[key] | ||||
| //     } | ||||
| //     return str | ||||
| //   } | ||||
| // | ||||
| //   private RoadData: Array<RoadDataType> = [ | ||||
| //     { name: '路段组号', key: 'MapRoad_Code_No' }, | ||||
| //     { name: '路段编码', key: 'MapRoad_Name' }, | ||||
| //     { name: '车轮压线', key: ['TouchLineType', 'TouchDir'] }, | ||||
| //     { name: '车身碰线', key: ['TouchLineTypeCS', 'TouchLineDirCS'] }, | ||||
| //     { name: '基准车道', key: ['BasePointInLaneNo', 'BaseLaneCount'] }, | ||||
| //     { name: '前点车道', key: ['FrontPointLaneNo', 'FrontPointLaneCount'] }, | ||||
| //     { name: '后车点道', key: ['BackPointLaneNo','BackPointLaneCount'] }, | ||||
| //     { name: '左前/后车身距离', key: ['Body_LF_ToLeftEdge', 'Body_LB_ToLeftEdge'] }, | ||||
| //     { name: '右前/后车身距离', key: ['Body_RF_ToRightEdge', 'Body_RB_ToRightEdge'] }, | ||||
| //     { name: '右前/后车身边线', key: ['Body_RF_ToBaseLine','Body_RB_ToBaseLine'] }, | ||||
| //     { name: '右前/后轮距离', key: ['Wheel_RF_ToRightEdge', 'Wheel_RB_ToRightEdge'] }, | ||||
| //     { name: '右前/后轮边线', key: ['Wheel_RF_ToBaseLine', 'Wheel_RB_ToBaseLine'] }, | ||||
| //     { name: '左前/后轮距离', key: ['Wheel_LF_ToRightEdge', 'Wheel_LB_ToRightEdge'] }, | ||||
| //     { name: '左前/后轮边线', key: ['Wheel_LF_ToBaseLine', 'Wheel_LB_ToBaseLine'] }, | ||||
| //     { name: '车道属性', key: ['BasePointInLaneDir', 'CrossLineAttr','DirInverse'] }, | ||||
| //     { name: '形状', key: ['InShapeAttr', 'ShapeNo','ShapeNoWheel'] }, | ||||
| //     { name: '路段点', key: ['CrossPointNo'] }, | ||||
| //   ] | ||||
| // | ||||
| //   scaleFn = async (num)=>{ | ||||
| //     const scaleNum = this.scaleNum | ||||
| //     if(scaleNum >0 && scaleNum < 5000){ | ||||
| //       this.scaleNum += num; | ||||
| //     } | ||||
| //     if(scaleNum === 0 && num > 0){ | ||||
| //       this.scaleNum += num; | ||||
| //     } | ||||
| //     if(scaleNum > 5000 && num < 0){ | ||||
| //       this.scaleNum += num; | ||||
| //     } | ||||
| //     await examJudgeMapSetScaling(this.scaleNum); | ||||
| //   } | ||||
| // | ||||
| // } | ||||
| // | ||||
|  | ||||
| @ -10,44 +10,46 @@ export interface Project { | ||||
|   //项目状态:未做 正在做 及格 不及格 有扣分
 | ||||
|   type?: '1' | '2' | '3' | '4' | '5' | ||||
|   //
 | ||||
|   isEnd:boolean, | ||||
|   isUpload:boolean | ||||
|   isEnd: boolean, | ||||
|   isUpload: boolean | ||||
| } | ||||
| 
 | ||||
| export interface MarkRule { | ||||
|   itemno: number | ||||
|   markcatalog: string | ||||
|   markshow: string | ||||
|   markserial: string | ||||
|   markstandard: number, | ||||
|   markreal: number | ||||
|   kfxh: string | ||||
|   onlyoneid: number | ||||
|   OnlyOneKind: number | ||||
|   nocancelid: number | ||||
|   NoCancelId: number | ||||
|   gps_sid: number, | ||||
|   GPS_SID:boolean | ||||
|   score:number | ||||
|   xmmcStr: string | ||||
|   desc: string | ||||
|   itemno?: number | ||||
|   markcatalog?: string | ||||
|   markshow?: string | ||||
|   markserial?: string | ||||
|   markstandard?: number, | ||||
|   markreal?: number | ||||
|   kfxh?: string | ||||
|   onlyoneid?: number | ||||
|   OnlyOneKind?: number | ||||
|   nocancelid?: number | ||||
|   NoCancelId?: number | ||||
|   gps_sid?: number, | ||||
|   GPS_SID?: boolean | ||||
|   score?: number | ||||
|   xmmcStr?: string | ||||
|   desc?: string | ||||
|   xmdm?: number | ||||
|   type?: 0 | 1 | 2 | ||||
| } | ||||
| 
 | ||||
| export interface KF{ | ||||
| export interface KF { | ||||
|   //项目名称
 | ||||
|   xmmcStr: string, | ||||
|   xmdm: string | number, | ||||
| 
 | ||||
|   //扣分描述
 | ||||
|   desc: string, | ||||
| 
 | ||||
|   //扣分
 | ||||
|   score: string | ||||
|   //无锡所扣分代码
 | ||||
|   markcatalog: string | ||||
|   markserial: string | ||||
|   kfxh: string | ||||
|   type: 0| 1 | 2 | ||||
|   type: 0 | 1 | 2 | ||||
| } | ||||
| 
 | ||||
| export interface SYSTEMPARMARR { | ||||
| @ -123,6 +125,7 @@ export interface EXAMDATA { | ||||
|     xmxh: string, | ||||
|     xmhg: 1 | 0 | ||||
|   }, | ||||
| 
 | ||||
|   //扣分
 | ||||
|   kf: { | ||||
|     //项目代码
 | ||||
| @ -161,18 +164,18 @@ export interface EXAMDATA { | ||||
|     code: string, | ||||
|     type: number | ||||
|   }, | ||||
| 
 | ||||
|   //模拟灯光
 | ||||
|   mndg: string, | ||||
|   lane: LANE, | ||||
|   type: number | ||||
| 
 | ||||
|   //预进项目
 | ||||
|   precast:{ | ||||
|     xmdm:number, | ||||
|     xmxh:string | ||||
|   precast: { | ||||
|     xmdm: number, | ||||
|     xmxh: string | ||||
|   } | ||||
|   nongps:{ | ||||
|     type:0|1|2|3|4 | ||||
|   nongps: { | ||||
|     type: 0 | 1 | 2 | 3 | 4 | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user