Compare commits
	
		
			3 Commits
		
	
	
		
			6ede5e69bb
			...
			f604c1c8f2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | f604c1c8f2 | ||
|  | 0be3e1b970 | ||
|  | ee0b96125c | 
| @ -402,6 +402,7 @@ export interface SYSSET { | |||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| export interface ProjectRoads { | export interface ProjectRoads { | ||||||
|   param_3?: string[] |   param_3?: string[] | ||||||
|   param_4?: string[] |   param_4?: string[] | ||||||
| @ -411,7 +412,7 @@ export interface ProjectRoads { | |||||||
|   param_12?: string[] |   param_12?: string[] | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| interface MAPPOINT { | export interface MAPPOINT { | ||||||
|   point_no: number, |   point_no: number, | ||||||
|   gps_e: number, |   gps_e: number, | ||||||
|   gps_n: number, |   gps_n: number, | ||||||
| @ -425,7 +426,7 @@ interface MAPPOINT { | |||||||
|   passed: number |   passed: number | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| interface MAPITEMPOINTITEM { | export interface MAPITEMPOINTITEM { | ||||||
|   point_no: number, |   point_no: number, | ||||||
|   itemno: number, |   itemno: number, | ||||||
|   itemno1: number, |   itemno1: number, | ||||||
| @ -486,7 +487,7 @@ export interface JudgeUI { | |||||||
|   defaultTabIndex: number |   defaultTabIndex: number | ||||||
|   isDwztRight: boolean |   isDwztRight: boolean | ||||||
|   draw: boolean |   draw: boolean | ||||||
|   lane: JudgeLane |   lane: LANE | ||||||
|   sd: string |   sd: string | ||||||
|   dw: string |   dw: string | ||||||
| } | } | ||||||
| @ -708,11 +709,6 @@ export interface JudgeSoundB { | |||||||
|   type: 0 | 1 |   type: 0 | 1 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface JudgeLane { |  | ||||||
|   road: string |  | ||||||
|   num: number |  | ||||||
|   count: number |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| export interface JudgeNonGPS { | export interface JudgeNonGPS { | ||||||
|   type: 0 | 1 | 2 | 3 | 4 |   type: 0 | 1 | 2 | 3 | 4 | ||||||
| @ -780,7 +776,7 @@ export interface JudgeCallBackData { | |||||||
|   xmqx: JudgeKSXM |   xmqx: JudgeKSXM | ||||||
|   sound: JudgeSound |   sound: JudgeSound | ||||||
|   mndg: string |   mndg: string | ||||||
|   lane: JudgeLane |   lane: LANE | ||||||
|   precast: JudgeKSXM |   precast: JudgeKSXM | ||||||
|   nongps: JudgeNonGPS |   nongps: JudgeNonGPS | ||||||
| } | } | ||||||
| @ -833,3 +829,181 @@ export interface ProjectItemType { | |||||||
|   code: ProjectDataType |   code: ProjectDataType | ||||||
|   status: string |   status: string | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | export interface Project { | ||||||
|  |   //项目名称 | ||||||
|  |   name: string | ||||||
|  |   //项目代码 | ||||||
|  |   projectCode: string | ||||||
|  |   //无锡所项目代码 | ||||||
|  |   projectCodeCenter: string | ||||||
|  |   //项目简写 | ||||||
|  |   abbreviation?: string | ||||||
|  |   //项目状态:未做 正在做 及格 不及格 有扣分 | ||||||
|  |   type?: '1' | '2' | '3' | '4' | '5' | ||||||
|  |   // | ||||||
|  |   isEnd: boolean, | ||||||
|  |   isUpload: boolean | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | export interface KF { | ||||||
|  |   //项目名称 | ||||||
|  |   xmmcStr: string, | ||||||
|  |   xmdm: string | number, | ||||||
|  | 
 | ||||||
|  |   //扣分描述 | ||||||
|  |   desc: string, | ||||||
|  | 
 | ||||||
|  |   //扣分 | ||||||
|  |   score: string | ||||||
|  |   //无锡所扣分代码 | ||||||
|  |   markcatalog: string | ||||||
|  |   markserial: string | ||||||
|  |   kfxh: string | ||||||
|  |   type: 0 | 1 | 2 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | export interface SYSTEMPARMARROBJ { | ||||||
|  |   'no1': number, | ||||||
|  |   'no2': number, | ||||||
|  |   'no3': number, | ||||||
|  |   'txt1': string, | ||||||
|  |   'txt2': string, | ||||||
|  |   'txt3': string, | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | export interface EXAMDATA { | ||||||
|  |   //1:项目开始 2:项目结束 3:扣分 4:考车状态 5:考试结束 6:项目取消 7:语音播放和提示 8:模拟灯光事件 9:车道信息事件 10:预进项目事件 11:差分事件 | ||||||
|  |   event: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | ||||||
|  |   //时间 | ||||||
|  |   sj: number | ||||||
|  |   //考车状态 -1:后退 0:停车 1:前进 | ||||||
|  |   carzt: -1 | 0 | 1 | ||||||
|  |   //项目开始 | ||||||
|  |   xmks: xmksType | ||||||
|  |   //项目结束 | ||||||
|  |   xmjs: xmjsType | ||||||
|  |   //扣分 | ||||||
|  |   kf: kfType | ||||||
|  |   //考试结束 | ||||||
|  |   ksjs: ksjxType | ||||||
|  |   //项目取消 | ||||||
|  |   xmqx: xmqxType | ||||||
|  |   sound: soundType | ||||||
|  |   //模拟灯光 | ||||||
|  |   mndg: string | ||||||
|  |   lane: LANE | ||||||
|  |   type: number | ||||||
|  |   //预进项目 | ||||||
|  |   precast: precastType | ||||||
|  |   nongps: nongpsType | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | interface xmksType { | ||||||
|  |   //项目代码     项目子序号 | ||||||
|  |   xmdm: number, | ||||||
|  |   xmxh: string | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | interface xmjsType { | ||||||
|  |   //项目代码    项目子序号       项目是否合格 | ||||||
|  |   xmdm: number, | ||||||
|  |   xmxh: string, | ||||||
|  |   xmhg: 1 | 0 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | interface kfType { | ||||||
|  |   //项目代码 | ||||||
|  |   xmdm: number, | ||||||
|  | 
 | ||||||
|  |   //扣分代码 | ||||||
|  |   kfdm: string, | ||||||
|  | 
 | ||||||
|  |   //无锡所扣分代码 | ||||||
|  |   markcatalog: string | ||||||
|  |   // 0:评判自动扣分 1:本地人工扣分 2:远程人工扣分 | ||||||
|  |   type: 0 | 1 | 2 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | interface ksjxType { | ||||||
|  |   //前进距离 | ||||||
|  |   qjjl: number, | ||||||
|  | 
 | ||||||
|  |   //倒车距离 | ||||||
|  |   dcjl: number, | ||||||
|  |   d1: number | ||||||
|  |   d2: number | ||||||
|  |   d3: number | ||||||
|  |   d4: number | ||||||
|  |   d5: number | ||||||
|  |   d6: number | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | interface xmqxType { | ||||||
|  |   //项目代码     项目子序号 | ||||||
|  |   xmdm: number, | ||||||
|  |   xmxh: string | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | interface soundType { | ||||||
|  |   xmdm: number, | ||||||
|  | 
 | ||||||
|  |   //语音播放文件代码 | ||||||
|  |   code: string, | ||||||
|  |   type: number | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | interface precastType { | ||||||
|  |   xmdm: number, | ||||||
|  |   xmxh: string | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | interface nongpsType { | ||||||
|  |   type: 0 | 1 | 2 | 3 | 4 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface KSJS { | ||||||
|  |   //0:自动结束,1:手动结束 | ||||||
|  |   type: 0 | 1 | ||||||
|  |   qjjl: number, | ||||||
|  |   dcjl: number, | ||||||
|  |   d1: number, | ||||||
|  |   d2: number, | ||||||
|  |   d3: number, | ||||||
|  |   d4: number, | ||||||
|  |   d5: number, | ||||||
|  |   d6: number, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface MAPPOINTITEM {} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | export interface SOUND { | ||||||
|  |   //项目代码 | ||||||
|  |   xmdm: number | ||||||
|  |   //语音播放提示代码 | ||||||
|  |   code: string, | ||||||
|  | 
 | ||||||
|  |   //0:普通,1:模拟灯光 | ||||||
|  |   type: number | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface LANE { | ||||||
|  |   //当前路段号   如果road为空字符串””,说明当前在未测绘得道路上或者不在差分状态 | ||||||
|  |   road: string | ||||||
|  |   /*当前基准天线所在车道号 | ||||||
|  |       num等于0或者count等于0说明当前未在测绘路段,或者不在差分状态。 | ||||||
|  |       num等于1的时候表示在最右侧车道 | ||||||
|  |       num等于count的时候的表示在最左侧车道 | ||||||
|  |   */ | ||||||
|  |   num: number | ||||||
|  |   //当前基准天线共有几股车道 | ||||||
|  |   count: number | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | |||||||
| @ -10,14 +10,13 @@ import { defaultJudgeConfigObj } from './judgeSDK/utils//judgeCommon'; | |||||||
| import { uploadExamMileage } from '../api/judge'; | import { uploadExamMileage } from '../api/judge'; | ||||||
| import DwztErrorPopup from './compontents/judge/DwztErrorPopup'; | import DwztErrorPopup from './compontents/judge/DwztErrorPopup'; | ||||||
| import MsgPopup from './compontents/judge/MsgPopup'; | import MsgPopup from './compontents/judge/MsgPopup'; | ||||||
| import { CARINFO, CDSBInfo, LANE, MAPITEMPOINTITEM, MAPPOINT, Project, SYSTEMPARMARR } from './judgeSDK/api/judgeSDK.d'; |  | ||||||
| 
 |  | ||||||
| import { JudgeConfig } from '../config'; | import { JudgeConfig } from '../config'; | ||||||
| 
 | 
 | ||||||
| import SignDisplayCom from './compontents/SignDisplayCom'; |  | ||||||
| import { | import { | ||||||
|   AmplifyItem, |   AmplifyItem, | ||||||
|  |   CARINFO, | ||||||
|   CarInfoType, |   CarInfoType, | ||||||
|  |   CDSBInfo, | ||||||
|   CDSBInfos, |   CDSBInfos, | ||||||
|   DefaultJudgeConfigObj, |   DefaultJudgeConfigObj, | ||||||
|   ES_CARINFOType, |   ES_CARINFOType, | ||||||
| @ -25,20 +24,25 @@ import { | |||||||
|   JudgeBeginObj, |   JudgeBeginObj, | ||||||
|   JudgeCallBacData, |   JudgeCallBacData, | ||||||
|   JudgeInitObj, |   JudgeInitObj, | ||||||
|  |   LANE, | ||||||
|   MA_CDSBINFOType, |   MA_CDSBINFOType, | ||||||
|   MA_ITEMINFOType, |   MA_ITEMINFOType, | ||||||
|   MA_MAP_POINT_ITEMType, |   MA_MAP_POINT_ITEMType, | ||||||
|   MA_MAP_POINTType, |   MA_MAP_POINTType, | ||||||
|   MA_SYSTEMPARMType, |   MA_SYSTEMPARMType, | ||||||
|  |   MAPITEMPOINTITEM, | ||||||
|  |   MAPPOINT, | ||||||
|   MarkRule, |   MarkRule, | ||||||
|   MarkRules, |   MarkRules, | ||||||
|   MASYSSETTableType, |   MASYSSETTableType, | ||||||
|  |   Project, | ||||||
|   ProjectInfo, |   ProjectInfo, | ||||||
|   ProjectInfos, |   ProjectInfos, | ||||||
|   ProjectRoads, |   ProjectRoads, | ||||||
|   RouteParamsType, |   RouteParamsType, | ||||||
|   SYSSET, |   SYSSET, | ||||||
|   SyssetConfig, |   SyssetConfig, | ||||||
|  |   SYSTEMPARMARR, | ||||||
|   User |   User | ||||||
| } from '../model'; | } from '../model'; | ||||||
| import { GetSyncData } from '../utils/table/Operation'; | import { GetSyncData } from '../utils/table/Operation'; | ||||||
| @ -60,8 +64,6 @@ struct Index { | |||||||
|   @State endPopupVisible: boolean = false |   @State endPopupVisible: boolean = false | ||||||
|   //等待弹窗(考试及格,考试不及格使用) |   //等待弹窗(考试及格,考试不及格使用) | ||||||
|   @State loadingPopupVisible: boolean = false |   @State loadingPopupVisible: boolean = false | ||||||
|   //实时轨迹弹窗 |  | ||||||
|   @State signDisplayComVisible: boolean = false |  | ||||||
|   @State isDdxk: boolean = false; |   @State isDdxk: boolean = false; | ||||||
|   @State time: string = '' |   @State time: string = '' | ||||||
|   //考试用时 |   //考试用时 | ||||||
| @ -449,12 +451,12 @@ struct Index { | |||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       this.systemparmArr.push({ |       this.systemparmArr.push({ | ||||||
|         'NO1': Number(systemParm.no1), |         NO1: Number(systemParm.no1), | ||||||
|         'NO2': Number(systemParm.no2), |         NO2: Number(systemParm.no2), | ||||||
|         'NO3': Number(systemParm.no3), |         NO3: Number(systemParm.no3), | ||||||
|         'TXT1': decodeURIComponent(systemParm.txt1 || ""), |         TXT1: decodeURIComponent(systemParm.txt1 || ""), | ||||||
|         'TXT2': decodeURIComponent(systemParm.txt2 || ""), |         TXT2: decodeURIComponent(systemParm.txt2 || ""), | ||||||
|         'TXT3': decodeURIComponent(systemParm.txt3 || ""), |         TXT3: decodeURIComponent(systemParm.txt3 || ""), | ||||||
|       }) |       }) | ||||||
|     }) |     }) | ||||||
|     const projects = this.projects; |     const projects = this.projects; | ||||||
| @ -946,7 +948,6 @@ struct Index { | |||||||
|               //   type: 1, |               //   type: 1, | ||||||
|               //   name: 'button_media.wav' |               //   name: 'button_media.wav' | ||||||
|               // }) |               // }) | ||||||
|               // this.signDisplayComVisible = true |  | ||||||
|               this.signalTrajectoryDialog.open() |               this.signalTrajectoryDialog.open() | ||||||
|             }) |             }) | ||||||
| 
 | 
 | ||||||
| @ -1049,7 +1050,6 @@ struct Index { | |||||||
| 
 | 
 | ||||||
|       //科目三人工扣分弹窗 |       //科目三人工扣分弹窗 | ||||||
|       if (this.isDeductedPopShow && this.examSubject == '3' && Reflect.get(this.judgeConfigObj, '342') == '0') { |       if (this.isDeductedPopShow && this.examSubject == '3' && Reflect.get(this.judgeConfigObj, '342') == '0') { | ||||||
| 
 |  | ||||||
|         DeductedPopup({ |         DeductedPopup({ | ||||||
|           defaultTabIndex: this.defaultTabIndex, |           defaultTabIndex: this.defaultTabIndex, | ||||||
|           // currentItems: Reflect.ownKeys(this.projectsObj).map(projectKey => { |           // currentItems: Reflect.ownKeys(this.projectsObj).map(projectKey => { | ||||||
| @ -1076,31 +1076,6 @@ struct Index { | |||||||
|         }) |         }) | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if (this.signDisplayComVisible) { |  | ||||||
|         Column() { |  | ||||||
|           SignDisplayCom({ |  | ||||||
|             showBack: false, |  | ||||||
|             scaleNum: 1.8, |  | ||||||
|             msgStr: this.judge.plcStr || '', |  | ||||||
|             showTrajectory: this.singlePlay ? true : (this.syssetParam623), |  | ||||||
|           }).margin({ top: 100 }) |  | ||||||
| 
 |  | ||||||
|           Row() { |  | ||||||
|           } |  | ||||||
|           .width(240) |  | ||||||
|           .height(240) |  | ||||||
|           .position({ x: '81%', y: 80 }) |  | ||||||
|           .backgroundImage($rawfile('judge/close.png'), ImageRepeat.NoRepeat) |  | ||||||
|           .backgroundImageSize({ width: '33.33%', height: '33.33%' }) |  | ||||||
|           .onClick(() => { |  | ||||||
|             // this.vocObj.playAudio({ |  | ||||||
|             //   type: 1, |  | ||||||
|             //   name: 'button_media.wav' |  | ||||||
|             // }) |  | ||||||
|             this.signDisplayComVisible = false |  | ||||||
|           }) |  | ||||||
|         }.width('100%').height('100%').position({ y: 0 }).backgroundColor('rgba(0,0,0,0.6)') |  | ||||||
|       } |  | ||||||
| 
 | 
 | ||||||
|       //科目三人工项目确认框 |       //科目三人工项目确认框 | ||||||
|       if (this.isAmplifyPopShow && this.examSubject == '3') { |       if (this.isAmplifyPopShow && this.examSubject == '3') { | ||||||
| @ -1204,19 +1179,14 @@ struct Index { | |||||||
|     switch (type) { |     switch (type) { | ||||||
|       case '1': |       case '1': | ||||||
|         return '#E6DECF'; |         return '#E6DECF'; | ||||||
|         break; |  | ||||||
|       case '2': |       case '2': | ||||||
|         return '#FFAD33'; |         return '#FFAD33'; | ||||||
|         break; |  | ||||||
|       case '3': |       case '3': | ||||||
|         return '#ff109d0a'; |         return '#ff109d0a'; | ||||||
|         break; |  | ||||||
|       case '4': |       case '4': | ||||||
|         return '#FF7566'; |         return '#FF7566'; | ||||||
|         break; |  | ||||||
|       default: |       default: | ||||||
|         return '#E6DECF'; |         return '#E6DECF'; | ||||||
|         break; |  | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import libJudgeSdk from 'libjudgesdk.so'; | import libJudgeSdk from 'libjudgesdk.so'; | ||||||
| import { JudgeBeginObj, JudgeInitObj, Plc } from '../../../model'; | import { JudgeBeginObj, JudgeInitObj, Plc } from '../../model'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * 苏仁君 |  * 苏仁君 | ||||||
| @ -1,15 +1,44 @@ | |||||||
| import SignalDisplayComponent from '../compontents/SignalDisplay' | import SignalDisplayComponent from '../compontents/SignalDisplay' | ||||||
|  | import TabComponent from '../compontents/Tab' | ||||||
| 
 | 
 | ||||||
| @CustomDialog | @CustomDialog | ||||||
| export default struct SignalTrajectoryDialog { | export default struct SignalTrajectoryDialog { | ||||||
|  |   @State active: number = 0 | ||||||
|   private controller?: CustomDialogController |   private controller?: CustomDialogController | ||||||
| 
 | 
 | ||||||
|   build() { |   build() { | ||||||
|     Row() { |     // Scroll() { | ||||||
|       SignalDisplayComponent() | 
 | ||||||
|     }.width(1200).height(1200).border({ |     Column() { | ||||||
|       width: 1, |       Flex( | ||||||
|       color: "red" |         { | ||||||
|     }) |           justifyContent: FlexAlign.SpaceBetween, | ||||||
|  |           alignItems: ItemAlign.Center | ||||||
|  |         } | ||||||
|  |       ) { | ||||||
|  |         TabComponent({ | ||||||
|  |           isShowTrajectory: true, | ||||||
|  |           activeIndex: this.active, | ||||||
|  |           onchange: (index: number) => { | ||||||
|  |             this.active = index | ||||||
|  |           } | ||||||
|  |         }) | ||||||
|  |         //   关闭按钮 | ||||||
|  |         Image($rawfile('judge/close.png')).height(50).onClick(() => { | ||||||
|  |           this.controller?.close() | ||||||
|  |         }) | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       Scroll() { | ||||||
|  |         Column() { | ||||||
|  |           SignalDisplayComponent({ | ||||||
|  |             active: this.active | ||||||
|  |           }) | ||||||
|  |         }.height(890) | ||||||
|  |       }.width("100%") | ||||||
|  |       .height(700) | ||||||
|  |     }.width(1500) | ||||||
|  | 
 | ||||||
|  |     // }.width(1200).height(900) | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -25,7 +25,6 @@ struct SignDisplayPage { | |||||||
|             right: 10 |             right: 10 | ||||||
|           }) |           }) | ||||||
|           TabComponent({ |           TabComponent({ | ||||||
|             isShowTrajectory: true, |  | ||||||
|             activeIndex: this.active, |             activeIndex: this.active, | ||||||
|             onchange: (index: number) => { |             onchange: (index: number) => { | ||||||
|               this.active = index |               this.active = index | ||||||
| @ -42,8 +41,7 @@ struct SignDisplayPage { | |||||||
|       }.width("100%").height(100) |       }.width("100%").height(100) | ||||||
| 
 | 
 | ||||||
|       SignalDisplayComponent({ |       SignalDisplayComponent({ | ||||||
|         active: this.active, |         active: this.active | ||||||
|         isShowTrajectory: true |  | ||||||
|       }) |       }) | ||||||
|     } |     } | ||||||
|     .width('100%') |     .width('100%') | ||||||
|  | |||||||
| @ -1,8 +1,9 @@ | |||||||
| import { GPSData, InitialPerLane, SignalData } from '../../mock' | import { GPSData, InitialPerLane, SignalData } from '../../mock' | ||||||
| import { EnvironmentConfigurationType, PerLane, RoadDataType, SignalDataType, WorkerBackMessage } from '../../model' | import { EnvironmentConfigurationType, PerLane, RoadDataType, SignalDataType, WorkerBackMessage } from '../../model' | ||||||
| import apiJudgeSdk from 'libJudgeSdk.so' | import apiJudgeSdk from 'libJudgeSdk.so' | ||||||
| import { examJudgeMapSetScaling } from '../judgeSDK/api' | 
 | ||||||
| import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker' | import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker' | ||||||
|  | import { examJudgeMapSetScaling } from '../Judge/JudgeUtils' | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @Component | @Component | ||||||
| @ -19,8 +20,6 @@ export default struct SignalDisplayComponent { | |||||||
|   @State rawData: string = "$GPS,,,,,,,,,,,,,,,,,,,,,,,,,,,,," |   @State rawData: string = "$GPS,,,,,,,,,,,,,,,,,,,,,,,,,,,,," | ||||||
|   // 车道信息 |   // 车道信息 | ||||||
|   @State laneSignal: PerLane = InitialPerLane |   @State laneSignal: PerLane = InitialPerLane | ||||||
|   // 是否现实轨迹 |  | ||||||
|   @State isShowTrajectory: boolean = false |  | ||||||
| 
 | 
 | ||||||
|   aboutToAppear(): void { |   aboutToAppear(): void { | ||||||
|     DifferentialAndSignal.onMsg((data: string) => { |     DifferentialAndSignal.onMsg((data: string) => { | ||||||
| @ -111,29 +110,27 @@ export default struct SignalDisplayComponent { | |||||||
|             Text(this.rawData).fontSize(20).fontColor("#fff") |             Text(this.rawData).fontSize(20).fontColor("#fff") | ||||||
|           }.backgroundColor("#282828").width("100%").height("100%") |           }.backgroundColor("#282828").width("100%").height("100%") | ||||||
|         } else { |         } else { | ||||||
|           if (this.isShowTrajectory) { |           // 轨迹查看 | ||||||
|             // 轨迹查看 |           Flex() { | ||||||
|             Flex() { |             Column() { | ||||||
|               Column() { |               CoordinateComponent({ | ||||||
|                 CoordinateComponent({ |                 isItHorizontal: false, | ||||||
|                   isItHorizontal: false, |                 heightNum: 40, | ||||||
|                   heightNum: 40, |                 data: this.GPSColum | ||||||
|                   data: this.GPSColum |               }) | ||||||
|                 }) |             }.width("20%") | ||||||
|               }.width("20%") |  | ||||||
| 
 | 
 | ||||||
|               Column() { |             Column() { | ||||||
|                 LaneComponent({ |               LaneComponent({ | ||||||
|                   laneSignal: this.laneSignal |                 laneSignal: this.laneSignal | ||||||
|                 }) |               }) | ||||||
|               }.width("20%") |             }.width("20%") | ||||||
| 
 | 
 | ||||||
|               Column() { |             Column() { | ||||||
|                 trajectoryComponent() |               trajectoryComponent() | ||||||
|               }.height("100%").width("60%") |             }.height("100%").width("60%") | ||||||
| 
 | 
 | ||||||
|             }.backgroundColor("#282828").width("100%").height("100%") |           }.backgroundColor("#282828").width("100%").height("100%") | ||||||
|           } |  | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|       .width("100%") |       .width("100%") | ||||||
|  | |||||||
| @ -50,6 +50,7 @@ struct TabItemComponent { | |||||||
|       topLeft: 20, |       topLeft: 20, | ||||||
|       topRight: 20, |       topRight: 20, | ||||||
|     }) |     }) | ||||||
|  |     .backgroundColor("#262420") | ||||||
|     .border({ |     .border({ | ||||||
|       width: { top: 1, left: 1, right: 1 }, |       width: { top: 1, left: 1, right: 1 }, | ||||||
|       color: this.active ? "#ECAD5C" : "#DDCBAC" |       color: this.active ? "#ECAD5C" : "#DDCBAC" | ||||||
|  | |||||||
							
								
								
									
										232
									
								
								entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										232
									
								
								entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -1,232 +0,0 @@ | |||||||
| export interface Project { |  | ||||||
|   //项目名称
 |  | ||||||
|   name: string |  | ||||||
|   //项目代码
 |  | ||||||
|   projectCode: string |  | ||||||
|   //无锡所项目代码
 |  | ||||||
|   projectCodeCenter: string |  | ||||||
|   //项目简写
 |  | ||||||
|   abbreviation?: string |  | ||||||
|   //项目状态:未做 正在做 及格 不及格 有扣分
 |  | ||||||
|   type?: '1' | '2' | '3' | '4' | '5' |  | ||||||
|   //
 |  | ||||||
|   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 |  | ||||||
|   xmdm?: number |  | ||||||
|   type?: 0 | 1 | 2 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface KF { |  | ||||||
|   //项目名称
 |  | ||||||
|   xmmcStr: string, |  | ||||||
|   xmdm: string | number, |  | ||||||
| 
 |  | ||||||
|   //扣分描述
 |  | ||||||
|   desc: string, |  | ||||||
| 
 |  | ||||||
|   //扣分
 |  | ||||||
|   score: string |  | ||||||
|   //无锡所扣分代码
 |  | ||||||
|   markcatalog: string |  | ||||||
|   markserial: string |  | ||||||
|   kfxh: string |  | ||||||
|   type: 0 | 1 | 2 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface SYSTEMPARMARR { |  | ||||||
|   'NO1': number, |  | ||||||
|   'NO2': number, |  | ||||||
|   'NO3': number, |  | ||||||
|   'TXT1': string, |  | ||||||
|   'TXT2': string, |  | ||||||
|   'TXT3': string, |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface SYSTEMPARMARROBJ { |  | ||||||
|   'no1': number, |  | ||||||
|   'no2': number, |  | ||||||
|   'no3': number, |  | ||||||
|   'txt1': string, |  | ||||||
|   'txt2': string, |  | ||||||
|   'txt3': string, |  | ||||||
| 
 |  | ||||||
|   [k: string]: string | number |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| export interface CARINFO { |  | ||||||
|   CARID: string, |  | ||||||
|   IPADDR: string, |  | ||||||
|   CARCLASS: string, |  | ||||||
|   KSCX: string, |  | ||||||
|   CARNAME: string, |  | ||||||
|   FLAG: string, |  | ||||||
|   BK1: string, |  | ||||||
|   BK2: string |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface MAPPOINT { |  | ||||||
|   point_no: number, |  | ||||||
|   gps_e: number, |  | ||||||
|   gps_n: number, |  | ||||||
|   point_no_f: number, |  | ||||||
|   point_type: number, |  | ||||||
|   road_code: string, |  | ||||||
|   gps_e_Location: number |  | ||||||
|   gps_n_Location: number |  | ||||||
|   f_gps_e: number, |  | ||||||
|   f_gps_n: number, |  | ||||||
|   passed: number |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface MAPITEMPOINTITEM { |  | ||||||
|   point_no: number, |  | ||||||
|   itemno: number, |  | ||||||
|   itemno1: number, |  | ||||||
|   subname: string |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface EXAMDATA { |  | ||||||
|   //1:项目开始 2:项目结束 3:扣分 4:考车状态 5:考试结束 6:项目取消 7:语音播放和提示 8:模拟灯光事件 9:车道信息事件 10:预进项目事件 11:差分事件
 |  | ||||||
|   event: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |  | ||||||
|   //时间
 |  | ||||||
|   sj: number |  | ||||||
|   //考车状态 -1:后退 0:停车 1:前进
 |  | ||||||
|   carzt: -1 | 0 | 1 |  | ||||||
|   //项目开始
 |  | ||||||
|   xmks: { |  | ||||||
|     //项目代码     项目子序号
 |  | ||||||
|     xmdm: number, |  | ||||||
|     xmxh: string |  | ||||||
|   } |  | ||||||
|   //项目结束
 |  | ||||||
|   xmjs: { |  | ||||||
|     //项目代码    项目子序号       项目是否合格
 |  | ||||||
|     xmdm: number, |  | ||||||
|     xmxh: string, |  | ||||||
|     xmhg: 1 | 0 |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   //扣分
 |  | ||||||
|   kf: { |  | ||||||
|     //项目代码
 |  | ||||||
|     xmdm: number, |  | ||||||
|     //扣分代码
 |  | ||||||
|     kfdm: string, |  | ||||||
|     //无锡所扣分代码
 |  | ||||||
|     markcatalog: string |  | ||||||
|     // 0:评判自动扣分 1:本地人工扣分 2:远程人工扣分
 |  | ||||||
|     type: 0 | 1 | 2 |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   //考试结束
 |  | ||||||
|   ksjs: { |  | ||||||
|     //前进距离
 |  | ||||||
|     qjjl: number, |  | ||||||
|     //倒车距离
 |  | ||||||
|     dcjl: number, |  | ||||||
|     d1: number |  | ||||||
|     d2: number |  | ||||||
|     d3: number |  | ||||||
|     d4: number |  | ||||||
|     d5: number |  | ||||||
|     d6: number |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   //项目取消
 |  | ||||||
|   xmqx: { |  | ||||||
|     //项目代码     项目子序号
 |  | ||||||
|     xmdm: number, |  | ||||||
|     xmxh: string |  | ||||||
|   }, |  | ||||||
|   sound: { |  | ||||||
|     xmdm: number, |  | ||||||
|     //语音播放文件代码
 |  | ||||||
|     code: string, |  | ||||||
|     type: number |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   //模拟灯光
 |  | ||||||
|   mndg: string, |  | ||||||
|   lane: LANE, |  | ||||||
|   type: number |  | ||||||
|   //预进项目
 |  | ||||||
|   precast: { |  | ||||||
|     xmdm: number, |  | ||||||
|     xmxh: string |  | ||||||
|   } |  | ||||||
|   nongps: { |  | ||||||
|     type: 0 | 1 | 2 | 3 | 4 |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface KSJS { |  | ||||||
|   //0:自动结束,1:手动结束
 |  | ||||||
|   type: 0 | 1 |  | ||||||
|   qjjl: number, |  | ||||||
|   dcjl: number, |  | ||||||
|   d1: number, |  | ||||||
|   d2: number, |  | ||||||
|   d3: number, |  | ||||||
|   d4: number, |  | ||||||
|   d5: number, |  | ||||||
|   d6: number, |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface MAPPOINTITEM {} |  | ||||||
| 
 |  | ||||||
| export interface CDSBInfo {} |  | ||||||
| 
 |  | ||||||
| export interface SOUND { |  | ||||||
|   //项目代码
 |  | ||||||
|   xmdm: number |  | ||||||
|   //语音播放提示代码
 |  | ||||||
|   code: string, |  | ||||||
| 
 |  | ||||||
|   //0:普通,1:模拟灯光
 |  | ||||||
|   type: number |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface SYSSET { |  | ||||||
|   v_no: string, |  | ||||||
|   v_name: string, |  | ||||||
|   v_value: string |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface LANE { |  | ||||||
|   //当前路段号   如果road为空字符串””,说明当前在未测绘得道路上或者不在差分状态
 |  | ||||||
|   road: string |  | ||||||
|   /*当前基准天线所在车道号 |  | ||||||
|       num等于0或者count等于0说明当前未在测绘路段,或者不在差分状态。 |  | ||||||
|       num等于1的时候表示在最右侧车道 |  | ||||||
|       num等于count的时候的表示在最左侧车道 |  | ||||||
|   */ |  | ||||||
|   num: number |  | ||||||
|   //当前基准天线共有几股车道
 |  | ||||||
|   count: number |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface ProjectObj { |  | ||||||
|   [k: string]: Project |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| @ -3,33 +3,17 @@ import router from '@ohos.router'; | |||||||
| import util from '@ohos.util'; | import util from '@ohos.util'; | ||||||
| import buffer from '@ohos.buffer'; | import buffer from '@ohos.buffer'; | ||||||
| import { testKm2Items, testKm3Items } from './dataTest/index'; | import { testKm2Items, testKm3Items } from './dataTest/index'; | ||||||
| import { KSJS } from './api/judgeSDK'; | 
 | ||||||
| import VoiceAnnounce from './utils/voiceAnnouncements'; | import VoiceAnnounce from './utils/voiceAnnouncements'; | ||||||
| import FileModel from './utils/fileModel'; | import FileModel from './utils/fileModel'; | ||||||
| import FilePhoto from './utils/filePhoto'; | import FilePhoto from './utils/filePhoto'; | ||||||
| import FileLog from './utils/fileLog'; | import FileLog from './utils/fileLog'; | ||||||
| import JudgeTask from './utils/judgeTask'; | import JudgeTask from './utils/judgeTask'; | ||||||
| import { JudgeConfig } from '../../config'; | import { JudgeConfig } from '../../config'; | ||||||
| import { LANE } from '../judgeSDK/api/judgeSDK.d'; |  | ||||||
| import { GetSyncData, SqlInsertTable } from '../../utils/table/Operation'; | import { GetSyncData, SqlInsertTable } from '../../utils/table/Operation'; | ||||||
| 
 | 
 | ||||||
| import { getCarStatus, getCenterProjectStatus, plcStrToJson, plcStrToWXJson, promptWxCode } from './utils/judgeCommon'; | import { getCarStatus, getCenterProjectStatus, plcStrToJson, plcStrToWXJson, promptWxCode } from './utils/judgeCommon'; | ||||||
| 
 | 
 | ||||||
| import { |  | ||||||
|   examCalcGpsDistance, |  | ||||||
|   examJudgeArtificialItem, |  | ||||||
|   examJudgeArtificialMark, |  | ||||||
|   examJudgeBeginExam, |  | ||||||
|   examJudgeEndExam, |  | ||||||
|   examJudgeInit, |  | ||||||
|   examJudgeRealExam, |  | ||||||
|   examJudgeSetLogCallback, |  | ||||||
|   examJudgeSetPerformCallback, |  | ||||||
|   examJudgeSetRealExamCallback, |  | ||||||
|   examJudgeSoundEnd, |  | ||||||
|   examJudgeVersion |  | ||||||
| } from './api/index'; |  | ||||||
| 
 |  | ||||||
| import { uploadExamProgressData, writeObjectOut } from '../../api/judge'; | import { uploadExamProgressData, writeObjectOut } from '../../api/judge'; | ||||||
| import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video'; | import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video'; | ||||||
| import common from '@ohos.app.ability.common'; | import common from '@ohos.app.ability.common'; | ||||||
| @ -59,6 +43,7 @@ import { | |||||||
|   JudgeXMJS, |   JudgeXMJS, | ||||||
|   Km3JudgeInitConfig, |   Km3JudgeInitConfig, | ||||||
|   KmItem, |   KmItem, | ||||||
|  |   LANE, | ||||||
|   MarkRule, |   MarkRule, | ||||||
|   Plc, |   Plc, | ||||||
|   ProjectInfo, |   ProjectInfo, | ||||||
| @ -70,6 +55,20 @@ import { | |||||||
|   WR |   WR | ||||||
| } from '../../model'; | } from '../../model'; | ||||||
| import { DrivingDataStorage } from '../../utils/business/DrivingDataStorage'; | import { DrivingDataStorage } from '../../utils/business/DrivingDataStorage'; | ||||||
|  | import { | ||||||
|  |   examCalcGpsDistance, | ||||||
|  |   examJudgeArtificialItem, | ||||||
|  |   examJudgeArtificialMark, | ||||||
|  |   examJudgeBeginExam, | ||||||
|  |   examJudgeEndExam, | ||||||
|  |   examJudgeInit, | ||||||
|  |   examJudgeRealExam, | ||||||
|  |   examJudgeSetLogCallback, | ||||||
|  |   examJudgeSetPerformCallback, | ||||||
|  |   examJudgeSetRealExamCallback, | ||||||
|  |   examJudgeSoundEnd, | ||||||
|  |   examJudgeVersion | ||||||
|  | } from '../Judge/JudgeUtils'; | ||||||
| 
 | 
 | ||||||
| const judgeTag = 'SURENJUN_JUDGE' | const judgeTag = 'SURENJUN_JUDGE' | ||||||
| 
 | 
 | ||||||
| @ -1192,7 +1191,7 @@ export default class Judge { | |||||||
|           judgeTask.addTask(async () => { |           judgeTask.addTask(async () => { | ||||||
|             console.info(judgeTag, '考试结束 start') |             console.info(judgeTag, '考试结束 start') | ||||||
|             AppStorage.setOrCreate('isJudge', false) |             AppStorage.setOrCreate('isJudge', false) | ||||||
|             await handEndExam(ksjs) |             await handEndExam() | ||||||
|           }) |           }) | ||||||
|         // TODO待修改 |         // TODO待修改 | ||||||
|         // clearInterval(globalThis.judgeTimer) |         // clearInterval(globalThis.judgeTimer) | ||||||
| @ -1318,7 +1317,7 @@ export default class Judge { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   // 处理考试结束 |   // 处理考试结束 | ||||||
|   public handEndExam = async (ksjs: KSJS) => { |   public handEndExam = async () => { | ||||||
|     this.judgeUI.loadingPopupVisible = true; |     this.judgeUI.loadingPopupVisible = true; | ||||||
|     this.judgeUI.endPopupVisible = false; |     this.judgeUI.endPopupVisible = false; | ||||||
|     this.judgeUI.isDeductedPopShow = false; |     this.judgeUI.isDeductedPopShow = false; | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ import { ArrayToByteArray, NumberToByteArray } from '../../../utils/Common'; | |||||||
| import systemTime from '@ohos.systemDateTime'; | import systemTime from '@ohos.systemDateTime'; | ||||||
| 
 | 
 | ||||||
| import { CarInfoType } from '../../../model'; | import { CarInfoType } from '../../../model'; | ||||||
| import { DefaultJudgeConfigObj, Gps, JudgeLane, Plc, Radar, Vision } from '../../../model/Judge'; | import { DefaultJudgeConfigObj, Gps, LANE, Plc, Radar, Vision } from '../../../model/Judge'; | ||||||
| 
 | 
 | ||||||
| interface Extend {} | interface Extend {} | ||||||
| 
 | 
 | ||||||
| @ -98,7 +98,7 @@ export function getKmProjectVoice( | |||||||
|   // 1:项目开始 2:项目结束 |   // 1:项目开始 2:项目结束 | ||||||
|   type: 1 | 2, |   type: 1 | 2, | ||||||
|   judgeConfig: object, |   judgeConfig: object, | ||||||
|   lane: JudgeLane, |   lane: LANE, | ||||||
|   xmxh: string |   xmxh: string | ||||||
| ) { | ) { | ||||||
|   const carInfo = AppStorage.get<CarInfoType>('carInfo')!; |   const carInfo = AppStorage.get<CarInfoType>('carInfo')!; | ||||||
| @ -110,9 +110,8 @@ export function getKmProjectVoice( | |||||||
| 
 | 
 | ||||||
|   console.info('surenjun => param544Str.length', param544Str.length) |   console.info('surenjun => param544Str.length', param544Str.length) | ||||||
| 
 | 
 | ||||||
|   const num = lane.num |   const num: number = lane?.num | ||||||
|   const count = lane.count |   const count: number = lane?.count | ||||||
|   const road = lane.road |  | ||||||
|   if (examSubject == '2') { |   if (examSubject == '2') { | ||||||
|     return projectCode |     return projectCode | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -1,43 +0,0 @@ | |||||||
| import FileUtils from '../../../utils/FileUtils'; |  | ||||||
| import { examJudgeMapSetParam, examJudgeMapSetScaling } from '../api/index'; |  | ||||||
| 
 |  | ||||||
| import FileModel from './fileModel'; |  | ||||||
| 
 |  | ||||||
| const judgeTag = 'SURENJUN_JUDGE' |  | ||||||
| 
 |  | ||||||
| export default class JudgeImg { |  | ||||||
|   private judgeUI |  | ||||||
|   private modelPath: string |  | ||||||
|   private fileModel: FileModel |  | ||||||
|   private fileUtil: FileUtils |  | ||||||
| 
 |  | ||||||
|   // private plcData: any |  | ||||||
| 
 |  | ||||||
|   constructor(judgeUI) { |  | ||||||
|     this.modelPath = 'models/model_enc' |  | ||||||
|     this.judgeUI = judgeUI |  | ||||||
|     this.fileUtil = new FileUtils(judgeUI.context) |  | ||||||
|     this.fileModel = new FileModel(judgeUI.context) |  | ||||||
|     this.init() |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   async init() { |  | ||||||
|     const isJudgeInitBool = AppStorage.get<boolean>('isJudgeInitBool'); |  | ||||||
|     const { judgeUI } = this; |  | ||||||
| 
 |  | ||||||
|     //TODO 临时处理 |  | ||||||
|     setTimeout(async () => { |  | ||||||
|       console.info(judgeTag, '1.进入评判入口') |  | ||||||
|       await examJudgeMapSetParam(640, 480); //设置参数宽、高 |  | ||||||
|       await examJudgeMapSetScaling(100); //设置缩放比例,一般默认填100(就是100%的意思) ,数字越大视野越大,数字越小视野越小,不能为0 |  | ||||||
|     }) |  | ||||||
| 
 |  | ||||||
|     judgeUI.draw = true |  | ||||||
| 
 |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   //获取评判初始化数据 |  | ||||||
|   getInitInfo = () => { |  | ||||||
| 
 |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| @ -3,6 +3,9 @@ import HiSerialSDK from '@ohos.hiserialsdk'; | |||||||
| import { SerialPortTag } from '../config'; | import { SerialPortTag } from '../config'; | ||||||
| 
 | 
 | ||||||
| // 打开串口工具 | // 打开串口工具 | ||||||
|  | /* | ||||||
|  |   * @param serialPort 串口名称 | ||||||
|  |  */ | ||||||
| export const OpenSerialPort = (serialPort: string) => { | export const OpenSerialPort = (serialPort: string) => { | ||||||
|   return new Promise<number>((resolve, reject) => { |   return new Promise<number>((resolve, reject) => { | ||||||
|     testNapi.SerialOpenAsync(serialPort, (value: number) => { |     testNapi.SerialOpenAsync(serialPort, (value: number) => { | ||||||
| @ -17,6 +20,11 @@ export const OpenSerialPort = (serialPort: string) => { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //初始化串口数据 | //初始化串口数据 | ||||||
|  | /* | ||||||
|  |   * @param fd 串口文件描述符 | ||||||
|  |   * @param speed 波特率 | ||||||
|  |   * @returns Promise<boolean> 成功返回true,失败返回false | ||||||
|  |  */ | ||||||
| export const InitSerialPortData = | export const InitSerialPortData = | ||||||
|   async (fd: number, speed: number) => { |   async (fd: number, speed: number) => { | ||||||
|     return new Promise<boolean>((resolve, reject) => { |     return new Promise<boolean>((resolve, reject) => { | ||||||
| @ -35,6 +43,11 @@ export const InitSerialPortData = | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| //发送数据 | //发送数据 | ||||||
|  | /* | ||||||
|  |   * @param fd 串口文件描述符 | ||||||
|  |   * @param data 要发送的数据数组 | ||||||
|  |   * @returns Promise<number> 成功返回发送的字节数,失败返回-1 | ||||||
|  |  */ | ||||||
| export const SendSerialPortData = (fd: number, data: number[]) => { | export const SendSerialPortData = (fd: number, data: number[]) => { | ||||||
|   console.log(SerialPortTag, "wzj-----发送数据") |   console.log(SerialPortTag, "wzj-----发送数据") | ||||||
|   return new Promise<number>((resolve, reject) => { |   return new Promise<number>((resolve, reject) => { | ||||||
| @ -49,6 +62,11 @@ export const SendSerialPortData = (fd: number, data: number[]) => { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // 接受数据 | // 接受数据 | ||||||
|  | /* | ||||||
|  |   * @param fd 串口文件描述符 | ||||||
|  |   * @param timeout 超时时间,单位毫秒 | ||||||
|  |   * @returns Promise<HiSerialSDK.receiveInfo> 成功返回接收到的数据,失败返回-1 | ||||||
|  |  */ | ||||||
| export const ReceiveSerialPortData = (fd: number, timeout: number,) => { | export const ReceiveSerialPortData = (fd: number, timeout: number,) => { | ||||||
|   console.log(SerialPortTag, "wzj-----接受数据") |   console.log(SerialPortTag, "wzj-----接受数据") | ||||||
|   return new Promise<HiSerialSDK.receiveInfo>((resolve) => { |   return new Promise<HiSerialSDK.receiveInfo>((resolve) => { | ||||||
|  | |||||||
| @ -16,8 +16,8 @@ import UdpClient from '../UdpUtils'; | |||||||
| import { CenterUDPBusinessInstance } from './CenterUdpBusiness'; | import { CenterUDPBusinessInstance } from './CenterUdpBusiness'; | ||||||
| import { ObtainUdpBusinessInstance } from './ObtainUdpBusiness'; | import { ObtainUdpBusinessInstance } from './ObtainUdpBusiness'; | ||||||
| import systemTime from '@ohos.systemDateTime'; | import systemTime from '@ohos.systemDateTime'; | ||||||
| import { examCalcGpsDistance } from '../../pages/judgeSDK/api'; |  | ||||||
| import { SerialNumberInstance } from '../SerialNumber'; | import { SerialNumberInstance } from '../SerialNumber'; | ||||||
|  | import { examCalcGpsDistance } from '../../pages/Judge/JudgeUtils'; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class JudgeUdpBusiness { | class JudgeUdpBusiness { | ||||||
|  | |||||||
							
								
								
									
										72
									
								
								entry/src/main/ets/utils/business/SerialPortService.ets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								entry/src/main/ets/utils/business/SerialPortService.ets
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,72 @@ | |||||||
|  | // 串口业务逻辑 | ||||||
|  | 
 | ||||||
|  | import { | ||||||
|  |   CancelReceiveSerialPortData, | ||||||
|  |   InitSerialPortData, | ||||||
|  |   OpenSerialPort, | ||||||
|  |   ReceiveSerialPortDataBySelf | ||||||
|  | } from '../SerialPort'; | ||||||
|  | import Prompt from '@system.prompt'; | ||||||
|  | import { SerialPortTag } from '../../config'; | ||||||
|  | 
 | ||||||
|  | class serialPortService { | ||||||
|  |   private fd: number = -1 | ||||||
|  |   private serialPort: string = "/dev/ttyS3" | ||||||
|  |   // 波特率 | ||||||
|  |   private baudRate: string = "115200" | ||||||
|  |   private events: Array<Function> = [] | ||||||
|  |   // 尝试次数 | ||||||
|  |   private tryCount: number = 0 | ||||||
|  | 
 | ||||||
|  |   async init() { | ||||||
|  |     const res = await OpenSerialPort(this.serialPort) | ||||||
|  |     if (res === -1) { | ||||||
|  |       Prompt.showToast({ | ||||||
|  |         message: "串口打开失败" | ||||||
|  |       }) | ||||||
|  |       //   失败了重试,最大次数为5次 | ||||||
|  |       this.tryCount++; | ||||||
|  |       if (this.tryCount < 5) { | ||||||
|  |         console.log(SerialPortTag, "串口打开失败,尝试第", this.tryCount, "次重试") | ||||||
|  |         setTimeout(() => { | ||||||
|  |           this.init(); | ||||||
|  |         }, 1000); | ||||||
|  |         return; | ||||||
|  |       } else { | ||||||
|  |         console.error(SerialPortTag, "串口打开失败,重试次数已达上限") | ||||||
|  |         return; | ||||||
|  |       } | ||||||
|  |     } else { | ||||||
|  |       this.fd = res; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   async canInit() { | ||||||
|  |     if (this.fd !== -1) { | ||||||
|  |       await InitSerialPortData(this.fd, Number(this.baudRate)) | ||||||
|  |       ReceiveSerialPortDataBySelf(this.fd, (res1: number, res2: number, res3: number[]) => { | ||||||
|  |         this.events.forEach((callback) => { | ||||||
|  |           callback(res3); | ||||||
|  |         }); | ||||||
|  |       }) | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   onMsg(callback: Function) { | ||||||
|  |     if (this.events.indexOf(callback) === -1) { | ||||||
|  |       this.events.push(callback); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   async closed() { | ||||||
|  |     const res = await CancelReceiveSerialPortData(this.fd); | ||||||
|  |     this.events = []; | ||||||
|  |     if (res) { | ||||||
|  |       console.log(SerialPortTag, "串口关闭成功") | ||||||
|  |     } else { | ||||||
|  |       console.error(SerialPortTag, "串口关闭失败") | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export const SerialPortService = new serialPortService(); | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user