一代机
This commit is contained in:
		
							parent
							
								
									956e57ee8a
								
							
						
					
					
						commit
						8e53b2025f
					
				| @ -5,19 +5,19 @@ export default class UdpByOne { | |||||||
|   //   PLC udp
 |   //   PLC udp
 | ||||||
|   private PLCUDP: any; |   private PLCUDP: any; | ||||||
|   // PLC localIp
 |   // PLC localIp
 | ||||||
|   private PLCLocalIp: string; |   private PLCLocalIp: string='192.168.7.170'; | ||||||
|   // PLC localIpPort
 |   // PLC localIpPort
 | ||||||
|   private PLCLocalIpPort: string; |   private PLCLocalIpPort: string='31012'; | ||||||
|   // PLC oppositeIpPort
 |   // PLC oppositeIpPort
 | ||||||
|   private PLCOppositeIpPort: string; |   private PLCOppositeIpPort: string='30012'; | ||||||
|   // PLC消息
 |   // PLC消息
 | ||||||
|   private PLCMsg: number[]; |   private PLCMsg: number[]; | ||||||
|   //   GPS udp
 |   //   GPS udp
 | ||||||
|   private GPSUDP: any; |   private GPSUDP: any; | ||||||
|   // GPS localIp
 |   // GPS localIp
 | ||||||
|   private GPSLocalIp: string; |   private GPSLocalIp: string='192.168.7.124'; | ||||||
|   // GPS localIpPort
 |   // GPS localIpPort
 | ||||||
|   private GPSLocalIpPort: string; |   private GPSLocalIpPort: string='30013'; | ||||||
|   // GPS oppositeIpPort
 |   // GPS oppositeIpPort
 | ||||||
|   private GPSOppositeIpPort: string; |   private GPSOppositeIpPort: string; | ||||||
|   // GPS消息
 |   // GPS消息
 | ||||||
| @ -26,9 +26,13 @@ export default class UdpByOne { | |||||||
|   constructor() { |   constructor() { | ||||||
|     //   初始化UDP
 |     //   初始化UDP
 | ||||||
|     this.PLCUDP = socket.constructUDPSocketInstance(); |     this.PLCUDP = socket.constructUDPSocketInstance(); | ||||||
|     this.PLCUDP.bind(this.PLCLocalIp, this.PLCLocalIpPort); |     // this.PLCUDP.bind(this.PLCLocalIp, this.PLCLocalIpPort);
 | ||||||
|     this.GPSUDP = socket.constructUDPSocketInstance(); |     this.PLCUDP.bind({ | ||||||
|     this.GPSUDP.bind(this.GPSLocalIp, this.GPSLocalIpPort); |       // address: '192.168.7.170', port: 20122, family: 1
 | ||||||
|  |       address: this.PLCLocalIp, port: parseInt(this.PLCLocalIpPort), family: 1 | ||||||
|  |     }); | ||||||
|  |     // this.GPSUDP = socket.constructUDPSocketInstance();
 | ||||||
|  |     // this.GPSUDP.bind(this.GPSLocalIp, this.GPSLocalIpPort);
 | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   //   重新绑定
 |   //   重新绑定
 | ||||||
| @ -39,7 +43,14 @@ export default class UdpByOne { | |||||||
| 
 | 
 | ||||||
|   //   PLC发送消息
 |   //   PLC发送消息
 | ||||||
|   public sendPLCMsg(msg: string) { |   public sendPLCMsg(msg: string) { | ||||||
|     this.PLCUDP.sendTo(msg, this.PLCOppositeIpPort); |     this.PLCUDP.send({ | ||||||
|  |       data: '111111', | ||||||
|  |       address: { | ||||||
|  |         address: '192.168.7.124', | ||||||
|  |         port: parseInt(this.PLCOppositeIpPort), | ||||||
|  |       } | ||||||
|  |     }) | ||||||
|  |     // this.PLCUDP.sendTo(msg, this.PLCOppositeIpPort);
 | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   //   GPS发送消息
 |   //   GPS发送消息
 | ||||||
| @ -49,7 +60,19 @@ export default class UdpByOne { | |||||||
| 
 | 
 | ||||||
|   // 接受消息
 |   // 接受消息
 | ||||||
|   public receiveMsg(callback) { |   public receiveMsg(callback) { | ||||||
|  |     console.log('heartMsg','getCallback') | ||||||
|  |     this.sendPLCMsg('1111') | ||||||
|  |     this.PLCUDP.on("message", (message2, remoteInfo) => { | ||||||
|  |       console.log('heartMsg','getPlc') | ||||||
|  | 
 | ||||||
|  |       this.PLCMsg = message2; | ||||||
|  |       //   组合数据
 | ||||||
|  |       let newMessage = this.handleMsg() | ||||||
|  |       callback(newMessage) | ||||||
|  |     }) | ||||||
|  |     return | ||||||
|     this.GPSUDP.on("message", (message1, remoteInfo) => { |     this.GPSUDP.on("message", (message1, remoteInfo) => { | ||||||
|  |       console.log('heartMsg','GPSUDP') | ||||||
|       this.GPSMsg = message1; |       this.GPSMsg = message1; | ||||||
|       this.PLCUDP.on("message", (message2, remoteInfo) => { |       this.PLCUDP.on("message", (message2, remoteInfo) => { | ||||||
|         this.PLCMsg = message2; |         this.PLCMsg = message2; | ||||||
| @ -67,6 +90,7 @@ export default class UdpByOne { | |||||||
|     // $GPGST,021126.00,3.30,1.77,3.30,0.0000,1.77,1.25,3.30*67
 |     // $GPGST,021126.00,3.30,1.77,3.30,0.0000,1.77,1.25,3.30*67
 | ||||||
|     // $PTNL,AVR,021126.00,+47.3119,Yaw,+0.4832,Tilt,,,0.817,3,1.7,25*09`
 |     // $PTNL,AVR,021126.00,+47.3119,Yaw,+0.4832,Tilt,,,0.817,3,1.7,25*09`
 | ||||||
|     let newMessage = PLCGPSData; |     let newMessage = PLCGPSData; | ||||||
|  |     console.log('heartMsg000',PLCGPSData) | ||||||
|     //   海拔高度
 |     //   海拔高度
 | ||||||
|     // 原始GPS消息字符串
 |     // 原始GPS消息字符串
 | ||||||
|     this.GPSMsg = `$GPGGA,021126.00,2955.5885178,N,11953.8931034,E,5,12,0.8,13.191,M,6.838,M,2.000,0000*49$GPRMC,021126.00,A,2955.5885178,N,11953.8931034,E,4.881,318.3,170623,0.0,E,F*37$GPGST,021126.00,3.30,1.77,3.30,0.0000,1.77,1.25,3.30*67$PTNL,AVR,021126.00,+47.3119,Yaw,+0.4832,Tilt,,,0.817,3,1.7,25*09`; |     this.GPSMsg = `$GPGGA,021126.00,2955.5885178,N,11953.8931034,E,5,12,0.8,13.191,M,6.838,M,2.000,0000*49$GPRMC,021126.00,A,2955.5885178,N,11953.8931034,E,4.881,318.3,170623,0.0,E,F*37$GPGST,021126.00,3.30,1.77,3.30,0.0000,1.77,1.25,3.30*67$PTNL,AVR,021126.00,+47.3119,Yaw,+0.4832,Tilt,,,0.817,3,1.7,25*09`; | ||||||
| @ -216,6 +240,8 @@ export default class UdpByOne { | |||||||
|     // GPS错误次数 60
 |     // GPS错误次数 60
 | ||||||
|     // 已工作时长/设定的工作时长 61
 |     // 已工作时长/设定的工作时长 61
 | ||||||
|     // 改正数数据长度*数据长度-基准站RTCM改正数类型 62
 |     // 改正数数据长度*数据长度-基准站RTCM改正数类型 62
 | ||||||
|  |     console.log('heartMsgend',newMessage.join(",")) | ||||||
|  | 
 | ||||||
|     return newMessage.join(",") |     return newMessage.join(",") | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user