小红球udp
This commit is contained in:
		
							parent
							
								
									1671d57221
								
							
						
					
					
						commit
						6ef29e8144
					
				| @ -4,7 +4,6 @@ import { | |||||||
|   JudgeKSJS, |   JudgeKSJS, | ||||||
|   JudgePerformInfo, |   JudgePerformInfo, | ||||||
|   LANE, |   LANE, | ||||||
|   MarkRule, |  | ||||||
|   PLCType, |   PLCType, | ||||||
|   ProcessDataEnumType, |   ProcessDataEnumType, | ||||||
|   RecordHandleType, |   RecordHandleType, | ||||||
| @ -23,6 +22,7 @@ import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSigna | |||||||
| import { PlcStrToJson, PlcStrToWXJson } from './utils' | import { PlcStrToJson, PlcStrToWXJson } from './utils' | ||||||
| import { BaseJudgeImpl, SetJudgeItem } from './BaseJudgeBussines' | import { BaseJudgeImpl, SetJudgeItem } from './BaseJudgeBussines' | ||||||
| import { JudgePage } from '../Judge'; | import { JudgePage } from '../Judge'; | ||||||
|  | import { JudgeUdpBusinessInstance } from '../../utils/business/JudgeUdpBusiness' | ||||||
| 
 | 
 | ||||||
| export default class JudgeBusiness { | export default class JudgeBusiness { | ||||||
|   public mndgStr: string | undefined |   public mndgStr: string | undefined | ||||||
| @ -60,8 +60,8 @@ export default class JudgeBusiness { | |||||||
|   private judgeUI: JudgePage |   private judgeUI: JudgePage | ||||||
|   private tempData?: PLCType |   private tempData?: PLCType | ||||||
|   // 是否发送udp |   // 是否发送udp | ||||||
|   private isUdpEnd: boolean = false |  | ||||||
|   private judgeBusiness: BaseJudgeImpl |   private judgeBusiness: BaseJudgeImpl | ||||||
|  |   private udpCount: number = 0 | ||||||
| 
 | 
 | ||||||
|   constructor(judgeUI: JudgePage) { |   constructor(judgeUI: JudgePage) { | ||||||
|     this.judgeUI = judgeUI |     this.judgeUI = judgeUI | ||||||
| @ -138,8 +138,9 @@ export default class JudgeBusiness { | |||||||
| 
 | 
 | ||||||
|   // 处理PLC数据 |   // 处理PLC数据 | ||||||
|   private async HandlePLCData(msg: string) { |   private async HandlePLCData(msg: string) { | ||||||
|  |     this.udpCount++ | ||||||
|     const plcArr = msg.split(',') |     const plcArr = msg.split(',') | ||||||
|     if (plcArr[0] != '#DN_GD' || this.isUdpEnd) { |     if (plcArr[0] != '#DN_GD' || this.isExamEnd) { | ||||||
|       return |       return | ||||||
|     } |     } | ||||||
|     const gpsPart = msg.split("#END$GPS,")[1]; |     const gpsPart = msg.split("#END$GPS,")[1]; | ||||||
| @ -170,6 +171,12 @@ export default class JudgeBusiness { | |||||||
|     const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350') |     const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350') | ||||||
|     this.judgeUI.sd = ((param350 == 0 ? this.plcData.gps.sd : this.plcData.sensor.cs) as number * 1.852).toFixed(0) + '' |     this.judgeUI.sd = ((param350 == 0 ? this.plcData.gps.sd : this.plcData.sensor.cs) as number * 1.852).toFixed(0) + '' | ||||||
|     this.judgeUI.dw = (Math.floor(this.plcData.sensor.dw as number) || 0) + '' |     this.judgeUI.dw = (Math.floor(this.plcData.sensor.dw as number) || 0) + '' | ||||||
|  | 
 | ||||||
|  |     if (this.udpCount % 5 === 0 && !this.isExamEnd) { | ||||||
|  |       const bytes = await JudgeUdpBusinessInstance.getMessageHeartbeat(msg); | ||||||
|  |       JudgeUdpBusinessInstance.sendData(bytes) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     if (!this.isExamEnd) { |     if (!this.isExamEnd) { | ||||||
|       await examJudgeRealExam(this.plcData) |       await examJudgeRealExam(this.plcData) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -82,7 +82,7 @@ export default class UdpClient { | |||||||
|         address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1 |         address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1 | ||||||
|       } |       } | ||||||
|     }).then(res => { |     }).then(res => { | ||||||
|       // console.log(UDPTag, "udp发送成功", JSON.stringify(res)) |       console.log(UDPTag, "udp发送成功", JSON.stringify(res)) | ||||||
|     }).catch((e: BusinessError) => { |     }).catch((e: BusinessError) => { | ||||||
|       console.error(UDPTag, "udp发送失败", JSON.stringify(e)) |       console.error(UDPTag, "udp发送失败", JSON.stringify(e)) | ||||||
|     }) |     }) | ||||||
|  | |||||||
| @ -43,6 +43,7 @@ class CenterUDPBusiness { | |||||||
|     console.log(CenterUdpTag, "心跳", JSON.stringify(this.carInfo)) |     console.log(CenterUdpTag, "心跳", JSON.stringify(this.carInfo)) | ||||||
|     // 组装消息,一秒发送一次 |     // 组装消息,一秒发送一次 | ||||||
|     this.timer = setInterval(() => { |     this.timer = setInterval(() => { | ||||||
|  |       console.log(CenterUdpTag, "发送心跳") | ||||||
|       // 生成流水号 |       // 生成流水号 | ||||||
|       SerialNumberInstance.generate() |       SerialNumberInstance.generate() | ||||||
|       // console.log(CenterUdpTag, "流水号生成") |       // console.log(CenterUdpTag, "流水号生成") | ||||||
|  | |||||||
| @ -50,7 +50,7 @@ function initFn(result: WorkerMessage) { | |||||||
|   // 中心心跳 |   // 中心心跳 | ||||||
|   CenterUDPBusinessInstance.startHeartBeat() |   CenterUDPBusinessInstance.startHeartBeat() | ||||||
|   // 初始化考试过程UDP |   // 初始化考试过程UDP | ||||||
|   // JudgeUdpBusinessInstance.init(result.config, result.carInfo, result?.singlePlay || false, result.otherMessage.lsh) |   JudgeUdpBusinessInstance.init(result.config, result.carInfo, result?.singlePlay || false, result.otherMessage.lsh) | ||||||
|   //   初始化档位信号串口 |   //   初始化档位信号串口 | ||||||
|   if (result.config.carType !== "2") { |   if (result.config.carType !== "2") { | ||||||
|     SerialPortService.init() |     SerialPortService.init() | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user