Merge branch 'dev' of http://88.22.24.105:3000/harmony_car/subject-two into dev
This commit is contained in:
commit
2f524da992
@ -11,54 +11,80 @@ export default class UdpByOne {
|
||||
// PLC localIp
|
||||
private LocalIp: string = '192.168.7.170';
|
||||
// PLC localIpPort
|
||||
private PLCLocalIpPort: string = '31012';
|
||||
private PLCLocalIpPort: number = 31012;
|
||||
private OppositeIp: string = '192.168.7.124'
|
||||
// PLC oppositeIpPort
|
||||
private PLCOppositeIpPort: string = '30012';
|
||||
private PLCOppositeIpPort: number = 30012;
|
||||
// PLC消息
|
||||
private PLCMsg: ArrayBuffer;
|
||||
// GPS udp
|
||||
private GPSUDP: any;
|
||||
private GPSTCP: any;
|
||||
// GPS localIp
|
||||
// GPS localIpPort
|
||||
private GPSLocalIpPort: string = '31013';
|
||||
private GPSLocalIpPort: number = 31013;
|
||||
// GPS oppositeIpPort
|
||||
private GPSOppositeIpPort: string = '30013';
|
||||
private GPSOppositeIpPort: number = 30013;
|
||||
// GPS消息
|
||||
private GPSMsg: any;
|
||||
|
||||
private timer: number;
|
||||
|
||||
public type: 1| 2
|
||||
constructor(type) {
|
||||
//一型机 二型机
|
||||
public terType: 1 | 2
|
||||
//板卡类型
|
||||
public cardType: 0| 1 | 2
|
||||
constructor(terType,cardType) {
|
||||
this.terType = terType;
|
||||
this.cardType = cardType;
|
||||
this.init()
|
||||
console.info('surenjun type=>',type +'')
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
async init(){
|
||||
const fileUtil = new FileUtil(globalThis.context)
|
||||
const {terType,cardType} = this
|
||||
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
|
||||
const result = JSON.parse(data)
|
||||
this.LocalIp = result.udplocalIp;
|
||||
this.OppositeIp = result.udpOppositeIp;
|
||||
this.OppositeIp = result.udpOppositeIp;
|
||||
|
||||
// 初始化UDP
|
||||
this.PLCUDP = socket.constructUDPSocketInstance();
|
||||
// this.PLCUDP.bind(this.PLCLocalIp, this.PLCLocalIpPort);
|
||||
this.PLCUDP.bind({
|
||||
address: this.LocalIp, port: parseInt(this.PLCLocalIpPort), family: 1
|
||||
address: this.LocalIp, port: this.PLCLocalIpPort, family: 1
|
||||
});
|
||||
this.GPSUDP = socket.constructUDPSocketInstance();
|
||||
// this.GPSUDP.bind(this.GPSLocalIp, this.GPSLocalIpPort);
|
||||
this.GPSUDP.bind({
|
||||
address: this.LocalIp, port: parseInt(this.GPSLocalIpPort), family: 1
|
||||
});
|
||||
|
||||
this.PLCUDP.on("message", (res, remoteInfo) => {
|
||||
this.PLCMsg = res.message;
|
||||
})
|
||||
|
||||
if(terType == 1 && cardType == 1){
|
||||
this.GPSTCP = socket.constructTCPSocketInstance();
|
||||
await this.GPSTCP.bind({address:this.LocalIp,port:this.GPSLocalIpPort,family: 1});
|
||||
try {
|
||||
await this.GPSTCP.connect({address:{
|
||||
address:this.OppositeIp,port:this.GPSOppositeIpPort
|
||||
}});
|
||||
}catch (e) {
|
||||
console.info('surenjun e=>',JSON.stringify(e))
|
||||
}
|
||||
console.info('surenjun=>','3')
|
||||
this.GPSTCP.on("message", (res1, remoteInfo) => {
|
||||
let dataView = new DataView(res1.message)
|
||||
let str = ""
|
||||
for (let i = 0; i < dataView?.byteLength; ++i) {
|
||||
let c = String.fromCharCode(dataView?.getUint8(i))
|
||||
if (c !== "\n") {str += c}
|
||||
}
|
||||
this.GPSMsg = str;
|
||||
})
|
||||
}else{
|
||||
this.GPSUDP = socket.constructUDPSocketInstance();
|
||||
// this.GPSUDP.bind(this.GPSLocalIp, this.GPSLocalIpPort);
|
||||
await this.GPSUDP.bind({
|
||||
address: this.LocalIp, port: this.GPSLocalIpPort, family: 1
|
||||
});
|
||||
this.GPSUDP.on("message", (res1, remoteInfo) => {
|
||||
let dataView = new DataView(res1.message)
|
||||
let str = ""
|
||||
@ -71,10 +97,14 @@ export default class UdpByOne {
|
||||
this.GPSMsg = str;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// 重新绑定
|
||||
public rebind() {
|
||||
this.PLCUDP.bind(this.LocalIp, this.PLCLocalIpPort);
|
||||
this.GPSUDP.bind(this.LocalIp, this.GPSLocalIpPort);
|
||||
this.PLCUDP.rebind(this.LocalIp, this.PLCLocalIpPort);
|
||||
this.GPSUDP?.rebind(this.LocalIp, this.GPSLocalIpPort);
|
||||
this.GPSTCP?.rebind(this.LocalIp, this.GPSLocalIpPort);
|
||||
}
|
||||
|
||||
// PLC发送消息
|
||||
@ -83,7 +113,7 @@ export default class UdpByOne {
|
||||
data: '111111',
|
||||
address: {
|
||||
address: this.OppositeIp,
|
||||
port: parseInt(this.PLCOppositeIpPort),
|
||||
port: this.PLCOppositeIpPort,
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -96,6 +126,8 @@ export default class UdpByOne {
|
||||
// 处理消息
|
||||
public handleMsg() {
|
||||
let newMessage = PLCGPSData;
|
||||
const cardType = this.cardType;
|
||||
console.info('surenjun=> cardType',cardType)
|
||||
if (this.GPSMsg) {
|
||||
|
||||
let GPGGAMatch = this.GPSMsg.match(/\$GPGGA[^$]*/);
|
||||
@ -106,10 +138,14 @@ export default class UdpByOne {
|
||||
// 使用正则表达式提取$GPGST消息
|
||||
let GPGSTMatch = this.GPSMsg.match(/\$GPGST[^$]*/);
|
||||
let GPGSTMsgArr = GPGSTMatch ? GPGSTMatch[0]?.split(",").slice(0, 9) : [];
|
||||
|
||||
// 使用正则表达式提取$GPGST消息
|
||||
let GNGSTMatch = this.GPSMsg.match(/\$GNGST[^$]*/);
|
||||
let GNGSTMsgArr = GNGSTMatch ? GNGSTMatch[0]?.split(",").slice(0, 9) : [];
|
||||
|
||||
// 使用正则提取$PTNL消息
|
||||
let PTNLMatch = this.GPSMsg.match(/\$PTNL[^$]*/);
|
||||
let PTNLMsgArr = PTNLMatch ? PTNLMatch[0].split(",")?.slice(0, 14) : [];
|
||||
|
||||
// 组合GPS数据
|
||||
// 状态83
|
||||
newMessage[83] = GPGGAMsgArr[6];
|
||||
@ -122,11 +158,13 @@ export default class UdpByOne {
|
||||
// 龄期87
|
||||
newMessage[87] = GPGGAMsgArr[13];
|
||||
// 维度因子88
|
||||
newMessage[88] = GPGSTMsgArr[6];
|
||||
newMessage[88] = GPGSTMsgArr[6] || GNGSTMsgArr[6];
|
||||
// 经度因子89
|
||||
newMessage[89] = GPGSTMsgArr[7]
|
||||
newMessage[89] = GPGSTMsgArr[7] || GNGSTMsgArr[7];
|
||||
// 航向角90
|
||||
newMessage[90] = PTNLMsgArr[3];
|
||||
const hxj = Number(PTNLMsgArr[3])
|
||||
newMessage[90] = (cardType == 0 ? hxj : ((hxj + 180 > 360) ?(hxj + 180 - 360): hxj + 180)).toFixed(4)
|
||||
// newMessage[90] = PTNLMsgArr[3];
|
||||
// 俯仰角91
|
||||
newMessage[91] = PTNLMsgArr[5];
|
||||
// 航向角状态-收星数92
|
||||
@ -210,18 +248,19 @@ export default class UdpByOne {
|
||||
newMessage[25] = ((Data29 << 24) + (Data30 << 16) + (Data31 << 8) + Data32).toString();
|
||||
// 熄火次数 26
|
||||
newMessage[26] = parseInt(PLCByteArr[33], 2) + '';
|
||||
|
||||
// 方向盘角度 27
|
||||
// TODO 档位 磁档位为外接信号
|
||||
newMessage[28] = (globalThis.chuankoMsg == '0' || globalThis.chuankoMsg == '' ||globalThis.chuankoMsg == undefined)?(parseInt(PLCByteArr[13], 2) + ''): globalThis.chuankoMsg;
|
||||
|
||||
if(this.type == 1){
|
||||
if(this.terType == 1){
|
||||
// 超声波1
|
||||
newMessage[29] = (PLCByteArr[4][1] > 0 ? '300' : '1200')
|
||||
// 超声波2
|
||||
newMessage[30] = (PLCByteArr[4][0] > 0 ? '300': '1200' )
|
||||
}
|
||||
|
||||
if(this.type == 2){
|
||||
if(this.terType == 2){
|
||||
newMessage[29] = (parseInt(PLCByteArr[52], 2) > 10) ? '1200' : '300'
|
||||
newMessage[30] = (parseInt(PLCByteArr[54], 2) > 10) ? '1200': '300'
|
||||
}
|
||||
|
||||
@ -8,6 +8,8 @@ import GpsTcpClient from '../utils/GpsTcpClient'
|
||||
export default class RearEndUnitsTool {
|
||||
//一型机 二型机 三型机 一体机
|
||||
public terType: 0 | 1 | 2 | 3 = 2;
|
||||
//C1板卡 B4板卡
|
||||
public cardType: 0 | 1;
|
||||
public timer: number = 0
|
||||
public diffTimer: number = 0
|
||||
private UdpByOneClass: UdpByOne
|
||||
@ -21,6 +23,7 @@ export default class RearEndUnitsTool {
|
||||
|
||||
public receiveMsg = (callBack)=> {
|
||||
const terType = this.terType;
|
||||
const cardType = this.cardType;
|
||||
//TODO 临时处理关闭消息接收
|
||||
this.cancelMsg()
|
||||
|
||||
@ -28,8 +31,10 @@ export default class RearEndUnitsTool {
|
||||
//一型机
|
||||
case 0: {
|
||||
const udpClass = this.getFUdp({
|
||||
type: 1
|
||||
})
|
||||
terType: 1,
|
||||
cardType,
|
||||
});
|
||||
|
||||
this.timer = setInterval(() => {
|
||||
const message = udpClass.handleMsg()
|
||||
callBack && callBack(message)
|
||||
@ -40,7 +45,8 @@ export default class RearEndUnitsTool {
|
||||
//二型机
|
||||
case 1: {
|
||||
const udpClass = this.getFUdp({
|
||||
type: 2
|
||||
terType: 2,
|
||||
cardType
|
||||
})
|
||||
this.timer = setInterval(() => {
|
||||
const message = udpClass.handleMsg()
|
||||
@ -88,13 +94,14 @@ export default class RearEndUnitsTool {
|
||||
const result = JSON.parse(config || '{}')
|
||||
//默认设置为三代机
|
||||
this.terType = result.terType
|
||||
this.cardType = result.cardType
|
||||
return this.terType
|
||||
}
|
||||
|
||||
//获取一型机&二型机单例
|
||||
private getFUdp({type}) {
|
||||
private getFUdp({terType,cardType}) {
|
||||
if (!this.UdpByOneClass) {
|
||||
this.UdpByOneClass = new UdpByOne(type);
|
||||
this.UdpByOneClass = new UdpByOne(terType,cardType);
|
||||
}
|
||||
return this.UdpByOneClass;
|
||||
}
|
||||
@ -118,6 +125,7 @@ export default class RearEndUnitsTool {
|
||||
// 转发差分改正数
|
||||
public sendDiffCorrections = (message) => {
|
||||
const type = this.terType
|
||||
const cardType = this.cardType
|
||||
//差分改正数截取前5位
|
||||
let dataView = new DataView(message)
|
||||
const Arraybuffer = message.slice(5, dataView?.byteLength);
|
||||
@ -125,8 +133,13 @@ export default class RearEndUnitsTool {
|
||||
switch (type){
|
||||
//一型机
|
||||
case 0:
|
||||
//天宝类型板卡
|
||||
if(cardType === 1){
|
||||
globalThis.udpClient?.sendMsg(Arraybuffer);break
|
||||
}else{
|
||||
const GpsTcpClientClass = this.getGpsTcp()
|
||||
GpsTcpClientClass.sendGpsMsg(Arraybuffer);break
|
||||
}
|
||||
|
||||
//二型机
|
||||
case 1: globalThis.udpClient?.sendMsg(Arraybuffer);break
|
||||
|
||||
@ -21,8 +21,10 @@ struct Index {
|
||||
// @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 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 terTextList: string[] = ['一型机', '二型机', '三型机', '一体机']
|
||||
@State cardTextList: string[] = ['北云', '天宝MB2']
|
||||
@State netTextList: string[] = ['否', '是']
|
||||
@State selectedTerType: number = 0
|
||||
@State selectedCardType: number = 0
|
||||
//是否启用网络差分
|
||||
@State netOpen: number = 0
|
||||
// @State inputTextList2: string[] = []
|
||||
@ -94,6 +96,7 @@ struct Index {
|
||||
})
|
||||
}.width('50%').height('14%')
|
||||
|
||||
|
||||
Row() {
|
||||
Text('是否启用网络差分')
|
||||
.width('40%')
|
||||
@ -113,7 +116,30 @@ struct Index {
|
||||
})
|
||||
Text(netText).fontSize(20).fontColor('#FFF')
|
||||
})
|
||||
}.width('52%').height('14%')
|
||||
}.width('51%').height('14%')
|
||||
|
||||
|
||||
Row(){
|
||||
Text('板卡类型')
|
||||
.width('40%')
|
||||
.height('100%')
|
||||
.fontColor('#E5CBA1')
|
||||
.padding({ 'left': '35px' })
|
||||
.fontSize(this.inputFontSize * this.ratio)
|
||||
|
||||
ForEach(this.cardTextList, (cardText, index) => {
|
||||
Radio({ value: cardText, group: 'cardRadioGroup' })
|
||||
.borderColor('#E5CBA1')
|
||||
.checked(index === this.selectedCardType)
|
||||
.onChange((value: boolean) => {
|
||||
if(value){
|
||||
this.selectedCardType = index
|
||||
}
|
||||
})
|
||||
Text(cardText).fontSize(20).fontColor('#FFF')
|
||||
})
|
||||
}.width('49%').height('14%')
|
||||
|
||||
}
|
||||
}
|
||||
.width('95%')
|
||||
@ -145,6 +171,7 @@ struct Index {
|
||||
centerIp: this.inputTextList1[2],
|
||||
centerPort: this.inputTextList1[3],
|
||||
terType: this.selectedTerType,
|
||||
cardType: this.selectedCardType,
|
||||
netOpen: this.netOpen
|
||||
}
|
||||
fileUtil.addFile(`${folderPath}/ipConfig.txt`, JSON.stringify(param), '')
|
||||
@ -218,6 +245,7 @@ struct Index {
|
||||
this.inputTextList1[2] = result.centerIp
|
||||
this.inputTextList1[3] = result.centerPort
|
||||
this.selectedTerType = result.terType
|
||||
this.selectedCardType = result.cardType
|
||||
this.netOpen= result.netOpen
|
||||
console.log('surenjun', this.selectedTerType + '');
|
||||
}
|
||||
|
||||
@ -3,8 +3,9 @@ import Judge from '../../judgeSDK/utils/judgeReal';
|
||||
import { MarkRule, Project, ProjectObj } from '../../judgeSDK/api/judgeSDK.d';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import {
|
||||
examJudgeMapSetScaling
|
||||
examJudgeMapSetScaling, examJudgeVersion
|
||||
} from '../../judgeSDK/api'
|
||||
import { judgeConfig } from '../../judgeSDK/utils/judgeConfig';
|
||||
|
||||
interface RoadDataType {
|
||||
name: string,
|
||||
@ -30,6 +31,8 @@ export default struct RealTime {
|
||||
@State ratio: number = 1
|
||||
@State lane: Object = {}
|
||||
@State timer:number = 0
|
||||
@State version: string = ""
|
||||
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
@ -67,11 +70,11 @@ export default struct RealTime {
|
||||
|
||||
Column() {
|
||||
if (this.draw) {
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
XComponent({
|
||||
id: 'duolun_plugin_id_draw', //显示轨迹窗口id名称,注意这个ID要和C++侧一致,不能变
|
||||
type: 'surface',
|
||||
libraryname: 'JudgeSdk'
|
||||
// libraryname: 'judgesdk'
|
||||
})
|
||||
.width(this.widthNumber)
|
||||
.height(this.heightNumber)
|
||||
@ -83,6 +86,12 @@ export default struct RealTime {
|
||||
this.draw = false;
|
||||
clearInterval(globalThis.realTimer)
|
||||
})
|
||||
|
||||
}.width(this.widthNumber)
|
||||
.height(this.heightNumber)
|
||||
Row() {
|
||||
Text(this.version).margin({ right: 10 }).fontSize(14).fontColor(0x333333)
|
||||
}
|
||||
} else {
|
||||
Column() {
|
||||
}
|
||||
@ -108,7 +117,10 @@ export default struct RealTime {
|
||||
async aboutToDisappear() {
|
||||
clearInterval(this.timer)
|
||||
}
|
||||
|
||||
async aboutToAppear() {
|
||||
this.version = (await examJudgeVersion()) + "/" + judgeConfig.version
|
||||
|
||||
const judge = new Judge(this)
|
||||
let timer = setInterval(()=>{
|
||||
this.lane = globalThis.laneData;
|
||||
|
||||
@ -55,7 +55,7 @@ import {
|
||||
examJudgeVersion
|
||||
} from './api/index';
|
||||
import { getSyncData, upDateTableByArray } from '../../common/service/initable';
|
||||
|
||||
import { GlobalConfig } from '../../config';
|
||||
const judgeTag = 'SURENJUN_JUDGE'
|
||||
|
||||
function ifNeedRetry(code: number | string): boolean {
|
||||
@ -276,6 +276,7 @@ export default class Judge {
|
||||
}
|
||||
private fileLog
|
||||
private filePath
|
||||
private bklx: number = 0
|
||||
private totalScore: number
|
||||
private prevJd: number = 0
|
||||
private prevWd: number = 0
|
||||
@ -726,12 +727,15 @@ export default class Judge {
|
||||
|
||||
// 获取评判初始化数据
|
||||
getJudgeInitData = async () => {
|
||||
const {getModelData,getKm3JudgeInitConfig} = this
|
||||
const {getModelData,getKm3JudgeInitConfig,bklx} = this
|
||||
const carInfo = globalThis.carInfo;
|
||||
const { examSubject,plateNo,carId } = carInfo;
|
||||
const judgeUI = this.judgeUI
|
||||
const {projectsObj,itemInfoObj,markRuleListObj,carType,carName,systemparmArr,carinfoArr} = judgeUI
|
||||
const examType = examSubject == 2 ? 'km2' : 'km3'
|
||||
const fileUtil = new FileUtil(globalThis.context)
|
||||
const ipConfigStr = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
|
||||
const ipConfig = JSON.parse(ipConfigStr)
|
||||
|
||||
let allitems = [];
|
||||
if (examSubject == 2) {
|
||||
@ -768,6 +772,8 @@ export default class Judge {
|
||||
itemInfoObj,
|
||||
carlist: judgeUI.carlist,
|
||||
carinfo: carinfoArr,
|
||||
//板卡类型
|
||||
bklx,
|
||||
};
|
||||
let km3Config = {}
|
||||
|
||||
@ -1752,8 +1758,14 @@ export default class Judge {
|
||||
const filePath = await fileLog.initFileLogo({
|
||||
name, lsh, idCard
|
||||
});
|
||||
|
||||
const ipFileUtil = new FileUtil(globalThis.context)
|
||||
const ipConfigStr = await ipFileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
|
||||
const ipConfig = JSON.parse(ipConfigStr)
|
||||
|
||||
this.fileLog = fileLog;
|
||||
this.filePath = filePath;
|
||||
this.bklx = Number(ipConfig.cardType)
|
||||
|
||||
const {
|
||||
getJudgeBeginData,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
//考试回放开关
|
||||
export const judgeConfig = {
|
||||
version:'2024.08.21.01',
|
||||
//本地目录开关
|
||||
isTrajectoryOpen: false,
|
||||
//是否开启拍照
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user