Merge branch 'api10' of http://88.22.24.105:3000/harmony_car/subject-two into api10
This commit is contained in:
commit
1336100978
@ -86,6 +86,142 @@ interface JudgeFile {
|
|||||||
param?: JudgeFileParam[];
|
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: string
|
||||||
|
rmndg: number
|
||||||
|
wav: number
|
||||||
|
mndg: string
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
export interface DrvexamType extends BaseExamFields {
|
||||||
lsh?: string;
|
lsh?: string;
|
||||||
@ -99,4 +235,22 @@ export interface DrvexamType extends BaseExamFields {
|
|||||||
ksxtbh?: string;
|
ksxtbh?: string;
|
||||||
ksysfzmhm?: string;
|
ksysfzmhm?: string;
|
||||||
Ksy2sfzmhm?: string;
|
Ksy2sfzmhm?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface DefaultJudgeConfigObj{
|
||||||
|
param_302:string
|
||||||
|
param_332:string
|
||||||
|
param_342:string
|
||||||
|
param_343:string
|
||||||
|
param_344:string
|
||||||
|
param_348:string
|
||||||
|
param_353:string
|
||||||
|
param_369:string
|
||||||
|
param_375:string
|
||||||
|
param_387:string
|
||||||
|
param_432:string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,27 +1,17 @@
|
|||||||
import { testMarkRules, testRealExam } from '../dataTest/index';
|
import { testMarkRules, testRealExam } from '../dataTest/index';
|
||||||
|
import { GetCurrentTime, NumberToByteArray } from '../../../utils/Common';
|
||||||
|
|
||||||
import systemTime from '@ohos.systemDateTime';
|
import systemTime from '@ohos.systemDateTime';
|
||||||
import { Array2Byte } from './Common';
|
import { Array2Byte } from './Common';
|
||||||
import { CarInfoType } from '../../../model';
|
import { CarInfoType } from '../../../model';
|
||||||
|
import { Gps, Lane,Plc,Vision,Radar, Sensor,DefaultJudgeConfigObj} from '../../../model/Judge'
|
||||||
|
|
||||||
//获取本地扣分项
|
interface Extend {}
|
||||||
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
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 中心信号转换
|
// 中心信号转换
|
||||||
export const getTranslateSignals = (tempItems) => {
|
export const getTranslateSignals = (tempItems:number[]) => {
|
||||||
const len = Math.floor(tempItems.length / 8);
|
const len = Math.floor(tempItems.length / 8);
|
||||||
const arr = [];
|
const arr:string[] = [];
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
const temp = tempItems.slice(i * 8, (i + 1) * 8);
|
const temp = tempItems.slice(i * 8, (i + 1) * 8);
|
||||||
arr.push(temp.join(''));
|
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) {
|
switch (carzt) {
|
||||||
case -1:
|
case -1:
|
||||||
return [1, 0]
|
return [1, 0]
|
||||||
@ -59,7 +49,7 @@ export function getCarStatusType(carzt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取档位信号
|
// 获取档位信号
|
||||||
export function getDwStatusType(dw) {
|
export function getDwStatusType(dw?:number) {
|
||||||
switch (dw) {
|
switch (dw) {
|
||||||
case 0:
|
case 0:
|
||||||
return [0, 0, 0, 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) {
|
switch (status) {
|
||||||
//不考
|
//不考
|
||||||
case 0:
|
case 0:
|
||||||
@ -104,27 +94,29 @@ export function getCenterProjectStatus(status) {
|
|||||||
|
|
||||||
//获取科目三开始项目、结束项目语音
|
//获取科目三开始项目、结束项目语音
|
||||||
export function getKmProjectVoice(
|
export function getKmProjectVoice(
|
||||||
projectCode,
|
projectCode:string,
|
||||||
// 1:项目开始 2:项目结束
|
// 1:项目开始 2:项目结束
|
||||||
type: 1 | 2,
|
type: 1 | 2,
|
||||||
judgeConfig,
|
judgeConfig:object,
|
||||||
lane,
|
lane:Lane,
|
||||||
xmxh
|
xmxh:number
|
||||||
) {
|
) {
|
||||||
const carInfo = AppStorage.get<CarInfoType>('carInfo');
|
const carInfo = AppStorage.get<CarInfoType>('carInfo');
|
||||||
const { examSubject } = carInfo;
|
const examSubject = carInfo.examSubject;
|
||||||
const param506Str = judgeConfig['506']?.split(',') || [];
|
const param506Str:number[] = ( Reflect.get(judgeConfig,'506')?.split(',') ) || []
|
||||||
const param512Str = judgeConfig['512']?.split(',') || [];
|
const param512Str:number[] = ( Reflect.get(judgeConfig,'512')?.split(',') ) || []
|
||||||
const param544Str = judgeConfig['544']?.split(',') || [];
|
const param544Str:number[] = ( Reflect.get(judgeConfig,'544')?.split(',') ) || []
|
||||||
const param405Str = judgeConfig['405'] || 0;
|
const param405Str:number = Reflect.get(judgeConfig,'405') || 0;
|
||||||
|
|
||||||
console.info('surenjun => param544Str.length', param544Str.length)
|
console.info('surenjun => param544Str.length', param544Str.length)
|
||||||
|
|
||||||
const { num, count, road } = lane
|
const num = lane.num
|
||||||
if (examSubject == 2) {
|
const count = lane.count
|
||||||
|
const road = lane.road
|
||||||
|
if (examSubject == '2') {
|
||||||
return projectCode
|
return projectCode
|
||||||
}
|
}
|
||||||
switch (projectCode * 1) {
|
switch (Number(projectCode)) {
|
||||||
//直线行驶
|
//直线行驶
|
||||||
case 40300:
|
case 40300:
|
||||||
return type === 1 ? 403001 : 403002
|
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) {
|
if (examSubject == 2) {
|
||||||
return 'xmqx'
|
return 'xmqx'
|
||||||
}
|
}
|
||||||
switch (projectCode * 1) {
|
switch (Number(projectCode)) {
|
||||||
//变更车道
|
//变更车道
|
||||||
case 40500:
|
case 40500:
|
||||||
return 405004
|
return 405004
|
||||||
@ -458,17 +450,66 @@ export function promptWxCode(
|
|||||||
|
|
||||||
// 获取plc数据
|
// 获取plc数据
|
||||||
export const plcStrToJson = async (plc: string) => {
|
export const plcStrToJson = async (plc: string) => {
|
||||||
|
const plcArr = plc.split(',')
|
||||||
const p = plc.split(',').map((val, key) => {
|
const p = plcArr.map((val, key) => {
|
||||||
if (key !== 27 && key !== 92) {
|
if (key !== 27 && key !== 92) {
|
||||||
return val * 1
|
return Number(val)
|
||||||
} else {
|
|
||||||
return val
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let data: any = testRealExam;
|
|
||||||
const time = await systemTime.getCurrentTime()
|
const time = await systemTime.getCurrentTime()
|
||||||
const tempData = {
|
|
||||||
|
|
||||||
|
const sensor: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],
|
||||||
|
// 方向盘
|
||||||
|
fxp: Number(plcArr[27].split('_')[0]),
|
||||||
|
//累计脉冲 溜车脉冲 超声波左后 超声波右后 超声波右前 超声波左前 座椅 仪表盘 后视镜 倒车镜 光照 雨量
|
||||||
|
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,
|
||||||
|
//TODO 数据待替换 油压 闪灯 信号灯
|
||||||
|
yy: 0,
|
||||||
|
sde: 0,
|
||||||
|
xhd: '',
|
||||||
|
rmndg: 0,
|
||||||
|
wav: 0,
|
||||||
|
mndg: ''
|
||||||
|
}
|
||||||
|
const gps2:Gps =testRealExam.gps2
|
||||||
|
const radar:Radar =testRealExam.radar
|
||||||
|
const vision:Vision =testRealExam.vision
|
||||||
|
const extend:Extend = {};
|
||||||
|
const tempData:Plc = {
|
||||||
sensor: {
|
sensor: {
|
||||||
//安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯
|
//安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯
|
||||||
aqd: p[19],
|
aqd: p[19],
|
||||||
@ -493,7 +534,7 @@ export const plcStrToJson = async (plc: string) => {
|
|||||||
dw: p[28],
|
dw: p[28],
|
||||||
cs: p[23],
|
cs: p[23],
|
||||||
// 方向盘
|
// 方向盘
|
||||||
fxp: p[27].split('_')[0] * 1,
|
fxp: Number(plcArr[27].split('_')[0]),
|
||||||
//累计脉冲 溜车脉冲 超声波左后 超声波右后 超声波右前 超声波左前 座椅 仪表盘 后视镜 倒车镜 光照 雨量
|
//累计脉冲 溜车脉冲 超声波左后 超声波右后 超声波右前 超声波左前 座椅 仪表盘 后视镜 倒车镜 光照 雨量
|
||||||
ljmc: p[24],
|
ljmc: p[24],
|
||||||
lcmc: 0,
|
lcmc: 0,
|
||||||
@ -520,7 +561,7 @@ export const plcStrToJson = async (plc: string) => {
|
|||||||
bklx: p[56],
|
bklx: p[56],
|
||||||
dwzt: p[83],
|
dwzt: p[83],
|
||||||
// 角度差分状态
|
// 角度差分状态
|
||||||
jdzt: p[92].split('-')[0] * 1,
|
jdzt: Number(plcArr[92].split('-')[0]),
|
||||||
//gps数据
|
//gps数据
|
||||||
//gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度
|
//gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度
|
||||||
sj: time,
|
sj: time,
|
||||||
@ -537,26 +578,25 @@ export const plcStrToJson = async (plc: string) => {
|
|||||||
wdyz: p[88],
|
wdyz: p[88],
|
||||||
dwsxs: p[84] || 0,
|
dwsxs: p[84] || 0,
|
||||||
// 角度搜星数
|
// 角度搜星数
|
||||||
jdsxs: p[92].split('-')[1] * 1 || 0
|
jdsxs: Number(plcArr[92].split('-')[1]) || 0
|
||||||
},
|
},
|
||||||
gps2: data.gps,
|
gps2: gps2,
|
||||||
vision: data.vision,
|
vision,
|
||||||
radar: data.radar,
|
radar,
|
||||||
extend: {}
|
extend
|
||||||
}
|
}
|
||||||
return tempData
|
return tempData
|
||||||
}
|
}
|
||||||
|
|
||||||
export const plcStrToWXJson = async (plc: string) => {
|
export const plcStrToWXJson = async (plc: string) => {
|
||||||
|
const plcArr = plc.split(',')
|
||||||
const p = plc.split(',').map((val, key) => {
|
const p = plc.split(',').map((val, key) => {
|
||||||
if (key !== 27 && key !== 92) {
|
if (key !== 27 && key !== 92) {
|
||||||
return val * 1
|
return Number(val)
|
||||||
} else {
|
|
||||||
return val
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const timeStr = p[93] + '' + p[94];
|
const timeStr = p[93] + '' + p[94];
|
||||||
const gps = {
|
const gps:Gps = {
|
||||||
//办卡类型 定位差分状态
|
//办卡类型 定位差分状态
|
||||||
bklx: p[56],
|
bklx: p[56],
|
||||||
dwzt: p[83],
|
dwzt: p[83],
|
||||||
@ -580,35 +620,39 @@ export const plcStrToWXJson = async (plc: string) => {
|
|||||||
// 注车制动 行车制动 离合器 副制动 喇叭 雨刷 危险报警灯 示廓灯 系统未涉及的传感器信号
|
// 注车制动 行车制动 离合器 副制动 喇叭 雨刷 危险报警灯 示廓灯 系统未涉及的传感器信号
|
||||||
p[13], p[12], p[17], p[18], p[4], p[11], p[20], p[9], 0
|
p[13], p[12], p[17], p[18], p[4], p[11], p[20], p[9], 0
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const judgeSignalNum = Number(judgeSignal.join(''))
|
||||||
const judgeAnotherSignal = [
|
const judgeAnotherSignal = [
|
||||||
// 低三挡位 左侧单边桥1 左侧单边桥2 右侧单边桥1 右侧单边桥2 雾灯
|
// 低三挡位 左侧单边桥1 左侧单边桥2 右侧单边桥1 右侧单边桥2 雾灯
|
||||||
'000', '0', '0', '0', '0', p[10],
|
'000', '0', '0', '0', '0', p[10],
|
||||||
// 桩杆全无信号 左后绕车 右后绕车 右前绕车 左前绕车
|
// 桩杆全无信号 左后绕车 右后绕车 右前绕车 左前绕车
|
||||||
'000', '0', '0', '0', '0'
|
'000', '0', '0', '0', '0'
|
||||||
]
|
]
|
||||||
|
const judgeAnotherSignalNum = Number(judgeAnotherSignal.join(''))
|
||||||
|
|
||||||
const wuXiData = [
|
const wuXiData = [
|
||||||
// 卫星时间 精度 纬度 高度 方位角 俯仰角 速度角 速度 横滚 卫星定位状态
|
// 卫星时间 精度 纬度 高度 方位角 俯仰角 速度角 速度 横滚 卫星定位状态
|
||||||
'$KSXT', timeStr, gps.jd, gps.wd, gps.hbg, gps.hxj, gps.fyj, '', gps.sd, '', gps.dwzt, gps.dwzt,
|
'$KSXT', timeStr, gps.jd, gps.wd, gps.hbg, gps.hxj, gps.fyj, '', gps.sd, '', gps.dwzt, gps.dwzt,
|
||||||
//前天线可用星数 后天线可用星数 东向坐标位置 北向位置坐标 天向位置坐标 东向速度 北向速度 天向速度
|
//前天线可用星数 后天线可用星数 东向坐标位置 北向位置坐标 天向位置坐标 东向速度 北向速度 天向速度
|
||||||
'', '', '', '', '', '', '', '',
|
'', '', '', '', '', '', '', '',
|
||||||
// 评判信号1 评判信号2 发动机转速
|
// 评判信号1 评判信号2 发动机转速
|
||||||
(judgeSignal.join('') * 1).toString(16), (judgeAnotherSignal.join('') * 1).toString(16), p[25],
|
judgeSignalNum.toString(16),judgeAnotherSignalNum.toString(16), p[25],
|
||||||
'0xFFFFFFF'
|
'0xFFFFFFF'
|
||||||
]
|
]
|
||||||
const wuXiDataStr = wuXiData.join(',')
|
const wuXiDataStr = wuXiData.join(',')
|
||||||
return wuXiDataStr
|
return wuXiDataStr
|
||||||
}
|
}
|
||||||
|
|
||||||
export const senorToWXDataStr = async (tempData) => {
|
export const senorToWXDataStr = async (tempData:Plc) => {
|
||||||
const { sensor, gps } = tempData;
|
const sensor = tempData.sensor
|
||||||
|
const gps = tempData.gps
|
||||||
const timeStr = await getTimeStr()
|
const timeStr = await getTimeStr()
|
||||||
|
|
||||||
const { mkg, aqd, dh1, dh2, zfxd, yfxd, jgd, ygd, ssc, jsc, lhq, fsc, lb, ygq, wd } = sensor
|
const judgeSignal:number[] = [
|
||||||
const judgeSignal = [
|
|
||||||
//车门 安全带 熄火 发动机启动 左转向 右转向 前照灯近灯 前照灯远灯
|
//车门 安全带 熄火 发动机启动 左转向 右转向 前照灯近灯 前照灯远灯
|
||||||
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 = [
|
const judgeAnotherSignal = [
|
||||||
@ -618,8 +662,8 @@ export const senorToWXDataStr = async (tempData) => {
|
|||||||
'000', '0', '0', '0', '0', '0', '0'
|
'000', '0', '0', '0', '0', '0', '0'
|
||||||
]
|
]
|
||||||
|
|
||||||
const str1 = (judgeSignal.join('') * 1).toString(16);
|
const str1 = (Number(judgeSignal.join(''))).toString(16);
|
||||||
const str2 = (judgeAnotherSignal.join('') * 1).toString(16);
|
const str2 = (Number(judgeAnotherSignal.join(''))).toString(16);
|
||||||
|
|
||||||
const wuXiData = [
|
const wuXiData = [
|
||||||
// 卫星时间 精度 纬度 高度 方位角 俯仰角 速度角 速度 横滚 卫星定位状态
|
// 卫星时间 精度 纬度 高度 方位角 俯仰角 速度角 速度 横滚 卫星定位状态
|
||||||
@ -652,43 +696,44 @@ export const getTimeStr = async () => {
|
|||||||
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
|
||||||
globalThis.lightLineUdp.send(arrRedBuffer);
|
// globalThis.lightLineUdp.send(arrRedBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultJudgeConfigObj = {
|
|
||||||
|
export const defaultJudgeConfigObj:DefaultJudgeConfigObj = {
|
||||||
//结束考试方式 0-不合格继续 1-考试不合格报靠边停车 2-不合格不报靠边 3-训练不合格报靠边 4-自动退出 5-不合格自动退出
|
//结束考试方式 0-不合格继续 1-考试不合格报靠边停车 2-不合格不报靠边 3-训练不合格报靠边 4-自动退出 5-不合格自动退出
|
||||||
302: '5',
|
param_302: '5',
|
||||||
332: '',
|
param_332: '',
|
||||||
//是否能进行人工操作 0-不能人工评判 1-不能人工进项目 3-都不能
|
//是否能进行人工操作 0-不能人工评判 1-不能人工进项目 3-都不能
|
||||||
342: '',
|
param_342: '',
|
||||||
//有项目未结束时可以靠边停车 0-否 1-是
|
//有项目未结束时可以靠边停车 0-否 1-是
|
||||||
343: '1',
|
param_343: '1',
|
||||||
//考试未结束且有扣分,是否可以退出
|
//考试未结束且有扣分,是否可以退出
|
||||||
344: '0',
|
param_344: '0',
|
||||||
//直线行驶中是否可以进其它项目 0-否 1-是
|
//直线行驶中是否可以进其它项目 0-否 1-是
|
||||||
348: '0',
|
param_348: '0',
|
||||||
//车上是否能点结束考试 0:否 1:是
|
//车上是否能点结束考试 0:否 1:是
|
||||||
353: '0',
|
param_353: '0',
|
||||||
//是否启动断电续考 0:否 1:是
|
//是否启动断电续考 0:否 1:是
|
||||||
369: '1',
|
param_369: '1',
|
||||||
//是否显示应考里程
|
//是否显示应考里程
|
||||||
375: '0',
|
param_375: '0',
|
||||||
//里程不够允许手工点靠边停车
|
//里程不够允许手工点靠边停车
|
||||||
387: '0',
|
param_387: '0',
|
||||||
//监管模式有扣分续考(0-否++1-是+把上次未考完的扣分带下来重新考试)
|
//监管模式有扣分续考(0-否++1-是+把上次未考完的扣分带下来重新考试)
|
||||||
432: '1'
|
param_432: '1'
|
||||||
}
|
}
|
||||||
58
entry/src/main/ets/pages/judgeSDK/utils/judgeTask.ets
Normal file
58
entry/src/main/ets/pages/judgeSDK/utils/judgeTask.ets
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import Prompt from '@system.prompt'
|
||||||
|
|
||||||
|
const TAG = 'SURENJUN_JUDGE'
|
||||||
|
|
||||||
|
interface DelayConfig{
|
||||||
|
isDelay: boolean
|
||||||
|
delayTime: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface QUEUE {
|
||||||
|
fn: Function,
|
||||||
|
delayConfig?: DelayConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
type GoTask = (currentTask:QUEUE)=>Promise<boolean>
|
||||||
|
|
||||||
|
export default class JudgeTask {
|
||||||
|
private queue?:QUEUE[] = []
|
||||||
|
private status: string
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.queue = []
|
||||||
|
this.status = 'end'
|
||||||
|
}
|
||||||
|
|
||||||
|
//执行任务
|
||||||
|
goTask:GoTask = async (currentTask:QUEUE) => {
|
||||||
|
const fn = currentTask.fn;
|
||||||
|
const delayConfig = currentTask.delayConfig || {isDelay:false,delayTime:1000}
|
||||||
|
const isDelay = delayConfig.isDelay
|
||||||
|
const delayTime = delayConfig.delayTime
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
executeQueue = async () => {
|
||||||
|
const queue = this.queue;
|
||||||
|
const executeQueue = this.executeQueue
|
||||||
|
if (queue.length) {
|
||||||
|
for (const currentTask of queue) {
|
||||||
|
await this.goTask(currentTask)
|
||||||
|
this.queue.shift()
|
||||||
|
await executeQueue()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.status = 'end'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addTask = async (fn:Function, delayConfig?: DelayConfig) => {
|
||||||
|
this.queue.push({
|
||||||
|
fn, delayConfig
|
||||||
|
});
|
||||||
|
if (this.status == 'end' && this.queue.length === 1) {
|
||||||
|
await this.executeQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,67 +0,0 @@
|
|||||||
import Prompt from '@system.prompt'
|
|
||||||
|
|
||||||
const TAG = 'SURENJUN_JUDGE'
|
|
||||||
|
|
||||||
interface QUEUE {
|
|
||||||
fn: Function,
|
|
||||||
config?: {
|
|
||||||
isDelay: boolean
|
|
||||||
delayTime: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class JudgeTask {
|
|
||||||
private queue = []
|
|
||||||
private status: string
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.queue = []
|
|
||||||
this.status = 'end'
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
goTask = async (currentTask) => {
|
|
||||||
const {fn,delayConfig={}} = currentTask;
|
|
||||||
const { isDelay = false,delayTime = 1000} = delayConfig
|
|
||||||
return new Promise(async (res, rej) => {
|
|
||||||
setTimeout(async () => {
|
|
||||||
try {
|
|
||||||
await fn()
|
|
||||||
res(true)
|
|
||||||
} catch (e) {
|
|
||||||
console.info(TAG, '过程任务执行失败=>' + JSON.stringify(e))
|
|
||||||
Prompt.showToast({
|
|
||||||
message: '过程任务执行失败=>' + JSON.stringify(e),
|
|
||||||
duration: 3000
|
|
||||||
});
|
|
||||||
res(false)
|
|
||||||
}
|
|
||||||
}, isDelay ? delayTime : 0);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
executeQueue = async () => {
|
|
||||||
const {queue,executeQueue} = this
|
|
||||||
if (queue.length) {
|
|
||||||
for (const currentTask of queue) {
|
|
||||||
await this.goTask(currentTask)
|
|
||||||
this.queue.shift()
|
|
||||||
await executeQueue()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.status = 'end'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addTask = async (fn, delayConfig?: {
|
|
||||||
isDelay: Boolean,
|
|
||||||
delayTime?: Number
|
|
||||||
}) => {
|
|
||||||
this.queue.push({
|
|
||||||
fn, delayConfig
|
|
||||||
});
|
|
||||||
if (this.status == 'end' && this.queue.length === 1) {
|
|
||||||
await this.executeQueue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,17 +7,18 @@ import common from '@ohos.app.ability.common';
|
|||||||
|
|
||||||
const TAG = 'VoiceAnnounce'
|
const TAG = 'VoiceAnnounce'
|
||||||
|
|
||||||
|
interface Queue{
|
||||||
|
url: string,
|
||||||
|
callback?: Function
|
||||||
|
}
|
||||||
|
|
||||||
|
type PlayAudio = (urls: string[], shit?: boolean, callback?: Function) => Queue | void
|
||||||
|
|
||||||
export default class VoiceAnnounce {
|
export default class VoiceAnnounce {
|
||||||
//队列时候立马终止
|
//队列时候立马终止
|
||||||
private isStopped: Boolean
|
private isStopped: Boolean
|
||||||
private queue: {
|
private queue: Queue[]
|
||||||
url: string,
|
private newQueue: Queue[]
|
||||||
callback?: Function
|
|
||||||
}[]
|
|
||||||
private newQueue: {
|
|
||||||
url: string,
|
|
||||||
callback?: Function
|
|
||||||
}[]
|
|
||||||
private pendingQueue: String[]
|
private pendingQueue: String[]
|
||||||
private callback: Function;
|
private callback: Function;
|
||||||
|
|
||||||
@ -26,15 +27,18 @@ export default class VoiceAnnounce {
|
|||||||
this.queue = []
|
this.queue = []
|
||||||
}
|
}
|
||||||
|
|
||||||
async playAudio(urls: string[], shit?: boolean, callback?: Function) {
|
async playAudio(urls: string[], shit?: boolean, callbackFn?: Function) {
|
||||||
const { isStopped, queue } = this;
|
const isStopped = this.isStopped;
|
||||||
const tempUrls = urls.map((url, index) => {
|
const queue = this.queue;
|
||||||
return {
|
|
||||||
url,
|
const tempUrls: Queue[] = urls.map((url, index) => {
|
||||||
callback: (index === urls.length - 1) ? callback : undefined
|
const callback:Function|undefined = (index === urls.length - 1) ? callbackFn : undefined
|
||||||
}
|
const temp:Queue = {url, callback}
|
||||||
|
return temp
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (shit) {
|
if (shit) {
|
||||||
//队列清空,重新初始化
|
//队列清空,重新初始化
|
||||||
this.isStopped = true;
|
this.isStopped = true;
|
||||||
@ -53,7 +57,9 @@ export default class VoiceAnnounce {
|
|||||||
|
|
||||||
async executeQueue() {
|
async executeQueue() {
|
||||||
const go = async () => {
|
const go = async () => {
|
||||||
const { queue, isStopped, newQueue } = this;
|
const queue = this.queue;
|
||||||
|
const isStopped = this.isStopped;
|
||||||
|
const newQueue = this.newQueue;
|
||||||
const avPlayer = new AVPlayer();
|
const avPlayer = new AVPlayer();
|
||||||
if (isStopped) {
|
if (isStopped) {
|
||||||
//清空原来队列
|
//清空原来队列
|
||||||
@ -77,8 +83,7 @@ export default class VoiceAnnounce {
|
|||||||
|
|
||||||
|
|
||||||
class AVPlayer {
|
class AVPlayer {
|
||||||
public avPlayer: any = null;
|
public avPlayer?: media.AVPlayer;
|
||||||
|
|
||||||
private voiceUrl: string[];
|
private voiceUrl: string[];
|
||||||
private voiceStatus: 'completed' | 'playing'
|
private voiceStatus: 'completed' | 'playing'
|
||||||
private endCallback: Function
|
private endCallback: Function
|
||||||
@ -87,7 +92,7 @@ class AVPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例
|
// 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例
|
||||||
async play(name, callback) {
|
async play(name:string, callback:Function):Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
//检查SD中的语音
|
//检查SD中的语音
|
||||||
// console.info('surenjun name',name)
|
// console.info('surenjun name',name)
|
||||||
@ -123,7 +128,7 @@ class AVPlayer {
|
|||||||
this.avPlayer = await media.createAVPlayer();
|
this.avPlayer = await media.createAVPlayer();
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
await this.setAVPlayerCallback(() => {
|
await this.setAVPlayerCallback(() => {
|
||||||
resolve()
|
resolve(true)
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const context: common.UIAbilityContext = AppStorage.get('context')
|
const context: common.UIAbilityContext = AppStorage.get('context')
|
||||||
@ -133,34 +138,28 @@ class AVPlayer {
|
|||||||
message: `${name}语音文件不存在`,
|
message: `${name}语音文件不存在`,
|
||||||
duration: 4000
|
duration: 4000
|
||||||
});
|
});
|
||||||
resolve(1)
|
resolve(true)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryFile(displayName): Promise<mediaLibrary.FileAsset> {
|
async queryFile(displayName:string): Promise<mediaLibrary.FileAsset> {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const context = AppStorage.get('context')
|
const context = AppStorage.get<common.UIAbilityContext>('context')
|
||||||
const mediaLib = mediaLibrary.getMediaLibrary(context);
|
const mediaLib = mediaLibrary.getMediaLibrary(context);
|
||||||
let ret
|
let fileResult = await mediaLib.getFileAssets({
|
||||||
let fetchOp = {
|
|
||||||
selections: `media_type=? AND display_name = ?`,
|
selections: `media_type=? AND display_name = ?`,
|
||||||
selectionArgs: [`${mediaLibrary.MediaType.AUDIO}`, displayName],
|
selectionArgs: [`${mediaLibrary.MediaType.AUDIO}`, displayName],
|
||||||
};
|
});
|
||||||
let fileResult = await mediaLib.getFileAssets(fetchOp);
|
|
||||||
let retCount = fileResult.getCount();
|
let retCount = fileResult.getCount();
|
||||||
if (retCount > 0) {
|
if (retCount > 0) {
|
||||||
ret = await fileResult.getFirstObject();
|
let ret = await fileResult.getFirstObject();
|
||||||
return resolve(ret);
|
return resolve(ret);
|
||||||
} else {
|
} else {
|
||||||
return reject(false);
|
return reject(false);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//音频播放队列
|
//音频播放队列
|
||||||
@ -175,7 +174,7 @@ class AVPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 注册avplayer回调函数
|
// 注册avplayer回调函数
|
||||||
setAVPlayerCallback(callBack) {
|
setAVPlayerCallback(callBack:Function) {
|
||||||
this.avPlayer.on('error', (err) => {
|
this.avPlayer.on('error', (err) => {
|
||||||
this.avPlayer && this.avPlayer.stop()
|
this.avPlayer && this.avPlayer.stop()
|
||||||
this.avPlayer && this.avPlayer.reset()
|
this.avPlayer && this.avPlayer.reset()
|
||||||
@ -185,7 +184,7 @@ class AVPlayer {
|
|||||||
let num = 0;
|
let num = 0;
|
||||||
// 状态机变化回调函数
|
// 状态机变化回调函数
|
||||||
this.avPlayer.on('stateChange', async (state, reason) => {
|
this.avPlayer.on('stateChange', async (state, reason) => {
|
||||||
const { endCallback } = this;
|
const endCallback = this.endCallback;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 'idle': // 成功调用reset接口后触发该状态机上报
|
case 'idle': // 成功调用reset接口后触发该状态机上报
|
||||||
break;
|
break;
|
||||||
Loading…
x
Reference in New Issue
Block a user