forked from harmony_car/subject-two
1111
This commit is contained in:
parent
6db05ab2e1
commit
e6420a333d
@ -15,7 +15,7 @@ import { VideoConfig, User } from './interfaces'
|
|||||||
import WebRTCVoice from './webRTC/'
|
import WebRTCVoice from './webRTC/'
|
||||||
import promptAction from '@ohos.promptAction'
|
import promptAction from '@ohos.promptAction'
|
||||||
import { CandidateData, EmptyCandidateObject } from "../mock/CandidateData"
|
import { CandidateData, EmptyCandidateObject } from "../mock/CandidateData"
|
||||||
|
import {string2Bytes} from '../common/utils/tools'
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct UserInfo {
|
struct UserInfo {
|
||||||
@ -81,39 +81,12 @@ struct UserInfo {
|
|||||||
|
|
||||||
onPageShow() {
|
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') {
|
new WebRTCVoice(this.context);
|
||||||
console.log('qkfnqkfn', val.body[0])
|
//初始化数据
|
||||||
this.qkFn()
|
this.initData()
|
||||||
} else if (val.id == '48') {
|
//身份证读卡器初始化
|
||||||
console.log('valvalkkkk', val.body)
|
this.openDeviceByIDCard()
|
||||||
}
|
|
||||||
})
|
|
||||||
// 应用启动时打开读卡设备
|
|
||||||
let ret = testNapi.OpenDevice();
|
|
||||||
if (ret == 0) {
|
|
||||||
testNapi.StartReadCard(this.onReadCard);
|
|
||||||
} else {
|
|
||||||
console.error("zzctest Failed to Open Device");
|
|
||||||
}
|
|
||||||
// 如果是单机模式则模拟假数据
|
// 如果是单机模式则模拟假数据
|
||||||
if (globalThis.singlePlay) {
|
if (globalThis.singlePlay) {
|
||||||
// TODO 模拟假数据
|
// TODO 模拟假数据
|
||||||
@ -130,88 +103,56 @@ struct UserInfo {
|
|||||||
}
|
}
|
||||||
this.initSysset()
|
this.initSysset()
|
||||||
initJudgeUdp()
|
initJudgeUdp()
|
||||||
}
|
|
||||||
|
|
||||||
changeQkfn() {
|
|
||||||
this.qkFn()
|
|
||||||
}
|
|
||||||
|
|
||||||
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(()=>{
|
this.interval=setInterval(()=>{
|
||||||
if (this.callBackFlag) {
|
this.heartMsg()
|
||||||
console.log('validqqq333')
|
|
||||||
const param2 = {
|
|
||||||
id: 47,
|
|
||||||
list: tmpList,
|
|
||||||
carNo: globalThis.carInfo.carNo,
|
|
||||||
placeId: globalThis.carInfo.examinationRoomId
|
|
||||||
}
|
|
||||||
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param2, this.context)
|
|
||||||
}
|
|
||||||
},1000)
|
},1000)
|
||||||
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param, this.context)
|
|
||||||
}
|
}
|
||||||
|
//身份证读卡器初始化
|
||||||
|
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
|
||||||
|
|
||||||
aboutToDisappear() {
|
// this.currentUser.kszp=this.photo+res.kszp
|
||||||
clearInterval(this.interval)
|
// this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp
|
||||||
clearInterval(this.interval2)
|
if (globalThis.singlePlay) {
|
||||||
testNapi.StopReadCard();
|
testNapi.StopReadCard();
|
||||||
|
// globalThis.statue=4
|
||||||
|
router.pushUrl({
|
||||||
|
url: 'pages/Judge',
|
||||||
|
}, router.RouterMode.Single);
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
changeStudentStatue(val) {
|
this.showFaceCompare = true
|
||||||
const arr = [globalThis.signNum || 0, val]
|
this.pageIndex = Math.floor(index / 4)
|
||||||
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,
|
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
|
||||||
list: tmpList,
|
if (!flag) {
|
||||||
carNo: globalThis.carInfo.carNo,
|
promptAction.showToast({
|
||||||
placeId: globalThis.carInfo.examinationRoomId
|
message: '未匹配到对应下载学员',
|
||||||
}
|
duration: 3000
|
||||||
|
});
|
||||||
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param, this.context)
|
|
||||||
}
|
|
||||||
|
|
||||||
facePass() {
|
|
||||||
if (!this.stepFlag) {
|
|
||||||
this.sfbdinterfaceFn()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onReadCard(ret) {
|
onReadCard(ret) {
|
||||||
console.info(`zzctest xx Read Card ret =${ret.status}`)
|
console.info(`zzctest xx Read Card ret =${ret.status}`)
|
||||||
let thisVar = globalThis.indexComponent;
|
let thisVar = globalThis.indexComponent;
|
||||||
@ -265,6 +206,63 @@ struct UserInfo {
|
|||||||
return true;
|
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() {
|
async initSysset() {
|
||||||
const that = this;
|
const that = this;
|
||||||
const db = new AccountTable(() => {
|
const db = new AccountTable(() => {
|
||||||
@ -322,41 +320,6 @@ struct UserInfo {
|
|||||||
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
|
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() {
|
getExaminationStudentInfoFn() {
|
||||||
if (globalThis.singlePlay) {
|
if (globalThis.singlePlay) {
|
||||||
return
|
return
|
||||||
@ -409,49 +372,6 @@ struct UserInfo {
|
|||||||
console.log('error12error' + error)
|
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() {
|
qkFn() {
|
||||||
this.faceCompareSucess = 0
|
this.faceCompareSucess = 0
|
||||||
if (globalThis.singlePlay) {
|
if (globalThis.singlePlay) {
|
||||||
@ -465,8 +385,8 @@ struct UserInfo {
|
|||||||
examinationStuAbsent(param).then(res => {
|
examinationStuAbsent(param).then(res => {
|
||||||
const arr = [this.signNum || 0, 1]
|
const arr = [this.signNum || 0, 1]
|
||||||
let tmpList = [];
|
let tmpList = [];
|
||||||
tmpList.push(this.string2Bytes(arr[0], 1 * 8)[0])
|
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
|
||||||
tmpList.push(this.string2Bytes(arr[1], 1 * 8)[0])
|
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
|
||||||
console.log('globalThis.signNum', globalThis.signNum)
|
console.log('globalThis.signNum', globalThis.signNum)
|
||||||
const param = {
|
const param = {
|
||||||
id: 43,
|
id: 43,
|
||||||
@ -489,10 +409,7 @@ struct UserInfo {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outClick() {
|
//身份比对
|
||||||
testNapi.StopReadCard();
|
|
||||||
}
|
|
||||||
|
|
||||||
async sfbdinterfaceFn() {
|
async sfbdinterfaceFn() {
|
||||||
this.stepFlag = true
|
this.stepFlag = true
|
||||||
console.info('surenjun', this.currentUser.lsh)
|
console.info('surenjun', this.currentUser.lsh)
|
||||||
@ -565,7 +482,14 @@ struct UserInfo {
|
|||||||
this.stepFlag = false
|
this.stepFlag = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
aboutToDisappear() {
|
||||||
|
this.outClick()
|
||||||
|
}
|
||||||
|
outClick() {
|
||||||
|
clearInterval(this.interval)
|
||||||
|
clearInterval(this.interval2)
|
||||||
|
testNapi.StopReadCard();
|
||||||
|
}
|
||||||
// 几个按钮公共样式
|
// 几个按钮公共样式
|
||||||
@Styles
|
@Styles
|
||||||
commStyle(){
|
commStyle(){
|
||||||
|
|||||||
@ -1,14 +1,9 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import hilog from '@ohos.hilog';
|
import hilog from '@ohos.hilog';
|
||||||
import apiJudgeSdk from 'libJudgeSdk.so';
|
import apiJudgeSdk from 'libJudgeSdk.so';
|
||||||
import Judge from '../../JudgeSDK/utils/judge-real'
|
import Judge from '../../judgeSDK/utils/judge-real'
|
||||||
// import Judge from '../../judgeSDK/judge-track-playback'
|
|
||||||
import {Project,ProjectObj,MarkRule} from '../../judgeSDK/api/judgeSDK.d'
|
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 common from '@ohos.app.ability.common';
|
||||||
import { getSyncData } from '../../../common/service/initable'
|
|
||||||
import {testAllitems,testUIAllitems,testMarkRules} from '../../judgeSDK/dataTest/index'
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
struct RealTime {
|
struct RealTime {
|
||||||
|
|||||||
@ -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 FileUtil from '../../../common/utils/File'
|
||||||
import zlib from '@ohos.zlib';
|
import zlib from '@ohos.zlib';
|
||||||
|
|
||||||
const MODELTAG = 'MODELTAG'
|
|
||||||
export default class FileModel{
|
export default class FileModel{
|
||||||
|
|
||||||
//后续文件路径待替换
|
//后续文件路径待替换
|
||||||
@ -26,9 +18,6 @@ export default class FileModel{
|
|||||||
public initFolder = async () => {
|
public initFolder = async () => {
|
||||||
const {fileUtil} = this
|
const {fileUtil} = this
|
||||||
await fileUtil.initFolder(`/models/model_enc`);
|
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`);
|
const folderPath = await fileUtil.initFolder(`/models`);
|
||||||
this.folderPath = folderPath;
|
this.folderPath = folderPath;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ export const getTranslateSignals = (tempItems) => {
|
|||||||
return temp.map(item => string2Bytes(item , 8)[0])
|
return temp.map(item => string2Bytes(item , 8)[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当前考车行驶状态转换
|
// c++评判考车行驶状态转换
|
||||||
export function getCarStatus(status: -1 | 0 | 1):string {
|
export function getCarStatus(status: -1 | 0 | 1):string {
|
||||||
switch (status){
|
switch (status){
|
||||||
case -1:return '后退'
|
case -1:return '后退'
|
||||||
@ -251,17 +251,21 @@ export const plcStrToWXJson = async (plc:string) =>{
|
|||||||
return wuXiDataStr
|
return wuXiDataStr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//蓝灯
|
||||||
export function sendBlue(){
|
export function sendBlue(){
|
||||||
const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00];
|
const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00];
|
||||||
const arrBlueBuffer= Array2Byte(arrBlue).buffer
|
const arrBlueBuffer= Array2Byte(arrBlue).buffer
|
||||||
globalThis.lightLineUdp.send(arrBlueBuffer);
|
globalThis.lightLineUdp.send(arrBlueBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//绿灯
|
||||||
export function sendGreen(){
|
export function sendGreen(){
|
||||||
const arrGreen = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x00, 0x03, 0x01];
|
const arrGreen = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x00, 0x03, 0x01];
|
||||||
const arrGreenBuffer= Array2Byte(arrGreen).buffer
|
const arrGreenBuffer= Array2Byte(arrGreen).buffer
|
||||||
globalThis.lightLineUdp.send(arrGreenBuffer);
|
globalThis.lightLineUdp.send(arrGreenBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//红灯
|
||||||
export function sendRed(){
|
export function sendRed(){
|
||||||
const arrRed= [0x55, 0xaa, 0x01, 0x01, 0x02, 0x00, 0x03, 0x00];
|
const arrRed= [0x55, 0xaa, 0x01, 0x01, 0x02, 0x00, 0x03, 0x00];
|
||||||
const arrRedBuffer= Array2Byte(arrRed).buffer
|
const arrRedBuffer= Array2Byte(arrRed).buffer
|
||||||
|
|||||||
@ -7,9 +7,8 @@ export const judgeConfig = {
|
|||||||
// 本地模型地址
|
// 本地模型地址
|
||||||
modelPath: 'models/model_enc',
|
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_11_30_06_2210707689316_620502199005070478_马鸣五
|
||||||
|
|
||||||
// 2024_01_24_10_25_41_2231212226990_330184200208281821_金晓婷
|
// 2024_01_24_10_25_41_2231212226990_330184200208281821_金晓婷
|
||||||
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user