Compare commits
	
		
			7 Commits
		
	
	
		
			902130f07a
			...
			3d5bba8022
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 3d5bba8022 | ||
|  | 2481438651 | ||
|  | e355f3d283 | ||
|  | 94e060187e | ||
|  | 982fd6273d | ||
|  | fcf41bb2f0 | ||
|  | ef94029967 | 
							
								
								
									
										120
									
								
								entry/src/main/ets/common/service/usbService.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								entry/src/main/ets/common/service/usbService.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,120 @@ | ||||
| // 导入USB接口api包。
 | ||||
| import usb from '@ohos.usbManager'; | ||||
| const LOGTAG = 'USBSERVICES' | ||||
| 
 | ||||
| 
 | ||||
| //字符串转字节
 | ||||
| function stringToArr(str){ | ||||
|   var arr = []; | ||||
|   for (var i = 0, j = str.length; i < j; ++i) { | ||||
|     arr.push(str.charCodeAt(i)); | ||||
|   } | ||||
|   return arr | ||||
| } | ||||
| 
 | ||||
| //plc数据转成无锡科研所usb字节数据
 | ||||
| function plcStrToWXCodeArr(wuXiDataStr){ | ||||
|   const arr = stringToArr(wuXiDataStr); | ||||
|   //数据包总长度 有效长度
 | ||||
|   let packetSize = 65,maxDataSize = 63; | ||||
|   let packetArr = [] | ||||
|   const loop =  Math.ceil(arr.length / maxDataSize) | ||||
|   for(let i = 0; i< loop; i++){ | ||||
|     const thisPacket = arr.slice(i * maxDataSize,(i + 1) * maxDataSize) | ||||
|     const oSize = maxDataSize - thisPacket.length; | ||||
|     //补齐0x00
 | ||||
|     if(oSize > 0){ | ||||
|       let oSizeArr = [] | ||||
|       for(let j  = 0;j < oSize;j++){oSizeArr.push(0x00)} | ||||
|       packetArr.push([thisPacket.length].concat(thisPacket).concat(oSizeArr)); | ||||
|     }else{ | ||||
|       packetArr.push([thisPacket.length].concat(thisPacket)); | ||||
|     } | ||||
|   } | ||||
|   return packetArr | ||||
| } | ||||
| 
 | ||||
