feat:judgeCommon.ets修改
This commit is contained in:
		
							parent
							
								
									5910f134a2
								
							
						
					
					
						commit
						95eff3df79
					
				| @ -86,6 +86,142 @@ interface JudgeFile { | ||||
|   param?: JudgeFileParam[]; | ||||
| } | ||||
| 
 | ||||
| /** 扣分表 **/ | ||||
| export interface Mark { | ||||
|   itemno; | ||||
|   string | ||||
|   markcatalog: string | ||||
|   markshow: string | ||||
|   markreal: string | ||||
|   markserial: string | ||||
|   kfxh: string | ||||
| } | ||||
| 
 | ||||
| /** lane **/ | ||||
| export interface Lane { | ||||
|   num: number | ||||
|   count: number | ||||
|   road: number | ||||
| } | ||||
| 
 | ||||
| export interface Sensor { | ||||
|   aqd: number | ||||
|   mkg: number | ||||
|   ssc: number | ||||
|   jsc: number | ||||
|   fsc: number | ||||
|   lhq: number | ||||
|   lb: number | ||||
|   skd: number | ||||
|   jgd: number | ||||
|   ygd: number | ||||
|   zfxd: number | ||||
|   yfxd: number | ||||
|   shtd: number | ||||
|   wd: number | ||||
|   ygq: number | ||||
|   dh1: number | ||||
|   dh2: number | ||||
|   fdjzs: number | ||||
|   dw: number | ||||
|   cs: number | ||||
|   fxp: number | ||||
|   ljmc: number | ||||
|   lcmc: number | ||||
|   csbzh: number | ||||
|   csbyh: number | ||||
|   csbyq: number | ||||
|   csbzq: number | ||||
|   zy: number | ||||
|   tbp: number | ||||
|   hsj: number | ||||
|   dcj: number | ||||
|   gx: number | ||||
|   yl: number | ||||
|   yy: number | ||||
|   sde: number | ||||
|   xhd: number | ||||
|   rmndg: number | ||||
|   wav: number | ||||
|   mndg: number | ||||
| } | ||||
| 
 | ||||
| export interface Gps { | ||||
|   bklx: number | ||||
|   dwzt: number | ||||
|   jdzt?: number | ||||
|   sj?: number, | ||||
|   jd: number | ||||
|   wd: number | ||||
|   hxj: number | ||||
|   fyj: number | ||||
|   hbg: number | ||||
|   gdc: number | ||||
|   sd: number | ||||
|   age: number | ||||
|   jdyz: number | ||||
|   wdyz: number | ||||
|   dwsxs: number | ||||
|   jdsxs?: number | ||||
| } | ||||
| 
 | ||||
| export interface Vision { | ||||
|   sj: number | ||||
|   score: number | ||||
|   zyjd: number | ||||
|   sxjd: number | ||||
|   ytjd: number | ||||
|   fxp: number | ||||
|   ch: number | ||||
|   hld: number | ||||
| } | ||||
| 
 | ||||
| export interface Radar { | ||||
|   sj: number | ||||
|   zxh: number | ||||
|   qfsj: Qfsj[] | ||||
|   hfsj: Qfsj[] | ||||
|   zqsj: Qfsj[] | ||||
|   zhsj: Qfsj[] | ||||
|   zcsj: Qfsj[] | ||||
|   yqsj: Qfsj[] | ||||
|   yhsj: Qfsj[] | ||||
|   ycsj: Qfsj[] | ||||
|   fqsj: Qfsj[] | ||||
|   qfwt: Qfwt | ||||
|   rcyz: number | ||||
|   show: Show[] | ||||
| } | ||||
| 
 | ||||
| interface Qfwt { | ||||
|   xrjl: number | ||||
|   zawjl: number | ||||
| } | ||||
| 
 | ||||
| export interface Plc { | ||||
|   sensor: Sensor, | ||||
|   gps: Gps, | ||||
|   gps2: Gps, | ||||
|   vision: Vision, | ||||
|   radar: Radar, | ||||
|   extend: object | ||||
| } | ||||
| 
 | ||||
