评判udp优化
This commit is contained in:
parent
89a192408a
commit
d3eee4a3a5
@ -115,6 +115,7 @@ export interface CarInfoType {
|
||||
isNeedCheck?: string;
|
||||
udpAddress?: string
|
||||
messagePort?: string
|
||||
hintPort?: string
|
||||
}
|
||||
|
||||
export interface ExaminerInfoType {
|
||||
|
||||
@ -8,6 +8,7 @@ import {
|
||||
ObtainCarExamInfoParams,
|
||||
ObtainCarExamInfoRspBody,
|
||||
TimeSynchronizationParams,
|
||||
TimeSynchronizationRspBody,
|
||||
VideoConfig
|
||||
} from '../../model';
|
||||
import dayTs from '../../utils/Date';
|
||||
|
||||
@ -6,6 +6,7 @@ import { GlobalConfig } from '../config';
|
||||
import Prompt from '@system.prompt';
|
||||
import FileUtils from '../utils/FileUtils';
|
||||
import { EnvironmentConfigurationType } from '../model/Common';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
|
||||
|
||||
@Entry
|
||||
@ -14,24 +15,14 @@ struct Index {
|
||||
@State textList1: string[] =
|
||||
['差分服务器Ip', '响应端口', '中心服务器IP', '响应端口', '子网掩码', '默认网关', 'dns', '后置机IP ', '响应端口',
|
||||
'前置机IP', '本地端口']
|
||||
// @State textList2: string[] = []
|
||||
@State ratio: number = 1700 / 960
|
||||
@State inputFontSize: number = 12 //12
|
||||
// @State inputTextList1: string[] = ['172.37.55.191','18782','192.168.7.1','8082','255.255.255.0','192.168.7.170','114.114.114.114','192.168.7.124','20022','172.37.55.59','20122']
|
||||
@State inputFontSize: number = 12
|
||||
@State inputTextList1: string[] =
|
||||
['172.37.55.191', '18782', '172.37.55.191', '8082', '255.255.255.0', '192.168.7.1', '114.114.114.114',
|
||||
'192.168.7.124', '20022', '192.168.7.170', '20122']
|
||||
//
|
||||
// @State inputTextList1: string[] = ['192.168.7.170','8084','192.168.7.170','20122','255.255.255.0','192.168.7.1','','','114.114.114.114','112.80.35.83','11055' +
|
||||
// '',]
|
||||
// @State inputTextList2: string[] = ['192.168.7.124','20022']
|
||||
// @State inputTextList1: string[] = ['192.168.36.2','8084','192.168.36.200','20122','255.255.255.0','192.168.36.1','','','114.114.114.114','192.168.36.139','8000']
|
||||
@State @Watch('outClick') outFlag: boolean = false;
|
||||
// @State inputTextList2: string[] = []
|
||||
// 112.80.35.83 11052
|
||||
scroller: Scroller = new Scroller()
|
||||
private fileUtil: FileUtils
|
||||
// @State inputTextList2: string[] = ['192.168.36.139','20022']
|
||||
private context = getContext(this) as common.UIAbilityContext;
|
||||
|
||||
build() {
|
||||
@ -103,15 +94,15 @@ struct Index {
|
||||
}
|
||||
this.fileUtil.addFile(`${folderPath}/ipConfig.txt`, JSON.stringify(param))
|
||||
AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", param)
|
||||
// upDateTableByArray('IpConfigTable',[])
|
||||
ethernet.setIfaceConfig("eth0", {
|
||||
mode: 0,
|
||||
mode: ethernet.IPSetMode.STATIC,
|
||||
ipAddr: this.inputTextList1[9],
|
||||
route: "0.0.0.0",
|
||||
gateway: this.inputTextList1[5], //value.gateway网关
|
||||
netMask: this.inputTextList1[4], //value.netMask网络掩码
|
||||
dnsServers: this.inputTextList1[6],
|
||||
}, (error) => {
|
||||
domain: ""
|
||||
}, (error: BusinessError) => {
|
||||
if (error) {
|
||||
Prompt.showToast({
|
||||
message: '设置失败' + JSON.stringify(error),
|
||||
@ -171,21 +162,16 @@ struct Index {
|
||||
this.inputTextList1[3] = result.centerPort
|
||||
}
|
||||
|
||||
|
||||
ethernet.getIfaceConfig("eth0", (error, value) => {
|
||||
if (error) {
|
||||
// that.errorMsg='error'
|
||||
console.log("boot_up getIp_new callback error = " + JSON.stringify(error));
|
||||
} else {
|
||||
ethernet.getIfaceConfig("eth0").then(value => {
|
||||
console.log("boot_up getIp_new callback ipAddr = " + JSON.stringify(value.ipAddr)); //
|
||||
console.log(" boot_up getIp_new callback mode = " + JSON.stringify(value.mode));
|
||||
console.log("boot_up getIp_new callback route = " + JSON.stringify(value.route));
|
||||
console.log("boot_up getIp_new callback gateway = " + JSON.stringify(value.gateway));
|
||||
console.log("boot_up getIp_new callback netMask = " + JSON.stringify(value.netMask));
|
||||
console.log("boot_up getIp_new callback dnsServers = " + JSON.stringify(value.dnsServers));
|
||||
}
|
||||
}).catch((error: BusinessError) => {
|
||||
console.log("boot_up getIp_new callback error = " + JSON.stringify(error));
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
onPageShow() {
|
||||
|
||||
@ -6,7 +6,7 @@ export const testInit = {
|
||||
"kscx": "C1",
|
||||
"cxcode": "1",
|
||||
"name": "桑塔纳",
|
||||
"allitems": [ {
|
||||
"allitems": [{
|
||||
"xmdm": 6,
|
||||
"xmxh": "01"
|
||||
}]
|
||||
@ -14,7 +14,7 @@ export const testInit = {
|
||||
|
||||
|
||||
//开始考试模拟数据
|
||||
export const testBeginExam ={
|
||||
export const testBeginExam = {
|
||||
"ic": "xxx",
|
||||
"kgid": "1002",
|
||||
"kgxm": "考官姓名",
|
||||
@ -47,7 +47,7 @@ export const testBeginExam ={
|
||||
"kfdm": "02"
|
||||
}],
|
||||
"yklc": 500,
|
||||
"special": [1, 2,3]
|
||||
"special": [1, 2, 3]
|
||||
}
|
||||
|
||||
//gps模拟数据
|
||||
@ -451,10 +451,10 @@ export const testRealExam = {
|
||||
"fxp": -5,
|
||||
"ljmc": 23,
|
||||
"lcmc": 0,
|
||||
"csbzh":0,
|
||||
"csbyh":0,
|
||||
"csbyq":0,
|
||||
"csbzq":0,
|
||||
"csbzh": 0,
|
||||
"csbyh": 0,
|
||||
"csbyq": 0,
|
||||
"csbzq": 0,
|
||||
"csb1": 3000,
|
||||
"csb2": 0,
|
||||
"csb3": 0,
|
||||
@ -467,9 +467,9 @@ export const testRealExam = {
|
||||
"yl": 0
|
||||
},
|
||||
"gps": {
|
||||
"bklx":2,
|
||||
"dwzt":4,
|
||||
"jdzt":3,
|
||||
"bklx": 2,
|
||||
"dwzt": 4,
|
||||
"jdzt": 3,
|
||||
"sj": 1680840026000,
|
||||
"jd": 113.12345678,
|
||||
"wd": 31.12345678,
|
||||
@ -485,9 +485,9 @@ export const testRealExam = {
|
||||
"jdsxs": 14
|
||||
},
|
||||
"gps2": {
|
||||
"bklx":1,
|
||||
"dwzt":4,
|
||||
"jdzt":4,
|
||||
"bklx": 1,
|
||||
"dwzt": 4,
|
||||
"jdzt": 4,
|
||||
"sj": 1680840026000,
|
||||
"jd": 113.12345678,
|
||||
"wd": 31.12345678,
|
||||
@ -515,116 +515,377 @@ export const testRealExam = {
|
||||
"radar": {
|
||||
"sj": 1680840026000,
|
||||
"zxh": 999,
|
||||
"qfsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh": 2,"lx": 2 ,"jl": 4.82,"sd": 5.24}],
|
||||
"hfsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh": 2,"lx": 2 , "jl": 4.82,"sd": 5.24}],
|
||||
"zqsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh": 2,"lx": 2 , "jl": 4.82,"sd": 5.24}],
|
||||
"zhsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh": 2,"lx": 2 , "jl": 4.82,"sd": 5.24}],
|
||||
"zcsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh":2,"lx": 2 , "jl": 4.82,"sd": 5.24}],
|
||||
"yqsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh":2,"lx": 2 , "jl": 4.82,"sd": 5.24}],
|
||||
"yhsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh":2,"lx": 2 , "jl": 4.82,"sd": 5.24}],
|
||||
"ycsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh":2,"lx": 2 , "jl": 4.82,"sd": 5.24}],
|
||||
"fqsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh":2,"lx": 2 , "jl": 4.82,"sd": 5.24}],
|
||||
"qfwt": {"xrjl": 2.357,"zawjl": 3.608},
|
||||
"qfsj": [{
|
||||
"bh": 1,
|
||||
"lx": 1,
|
||||
"jl": 2.35,
|
||||
"sd": 3.68
|
||||
}, {
|
||||
"bh": 2,
|
||||
"lx": 2,
|
||||
"jl": 4.82,
|
||||
"sd": 5.24
|
||||
}],
|
||||
"hfsj": [{
|
||||
"bh": 1,
|
||||
"lx": 1,
|
||||
"jl": 2.35,
|
||||
"sd": 3.68
|
||||
}, {
|
||||
"bh": 2,
|
||||
"lx": 2,
|
||||
"jl": 4.82,
|
||||
"sd": 5.24
|
||||
}],
|
||||
"zqsj": [{
|
||||
"bh": 1,
|
||||
"lx": 1,
|
||||
"jl": 2.35,
|
||||
"sd": 3.68
|
||||
}, {
|
||||
"bh": 2,
|
||||
"lx": 2,
|
||||
"jl": 4.82,
|
||||
"sd": 5.24
|
||||
}],
|
||||
"zhsj": [{
|
||||
"bh": 1,
|
||||
"lx": 1,
|
||||
"jl": 2.35,
|
||||
"sd": 3.68
|
||||
}, {
|
||||
"bh": 2,
|
||||
"lx": 2,
|
||||
"jl": 4.82,
|
||||
"sd": 5.24
|
||||
}],
|
||||
"zcsj": [{
|
||||
"bh": 1,
|
||||
"lx": 1,
|
||||
"jl": 2.35,
|
||||
"sd": 3.68
|
||||
}, {
|
||||
"bh": 2,
|
||||
"lx": 2,
|
||||
"jl": 4.82,
|
||||
"sd": 5.24
|
||||
}],
|
||||
"yqsj": [{
|
||||
"bh": 1,
|
||||
"lx": 1,
|
||||
"jl": 2.35,
|
||||
"sd": 3.68
|
||||
}, {
|
||||
"bh": 2,
|
||||
"lx": 2,
|
||||
"jl": 4.82,
|
||||
"sd": 5.24
|
||||
}],
|
||||
"yhsj": [{
|
||||
"bh": 1,
|
||||
"lx": 1,
|
||||
"jl": 2.35,
|
||||
"sd": 3.68
|
||||
}, {
|
||||
"bh": 2,
|
||||
"lx": 2,
|
||||
"jl": 4.82,
|
||||
"sd": 5.24
|
||||
}],
|
||||
"ycsj": [{
|
||||
"bh": 1,
|
||||
"lx": 1,
|
||||
"jl": 2.35,
|
||||
"sd": 3.68
|
||||
}, {
|
||||
"bh": 2,
|
||||
"lx": 2,
|
||||
"jl": 4.82,
|
||||
"sd": 5.24
|
||||
}],
|
||||
"fqsj": [{
|
||||
"bh": 1,
|
||||
"lx": 1,
|
||||
"jl": 2.35,
|
||||
"sd": 3.68
|
||||
}, {
|
||||
"bh": 2,
|
||||
"lx": 2,
|
||||
"jl": 4.82,
|
||||
"sd": 5.24
|
||||
}],
|
||||
"qfwt": { "xrjl": 2.357, "zawjl": 3.608 },
|
||||
"rcyz": 1,
|
||||
"show":[{"bh":1,"zb": [{"x": 0, "y": 1},{"x": 0, "y": 1},{"x": 0, "y": 1},{"x": 0, "y":1}]},
|
||||
{"bh":2,"zb": [{"x": 0, "y": 1},{"x": 0, "y": 1},{"x": 0, "y": 1},{"x": 0, "y": 1}]}]
|
||||
"show": [{ "bh": 1, "zb": [{ "x": 0, "y": 1 }, { "x": 0, "y": 1 }, { "x": 0, "y": 1 }, { "x": 0, "y": 1 }] },
|
||||
{ "bh": 2, "zb": [{ "x": 0, "y": 1 }, { "x": 0, "y": 1 }, { "x": 0, "y": 1 }, { "x": 0, "y": 1 }] }]
|
||||
},
|
||||
"extend": {}
|
||||
}
|
||||
|
||||
export const testAllitems = [
|
||||
{name:'倒车入库',abbreviation:'倒车入库',projectCode:'0',projectCodeCenter:'20100',type:'1'},
|
||||
{name:'倒车入库',abbreviation:'倒车入库',projectCode:'0',projectCodeCenter:'20100',type:'2'},
|
||||
{
|
||||
name: '倒车入库',
|
||||
abbreviation: '倒车入库',
|
||||
projectCode: '0',
|
||||
projectCodeCenter: '20100',
|
||||
type: '1'
|
||||
},
|
||||
{
|
||||
name: '倒车入库',
|
||||
abbreviation: '倒车入库',
|
||||
projectCode: '0',
|
||||
projectCodeCenter: '20100',
|
||||
type: '2'
|
||||
},
|
||||
|
||||
{name:'坡道定点停车和起步',abbreviation:'坡道定点停车和起步',projectCode:'2',projectCodeCenter:'20300',type:'10'},
|
||||
{name:'坡道定点停车和起步',abbreviation:'坡道定点停车和起步',projectCode:'2',projectCodeCenter:'20300',type:'9'},
|
||||
{
|
||||
name: '坡道定点停车和起步',
|
||||
abbreviation: '坡道定点停车和起步',
|
||||
projectCode: '2',
|
||||
projectCodeCenter: '20300',
|
||||
type: '10'
|
||||
},
|
||||
{
|
||||
name: '坡道定点停车和起步',
|
||||
abbreviation: '坡道定点停车和起步',
|
||||
projectCode: '2',
|
||||
projectCodeCenter: '20300',
|
||||
type: '9'
|
||||
},
|
||||
|
||||
{name:'侧方停车',abbreviation:'侧方停车',projectCode:'3',projectCodeCenter:'20400',type:'5'},
|
||||
{name:'侧方停车',abbreviation:'侧方停车',projectCode:'3',projectCodeCenter:'20400',type:'6'},
|
||||
{
|
||||
name: '侧方停车',
|
||||
abbreviation: '侧方停车',
|
||||
projectCode: '3',
|
||||
projectCodeCenter: '20400',
|
||||
type: '5'
|
||||
},
|
||||
{
|
||||
name: '侧方停车',
|
||||
abbreviation: '侧方停车',
|
||||
projectCode: '3',
|
||||
projectCodeCenter: '20400',
|
||||
type: '6'
|
||||
},
|
||||
|
||||
{name:'曲线行驶',abbreviation:'曲线行驶',projectCode:'5',projectCodeCenter:'20600',type:'7'},
|
||||
{name:'曲线行驶',abbreviation:'曲线行驶',projectCode:'5',projectCodeCenter:'20600',type:'8'},
|
||||
{
|
||||
name: '曲线行驶',
|
||||
abbreviation: '曲线行驶',
|
||||
projectCode: '5',
|
||||
projectCodeCenter: '20600',
|
||||
type: '7'
|
||||
},
|
||||
{
|
||||
name: '曲线行驶',
|
||||
abbreviation: '曲线行驶',
|
||||
projectCode: '5',
|
||||
projectCodeCenter: '20600',
|
||||
type: '8'
|
||||
},
|
||||
|
||||
{name:'直角转弯',abbreviation:'直角转弯',projectCode:'6',projectCodeCenter:'20700',type:'3'},
|
||||
{name:'直角转弯',abbreviation:'直角转弯',projectCode:'6',projectCodeCenter:'20700',type:'4'},
|
||||
{
|
||||
name: '直角转弯',
|
||||
abbreviation: '直角转弯',
|
||||
projectCode: '6',
|
||||
projectCodeCenter: '20700',
|
||||
type: '3'
|
||||
},
|
||||
{
|
||||
name: '直角转弯',
|
||||
abbreviation: '直角转弯',
|
||||
projectCode: '6',
|
||||
projectCodeCenter: '20700',
|
||||
type: '4'
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
export const testUIAllitems = [
|
||||
{"name":"倒车入库","abbreviation":"倒车入库","projectCode":"0","projectCodeCenter":"20100","type":"1"},
|
||||
{"name":"坡道停车","abbreviation":"坡道停车","projectCode":"2","projectCodeCenter":"20300","type":"10"},
|
||||
{"name":"侧方停车","abbreviation":"侧方停车","projectCode":"3","projectCodeCenter":"20400","type":"5"},
|
||||
{"name":"曲线行驶","abbreviation":"曲线行驶","projectCode":"5","projectCodeCenter":"20600","type":"7"},
|
||||
{"name":"直角转弯","abbreviation":"直角转弯","projectCode":"6","projectCodeCenter":"20700","type":"7"},
|
||||
{
|
||||
"name": "倒车入库",
|
||||
"abbreviation": "倒车入库",
|
||||
"projectCode": "0",
|
||||
"projectCodeCenter": "20100",
|
||||
"type": "1"
|
||||
},
|
||||
{
|
||||
"name": "坡道停车",
|
||||
"abbreviation": "坡道停车",
|
||||
"projectCode": "2",
|
||||
"projectCodeCenter": "20300",
|
||||
"type": "10"
|
||||
},
|
||||
{
|
||||
"name": "侧方停车",
|
||||
"abbreviation": "侧方停车",
|
||||
"projectCode": "3",
|
||||
"projectCodeCenter": "20400",
|
||||
"type": "5"
|
||||
},
|
||||
{
|
||||
"name": "曲线行驶",
|
||||
"abbreviation": "曲线行驶",
|
||||
"projectCode": "5",
|
||||
"projectCodeCenter": "20600",
|
||||
"type": "7"
|
||||
},
|
||||
{
|
||||
"name": "直角转弯",
|
||||
"abbreviation": "直角转弯",
|
||||
"projectCode": "6",
|
||||
"projectCodeCenter": "20700",
|
||||
"type": "7"
|
||||
},
|
||||
]
|
||||
|
||||
export const wuxiKm3Items = [
|
||||
//3,5,9,12,14,15,16,
|
||||
{projectCode:'1',projectCodeCenter:'40100',name:'上车准备',abbreviation:'上车准备'},
|
||||
{projectCode:'2',projectCodeCenter:'40200',name:'起步',abbreviation:'起步'},
|
||||
{projectCode:'3',projectCodeCenter:'40300',name:'直线行驶',abbreviation:'直线行驶'},
|
||||
{projectCode:'4',projectCodeCenter:'40500',name:'变更车道',abbreviation:'变更车道'},
|
||||
{projectCode:'5',projectCodeCenter:'40700',name:'直行通过路口',abbreviation:'直行通过路口'},
|
||||
{projectCode:'6',projectCodeCenter:'41000',name:'通过人行横道线',abbreviation:'通过人行横道线'},
|
||||
{projectCode:'7',projectCodeCenter:'41100',name:'通过学校区域',abbreviation:'通过学校区域'},
|
||||
{projectCode:'8',projectCodeCenter:'41200',name:'通过公共汽车站',abbreviation:'通过公共汽车站'},
|
||||
{projectCode:'9' ,projectCodeCenter:'41300',name:'会车',abbreviation:'会车'},
|
||||
{projectCode:'10',projectCodeCenter:'41400',name:'超车',abbreviation:'超车'},
|
||||
{projectCode:'11',projectCodeCenter:'40600',name:'靠边停车',abbreviation:'靠边停车'},
|
||||
{projectCode:'12',projectCodeCenter:'41500',name:'掉头',abbreviation:'掉头'},
|
||||
{projectCode:'41',projectCodeCenter:'41700',name:'模拟夜间灯光',abbreviation:'模拟夜间灯光'},
|
||||
{projectCode:'14',projectCodeCenter:'40400',name:'加减档位操作',abbreviation:'加减档位操作'},
|
||||
{projectCode:'15',projectCodeCenter:'40800',name:'路口左转弯',abbreviation:'路口左转弯'},
|
||||
{projectCode:'16',projectCodeCenter:'40900',name:'路口右转弯',abbreviation:'路口右转弯'},
|
||||
//3,5,9,12,14,15,16,
|
||||
{
|
||||
projectCode: '1',
|
||||
projectCodeCenter: '40100',
|
||||
name: '上车准备',
|
||||
abbreviation: '上车准备'
|
||||
},
|
||||
{
|
||||
projectCode: '2',
|
||||
projectCodeCenter: '40200',
|
||||
name: '起步',
|
||||
abbreviation: '起步'
|
||||
},
|
||||
{
|
||||
projectCode: '3',
|
||||
projectCodeCenter: '40300',
|
||||
name: '直线行驶',
|
||||
abbreviation: '直线行驶'
|
||||
},
|
||||
{
|
||||
projectCode: '4',
|
||||
projectCodeCenter: '40500',
|
||||
name: '变更车道',
|
||||
abbreviation: '变更车道'
|
||||
},
|
||||
{
|
||||
projectCode: '5',
|
||||
projectCodeCenter: '40700',
|
||||
name: '直行通过路口',
|
||||
abbreviation: '直行通过路口'
|
||||
},
|
||||
{
|
||||
projectCode: '6',
|
||||
projectCodeCenter: '41000',
|
||||
name: '通过人行横道线',
|
||||
abbreviation: '通过人行横道线'
|
||||
},
|
||||
{
|
||||
projectCode: '7',
|
||||
projectCodeCenter: '41100',
|
||||
name: '通过学校区域',
|
||||
abbreviation: '通过学校区域'
|
||||
},
|
||||
{
|
||||
projectCode: '8',
|
||||
projectCodeCenter: '41200',
|
||||
name: '通过公共汽车站',
|
||||
abbreviation: '通过公共汽车站'
|
||||
},
|
||||
{
|
||||
projectCode: '9',
|
||||
projectCodeCenter: '41300',
|
||||
name: '会车',
|
||||
abbreviation: '会车'
|
||||
},
|
||||
{
|
||||
projectCode: '10',
|
||||
projectCodeCenter: '41400',
|
||||
name: '超车',
|
||||
abbreviation: '超车'
|
||||
},
|
||||
{
|
||||
projectCode: '11',
|
||||
projectCodeCenter: '40600',
|
||||
name: '靠边停车',
|
||||
abbreviation: '靠边停车'
|
||||
},
|
||||
{
|
||||
projectCode: '12',
|
||||
projectCodeCenter: '41500',
|
||||
name: '掉头',
|
||||
abbreviation: '掉头'
|
||||
},
|
||||
{
|
||||
projectCode: '41',
|
||||
projectCodeCenter: '41700',
|
||||
name: '模拟夜间灯光',
|
||||
abbreviation: '模拟夜间灯光'
|
||||
},
|
||||
{
|
||||
projectCode: '14',
|
||||
projectCodeCenter: '40400',
|
||||
name: '加减档位操作',
|
||||
abbreviation: '加减档位操作'
|
||||
},
|
||||
{
|
||||
projectCode: '15',
|
||||
projectCodeCenter: '40800',
|
||||
name: '路口左转弯',
|
||||
abbreviation: '路口左转弯'
|
||||
},
|
||||
{
|
||||
projectCode: '16',
|
||||
projectCodeCenter: '40900',
|
||||
name: '路口右转弯',
|
||||
abbreviation: '路口右转弯'
|
||||
},
|
||||
]
|
||||
|
||||
//所有的科二 科目三项目
|
||||
export const testKm2Items = [
|
||||
{code:'20100',status:0},
|
||||
{code:'20200',status:0},
|
||||
{code:'20300',status:0},
|
||||
{code:'20400',status:0},
|
||||
{ code: '20100', status: 0 },
|
||||
{ code: '20200', status: 0 },
|
||||
{ code: '20300', status: 0 },
|
||||
{ code: '20400', status: 0 },
|
||||
|
||||
{code:'20500',status:0},
|
||||
{code:'20600',status:0},
|
||||
{code:'20700',status:0},
|
||||
{code:'20800',status:0},
|
||||
{ code: '20500', status: 0 },
|
||||
{ code: '20600', status: 0 },
|
||||
{ code: '20700', status: 0 },
|
||||
{ code: '20800', status: 0 },
|
||||
|
||||
{code:'20900',status:0},
|
||||
{code:'21000',status:0},
|
||||
{code:'21100',status:0},
|
||||
{code:'21200',status:0},
|
||||
{ code: '20900', status: 0 },
|
||||
{ code: '21000', status: 0 },
|
||||
{ code: '21100', status: 0 },
|
||||
{ code: '21200', status: 0 },
|
||||
|
||||
{code:'21300',status:0},
|
||||
{code:'21400',status:0},
|
||||
{code:'21500',status:0},
|
||||
{code:'21600',status:0},
|
||||
{ code: '21300', status: 0 },
|
||||
{ code: '21400', status: 0 },
|
||||
{ code: '21500', status: 0 },
|
||||
{ code: '21600', status: 0 },
|
||||
|
||||
{code:'21700',status:0},
|
||||
{code:'21800',status:0},
|
||||
{ code: '21700', status: 0 },
|
||||
{ code: '21800', status: 0 },
|
||||
]
|
||||
|
||||
export const testKm3Items= [
|
||||
{code:'40100',status:0},
|
||||
{code:'40200',status:0},
|
||||
{code:'40300',status:0},
|
||||
{code:'40400',status:0},
|
||||
export const testKm3Items = [
|
||||
{ code: '40100', status: 0 },
|
||||
{ code: '40200', status: 0 },
|
||||
{ code: '40300', status: 0 },
|
||||
{ code: '40400', status: 0 },
|
||||
|
||||
{code:'40500',status:0},
|
||||
{code:'40600',status:0},
|
||||
{code:'40700',status:0},
|
||||
{code:'40800',status:0},
|
||||
{ code: '40500', status: 0 },
|
||||
{ code: '40600', status: 0 },
|
||||
{ code: '40700', status: 0 },
|
||||
{ code: '40800', status: 0 },
|
||||
|
||||
{code:'40900',status:0},
|
||||
{code:'41000',status:0},
|
||||
{code:'41100',status:0},
|
||||
{code:'41200',status:0},
|
||||
{ code: '40900', status: 0 },
|
||||
{ code: '41000', status: 0 },
|
||||
{ code: '41100', status: 0 },
|
||||
{ code: '41200', status: 0 },
|
||||
|
||||
{code:'41300',status:0},
|
||||
{code:'41400',status:0},
|
||||
{code:'41500',status:0},
|
||||
{code:'41700',status:0},
|
||||
{ code: '41300', status: 0 },
|
||||
{ code: '41400', status: 0 },
|
||||
{ code: '41500', status: 0 },
|
||||
{ code: '41700', status: 0 },
|
||||
|
||||
{code:'41600',status:0},
|
||||
{ code: '41600', status: 0 },
|
||||
]
|
||||
|
||||
export const testMarkRules = [{
|
||||
|
||||
@ -68,7 +68,6 @@ export function ArrayToByteArray(array: number[]): Uint8Array {
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 字符串转字节数组
|
||||
* @param number 要转换的数字
|
||||
|
||||
@ -2,14 +2,32 @@ import socket from '@ohos.net.socket'
|
||||
import promptAction from '@ohos.promptAction'
|
||||
import { CarInfoType, EnvironmentConfigurationType } from '../model'
|
||||
import { UDPTag } from '../config'
|
||||
import { BusinessError } from '@ohos.base'
|
||||
import { FillZero, StringToBytes, StringToASCII } from './Common'
|
||||
|
||||
type DealMethod = (value: ArrayBuffer) => string
|
||||
|
||||
interface IPConfig {
|
||||
udplocalIp: string
|
||||
udplocalIpPort: string
|
||||
udpOppositeIp: string
|
||||
udpOppositeIpPort: string
|
||||
interface MsgExt {
|
||||
id: number,
|
||||
list: number[],
|
||||
carNo: string,
|
||||
placeId: string,
|
||||
}
|
||||
|
||||
function generateHead(param: MsgExt): number[] {
|
||||
let lshNo = AppStorage.get<string>("lsh")
|
||||
let a = new Uint16Array(StringToASCII(`${param.id}${FillZero(param.placeId, 3)}`))
|
||||
let b = new Uint32Array(StringToASCII(`${FillZero(param.carNo, 4)}${lshNo}`))
|
||||
let c = new Uint16Array(param.list.length)
|
||||
return [...a, ...b, ...c];
|
||||
}
|
||||
|
||||
function exclusive(target: number[]): number[] {
|
||||
let result = target[0]
|
||||
for (let i = 1; i < target.length; i++) {
|
||||
result = result ^ target[i]
|
||||
}
|
||||
return [result];
|
||||
}
|
||||
|
||||
export default class UdpClient {
|
||||
@ -45,7 +63,7 @@ export default class UdpClient {
|
||||
this.dealMethod = fun
|
||||
}
|
||||
|
||||
onMessage(callback: Function) {
|
||||
onMsg(callback: Function) {
|
||||
this.messageEvents.push(callback)
|
||||
}
|
||||
|
||||
@ -54,24 +72,37 @@ export default class UdpClient {
|
||||
}
|
||||
|
||||
sendMsg(data: ArrayBuffer | string): Promise<void> {
|
||||
return this.udp?.getState().then(() => {
|
||||
return this.udp.send({
|
||||
data,
|
||||
address: {
|
||||
address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
create(udpLocalIp: string, udpLocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
|
||||
setWholeMsg(params: MsgExt): ArrayBuffer {
|
||||
let head = generateHead(params);
|
||||
let headJudge = exclusive(head);
|
||||
let body = params.list;
|
||||
let bodyJudge = exclusive(body);
|
||||
let end = [13, 10];
|
||||
const arr = [...head, ...headJudge, ...body, ...bodyJudge, ...end]
|
||||
return new Uint8Array(arr).buffer
|
||||
}
|
||||
|
||||
sendMsgExt(param: MsgExt) {
|
||||
const msgData = this.setWholeMsg(param)
|
||||
this.sendMsg(msgData)
|
||||
}
|
||||
|
||||
async create(udpLocalIp: string, udpLocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
|
||||
this.localIp = udpLocalIp
|
||||
this.oppositeIp = udpOppositeIp
|
||||
this.localIpPort = udpLocalIpPort
|
||||
this.oppositeIpPort = udpOppositeIpPort
|
||||
this.udp = socket.constructUDPSocketInstance();
|
||||
this.bindEvent()
|
||||
this.bindUdp()
|
||||
return this.bindUdp()
|
||||
}
|
||||
|
||||
offMsg(callback: Function) {
|
||||
@ -95,69 +126,142 @@ export default class UdpClient {
|
||||
}
|
||||
|
||||
// 获取后置机信号
|
||||
// class ObjUdpClient extends UdpClient {
|
||||
// async init(context: common.UIAbilityContext) {
|
||||
// try {
|
||||
// const fileUtil = new FileUtils(context)
|
||||
// const data = await fileUtil.readFile("" + '/config/ipConfig.txt');
|
||||
// if (data?.length > 0) {
|
||||
// const result: IPConfig = JSON.parse(data)
|
||||
// this.create(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, result.udpOppositeIpPort)
|
||||
// }
|
||||
// } catch (e) {
|
||||
// promptAction.showToast({
|
||||
// message: "初始化obj udp失败"
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
class ObjUdpClient extends UdpClient {
|
||||
async init(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
let result: EnvironmentConfigurationType =
|
||||
AppStorage.get<EnvironmentConfigurationType>("EnvironmentConfiguration")
|
||||
if (result) {
|
||||
this.create(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, result.udpOppositeIpPort)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
}
|
||||
} catch (e) {
|
||||
promptAction.showToast({
|
||||
message: "初始化obj udp失败"
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 给中心发送GPS消息
|
||||
class centerUDPClient extends UdpClient {
|
||||
async init() {
|
||||
class CenterUDPClient extends UdpClient {
|
||||
async init(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
// const fileUtil = new FileUtils(context)
|
||||
// const data = await fileUtil.readFile("" + '/config/ipConfig.txt');
|
||||
let result: EnvironmentConfigurationType =
|
||||
AppStorage.get<EnvironmentConfigurationType>("EnvironmentConfiguration")
|
||||
const carInfo: CarInfoType = AppStorage.get<CarInfoType>('carInfo')
|
||||
if (result) {
|
||||
this.create(result.udplocalIp, '8800', carInfo?.udpAddress, carInfo?.messagePort)
|
||||
this.create(result.udplocalIp, '8800', carInfo?.udpAddress, carInfo?.messagePort).then(resolve).catch(reject)
|
||||
}
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
promptAction.showToast({
|
||||
message: "初始化中心 udp失败"
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 顶灯
|
||||
class LightUDPClient extends UdpClient {
|
||||
async init() {
|
||||
async init(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
// const fileUtil = new FileUtils(context)
|
||||
// const data = await fileUtil.readFile("" + '/config/ipConfig.txt');
|
||||
let result: EnvironmentConfigurationType =
|
||||
AppStorage.get<EnvironmentConfigurationType>("EnvironmentConfiguration")
|
||||
if (result) {
|
||||
// const result: IPConfig = JSON.parse(data)
|
||||
this.create(result.udplocalIp, '55509', result.udpOppositeIp, result.udpOppositeIpPort)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
}
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
promptAction.showToast({
|
||||
message: "初始化灯光 udp失败"
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 评判udp
|
||||
class JudgeUdp extends UdpClient {
|
||||
private udpIndex = 0;
|
||||
private currentUdpIndex = 0;
|
||||
|
||||
async init(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
let result: EnvironmentConfigurationType =
|
||||
AppStorage.get<EnvironmentConfigurationType>("EnvironmentConfiguration")
|
||||
const carInfo: CarInfoType = AppStorage.get<CarInfoType>('carInfo')
|
||||
if (result) {
|
||||
this.create(result.udplocalIp, '8080', carInfo.udpAddress, carInfo.hintPort).then(resolve).catch(reject)
|
||||
setInterval(() => {
|
||||
this.udpIndex += 1
|
||||
}, 1000)
|
||||
}
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
promptAction.showToast({
|
||||
message: "初始化评判 udp失败"
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
send(bytes: number[]) {
|
||||
const carInfo: CarInfoType = AppStorage.get<CarInfoType>('carInfo')
|
||||
if (this.udpIndex > this.currentUdpIndex) {
|
||||
this.sendMsgExt({
|
||||
id: 45,
|
||||
list: bytes,
|
||||
carNo: carInfo.carNo,
|
||||
placeId: carInfo.examinationRoomId
|
||||
})
|
||||
this.currentUdpIndex = this.udpIndex
|
||||
}
|
||||
}
|
||||
|
||||
//申请远程扣分查询
|
||||
askKf(directives: number) {
|
||||
const carInfo: CarInfoType = AppStorage.get<CarInfoType>('carInfo')
|
||||
centerUDPClient.sendMsgExt({
|
||||
id: 35,
|
||||
list: [directives],
|
||||
carNo: carInfo.carNo,
|
||||
placeId: carInfo.examinationRoomId,
|
||||
})
|
||||
console.info('surenjun', `考车查询扣分项目内容,请求指令为:${directives}`)
|
||||
}
|
||||
|
||||
//确定远程扣分
|
||||
confirmKf(directives: number, code: number) {
|
||||
const carInfo: CarInfoType = AppStorage.get<CarInfoType>('carInfo')
|
||||
centerUDPClient.sendMsgExt({
|
||||
id: 37,
|
||||
list: [directives, code],
|
||||
carNo: carInfo.carNo,
|
||||
placeId: carInfo.examinationRoomId
|
||||
})
|
||||
console.info('surenjun', `考车发送确定扣分指令,指令为:${directives}`)
|
||||
}
|
||||
}
|
||||
|
||||
// obj
|
||||
// export const objUDPClient = new ObjUdpClient()
|
||||
export const objUDPClient = new ObjUdpClient()
|
||||
|
||||
// 中心GPS
|
||||
export const CenterUDPClient = new centerUDPClient()
|
||||
export const centerUDPClient = new CenterUDPClient()
|
||||
|
||||
// 顶灯
|
||||
export const lightUDPClient = new LightUDPClient()
|
||||
|
||||
// 评判
|
||||
export const judgeUDPClient = new JudgeUdp()
|
||||
|
||||
@ -24,7 +24,7 @@ class centralHeartbeat {
|
||||
|
||||
// 接受中心远程指令
|
||||
getData(callback: (data: centerCallBackMsgType) => void) {
|
||||
this.centralHeartbeatUdp.onMessage((data: ArrayBuffer) => {
|
||||
this.centralHeartbeatUdp.onMsg((data: ArrayBuffer) => {
|
||||
let arr: number[] = []
|
||||
let dataView = new DataView(data)
|
||||
for (let i = 0; i < dataView?.byteLength; ++i) {
|
||||
|
||||
@ -37,7 +37,7 @@ class obtainSignalData {
|
||||
|
||||
// 三代机 通过UDP onMessage获取信号
|
||||
if (this.modelNo === "3") {
|
||||
this.thirdGenerationMachineUdp.onMessage((data: ArrayBuffer) => {
|
||||
this.thirdGenerationMachineUdp.onMsg((data: ArrayBuffer) => {
|
||||
const dataView = new DataView(data);
|
||||
let str = ""
|
||||
for (let i = 0; i < dataView?.byteLength; ++i) {
|
||||
|
||||
@ -1,62 +1,78 @@
|
||||
import emitter from '@ohos.events.emitter';
|
||||
import { judgeUDPClient } from '../UdpUtils';
|
||||
|
||||
export const EVENTID = {
|
||||
enum EventId {
|
||||
//远程扣分处理
|
||||
kfEventId: 35,
|
||||
kfEventId = 35,
|
||||
//远程扣分查询
|
||||
kfAskEventId: 36,
|
||||
kfAskEventId = 36,
|
||||
//远程扣分确认
|
||||
kfConfirmEventId: 37,
|
||||
|
||||
kfConfirmEventId = 37,
|
||||
//远程开始考试
|
||||
beginExamEventId: 11,
|
||||
beginExamEventId = 11,
|
||||
//远程结束考试
|
||||
endExamEventId: 12
|
||||
endExamEventId = 12
|
||||
}
|
||||
|
||||
export default class JudgeEmitter {
|
||||
private beginExamCallBack: Function = () => {
|
||||
}
|
||||
private endExamCallBack: Function = () => {
|
||||
}
|
||||
private kfContent: Function = () => {
|
||||
}
|
||||
private directives: string
|
||||
|
||||
constructor() {
|
||||
this.init()
|
||||
}
|
||||
|
||||
//监听开始考试
|
||||
public onBeginExam = async (callBack?: Function) => {
|
||||
public onBeginExam(callBack?: Function) {
|
||||
console.info('surenjun', '注册远程开始考试事件')
|
||||
this.beginExamCallBack = callBack
|
||||
}
|
||||
|
||||
//监听结束考试
|
||||
public onEndExam = async (callBack?: Function) => {
|
||||
public onEndExam(callBack?: Function) {
|
||||
console.info('surenjun', '注册远程结束考试事件')
|
||||
this.endExamCallBack = callBack
|
||||
}
|
||||
|
||||
//监听扣分处理
|
||||
public onKfExam = async (callBack?: Function) => {
|
||||
public onKfExam(callBack?: Function) {
|
||||
console.info('surenjun', '注册远程扣分考试事件')
|
||||
this.kfContent = callBack
|
||||
}
|
||||
|
||||
//开始考试
|
||||
public sendBeginExam = async (content: string) => {
|
||||
public sendBeginExam(content: string) {
|
||||
emitter.emit({
|
||||
eventId: EVENTID.beginExamEventId
|
||||
eventId: EventId.beginExamEventId
|
||||
}, {
|
||||
data: {
|
||||
directives: content
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//结束考试
|
||||
public sendEndExam = async (content: string) => {
|
||||
public sendEndExam(content: string) {
|
||||
emitter.emit({
|
||||
eventId: EVENTID.endExamEventId
|
||||
eventId: EventId.endExamEventId
|
||||
}, {
|
||||
data: {
|
||||
directives: content
|
||||
}
|
||||
});
|
||||
}
|
||||
private directives: string
|
||||
|
||||
//扣分
|
||||
public sendKfContent = async (kfxh: string) => {
|
||||
public sendKfContent(kfxh: string) {
|
||||
const directives = this.directives
|
||||
console.info('surenjun', `udpEvent收到扣分事件。kfxh=>${kfxh};directives=>${directives}`)
|
||||
emitter.emit({
|
||||
eventId: EVENTID.kfEventId
|
||||
eventId: EventId.kfEventId
|
||||
}, {
|
||||
data: {
|
||||
directives,
|
||||
@ -64,17 +80,18 @@ export default class JudgeEmitter {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//监听扣分指令
|
||||
public sendOnKf = async (directives: string) => {
|
||||
//TODO 临时存储指令编号
|
||||
public sendOnKf(directives: string) {
|
||||
this.directives = directives
|
||||
globalThis.judgeUdp.askKf(directives)
|
||||
judgeUDPClient.askKf(Number(directives))
|
||||
}
|
||||
|
||||
// 获取扣分项目编号
|
||||
public onConfirmKf = async (kfxh: string) => {
|
||||
public onConfirmKf(kfxh: string) {
|
||||
const directives = this.directives;
|
||||
emitter.emit({
|
||||
eventId: EVENTID.kfConfirmEventId
|
||||
eventId: EventId.kfConfirmEventId
|
||||
}, {
|
||||
data: {
|
||||
kfxh, directives
|
||||
@ -82,48 +99,28 @@ export default class JudgeEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.init()
|
||||
}
|
||||
|
||||
init = async () => {
|
||||
public init() {
|
||||
console.info('surenjun', '开始注册udp事件')
|
||||
emitter.off(EVENTID.beginExamEventId)
|
||||
emitter.off(EVENTID.endExamEventId)
|
||||
emitter.off(EVENTID.kfConfirmEventId)
|
||||
emitter.off(EVENTID.kfEventId)
|
||||
|
||||
emitter.off(EventId.beginExamEventId)
|
||||
emitter.off(EventId.endExamEventId)
|
||||
emitter.off(EventId.kfConfirmEventId)
|
||||
emitter.off(EventId.kfEventId)
|
||||
emitter.on({
|
||||
eventId: EVENTID.beginExamEventId
|
||||
eventId: EventId.beginExamEventId
|
||||
}, () => {
|
||||
this?.beginExamCallBack()
|
||||
});
|
||||
|
||||
emitter.on({
|
||||
eventId: EVENTID.endExamEventId
|
||||
eventId: EventId.endExamEventId
|
||||
}, () => {
|
||||
this?.endExamCallBack()
|
||||
});
|
||||
|
||||
emitter.on({
|
||||
eventId: EVENTID.kfEventId
|
||||
eventId: EventId.kfEventId
|
||||
}, (data) => {
|
||||
console.info('surenjun EVENTID.kfEvent' + JSON.stringify(data))
|
||||
console.info('surenjun EventId.kfEvent' + JSON.stringify(data))
|
||||
this?.kfContent(data)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private beginExamCallBack: Function = () => {
|
||||
}
|
||||
|
||||
private endExamCallBack: Function = () => {
|
||||
}
|
||||
|
||||
private confirmExamCallBack: Function = () => {
|
||||
}
|
||||
|
||||
private kfContent: Function = () => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,219 +3,98 @@ import systemTime from '@ohos.systemDateTime';
|
||||
import { testKm2Items, testKm3Items } from '../../pages/judgeSDK/dataTest/index';
|
||||
import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig';
|
||||
import { examCalcGpsDistance } from '../../pages/judgeSDK/api';
|
||||
import { judgeUDPClient, lightUDPClient, objUDPClient } from '../UdpUtils';
|
||||
import { CarInfoType, Gps, Sensor } from '../../model';
|
||||
import { FillZero, StringToASCII } from '../Common';
|
||||
|
||||
export const initJudgeUdp = async () => {
|
||||
globalThis.serialIndex = 0;
|
||||
globalThis.udpIndex = 0;
|
||||
const udp = await setJudgeUdp()
|
||||
globalThis.judgeUdp = udp
|
||||
|
||||
const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00];
|
||||
const arrBlueBuffer = Array2Byte(arrBlue).buffer
|
||||
|
||||
const lightLineUdp = await setTopLineUdp();
|
||||
if (lightLineUdp) {
|
||||
lightLineUdp.send(arrBlueBuffer);
|
||||
}
|
||||
globalThis.lightLineUdp = lightLineUdp
|
||||
|
||||
let [prevJd, preWd] = [0, 0]
|
||||
globalThis.udpClient.onMessage_1(async (msg) => {
|
||||
const stachArr = msg.split(',')
|
||||
if (stachArr[0] != '#DN_GD') {
|
||||
return
|
||||
}
|
||||
const udpIndex = globalThis.udpIndex;
|
||||
const isJudge = globalThis.isJudge;
|
||||
if (udpIndex % 5 === 0 && !isJudge) {
|
||||
const bytes = await getMessageHeartbeat(msg);
|
||||
const msgArr = msg.split(',');
|
||||
const jd = convertGpsCoord2(msgArr[96] * 1);
|
||||
const wd = convertGpsCoord2(msgArr[95] * 1 || 0);
|
||||
udp.send(bytes)
|
||||
if (prevJd && msgArr[83] == 4) {
|
||||
const distance = await examCalcGpsDistance({
|
||||
jd1: prevJd,
|
||||
wd1: preWd,
|
||||
jd2: jd,
|
||||
wd2: wd,
|
||||
h: msgArr[90] * 1 || 1,
|
||||
})
|
||||
//@ts-ignore
|
||||
// globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1)
|
||||
}
|
||||
prevJd = jd;
|
||||
preWd = wd;
|
||||
}
|
||||
globalThis.udpIndex += 1
|
||||
})
|
||||
interface PLCDataType {
|
||||
sensor: Sensor,
|
||||
gps: Gps,
|
||||
}
|
||||
|
||||
export const getMessageHeartbeat = async (msg) => {
|
||||
const carInfo = globalThis.carInfo;
|
||||
const { examSubject, plateNo } = carInfo;
|
||||
const ksyh = '0000000000000'
|
||||
const { fourInOneScreen:{ gpsDigit } } = judgeConfig
|
||||
const asclshArr = stringToASC(fillZero(
|
||||
globalThis.singlePlay
|
||||
? '1111111111111'
|
||||
: globalThis.lsh,
|
||||
13));
|
||||
const ascksyhArr = stringToASC(fillZero(examSubject == 2 ? '0000000000000' : '1111111111111', 13))
|
||||
const ascsbxhArr = stringToASC('00000000')
|
||||
// const ascsbxhArr = stringToASC('153216400880')
|
||||
const serialIndex = globalThis.serialIndex
|
||||
const tempData = await getPlcData(msg);
|
||||
const examType = examSubject == 2 ? 2 : 3
|
||||
const { sensor, gps } = tempData;
|
||||
const { zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, ygq, cs, fdjzs, dw } = sensor
|
||||
const { jd, wd, hxj, fyj, hbg, sd } = gps
|
||||
const translateSignals = getTranslateSignals(
|
||||
[zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd].concat(getDwStatusType(dw))
|
||||
.concat([0, 0, ygq, sensor.wd, 0])
|
||||
)
|
||||
const translateProject = getTranslateProject();
|
||||
//@ts-ignore
|
||||
const translateJd = convertGpsCoord2(wd).toFixed(gpsDigit) * Math.pow(10, gpsDigit);
|
||||
//@ts-ignore
|
||||
const translateWd = convertGpsCoord2(jd).toFixed(gpsDigit) * Math.pow(10, gpsDigit)
|
||||
//@ts-ignore
|
||||
const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0])
|
||||
//@ts-ignore
|
||||
let tempSd = (sd * 1.852).toFixed(0) * 1
|
||||
if (tempSd < 1) {
|
||||
tempSd = 0
|
||||
interface ProjectDataType {
|
||||
code: string
|
||||
status: number
|
||||
}
|
||||
|
||||
interface ProjectItemType {
|
||||
code: ProjectDataType
|
||||
status: string
|
||||
}
|
||||
|
||||
function convertGpsCoord2(num: number) {
|
||||
const tempNum = Math.floor(num);
|
||||
const du = Math.floor(tempNum / 100);
|
||||
const fen = tempNum % 100 + num - tempNum;
|
||||
return du + fen / 60
|
||||
}
|
||||
|
||||
function string2Bytes(num: number | string, len: number) {
|
||||
let str = (Math.floor(Number(num))).toString(2);
|
||||
if (str.length > len) {
|
||||
console.log('数据长度不对~~');
|
||||
return
|
||||
}
|
||||
let byteString = FillZero(str, len);
|
||||
|
||||
const arr = [
|
||||
//考生号
|
||||
asclshArr.map(lsh => string2Bytes(lsh, 8)[0]),
|
||||
//考试员号
|
||||
ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]),
|
||||
//科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间
|
||||
string2Bytes(`${0}${'00:00:000'}`, 4 * 8),
|
||||
// 消息序号
|
||||
string2Bytes(serialIndex, 2 * 8),
|
||||
translateSignals,
|
||||
//@ts-ignore
|
||||
string2Bytes(tempSd * 100, 2 * 8), string2Bytes(fdjzs / 100, 8), string2Bytes(translateJd, 4 * 8),
|
||||
string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8),
|
||||
//GPS东向距离
|
||||
string2Bytes(0, 4 * 8),
|
||||
//GPS北向距离
|
||||
string2Bytes(0, 4 * 8),
|
||||
//航向角 俯仰角 高程(海拔)
|
||||
//@ts-ignore
|
||||
string2Bytes((hxj) * 100, 2 * 8), string2Bytes(fyj * 100, 2 * 8), string2Bytes(hbg * 100, 4 * 8),
|
||||
//dddd
|
||||
translateProjects,
|
||||
//当前项目编号
|
||||
string2Bytes(0, 8),
|
||||
//场地设备编号
|
||||
ascsbxhArr.map(sbxh => string2Bytes(sbxh, 8)[0]),
|
||||
//本次考试行驶距离
|
||||
string2Bytes(0, 2 * 8),
|
||||
//扣分值
|
||||
string2Bytes(0, 2 * 8),
|
||||
//扣分数
|
||||
string2Bytes(0, 2 * 8),
|
||||
//扣分项数量
|
||||
string2Bytes(0, 8),
|
||||
//n个扣分序号
|
||||
[].map(kf => string2Bytes(kf.markcatalog, 8)),
|
||||
//牵引车第二gps精度、纬度
|
||||
string2Bytes(0, 4 * 8), string2Bytes(0, 4 * 8),
|
||||
//牵引车第二航向角
|
||||
string2Bytes(0, 2 * 8),
|
||||
//摩托压线 Byte[20],
|
||||
string2Bytes(0, 20 * 8),
|
||||
//考试用时
|
||||
string2Bytes(fillZero(0 + '', 4), 4 * 8),
|
||||
//项目用时
|
||||
string2Bytes(fillZero(0, 2), 2 * 8),
|
||||
//设备信号状态
|
||||
string2Bytes(0, 4 * 8),
|
||||
]
|
||||
let tempArr = [];
|
||||
arr.forEach(itemArr => {
|
||||
tempArr = tempArr.concat(itemArr)
|
||||
})
|
||||
|
||||
globalThis.serialIndex = 0;
|
||||
return Array2Byte(tempArr)
|
||||
let arrBytes: number[] = [];
|
||||
for (let i = byteString.length; i > 0; ) {
|
||||
let j = i - 8;
|
||||
if (j < 0) {
|
||||
j = 0
|
||||
}
|
||||
let s = byteString.slice(j, i);
|
||||
let v = parseInt(s, 2);
|
||||
arrBytes.push(v);
|
||||
i = i - 8
|
||||
}
|
||||
return arrBytes;
|
||||
}
|
||||
|
||||
// 中心plc实时信号转换成字节
|
||||
const getTranslateSignals = (tempItems) => {
|
||||
function getTranslateSignals(tempItems: number[]) {
|
||||
const len = Math.floor(tempItems.length / 8);
|
||||
const arr = [];
|
||||
const arr: string[] = [];
|
||||
for (let i = 0; i < len; i++) {
|
||||
const temp = tempItems.slice(i * 8, (i + 1) * 8);
|
||||
arr.push(temp.join(''));
|
||||
arr.push(tempItems.slice(i * 8, (i + 1) * 8).join(''));
|
||||
}
|
||||
const temp = arr.map(numStr => parseInt(numStr, 2))
|
||||
return temp.map(item => string2Bytes(item, 8)[0])
|
||||
return arr.map(numStr => parseInt(numStr, 2)).map(item => string2Bytes(item, 8)[0])
|
||||
}
|
||||
|
||||
// 中心所有项目转换
|
||||
const getTranslateProject = () => {
|
||||
const examSubject = globalThis.examSubject;
|
||||
|
||||
const tempItems = (examSubject == 2 ? testKm2Items : testKm3Items).map(code => {
|
||||
return {
|
||||
code, status: '0'
|
||||
function getTranslateProject(): string[] {
|
||||
const examSubject = AppStorage.get<string>("examSubject");
|
||||
const tempItems: ProjectItemType[] =
|
||||
(examSubject === '2' ? testKm2Items : testKm3Items).map((code: ProjectDataType) => {
|
||||
let data: ProjectItemType = {
|
||||
code,
|
||||
status: '0'
|
||||
}
|
||||
return data
|
||||
})
|
||||
const arr = [];
|
||||
const arr: string[] = [];
|
||||
for (let i = 0; i <= 4; i++) {
|
||||
const temp = tempItems.slice(i * 4, (i + 1) * 4);
|
||||
let tempArr = temp.map(item => item.status)
|
||||
if (i === 4) {
|
||||
tempArr = examSubject == 2
|
||||
tempArr = examSubject === '2'
|
||||
//bit36-bit39保留
|
||||
? tempArr.concat(['00', '00'])
|
||||
//bit30-bit39保留
|
||||
: tempArr.concat(['00', '00', '00'])
|
||||
}
|
||||
// if (i === 3 && examSubject == 3) {
|
||||
// tempArr = tempArr.concat(['00'])
|
||||
// }
|
||||
|
||||
arr.push(tempArr.join(''));
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
// 中心实时项目状态转换
|
||||
const getCenterProjectStatus = (status) => {
|
||||
switch (status) {
|
||||
//不考
|
||||
case 0:
|
||||
return '00'
|
||||
//未考
|
||||
case 1:
|
||||
return '01'
|
||||
//已考
|
||||
case 2:
|
||||
return '10'
|
||||
}
|
||||
}
|
||||
|
||||
// plc数据转换成对象
|
||||
const getPlcData = async (plc: string) => {
|
||||
async function getPlcData(plc: string): Promise<PLCDataType> {
|
||||
const time = await systemTime.getCurrentTime()
|
||||
const p = plc.split(',').map((val, key) => {
|
||||
if (key !== 27 && key !== 92) {
|
||||
//@ts-ignore
|
||||
return val * 1
|
||||
} else {
|
||||
return val
|
||||
}
|
||||
});
|
||||
|
||||
const tempData = {
|
||||
sensor: {
|
||||
//安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯
|
||||
let origin = plc.split(",")
|
||||
let p = origin.map(item => Number(item))
|
||||
let sensor: Sensor = {
|
||||
aqd: p[19],
|
||||
mkg: p[14],
|
||||
ssc: p[13],
|
||||
@ -237,8 +116,7 @@ const getPlcData = async (plc: string) => {
|
||||
fdjzs: p[25],
|
||||
dw: p[28],
|
||||
cs: p[23],
|
||||
//@ts-ignore 方向盘
|
||||
fxp: p[27].split('_')[0] * 1,
|
||||
fxp: Number(origin[27].split('_')[0]),
|
||||
//累计脉冲 溜车脉冲 超声波左后 超声波右后 超声波右前 超声波左前 座椅 仪表盘 后视镜 倒车镜 光照 雨量
|
||||
ljmc: p[24],
|
||||
lcmc: 0,
|
||||
@ -251,16 +129,18 @@ const getPlcData = async (plc: string) => {
|
||||
hsj: 0,
|
||||
dcj: 0,
|
||||
gx: 0,
|
||||
yl: 0
|
||||
},
|
||||
gps: {
|
||||
//TODO 办卡类型 定位差分状态
|
||||
yl: 0,
|
||||
yy: 0,
|
||||
sde: 0,
|
||||
xhd: '',
|
||||
rmndg: 0,
|
||||
wav: 0,
|
||||
mndg: ''
|
||||
}
|
||||
let gps: Gps = {
|
||||
bklx: p[56],
|
||||
dwzt: p[83],
|
||||
//@ts-ignore 角度差分状态
|
||||
jdzt: p[92].split('-')[0] * 1,
|
||||
//TODO gps数据
|
||||
//gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度
|
||||
jdzt: Number(origin[92].split('-')[0]),
|
||||
sj: time,
|
||||
jd: p[96],
|
||||
wd: p[95],
|
||||
@ -269,20 +149,20 @@ const getPlcData = async (plc: string) => {
|
||||
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
|
||||
},
|
||||
jdsxs: Number(origin[92].split('-')[1])
|
||||
}
|
||||
|
||||
return tempData
|
||||
return {
|
||||
sensor,
|
||||
gps,
|
||||
}
|
||||
}
|
||||
|
||||
const getDwStatusType = (dw) => {
|
||||
function getDwStatusType(dw: number) {
|
||||
switch (dw) {
|
||||
case 0:
|
||||
return [0, 0, 0, 0]
|
||||
@ -302,3 +182,133 @@ const getDwStatusType = (dw) => {
|
||||
return [0, 0, 0, 0]
|
||||
}
|
||||
}
|
||||
|
||||
export async function initJudgeUdp() {
|
||||
AppStorage.setOrCreate("serialIndex", 0)
|
||||
AppStorage.setOrCreate("udpIndex", 0)
|
||||
const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00];
|
||||
const arrBlueBuffer = new Uint8Array(arrBlue).buffer
|
||||
lightUDPClient.sendMsg(arrBlueBuffer);
|
||||
let prevJd = 0, preWd = 0
|
||||
objUDPClient.onMsg(async (msg: string) => {
|
||||
const stashArr = msg.split(',')
|
||||
if (stashArr[0] != '#DN_GD') {
|
||||
return
|
||||
}
|
||||
const udpIndex = AppStorage.get<number>("udpIndex");
|
||||
const isJudge = AppStorage.get<boolean>("isJudge");
|
||||
if (udpIndex % 5 === 0 && !isJudge) {
|
||||
const bytes = await getMessageHeartbeat(msg);
|
||||
const msgArr: string[] = msg.split(',');
|
||||
const jd = convertGpsCoord2(Number(msgArr[96]));
|
||||
const wd = convertGpsCoord2(Number(msgArr[95]) || 0);
|
||||
judgeUDPClient.send(bytes)
|
||||
if (prevJd && Number(msgArr[83]) === 4) {
|
||||
const distance = await examCalcGpsDistance({
|
||||
jd1: prevJd,
|
||||
wd1: preWd,
|
||||
jd2: jd,
|
||||
wd2: wd,
|
||||
h: Number(msgArr[90]) || 1,
|
||||
})
|
||||
//@ts-ignore
|
||||
// globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1)
|
||||
}
|
||||
prevJd = jd;
|
||||
preWd = wd;
|
||||
}
|
||||
AppStorage.set("udpIndex", udpIndex + 1)
|
||||
})
|
||||
}
|
||||
|
||||
export async function getMessageHeartbeat(msg: string): Promise<number[]> {
|
||||
const carInfo: CarInfoType = AppStorage.get<CarInfoType>('carInfo')
|
||||
let gpsDigit = judgeConfig.fourInOneScreen.gpsDigit
|
||||
const asclshArr = StringToASCII(FillZero(
|
||||
AppStorage.get<boolean>("singlePlay")
|
||||
? '1111111111111'
|
||||
: AppStorage.get<string>("lsh"),
|
||||
13));
|
||||
const ascksyhArr = StringToASCII(carInfo.examSubject === '2' ? '0000000000000' : '1111111111111')
|
||||
const ascsbxhArr = StringToASCII('00000000')
|
||||
const serialIndex = AppStorage.get<number>("serialIndex")
|
||||
const plcData = await getPlcData(msg);
|
||||
let param: number[] = Object.entries(plcData.sensor)
|
||||
.filter((item: [string, number]) => {
|
||||
let keys =
|
||||
["zfxd", "yfxd", "shtd", "ygd", "jgd", "skd", "dh1", "dh2", "lhq", "jsc", "ssc", "fsc", "lb", "mkg", "aqd"]
|
||||
return keys.indexOf(item[0])
|
||||
})
|
||||
.map((item: [string, number]) => item[1])
|
||||
.concat(getDwStatusType(plcData.sensor.dw))
|
||||
.concat([0, 0, plcData.sensor.ygq, plcData.sensor.wd, 0])
|
||||
const translateSignals = getTranslateSignals(param)
|
||||
const translateProject = getTranslateProject();
|
||||
const translateJd = Number(convertGpsCoord2(plcData.gps.wd).toFixed(gpsDigit)) * Math.pow(10, gpsDigit);
|
||||
const translateWd = Number(convertGpsCoord2(plcData.gps.jd).toFixed(gpsDigit)) * Math.pow(10, gpsDigit)
|
||||
const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0])
|
||||
let tempSd = Number((plcData.gps.sd * 1.852).toFixed(0))
|
||||
if (tempSd < 1) {
|
||||
tempSd = 0
|
||||
}
|
||||
const arr: number[][] = [
|
||||
//考生号
|
||||
asclshArr.map(lsh => string2Bytes(lsh, 8)[0]),
|
||||
//考试员号
|
||||
ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]),
|
||||
//科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间
|
||||
string2Bytes(`${0}${'00:00:000'}`, 4 * 8),
|
||||
// 消息序号
|
||||
string2Bytes(serialIndex, 2 * 8),
|
||||
translateSignals,
|
||||
string2Bytes(tempSd * 100, 2 * 8),
|
||||
string2Bytes(plcData.sensor.fdjzs / 100, 8),
|
||||
string2Bytes(translateJd, 4 * 8),
|
||||
string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8),
|
||||
//GPS东向距离
|
||||
string2Bytes(0, 4 * 8),
|
||||
//GPS北向距离
|
||||
string2Bytes(0, 4 * 8),
|
||||
//航向角
|
||||
string2Bytes(plcData.gps.hxj * 100, 2 * 8),
|
||||
//俯仰角
|
||||
string2Bytes(plcData.gps.fyj * 100, 2 * 8),
|
||||
// 高程(海拔)
|
||||
string2Bytes(plcData.gps.hbg * 100, 4 * 8),
|
||||
//dddd
|
||||
translateProjects,
|
||||
//当前项目编号
|
||||
string2Bytes(0, 8),
|
||||
//场地设备编号
|
||||
ascsbxhArr.map(sbxh => string2Bytes(sbxh, 8)[0]),
|
||||
//本次考试行驶距离
|
||||
string2Bytes(0, 2 * 8),
|
||||
//扣分值
|
||||
string2Bytes(0, 2 * 8),
|
||||
//扣分数
|
||||
string2Bytes(0, 2 * 8),
|
||||
//扣分项数量
|
||||
string2Bytes(0, 8),
|
||||
//n个扣分序号
|
||||
// [].map(kf => string2Bytes(kf.markcatalog, 8)),
|
||||
[],
|
||||
//牵引车第二gps精度、纬度
|
||||
string2Bytes(0, 4 * 8), string2Bytes(0, 4 * 8),
|
||||
//牵引车第二航向角
|
||||
string2Bytes(0, 2 * 8),
|
||||
//摩托压线 Byte[20],
|
||||
string2Bytes(0, 20 * 8),
|
||||
//考试用时
|
||||
string2Bytes(FillZero(0, 4), 4 * 8),
|
||||
//项目用时
|
||||
string2Bytes(FillZero(0, 2), 2 * 8),
|
||||
//设备信号状态
|
||||
string2Bytes(0, 4 * 8),
|
||||
]
|
||||
let result: number[] = [];
|
||||
arr.forEach(itemArr => {
|
||||
result = result.concat(itemArr)
|
||||
})
|
||||
AppStorage.setOrCreate("serialIndex", 0)
|
||||
return [...new Uint8Array(result)]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user