dev #65
@ -17,9 +17,9 @@ export default class UdpByOne {
|
||||
private GPSUDP: any;
|
||||
// GPS localIp
|
||||
// GPS localIpPort
|
||||
private GPSLocalIpPort: string = '30013';
|
||||
private GPSLocalIpPort: string = '31013';
|
||||
// GPS oppositeIpPort
|
||||
private GPSOppositeIpPort: string;
|
||||
private GPSOppositeIpPort: string = '30013';
|
||||
// GPS消息
|
||||
private GPSMsg: string;
|
||||
|
||||
@ -60,7 +60,7 @@ export default class UdpByOne {
|
||||
data: '111111',
|
||||
address: {
|
||||
address: this.OppositeIp,
|
||||
port: parseInt(this.PLCOppositeIpPort),
|
||||
port: parseInt(this.GPSOppositeIpPort),
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -70,29 +70,39 @@ export default class UdpByOne {
|
||||
console.log('heartMsg', 'getCallback')
|
||||
this.sendPLCMsg('1111')
|
||||
this.sendGPSMsg('1111')
|
||||
// this.PLCUDP.on("message", (res, remoteInfo) => {
|
||||
// console.log('heartMsg', 'getPlc')
|
||||
//
|
||||
// this.PLCMsg = res.message;
|
||||
// // 组合数据
|
||||
// let newMessage = this.handleMsg()
|
||||
// callback(newMessage)
|
||||
// })
|
||||
// return
|
||||
this.PLCUDP.on("message", (res, remoteInfo) => {
|
||||
console.log('heartMsg', 'getPlc')
|
||||
|
||||
this.PLCMsg = res.message;
|
||||
// 组合数据
|
||||
let newMessage = this.handleMsg(res.message)
|
||||
callback(newMessage)
|
||||
})
|
||||
return
|
||||
this.GPSUDP.on("message", (res1, remoteInfo) => {
|
||||
console.log('heartMsg', 'GPSUDP')
|
||||
this.GPSMsg = res1.message;
|
||||
this.PLCUDP.on("message", (res2, 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;
|
||||
console.log('heartMsgGPSstr', str)
|
||||
return this.PLCUDP.on("message", (res2, remoteInfo) => {
|
||||
this.PLCMsg = res2.message;
|
||||
// 组合数据
|
||||
let newMessage = this.handleMsg()
|
||||
callback(newMessage)
|
||||
// let newMessage = this.handleMsg()
|
||||
// callback(newMessage)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 处理消息
|
||||
public handleMsg() {
|
||||
public handleMsg(plcMessage) {
|
||||
let newMessage = PLCGPSData;
|
||||
console.log('heartMsg000', PLCGPSData)
|
||||
// 海拔高度
|
||||
@ -141,9 +151,16 @@ export default class UdpByOne {
|
||||
newMessage[96] = GPGGAMsgArr[2];
|
||||
// 速度97
|
||||
newMessage[97] = GPRMCMsgArr[7];
|
||||
|
||||
let PLCByteArr = this.PLCMsg.map((num) => num.toString(2).padStart(8, "0"));
|
||||
console.log(PLCByteArr[1][2]);
|
||||
let dataView = new DataView(plcMessage)
|
||||
let PLCByteArr = []
|
||||
for (let i = 0; i < dataView?.byteLength; ++i) {
|
||||
let c = dataView?.getUint8(i).toString(2).padStart(8, "0")
|
||||
console.log('heartMsgheartMsg', c)
|
||||
PLCByteArr.push(c.toString())
|
||||
}
|
||||
// return
|
||||
// let PLCByteArr = this.PLCMsg.map((num) => num.toString(2).padStart(8, "0"));
|
||||
console.log("heartMsgheartMsg1", PLCByteArr.toString());
|
||||
// 左方向灯 2
|
||||
newMessage[2] = PLCByteArr[6][2];
|
||||
// 右方向灯 3
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user