| interface Qfsj { | ||||
|   bh: number | ||||
|   lx: number | ||||
|   jl: number | ||||
|   sd: number | ||||
| } | ||||
| interface Show{ | ||||
|   bh: number | ||||
|   zb:Zb[] | ||||
| } | ||||
| interface Zb{ | ||||
|   x:number, | ||||
|   y:number | ||||
| } | ||||
| 
 | ||||
| /** 考试过程数据 */ | ||||
| export interface DrvexamType extends BaseExamFields { | ||||
|   lsh?: string; | ||||
| @ -99,4 +235,21 @@ export interface DrvexamType extends BaseExamFields { | ||||
|   ksxtbh?: string; | ||||
|   ksysfzmhm?: string; | ||||
|   Ksy2sfzmhm?: string; | ||||
| } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| export interface DefaultJudgeConfigObj{ | ||||
|   302:string | ||||
|   332:string | ||||
|   342:string | ||||
|   343:string | ||||
|   344:string | ||||
|   348:string | ||||
|   353:string | ||||
|   369:string | ||||
|   375:string | ||||
|   387:string | ||||
|   432:string | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -1,27 +1,17 @@ | ||||
| import { testMarkRules, testRealExam } from '../dataTest/index'; | ||||
| import { GetCurrentTime, NumberToByteArray } from '../../../utils/Common'; | ||||
| 
 | ||||
| import systemTime from '@ohos.systemDateTime'; | ||||
| import { Array2Byte } from './Common'; | ||||
| import { CarInfoType } from '../../../model'; | ||||
| import { Gps, Lane,Plc,Vision,Radar, Sensor,DefaultJudgeConfigObj} from '../../../model/Judge' | ||||
| 
 | ||||
| //获取本地扣分项 | ||||
| export const getTestMarkRules = () => { | ||||
|   testMarkRules.map((mark: any) => { | ||||
|     return { | ||||
|       itemno: mark.itemno * 1, | ||||
|       markcatalog: mark.markcatalog, | ||||
|       markshow: mark.markshow, | ||||
|       markreal: mark.markreal * 1, | ||||
|       markserial: mark.markserial, | ||||
|       kfxh: mark.kfxh | ||||
|     } | ||||
|   }) | ||||
| } | ||||
| interface Extend {} | ||||
| 
 | ||||
| // 中心信号转换 | ||||
| export const getTranslateSignals = (tempItems) => { | ||||
| export const getTranslateSignals = (tempItems:number[]) => { | ||||
|   const len = Math.floor(tempItems.length / 8); | ||||
|   const arr = []; | ||||
|   const arr:string[] = []; | ||||
|   for (let i = 0; i < len; i++) { | ||||
|     const temp = tempItems.slice(i * 8, (i + 1) * 8); | ||||
|     arr.push(temp.join('')); | ||||
| @ -45,7 +35,7 @@ export function getCarStatus(status: -1 | 0 | 1): string { | ||||
| } | ||||
| 
 | ||||
| // 当前考车中心状态转换 | ||||
| export function getCarStatusType(carzt) { | ||||
| export function getCarStatusType(carzt?:number) { | ||||
|   switch (carzt) { | ||||
|     case -1: | ||||
|       return [1, 0] | ||||
| @ -59,7 +49,7 @@ export function getCarStatusType(carzt) { | ||||
| } | ||||
| 
 | ||||
| // 获取档位信号 | ||||
| export function getDwStatusType(dw) { | ||||
| export function getDwStatusType(dw?:number) { | ||||
|   switch (dw) { | ||||
|     case 0: | ||||
|       return [0, 0, 0, 0] | ||||
| @ -82,7 +72,7 @@ export function getDwStatusType(dw) { | ||||
| 
 | ||||
| 
 | ||||
| // 中心实时项目状态转换 | ||||
| export function getCenterProjectStatus(status) { | ||||
| export function getCenterProjectStatus(status?:number) { | ||||
|   switch (status) { | ||||
|   //不考 | ||||
|     case 0: | ||||
| @ -104,27 +94,29 @@ export function getCenterProjectStatus(status) { | ||||
| 
 | ||||
| //获取科目三开始项目、结束项目语音 | ||||
| export function getKmProjectVoice( | ||||
|   projectCode, | ||||
|   projectCode:string, | ||||
|   // 1:项目开始 2:项目结束 | ||||
|   type: 1 | 2, | ||||
|   judgeConfig, | ||||
|   lane, | ||||
|   xmxh | ||||
|   judgeConfig:object, | ||||
|   lane:Lane, | ||||
|   xmxh:number | ||||
| ) { | ||||
|   const carInfo = AppStorage.get<CarInfoType>('carInfo'); | ||||
|   const { examSubject } = carInfo; | ||||
|   const param506Str = judgeConfig['506']?.split(',') || []; | ||||
|   const param512Str = judgeConfig['512']?.split(',') || []; | ||||
|   const param544Str = judgeConfig['544']?.split(',') || []; | ||||
|   const param405Str = judgeConfig['405'] || 0; | ||||
|   const  examSubject = carInfo.examSubject; | ||||
|   const param506Str:number[] = ( Reflect.get(judgeConfig,'506')?.split(',') ) || [] | ||||
|   const param512Str:number[] = ( Reflect.get(judgeConfig,'512')?.split(',') ) || [] | ||||
|   const param544Str:number[] = ( Reflect.get(judgeConfig,'544')?.split(',') ) || [] | ||||
|   const param405Str:number = Reflect.get(judgeConfig,'405') || 0; | ||||
| 
 | ||||
|   console.info('surenjun => param544Str.length', param544Str.length) | ||||
| 
 | ||||
|   const { num, count, road } = lane | ||||
|   if (examSubject == 2) { | ||||
|   const num = lane.num | ||||
|   const count = lane.count | ||||
|   const road = lane.road | ||||
|   if (examSubject == '2') { | ||||
|     return projectCode | ||||
|   } | ||||
|   switch (projectCode * 1) { | ||||
|   switch (Number(projectCode)) { | ||||
|   //直线行驶 | ||||
|     case 40300: | ||||
|       return type === 1 ? 403001 : 403002 | ||||
| @ -181,11 +173,11 @@ export function getKmProjectVoice( | ||||
| 
 | ||||
| 
 | ||||
| //获取科目三&科目三取消项目语音 | ||||
| export function getKmProjectCancelVoice(examSubject, projectCode) { | ||||
| export function getKmProjectCancelVoice(examSubject:number, projectCode:number) { | ||||
|   if (examSubject == 2) { | ||||
|     return 'xmqx' | ||||
|   } | ||||
|   switch (projectCode * 1) { | ||||
|   switch (Number(projectCode)) { | ||||
|   //变更车道 | ||||
|     case 40500: | ||||
|       return 405004 | ||||
| @ -458,17 +450,20 @@ export function promptWxCode( | ||||
| 
 | ||||
| // 获取plc数据 | ||||
| export const plcStrToJson = async (plc: string) => { | ||||
| 
 | ||||
|   const p = plc.split(',').map((val, key) => { | ||||
|   const plcArr = plc.split(',') | ||||
|   const p = plcArr.map((val, key) => { | ||||
|     if (key !== 27 && key !== 92) { | ||||
|       return val * 1 | ||||
|     } else { | ||||
|       return val | ||||
|       return Number(val) | ||||
|     } | ||||
|   }); | ||||
|   let data: any = testRealExam; | ||||
|   const time = await systemTime.getCurrentTime() | ||||
|   const tempData = { | ||||
| 
 | ||||
| 
 | ||||
|   const gps2:Gps =testRealExam.gps2 | ||||
|   const radar:Radar =testRealExam.radar | ||||
|   const vision:Vision =testRealExam.vision | ||||
|   const extend:Extend = {}; | ||||
|   const tempData:Plc = { | ||||
|     sensor: { | ||||
|       //安全带     车门门开关   手刹        脚刹        副刹       离合器      喇叭      示宽灯     近光灯     远光灯 | ||||
|       aqd: p[19], | ||||
| @ -493,7 +488,7 @@ export const plcStrToJson = async (plc: string) => { | ||||
|       dw: p[28], | ||||
|       cs: p[23], | ||||
|       // 方向盘 | ||||
|       fxp: p[27].split('_')[0] * 1, | ||||
|       fxp: Number(plcArr[27].split('_')[0]), | ||||
|       //累计脉冲   溜车脉冲   超声波左后     超声波右后     超声波右前     超声波左前    座椅    仪表盘   后视镜   倒车镜   光照  雨量 | ||||
|       ljmc: p[24], | ||||
|       lcmc: 0, | ||||
| @ -520,7 +515,7 @@ export const plcStrToJson = async (plc: string) => { | ||||
|       bklx: p[56], | ||||
|       dwzt: p[83], | ||||
|       // 角度差分状态 | ||||
|       jdzt: p[92].split('-')[0] * 1, | ||||
|       jdzt:  Number(plcArr[92].split('-')[0]), | ||||
|       //gps数据 | ||||
|       //gps时间 经度      纬度       航向角      俯仰角      海拔高       高度差     速度 | ||||
|       sj: time, | ||||
| @ -537,26 +532,25 @@ export const plcStrToJson = async (plc: string) => { | ||||
|       wdyz: p[88], | ||||
|       dwsxs: p[84] || 0, | ||||
|       // 角度搜星数 | ||||
|       jdsxs: p[92].split('-')[1] * 1 || 0 | ||||
|       jdsxs: Number(plcArr[92].split('-')[1]) || 0 | ||||
|     }, | ||||
|     gps2: data.gps, | ||||
|     vision: data.vision, | ||||
|     radar: data.radar, | ||||
|     extend: {} | ||||
|     gps2: gps2, | ||||
|     vision, | ||||
|     radar, | ||||
|     extend | ||||
|   } | ||||
|   return tempData | ||||
| } | ||||
| 
 | ||||
| export const plcStrToWXJson = async (plc: string) => { | ||||
|   const plcArr = plc.split(',') | ||||
|   const p = plc.split(',').map((val, key) => { | ||||
|     if (key !== 27 && key !== 92) { | ||||
|       return val * 1 | ||||
|     } else { | ||||
|       return val | ||||
|       return Number(val) | ||||
|     } | ||||
|   }); | ||||
|   const timeStr = p[93] + '' + p[94]; | ||||
|   const gps = { | ||||
|   const gps:Gps = { | ||||
|     //办卡类型    定位差分状态 | ||||
|     bklx: p[56], | ||||
|     dwzt: p[83], | ||||
| @ -580,6 +574,9 @@ export const plcStrToWXJson = async (plc: string) => { | ||||
|     // 注车制动 行车制动 离合器 副制动   喇叭   雨刷    危险报警灯 示廓灯 系统未涉及的传感器信号 | ||||
|     p[13], p[12], p[17], p[18], p[4], p[11], p[20], p[9], 0 | ||||
|   ] | ||||
| 
 | ||||
|   const judgeSignalNum = Number(judgeSignal.join('')) | ||||
|   const judgeAnotherSignalNum = Number(judgeAnotherSignal.join('')) | ||||
|   const judgeAnotherSignal = [ | ||||
|   // 低三挡位 左侧单边桥1 左侧单边桥2 右侧单边桥1 右侧单边桥2 雾灯 | ||||
|     '000', '0', '0', '0', '0', p[10], | ||||
| @ -592,23 +589,23 @@ export const plcStrToWXJson = async (plc: string) => { | ||||
|     //前天线可用星数 后天线可用星数 东向坐标位置 北向位置坐标 天向位置坐标  东向速度 北向速度 天向速度 | ||||
|     '', '', '', '', '', '', '', '', | ||||
|     // 评判信号1 评判信号2 发动机转速 | ||||
|     (judgeSignal.join('') * 1).toString(16), (judgeAnotherSignal.join('') * 1).toString(16), p[25], | ||||
|     judgeSignalNum.toString(16),judgeAnotherSignalNum.toString(16), p[25], | ||||
|     '0xFFFFFFF' | ||||
|   ] | ||||
|   const wuXiDataStr = wuXiData.join(',') | ||||
|   return wuXiDataStr | ||||
| } | ||||
| 
 | ||||
| export const senorToWXDataStr = async (tempData) => { | ||||
|   const { sensor, gps } = tempData; | ||||
| export const senorToWXDataStr = async (tempData:Plc) => { | ||||
|   const sensor = tempData.sensor | ||||
|   const gps = tempData.gps | ||||
|   const timeStr = await getTimeStr() | ||||
| 
 | ||||
|   const { mkg, aqd, dh1, dh2, zfxd, yfxd, jgd, ygd, ssc, jsc, lhq, fsc, lb, ygq, wd } = sensor | ||||
|   const judgeSignal = [ | ||||
|   const judgeSignal:number[] = [ | ||||
|   //车门 安全带  熄火    发动机启动 左转向 右转向  前照灯近灯 前照灯远灯 | ||||
|     mkg, aqd, dh1, dh2, zfxd, yfxd, jgd, ygd, | ||||
|     sensor.mkg, sensor.aqd, sensor.dh1, sensor.dh2, sensor.zfxd, sensor.yfxd, sensor.jgd, sensor.ygd, | ||||
|     // 注车制动 行车制动 离合器 副制动   喇叭   雨刷    危险报警灯 示廓灯 系统未涉及的传感器信号 | ||||
|     ssc, jsc, lhq, fsc, lb, ygq, 0, 0, 0 | ||||
|     sensor.ssc, sensor.jsc, sensor.lhq, sensor.fsc, sensor.lb, sensor.ygq, 0, 0, 0 | ||||
|   ] | ||||
| 
 | ||||
|   const judgeAnotherSignal = [ | ||||
| @ -618,8 +615,8 @@ export const senorToWXDataStr = async (tempData) => { | ||||
|     '000', '0', '0', '0', '0', '0', '0' | ||||
|   ] | ||||
| 
 | ||||
|   const str1 = (judgeSignal.join('') * 1).toString(16); | ||||
|   const str2 = (judgeAnotherSignal.join('') * 1).toString(16); | ||||
|   const str1 = (Number(judgeSignal.join(''))).toString(16); | ||||
|   const str2 = (Number(judgeAnotherSignal.join(''))).toString(16); | ||||
| 
 | ||||
|   const wuXiData = [ | ||||
|   //         卫星时间     精度    纬度     高度      方位角    俯仰角    速度角  速度      横滚  卫星定位状态 | ||||
| @ -652,24 +649,25 @@ export const getTimeStr = async () => { | ||||
| export function sendBlue() { | ||||
|   const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]; | ||||
|   const arrBlueBuffer = Array2Byte(arrBlue).buffer | ||||
|   globalThis.lightLineUdp.send(arrBlueBuffer); | ||||
|   // globalThis.lightLineUdp.send(arrBlueBuffer); | ||||
| } | ||||
| 
 | ||||
| //绿灯 | ||||
| export function sendGreen() { | ||||
|   const arrGreen = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x00, 0x03, 0x01]; | ||||
|   const arrGreenBuffer = Array2Byte(arrGreen).buffer | ||||
|   globalThis.lightLineUdp.send(arrGreenBuffer); | ||||
|   // globalThis.lightLineUdp.send(arrGreenBuffer); | ||||
| } | ||||
| 
 | ||||
| //红灯 | ||||
| export function sendRed() { | ||||
|   const arrRed = [0x55, 0xaa, 0x01, 0x01, 0x02, 0x00, 0x03, 0x00]; | ||||
|   const arrRedBuffer = Array2Byte(arrRed).buffer | ||||
|   globalThis.lightLineUdp.send(arrRedBuffer); | ||||
|   // globalThis.lightLineUdp.send(arrRedBuffer); | ||||
| } | ||||
| 
 | ||||
| export const defaultJudgeConfigObj = { | ||||
| 
 | ||||
| export const defaultJudgeConfigObj:DefaultJudgeConfigObj = { | ||||
|   //结束考试方式 0-不合格继续 1-考试不合格报靠边停车 2-不合格不报靠边 3-训练不合格报靠边 4-自动退出 5-不合格自动退出 | ||||
|   302: '5', | ||||
|   332: '', | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user