This commit is contained in:
“wangzhongjie” 2024-02-23 10:43:11 +08:00
parent 6db05ab2e1
commit e6420a333d
7 changed files with 124 additions and 486 deletions

View File

@ -15,7 +15,7 @@ import { VideoConfig, User } from './interfaces'
import WebRTCVoice from './webRTC/'
import promptAction from '@ohos.promptAction'
import { CandidateData, EmptyCandidateObject } from "../mock/CandidateData"
import {string2Bytes} from '../common/utils/tools'
@Entry
@Component
struct UserInfo {
@ -81,39 +81,12 @@ struct UserInfo {
onPageShow() {
//语音功能
this.stepFlag = false
new WebRTCVoice(this.context);
this.faceCompareSucess = 0
this.showFaceCompare = false
globalThis.indexComponent = this;
this.lsh = '0000000000000'
this.callBackFlag = false
globalThis.lsh = this.lsh
this.currentUser = EmptyCandidateObject
globalThis.statue = 2
this.numCount = 0
globalThis.udpClient2 && globalThis.udpClient2.onMessage((val) => {
if (val.id == '32') {
globalThis.signNum = val.body[1]
if (val.body[0] == '7') {
this.getqkFn()
this.signNum = val.body[1]
}
} else if (val.id == '42') {
console.log('qkfnqkfn', val.body[0])
this.qkFn()
} else if (val.id == '48') {
console.log('valvalkkkk', val.body)
}
})
// 应用启动时打开读卡设备
let ret = testNapi.OpenDevice();
if (ret == 0) {
testNapi.StartReadCard(this.onReadCard);
} else {
console.error("zzctest Failed to Open Device");
}
new WebRTCVoice(this.context);
//初始化数据
this.initData()
//身份证读卡器初始化
this.openDeviceByIDCard()
// 如果是单机模式则模拟假数据
if (globalThis.singlePlay) {
// TODO 模拟假数据
@ -130,88 +103,56 @@ struct UserInfo {
}
this.initSysset()
initJudgeUdp()
this.interval=setInterval(()=>{
this.heartMsg()
},1000)
}
changeQkfn() {
this.qkFn()
//身份证读卡器初始化
openDeviceByIDCard(){
globalThis.indexComponent = this;
// 应用启动时打开读卡设备
let ret = testNapi.OpenDevice();
if (ret == 0) {
testNapi.StartReadCard(this.onReadCard);
} else {
console.error("zzctest Failed to Open Device");
}
}
// 通过身份证获取当前学员
getCurrentStudent(id) {
let flag = false
this.pageIndex
this.list.map((res, index) => {
if (res.sfzmhm == id) {
flag = true
this.currentUser = res
this.lsh = this.currentUser.lsh
globalThis.lsh = this.currentUser.lsh
globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm
getqkFn() {
let tmpList = [];
tmpList.push(this.string2Bytes(globalThis.signNum, 1 * 8)[0])
const param = {
id: 41,
list: tmpList,
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId
}
globalThis.udpClient2.sendMsg(param, this.context)
}
async heartMsg(context) {
let tmpList = []
const str = globalThis.lsh
for (let i = 0; i < str.length; i++) {
tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0])
}
const param = {
id: 46,
list: tmpList,
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId,
callback: () => {
console.log('46send')
this.callBackFlag = true
}
}
this.interval = setInterval(() => {
if (this.callBackFlag) {
console.log('validqqq333')
const param2 = {
id: 47,
list: tmpList,
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId
// this.currentUser.kszp=this.photo+res.kszp
// this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp
if (globalThis.singlePlay) {
testNapi.StopReadCard();
// globalThis.statue=4
router.pushUrl({
url: 'pages/Judge',
}, router.RouterMode.Single);
return
}
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param2, this.context)
this.showFaceCompare = true
this.pageIndex = Math.floor(index / 4)
}
}, 1000)
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param, this.context)
}
aboutToDisappear() {
clearInterval(this.interval)
clearInterval(this.interval2)
testNapi.StopReadCard();
}
changeStudentStatue(val) {
const arr = [globalThis.signNum || 0, val]
let tmpList = [];
tmpList.push(this.string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(this.string2Bytes(arr[1], 1 * 8)[0])
const str = globalThis.lsh
for (let i = 0; i < str.length; i++) {
tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0])
}
const param = {
id: 31,
list: tmpList,
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId
}
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param, this.context)
}
facePass() {
if (!this.stepFlag) {
this.sfbdinterfaceFn()
})
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
if (!flag) {
promptAction.showToast({
message: '未匹配到对应下载学员',
duration: 3000
});
}
}
onReadCard(ret) {
console.info(`zzctest xx Read Card ret =${ret.status}`)
let thisVar = globalThis.indexComponent;
@ -265,6 +206,63 @@ struct UserInfo {
return true;
}
changeQkfn() {
this.qkFn()
}
initData(){
this.stepFlag = false
this.faceCompareSucess = 0
this.showFaceCompare = false
this.lsh = '0000000000000'
this.callBackFlag = false
globalThis.lsh = this.lsh
this.currentUser = EmptyCandidateObject
globalThis.statue = 2
this.numCount = 0
}
async heartMsg() {
const arr = [globalThis.signNum||0, globalThis.statue||1]
let tmpList = [];
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
const str =globalThis.lsh|| '0000000000000'
for (let i = 0;i < str.length; i++) {
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
}
const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId,callback:(val)=>{
if(val.id=='32'){
globalThis.signNum=val.body[1]
if(val.body[0]=='7'){
this.getqkFn()
this.signNum=val.body[1]
}
}else if(val.id=='42'){
console.log('qkfnqkfn',val.body[0])
this.qkFn()
}
}}
globalThis.udpClient2.sendMsg(param, this.context)
}
getqkFn() {
let tmpList = [];
tmpList.push(string2Bytes(globalThis.signNum, 1 * 8)[0])
const param = {
id: 41,
list: tmpList,
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId
}
globalThis.udpClient2.sendMsg(param, this.context)
}
facePass() {
if (!this.stepFlag) {
this.sfbdinterfaceFn()
}
}
async initSysset() {
const that = this;
const db = new AccountTable(() => {
@ -322,41 +320,6 @@ struct UserInfo {
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
}
getCurrentStudent(id) {
let flag = false
this.pageIndex
this.list.map((res, index) => {
if (res.sfzmhm == id) {
flag = true
this.currentUser = res
this.lsh = this.currentUser.lsh
globalThis.lsh = this.currentUser.lsh
globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm
// this.currentUser.kszp=this.photo+res.kszp
// this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp
if (globalThis.singlePlay) {
testNapi.StopReadCard();
// globalThis.statue=4
router.pushUrl({
url: 'pages/Judge',
}, router.RouterMode.Single);
return
}
this.showFaceCompare = true
this.pageIndex = Math.floor(index / 4)
}
})
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
if (!flag) {
promptAction.showToast({
message: '未匹配到对应下载学员',
duration: 3000
});
}
}
getExaminationStudentInfoFn() {
if (globalThis.singlePlay) {
return
@ -409,49 +372,6 @@ struct UserInfo {
console.log('error12error' + error)
})
}
fillZero(str, len) {
str = String(str);
if (!len || str.length >= len) {
return str;
}
const num = len - str.length;
const zeroStr = '0'.repeat(num);
return zeroStr + str;
}
string2Bytes(number, len) {
const str = (+number).toString(2);
if (str.length > len) {
console.log('数据长度不对~~');
return
}
const byteString = this.fillZero(str, len);
const arrBytes = Array.from({ length: byteString.length / 8 }, (_, i) => {
const start = Math.max(byteString.length - (i + 1) * 8, 0);
const end = byteString.length - i * 8;
return parseInt(byteString.slice(start, end), 2);
});
return arrBytes;
}
getPhotosForOtherFn(data, type) {
const date = new Date()
const param = {
time: dateFormat(date),
ksrq: dateFormat(date).split(' ')[0],
sfzmhm: data.sfzmhm,
zptype: type
}
getPhotosForOther(param).then(res => {
if (type == '1') {
this.currentUser.kszp = 'data:image/jpg;base64,' + res.getBmzpRsp.body.kszp
} else {
this.currentUser.ksmjzp = 'data:image/jpg;base64,' + res.getBmzpRsp.body.ksmjzp
}
})
}
qkFn() {
this.faceCompareSucess = 0
if (globalThis.singlePlay) {
@ -465,8 +385,8 @@ struct UserInfo {
examinationStuAbsent(param).then(res => {
const arr = [this.signNum || 0, 1]
let tmpList = [];
tmpList.push(this.string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(this.string2Bytes(arr[1], 1 * 8)[0])
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
console.log('globalThis.signNum', globalThis.signNum)
const param = {
id: 43,
@ -489,10 +409,7 @@ struct UserInfo {
}
outClick() {
testNapi.StopReadCard();
}
//身份比对
async sfbdinterfaceFn() {
this.stepFlag = true
console.info('surenjun', this.currentUser.lsh)
@ -565,7 +482,14 @@ struct UserInfo {
this.stepFlag = false
}
}
aboutToDisappear() {
this.outClick()
}
outClick() {
clearInterval(this.interval)
clearInterval(this.interval2)
testNapi.StopReadCard();
}
// 几个按钮公共样式
@Styles
commStyle(){

View File

@ -1,14 +1,9 @@
// @ts-nocheck
import hilog from '@ohos.hilog';
import apiJudgeSdk from 'libJudgeSdk.so';
import Judge from '../../JudgeSDK/utils/judge-real'
// import Judge from '../../judgeSDK/judge-track-playback'
import Judge from '../../judgeSDK/utils/judge-real'
import {Project,ProjectObj,MarkRule} from '../../judgeSDK/api/judgeSDK.d'
import AccountTable from '../../../common/database/tables/AccountTable';
import MA_SYSSET from '../../../common//constants/MA_SYSSET';
import common from '@ohos.app.ability.common';
import { getSyncData } from '../../../common/service/initable'
import {testAllitems,testUIAllitems,testMarkRules} from '../../judgeSDK/dataTest/index'
@Component
struct RealTime {

View File

@ -1,13 +1,5 @@
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'
import promptAction from '@ohos.promptAction'
import fileAccess from '@ohos.file.fileAccess'
import common from '@ohos.app.ability.common'
import Want from '@ohos.app.ability.Want'
import fs from '@ohos.file.fs'
import FileUtil from '../../../common/utils/File'
import zlib from '@ohos.zlib';
const MODELTAG = 'MODELTAG'
export default class FileModel{
//后续文件路径待替换
@ -26,9 +18,6 @@ export default class FileModel{
public initFolder = async () => {
const {fileUtil} = this
await fileUtil.initFolder(`/models/model_enc`);
//TODO 删除待优化
const isDeletedModelEnc= await this.fileUtil.deleteF('models/model_enc',1)
const isDeletedModels = await this.fileUtil.deleteF('models',1)
const folderPath = await fileUtil.initFolder(`/models`);
this.folderPath = folderPath;
}

View File

@ -30,7 +30,7 @@ export const getTranslateSignals = (tempItems) => {
return temp.map(item => string2Bytes(item , 8)[0])
}
// 当前考车行驶状态转换
// c++评判考车行驶状态转换
export function getCarStatus(status: -1 | 0 | 1):string {
switch (status){
case -1:return '后退'
@ -251,17 +251,21 @@ export const plcStrToWXJson = async (plc:string) =>{
return wuXiDataStr
}
//蓝灯
export function sendBlue(){
const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00];
const arrBlueBuffer= Array2Byte(arrBlue).buffer
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);
}
//红灯
export function sendRed(){
const arrRed= [0x55, 0xaa, 0x01, 0x01, 0x02, 0x00, 0x03, 0x00];
const arrRedBuffer= Array2Byte(arrRed).buffer

View File

@ -7,9 +7,8 @@ export const judgeConfig = {
// 本地模型地址
modelPath: 'models/model_enc',
// 轨迹回放目录地址
trajectoryPath: '/logs/2024_01_24/2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五/judge_exam_data.txt'
trajectoryPath: 'logs/2024_01_24/2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五/judge_exam_data.txt'
}
// 2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五
// 2024_01_24_10_25_41_2231212226990_330184200208281821_金晓婷

View File

@ -1,143 +0,0 @@
import FileModel from '../utils/file-model'
import {testAllitems,testRealExam} from '../dataTest/index'
import { getSyncData } from '../../../common/service/initable'
import systemTime from '@ohos.systemDateTime'
import {testMarkRules} from '../dataTest/index'
import AccountTable from '../../../common/database/tables/AccountTable'
import USER from '../../../common/constants/USER'
export default class JudgeData{
private fileModel:FileModel
private modelPath:string
private markRuleListObj:object
constructor(judgeUI) {
this.fileModel = new FileModel(judgeUI.context);
this.modelPath = 'models/model_enc'
this.markRuleListObj = {}
}
//获取项目、扣分表数据
getInitData = async ()=>{
}
// 获取项目信息
initProjectInfo = async () => {
//TODO 待优化
const systemParamsArr = await getSyncData('MA_SYSTEMPARM')
const itemInfoArr = await getSyncData('MA_ITEMINFO')
//@ts-ignore
const filterProjectsArr = systemParamsArr.filter(item => item.no1 == 6)
}
// 获取扣分代码信息
initMarkRules = async () => {
const markRuleParams = await getSyncData('MA_MARKRULE')
//@ts-ignore
markRuleParams.forEach(mark=>{
this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = {
itemno:mark.itemno*1,
markcatalog:mark.markcatalog,
markshow:decodeURI(mark.markshow),
markreal:mark.markreal*1,
markserial:mark.markserial
};
})
}
//获取评判初始化数据
getJudgeInitData = async () => {
const carInfo = globalThis.carInfo;
const { examSubject,plateNo,carNo } = carInfo;
const {getModelData,initProjectInfo,initMarkRules} = this;
await initProjectInfo()
await initMarkRules()
const { markRuleListObj }= this;
const initInfo = {
kskm:examSubject*1,
kchp:plateNo,
kchm:carNo*1,
//考试车型
kscx:'C1',
cxcode:'1',
name:'桑塔纳',
carmodel:getModelData(`C1.txt`),
// TODO 待替换
allitems:testAllitems.map((project) => {
//@ts-ignore
const modelKey = project.projectCode + '_' + project.type;
return {
//@ts-ignore
xmdm:project.projectCode*1,
xmxh:project.type+'',
model:getModelData(`${modelKey}.txt`)
}
}),
mark:Reflect.ownKeys(markRuleListObj).map(ruleKey=>(markRuleListObj[ruleKey])),
sysset:[{
key:606,
value:"1",
name:"倒车入库、桩考、侧方不可以取消项目"
}],
};
return initInfo
}
// 获取plc数据
getPlcData = async (plc:string) =>{
const p = plc.split(',').map((val,key)=>{
if(key !== 27 && key !== 92){
//@ts-ignore
return val*1
}else{
return val
}
});
let data:any = testRealExam;
const time = await systemTime.getCurrentTime()
const tempData = {
sensor:{
//安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯
aqd:p[19], mkg:p[14], ssc:p[13], jsc:p[12], fsc:p[18], lhq:p[17], lb:p[4], skd:p[9], jgd:p[7], ygd:p[8],
//左方向灯 右方向灯 双跳灯 雾灯 雨刮器 点火1 点火2 发动机转速 档位 车速
zfxd:p[2], yfxd:p[3], shtd:p[20],wd:p[10], ygq:p[11], dh1:p[5], dh2:p[6], fdjzs:p[25], dw:p[28], cs:p[23],
//@ts-ignore 方向盘
fxp:p[27].split('_')[0]*1,
//累计脉冲 溜车脉冲 超声波左后 超声波右后 超声波右前 超声波左前 座椅 仪表盘 后视镜 倒车镜 光照 雨量
ljmc:p[24], lcmc:0, csbzh:p[32], csbyh:p[30], csbyq:p[31], csbzq:p[29], zy:0, tbp:0, hsj:0, dcj:0, gx:0, yl:0
},
gps:{
//办卡类型 定位差分状态
bklx:p[56], dwzt:p[83],
//@ts-ignore 角度差分状态
jdzt:p[92].split('-')[0]*1,
//gps数据
//gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度
sj:time, jd:p[96], wd:p[95], hxj:p[90], fyj:p[91], hbg:p[85], gdc:p[86], sd:p[97],
//龄期 经度因子 纬度因子 定位搜星数
age:p[87], jdyz:p[89], wdyz:p[88], dwsxs:p[84],
//@ts-ignore 角度搜星数
jdsxs:p[92].split('-')[1]*1
},
gps2:data.gps,
vision:data.vision,
radar:data.radar,
extend:{}
}
return tempData
}
// 获取模型数据
getModelData = (modelName) => {
const modelPath = this.modelPath
const fileModel = this.fileModel;
const modelData = fileModel.getModelContent(modelPath,modelName);
return modelData
}
}

View File

@ -1,130 +0,0 @@
import emitter from '@ohos.events.emitter'
export enum JudgeEvent{
//评判回调日志
JUDGE,
//实时过程数据
PERFORM,
//日志
LOG
}
const {IMMEDIATE,IDLE,HIGH} = emitter.EventPriority
import {
examJudgeSetLogCallback,
examJudgeBeginExam,
examJudgeInit,
examJudgeRealExam,
examJudgeSetRealExamCallback,
examJudgeSetPerformCallback,
examJudgeEndExam
} from '../api/index'
import JudgeData from './judge-data'
const judgeTag = 'SURENJUN_JUDGE'
export class GlobalJudge{
private judgeData:JudgeData
private initData:any
private fileLog:any
constructor(context) {
const {log} = this;
const judgeData = new JudgeData(context);
this.judgeData = judgeData;
}
// 评判初始化
public init = async () => {
const {log,judgeData} = this;
log('1.进入评判入口')
this.setLogCallback();
const initData = await judgeData.getJudgeInitData()
this.initData = initData;
log('2.获取评判初始化数据完成')
await examJudgeInit(initData);
log('3.评判初始化完成')
globalThis.isJudgeInitBool = true;
await this.setRealExamCallback()
await this.setJudgeSetPerformCallback()
}
// 开始考试
public startExam = async (beginData,fileLog) => {
const {log,initData} = this;
await fileLog.setExamJudgeData(initData)
await examJudgeBeginExam(beginData);
await fileLog.setExamJudgeData(beginData)
log('4.开始考试注册完成')
this.fileLog = fileLog;
}
// 传递实时数据
public executeGPSData = async (msg) => {
const {fileLog} = this;
const judgeData = this.judgeData;
const isString = typeof msg === 'string'
let plcData = {}
if(isString){
plcData = await judgeData.getPlcData(msg);
}else{
plcData = msg
}
await fileLog.setExamJudgeData(plcData)
await examJudgeRealExam(plcData)
}
// 结束考试
endExam = async () => {
await examJudgeEndExam()
}
// 评判过程回调
setRealExamCallback = async () => {
const JUDGE = JudgeEvent.JUDGE
const {log} = this;
let judgeEvent = {
eventId: JUDGE,
priority: IMMEDIATE
};
await examJudgeSetRealExamCallback(async (strData,len)=>{
log('评判回调数据' + strData)
emitter.emit(judgeEvent, strData);
})
}
// 实时数据回调
setJudgeSetPerformCallback = async () => {
const PERFORM = JudgeEvent.PERFORM
let performEvent = {
eventId: PERFORM,
priority: IDLE
};
await examJudgeSetPerformCallback(async (info)=>{
console.info('评判实时数据',info)
emitter.emit(performEvent , info);
})
}
// 通用日志回调
setLogCallback = async () => {
const LOG = JudgeEvent.LOG
let logEvent = {
eventId: LOG,
priority: IDLE
};
await examJudgeSetLogCallback(3, async (level, info,len)=>{
console.log('评判日志:' + info)
emitter.emit(logEvent, info);
})
}
log = (msg) => {
console.info(judgeTag,msg)
}
}