| export default class UsbService{ | ||||
|   private  devicepipe : usb.USBDevicePipe | ||||
|   private  outEndpoint: usb.USBEndpoint | ||||
|   public  isWXUSBDevice:Boolean | ||||
| 
 | ||||
|   constructor() { | ||||
|     //是否是无锡检测设备
 | ||||
|     this.isWXUSBDevice = false | ||||
|     this.devicepipe | ||||
|     this.init() | ||||
|   } | ||||
| 
 | ||||
|   init = async()=>{ | ||||
|     // 获取设备列表。
 | ||||
|     let deviceList : Array<usb.USBDevice> = usb.getDevices(); | ||||
| 
 | ||||
|     deviceList.forEach(async (device:usb.USBDevice) => { | ||||
|       const {vendorId,productId} = device; | ||||
|       console.log(LOGTAG,JSON.stringify(device)); | ||||
|       //无锡所检测设备接入
 | ||||
|       if(vendorId === 6790 && productId === 58409){ | ||||
|         // if(vendorId === 2385 && productId === 5734){
 | ||||
|         // 申请操作指定的device的操作权限。
 | ||||
|         try { | ||||
|           let bool = usb.hasRight(device.name); | ||||
|           console.info(LOGTAG,'bool =>' + bool) | ||||
|           const isExit = await usb.requestRight(device.name); | ||||
|           console.info(LOGTAG,'isExit =>' + isExit) | ||||
|           if(isExit){ | ||||
|             let devicepipe : usb.USBDevicePipe = usb.connectDevice(device); | ||||
|             let interfaces = device.configs[0].interfaces[0]; | ||||
|             let ret = usb.claimInterface(devicepipe, interfaces,true); | ||||
|             console.info(LOGTAG,'ret =>' + ret); | ||||
| 
 | ||||
|             if(ret === 0 ){ | ||||
|               let outEndpoint : usb.USBEndpoint = interfaces.endpoints[1]; | ||||
|               let inEndpoint : usb.USBEndpoint = interfaces.endpoints[0]; | ||||
|               this.isWXUSBDevice = true; | ||||
|               this.devicepipe = devicepipe | ||||
|               this.outEndpoint = outEndpoint | ||||
| 
 | ||||
|             }else{ | ||||
|               console.info(LOGTAG,'usb claimInterface failed') | ||||
|             } | ||||
| 
 | ||||
|           }else{ | ||||
|             console.info(LOGTAG,'isExit =>' +'false') | ||||
|           } | ||||
| 
 | ||||
|         } catch (e) { | ||||
|           console.info(LOGTAG,'e=>' + JSON.stringify(e)) | ||||
|         } | ||||
| 
 | ||||
|       } | ||||
|     }); | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   sendUSB =async (wuXiDataStr) => { | ||||
|     console.info(LOGTAG,'正在发送数据') | ||||
|     const {devicepipe,isWXUSBDevice,outEndpoint} = this; | ||||
|     console.info(LOGTAG,'正在发送数据') | ||||
|     if(isWXUSBDevice){ | ||||
|       console.info(LOGTAG,wuXiDataStr) | ||||
|       const codeArr = plcStrToWXCodeArr(wuXiDataStr); | ||||
|       for(let i = 0; i < codeArr.length;i++){ | ||||
|         try { | ||||
|           console.info(LOGTAG,'正在发送数据') | ||||
|           const f = await usb.bulkTransfer(devicepipe, outEndpoint, new Uint8Array(codeArr[i])) | ||||
|           console.info(LOGTAG,'发送成功数据长度为:' + f) | ||||
|         } catch (e) { | ||||
|           console.info(LOGTAG,JSON.stringify(e)) | ||||
|         } | ||||
|       } | ||||
|     }else{ | ||||
|       console.info(LOGTAG,'usb设备初始化失败') | ||||
|     } | ||||
| 
 | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| // export default initUsbServicesFn
 | ||||
| @ -9,7 +9,7 @@ import Judge from './judgeSDK/judge' | ||||
| import {defaultJudgeConfigObj} from './judgeSDK/utils//judge-common' | ||||
| import { | ||||
|   Project, ProjectObj, MarkRule, CDSBInfo, | ||||
|   SYSTEMPARMARR,CARINFO ,MAPPOINT ,MAPITEMPOINTITEM | ||||
|   SYSTEMPARMARR,CARINFO ,MAPPOINT ,MAPITEMPOINTITEM,SYSSET | ||||
| } from './judgeSDK/api/judgeSDK.d' | ||||
| import { getCurrentTime, formatTime, getCurrentHourTime,chunkArr } from '../common/utils/tools' | ||||
| import { examJudgeEndExam } from './judgeSDK/api/index' | ||||
| @ -29,9 +29,7 @@ struct Index { | ||||
|   async aboutToAppear() { | ||||
|     globalThis.windowClass.setWindowSystemBarEnable(['']) | ||||
|     const time = await getCurrentTime() | ||||
|     const examSubject = globalThis.carInfo.examSubject | ||||
| 
 | ||||
|     this.examSubject = examSubject | ||||
|     this.startTime = time.split(' ')[1] | ||||
|     this.startFullTime = await getCurrentTime(1); | ||||
|     this.startHourTime = await getCurrentHourTime() | ||||
| @ -67,9 +65,8 @@ struct Index { | ||||
|         ? await this.initSystemKm2Param() | ||||
|         : await this.initSystemKm3Param() | ||||
|       await this.initMarkRules(); | ||||
|       await this.initSysset(); | ||||
|     } | ||||
| 
 | ||||
|     await this.initSysset(); | ||||
|     await this.initCDSBInfo() | ||||
| 
 | ||||
|     // 科目三新增读取表数据 | ||||
| @ -122,7 +119,6 @@ struct Index { | ||||
|         markreal:mark.markreal * 1, | ||||
|         markserial:mark.markserial, | ||||
|         kfxh:mark.kfxh, | ||||
|         //TODO 科目三评判新参数 | ||||
|         OnlyOneKind:mark.onlyoneid * 1, | ||||
|         NoCancelId:mark.nocancelid * 1, | ||||
|         GPS_SID:mark.gps_sid == 0 ? false : true | ||||
| @ -141,34 +137,44 @@ struct Index { | ||||
|   } | ||||
| 
 | ||||
|   // 获取sysset表信息 | ||||
|   async initSysset() { | ||||
|     const syssetParams = await getSyncData('MA_SYSSET') | ||||
|   async initSysset(sysset?:SYSSET[]) { | ||||
|     const syssetParams = sysset ||  await getSyncData('MA_SYSSET') | ||||
|     //@ts-ignore | ||||
|     const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901'); | ||||
|     this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || '123456' | ||||
| 
 | ||||
|     const judgeConfig = [] | ||||
|     const {isTrajectoryOpen} = judgeConfig | ||||
|     const syssetJudgeConfigArr = [] | ||||
| 
 | ||||
|     //@ts-ignore | ||||
|     syssetParams.forEach((sys) => { | ||||
|       if(isTrajectoryOpen){ | ||||
|         sys.v_no = sys.key; | ||||
|         sys.v_name = sys.name; | ||||
|         sys.v_value = sys.value | ||||
|       } | ||||
| 
 | ||||
|       const {v_no,v_value} = sys; | ||||
|       const v_no_num = v_no * 1; | ||||
|       const value = decodeURIComponent(v_value) | ||||
|       if(v_no_num >= 10 &&v_no_num <= 900){ | ||||
|         judgeConfig.push({ | ||||
|         syssetJudgeConfigArr.push({ | ||||
|           key: v_no_num,value: value, | ||||
|           name: decodeURI(sys.v_name) | ||||
|         }) | ||||
|       } | ||||
|       //科目三应行驶距离参数 | ||||
|       if(sys.v_no == '303'){ | ||||
|         this.examMileage = sys.v_value + ''; | ||||
|       } | ||||
| 
 | ||||
|       this.judgeConfigObj[sys.v_no] = value | ||||
|     }); | ||||
|     this.judgeConfig = judgeConfig; | ||||
|     this.judgeConfig = syssetJudgeConfigArr; | ||||
|   } | ||||
| 
 | ||||
|   // 初始化systemParam表 | ||||
|   async initSystemKm2Param(){ | ||||
|     const systemParms:any = await getSyncData('MA_SYSTEMPARM') | ||||
|   async initSystemKm2Param(sysParam?:SYSTEMPARMARR[]){ | ||||
|     const systemParms:any = sysParam || await getSyncData('MA_SYSTEMPARM') | ||||
|     const carName = this.carName; | ||||
| 
 | ||||
|     let carNo2 = '',allItems = []; | ||||
| @ -232,7 +238,6 @@ struct Index { | ||||
|       } | ||||
| 
 | ||||
|       const {no1,no2,no3,} = systemParm; | ||||
| 
 | ||||
|       this.systemparmArr.push({ | ||||
|         'NO1':no1*1,'NO2':no2*1,'NO3':no3*1, | ||||
|         'TXT1':decodeURIComponent(systemParm.txt1), | ||||
| @ -241,7 +246,6 @@ struct Index { | ||||
|       }) | ||||
| 
 | ||||
|       const txt2 = decodeURIComponent(systemParm.txt2) | ||||
| 
 | ||||
|       if (no1 == 6) { | ||||
|         const currentProject = { | ||||
|           name: decodeURI(systemParm.txt1), | ||||
| @ -253,11 +257,10 @@ struct Index { | ||||
|         this.projectsCenterObj[txt2] = currentProject | ||||
|         this.projects.push(currentProject) | ||||
|       } | ||||
|       if(no1 == 3 && no2 == 1 && no3 == 15){ | ||||
|         this.examMileage = decodeURI(systemParm.txt1) | ||||
|       } | ||||
|       // if(no1 == 3 && no2 == 1 && no3 == 15){ | ||||
|       //   this.examMileage = decodeURI(systemParm.txt1) | ||||
|       // } | ||||
|     }) | ||||
| 
 | ||||
|     const projects = this.projects; | ||||
|     if (!projects.length) { | ||||
|       prompt.showToast({ | ||||
| @ -384,11 +387,9 @@ struct Index { | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   // 初始化本地systemparam表、markrule表 | ||||
|   async initTrajectoryParam(trajectoryPath:string){ | ||||
|     const examSubject = globalThis.carInfo.examSubject; | ||||
| 
 | ||||
|     const {isTrajectoryOpen} = judgeConfig | ||||
|     //轨迹回放读取 systemparam表、markrule表 | ||||
|     const fileUtil  = new FileUtil(this.context); | ||||
|     const folderPath = await fileUtil.initFolder(trajectoryPath); | ||||
| @ -396,12 +397,16 @@ struct Index { | ||||
|     const strArr = str.split('\n'); | ||||
|     const [initData,beginData] = [strArr[0],strArr[1]]; | ||||
|     const initDataObj = JSON.parse(initData) | ||||
| 
 | ||||
|     const systemparm = initDataObj.systemparm; | ||||
|     const examSubject = globalThis.carInfo.examSubject; | ||||
|     this.examSubject = isTrajectoryOpen ? (initDataObj.kskm*1):examSubject; | ||||
|     globalThis.carInfo.examSubject = this.examSubject | ||||
|     examSubject == 2 | ||||
|       ? await this.initSystemKm2Param() | ||||
|       : await this.initSystemKm3Param(initDataObj.systemparm) | ||||
|       ? await this.initSystemKm2Param(systemparm) | ||||
|       : await this.initSystemKm3Param(systemparm) | ||||
|     //@ts-ignore | ||||
|     await this.initMarkRules(testMarkRules); | ||||
|     await this.initSysset(initDataObj.sysset); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| @ -778,7 +783,7 @@ struct Index { | ||||
| 
 | ||||
|     const unExitManualProjects = judgeConfigObj['332'].split(',') || []; | ||||
|     const param348 = judgeConfigObj['348'] || '0'; | ||||
|     const param387 = judgeConfigObj['348'] || '0'; | ||||
|     const param387 = judgeConfigObj['387'] || '0'; | ||||
| 
 | ||||
|     if(judgeConfigObj['342'] === '3' || judgeConfigObj['342'] === '2'){ | ||||
|       return false | ||||
| @ -818,7 +823,7 @@ struct Index { | ||||
|   @State startFullTime: string = '' | ||||
|   @State startHourTime: string = '' | ||||
|   //科目类型 | ||||
|   @State examSubject: 2 | 3 = 2; | ||||
|   @State examSubject: 2 | 3 = 3; | ||||
|   @State ddxkTime: number = 0; | ||||
|   @State ddxkKsxmArr: string[] = [''] | ||||
|   @State ddxkKfArr: string[] = [''] | ||||
|  | ||||
| @ -140,6 +140,11 @@ export interface SOUND { | ||||
|   //语音播放提示代码
 | ||||
|   code:string | ||||
| } | ||||
| export  interface SYSSET { | ||||
|   v_no:string, | ||||
|   v_name:string, | ||||
|   v_value:string | ||||
| } | ||||
| 
 | ||||
| export interface ProjectObj { | ||||
|   [k:any]:Project | ||||
|  | ||||
| @ -18,10 +18,12 @@ import { judgeConfig } from './utils/judge-config' | ||||
| 
 | ||||
| import {writeObjectOut,uploadExamProgressData} from '../../api/judge' | ||||
| import {deepClone,getCurrentTime,stringToASC,string2Bytes,fillZero,Array2Byte,convertGpsCoord2} from '../../common/utils/tools' | ||||
| import {getTranslateSignals,getCarStatus,getCarStatusType,getCenterProjectStatus,plcStrToJson,plcStrToWXJson,promptWxCode,getKmProjectVoice}  from './utils//judge-common' | ||||
| import {getTranslateSignals,getCarStatus,getCarStatusType,getCenterProjectStatus,plcStrToJson,plcStrToWXJson,promptWxCode,getKmProjectVoice,senorToWXDataStr}  from './utils//judge-common' | ||||
| import {examJudgeSetLogCallback,examJudgeBeginExam,examJudgeInit,examJudgeRealExam,examJudgeSetRealExamCallback,examJudgeSetPerformCallback,examJudgeEndExam,examJudgeArtificialMark,examJudgeArtificialItem} from './api/index' | ||||
| import Want from '@ohos.app.ability.Want'; | ||||
| import UsbService from '../../common/service/usbService' | ||||
| 
 | ||||
| import prompt from '@ohos.prompt'; | ||||
| import usbManager from '@ohos.usbManager'; | ||||
| 
 | ||||
| const judgeTag = 'SURENJUN_JUDGE' | ||||
| 
 | ||||
| @ -40,6 +42,8 @@ export default class Judge{ | ||||
|     this.fileUtil = new FileUtil(judgeUI.context) | ||||
|     this.judgeTask = new JudgeTask() | ||||
|     const mediaTest= new FilePhoto(judgeUI.context); | ||||
|     const usbService = new UsbService(); | ||||
|     this.usbService = usbService | ||||
|     this.filePhoto = mediaTest | ||||
|     this.kfArr = judgeUI.kfArr | ||||
|     this.xmmcStr = '';this.xmmcCode = '';this.carztStr = ''; | ||||
| @ -129,6 +133,7 @@ export default class Judge{ | ||||
|     await examJudgeBeginExam(beginExamInfo); | ||||
|     console.info(judgeTag,'6.开始考试注册完成') | ||||
| 
 | ||||
|     avPlayer.playAudio(['voice/ksks.WAV']) | ||||
|     // 处理轨迹plc信息
 | ||||
|     if(isTrajectoryOpen){ | ||||
|       handleTrajectoryUdp(strArr); | ||||
| @ -139,7 +144,7 @@ export default class Judge{ | ||||
|     globalThis.udpClient.onMessage(async (msg) => { | ||||
|       handleUdp(msg) | ||||
|     }) | ||||
|     avPlayer.playAudio(['voice/ksks.WAV']) | ||||
| 
 | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
| @ -921,6 +926,7 @@ export default class Judge{ | ||||
|   handleTrajectoryUdp = async (strArr) => { | ||||
|     const {fileLog} = this; | ||||
|     let num = 2; | ||||
|     const {usbService} = this; | ||||
|     const judgeTimer = setInterval(async ()=>{ | ||||
|       const msg = JSON.parse(strArr[num]); | ||||
|       await fileLog.setExamJudgeData(msg) | ||||
| @ -935,6 +941,12 @@ export default class Judge{ | ||||
|       this.tempData = msg | ||||
|       this.plcData= msg | ||||
|       globalThis.msgStr= '' | ||||
|       const str = await senorToWXDataStr(msg); | ||||
|       //检测到有无锡所设备接入,需要发送特定的数据,供检测
 | ||||
|       if(usbService.isWXUSBDevice){ | ||||
|         usbService.sendUSB(str) | ||||
|       } | ||||
|       console.info(judgeTag,str) | ||||
|       await examJudgeRealExam(msg) | ||||
|       num++ | ||||
|     },200) | ||||
| @ -1000,6 +1012,7 @@ export default class Judge{ | ||||
|   private xmxh:string | ||||
|   private fileModel:FileModel | ||||
|   private filePhoto:FilePhoto | ||||
|   private usbService:any | ||||
|   //是否是考试模式
 | ||||
|   private isExam:boolean | ||||
|   //考试是否结束了
 | ||||
|  | ||||
| @ -301,6 +301,56 @@ export const plcStrToWXJson = async (plc:string) =>{ | ||||
|   return wuXiDataStr | ||||
| } | ||||
| 
 | ||||
| export const senorToWXDataStr= async (tempData) => { | ||||
|   const {sensor,gps} = tempData; | ||||
|   const timeStr = await getTimeStr() | ||||
| 
 | ||||
|   const {mkg,aqd,dh1,dh2, zfxd,  yfxd,  jgd,   ygd,ssc ,  jsc,    lhq,  fsc,   lb,   ygq,wd} = sensor | ||||
|   const judgeSignal = [ | ||||
|   //车门 安全带  熄火    发动机启动 左转向 右转向  前照灯近灯 前照灯远灯
 | ||||
|     mkg,   aqd,  dh1,   dh2,   zfxd,  yfxd,  jgd,   ygd, | ||||
|     // 注车制动 行车制动 离合器 副制动   喇叭   雨刷    危险报警灯 示廓灯 系统未涉及的传感器信号
 | ||||
|     ssc ,  jsc,    lhq,  fsc,   lb,   ygq,  0,  0, 0 | ||||
|   ] | ||||
| 
 | ||||
|   const judgeAnotherSignal = [ | ||||
|   // 低三挡位 左侧单边桥1 左侧单边桥2 右侧单边桥1 右侧单边桥2 雾灯
 | ||||
|     '000',    '0',       '0',      '0',      '0',     '0',,'0', | ||||
|     // 桩杆全无信号  左后绕车 右后绕车 右前绕车 左前绕车
 | ||||
|     '000',         '0',   '0',    '0',   '0',   '0','0' | ||||
|   ] | ||||
|   //@ts-ignore
 | ||||
|   const str1 = (judgeSignal.join('')*1).toString(16); | ||||
|   //@ts-ignore
 | ||||
|   const str2 = (judgeAnotherSignal.join('')*1).toString(16); | ||||
| 
 | ||||
|   const wuXiData = [ | ||||
|   //         卫星时间     精度    纬度     高度      方位角    俯仰角    速度角  速度      横滚  卫星定位状态
 | ||||
|     '$KSXT', timeStr,   gps.jd, gps.wd, gps.hbg, gps.hxj, gps.fyj, '0'    , gps.sd, '0',  gps.dwzt, | ||||
|     //前天线可用星数 后天线可用星数 东向坐标位置 北向位置坐标 天向位置坐标  东向速度 北向速度 天向速度
 | ||||
|     '0',            '0',         '0',        '0',       '0',        '0',      '0',    '0','0', | ||||
|     //@ts-ignore 评判信号1 评判信号2 发动机转速
 | ||||
|     // (judgeSignal.join('')*1).toString(16), (judgeAnotherSignal.join('')*1).toString(16) , sensor.fdjzs,
 | ||||
|     '0006', '0001' , sensor.fdjzs, | ||||
|     '0xFFFFFFF' | ||||
|   ] | ||||
|   return wuXiData.map(d => (d + '')).join(','); | ||||
|   // console.log('wuXiData',wuXiData.join(','));
 | ||||
| } | ||||
| 
 | ||||
| export const getTimeStr = async () =>{ | ||||
|   const date = await systemTime.getDate() | ||||
|   const timeStr = ''; | ||||
|   const Y = date.getFullYear(); | ||||
|   const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) ; | ||||
|   const D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()); | ||||
|   const h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()); | ||||
|   const m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()); | ||||
|   const s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds()); | ||||
|   const ss = (date.getMilliseconds() +'').slice(0,2); | ||||
|   return timeStr + Y + M +D +h +m +s +'.' + ss | ||||
| } | ||||
| 
 | ||||
| //蓝灯
 | ||||
| export function sendBlue(){ | ||||
|   const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]; | ||||
|  | ||||
| @ -3,12 +3,13 @@ | ||||
| //考试回放开关
 | ||||
| export const judgeConfig = { | ||||
|   //本地目录开关
 | ||||
|   isTrajectoryOpen: false, | ||||
|   isTrajectoryOpen: true, | ||||
|   //是否开启Udp
 | ||||
|   udpOpen:false, | ||||
|   // 本地模型地址
 | ||||
|   modelPath: 'models/model_enc', | ||||
|   trajectoryPath: 'logs/2024_05_14/0000000000001_342323199501470011_测试学员1_2024_05_14_11_28_31/judge_exam_data.txt' | ||||
|   // 轨迹回放地址
 | ||||
|   trajectoryPath: 'logs/0000000000001_342323199501470011_测试学员1_1970_01_01_08_44_33/judge_exam_data.txt' | ||||
| } | ||||
| 
 | ||||
| //0000000000001_342323199501470011_测试学员1_2024_04_28_10_59_44
 | ||||
| @ -17,7 +18,6 @@ export const judgeConfig = { | ||||
| 
 | ||||
| // 济南轨迹回放
 | ||||
| // test_sub3_car_test_jinan-32038219990808021X-20240322173643.txt
 | ||||
| 
 | ||||
| // test_sub3_car_test_jinan-32038219990808021X-20240322173643.track
 | ||||
| // 2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五
 | ||||
| // 2024_01_24_10_25_41_2231212226990_330184200208281821_金晓婷
 | ||||
| @ -1,4 +1,5 @@ | ||||
| import media from '@ohos.multimedia.media'; | ||||
| import prompt from '@ohos.prompt'; | ||||
| 
 | ||||
| const TAG = 'VoiceAnnounce' | ||||
| 
 | ||||
| @ -18,7 +19,6 @@ export default class VoiceAnnounce{ | ||||
|   async playAudio(urls:string[],shit,callback:Function){ | ||||
|     const {isStopped,queue} = this; | ||||
|     this.callback = callback | ||||
|     console.info('surenjun',JSON.stringify(callback)) | ||||
|     if(shit){ | ||||
|       //队列清空,重新初始化
 | ||||
|       this.isStopped = true; | ||||
| @ -45,6 +45,7 @@ export default class VoiceAnnounce{ | ||||
|         await go() | ||||
|         return | ||||
|       } | ||||
| 
 | ||||
|       await avPlayer.play(queue[0],callback); | ||||
|       this.queue.shift(); | ||||
|       console.info(TAG,JSON.stringify(this.queue),'堆栈弹出'); | ||||
| @ -73,14 +74,22 @@ class AVPlayer { | ||||
|     this.endCallback = callback | ||||
|     const avPlayer = await media.createAVPlayer(); | ||||
|     this.avPlayer = avPlayer; | ||||
|     return new Promise(async (resolve)=>{ | ||||
|     return new Promise(async (resolve,reject) => { | ||||
|       let url = '' | ||||
|       await this.setAVPlayerCallback(()=>{ | ||||
|         //@ts-ignore
 | ||||
|         resolve() | ||||
|       }); | ||||
|       let url =  await globalThis.context.resourceManager.getRawFd(name) | ||||
|       this.avPlayer.fdSrc = url; | ||||
| 
 | ||||
|       try { | ||||
|          url =  await globalThis.context.resourceManager.getRawFd(name); | ||||
|          this.avPlayer.fdSrc = url; | ||||
|       } catch  (e) { | ||||
|         prompt.showToast({ | ||||
|           message: `${name}语音文件不存在`, | ||||
|           duration: 4000 | ||||
|         }); | ||||
|         resolve(1) | ||||
|       } | ||||
|     }) | ||||
|   } | ||||
|   //音频播放队列
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user