public Session(ISpawnable spawnable, string line_terminator) { _spawnable = spawnable; LineTerminator = line_terminator; Expect = new ExpectCommands(this); Send = new SendCommands(this); }
void Start() { panelConnection.SetActive(true); panelGame.SetActive(false); panelVictory.SetActive(false); sendCommands = GetComponent <SendCommands>(); receiveCommands = GetComponent <ReceiveCommands>(); }
public Session(ISpawnable spawnable, string line_terminator, CancellationToken ct) { _spawnable = spawnable; LineTerminator = line_terminator; Expect = new ExpectCommands(this); Send = new SendCommands(this); Ct = ct; }
/// <summary> /// 检测板重新标定指令下发 /// </summary> /// <param name="deviceNo">设备编号</param> /// <returns>SendCommandDto:是否下发成功及时间戳</returns> public async Task <SendCommandDto> ReCalibration(string deviceNo) { Task <SendCommandDto> taskDto = new Task <SendCommandDto>(() => { SendCommandDto dto = new SendCommandDto(); dto.IsSuccess = false; if (string.IsNullOrWhiteSpace(deviceNo)) { return(dto); } //查找设备是否存在且在线连接 var model = this._deviceInfo.GetAll().Where(d => d.DeviceNo == deviceNo && d.DeviceStatus == 1).FirstOrDefault(); if (model == null) { return(dto); } //查看设备绑定的IP地址 var iPmodel = this._deviceIPEndPort.GetAll().Where(p => p.IsUseing == true && p.DeviceNo == deviceNo).FirstOrDefault(); if (iPmodel == null || string.IsNullOrWhiteSpace(iPmodel.IpEndPort)) { return(dto); } IPAddress IPadr = IPAddress.Parse(iPmodel.IpEndPort.Split(':')[0]);//先把string类型转换成IPAddress类型 IPEndPoint ipEndPort = new IPEndPoint(IPadr, int.Parse(iPmodel.IpEndPort.Split(':')[1])); string timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss"); string cmd = SendCommands.STestingBoardAgainSet(deviceNo, timeStamp); //插入数据记录帧 Command_Log cmdLog = new Command_Log { DeviceNo = deviceNo, CommandType = "A6", Tstamp = timeStamp, AddTime = DateTime.Now, SendType = 0, CmdStatus = 0 }; _commandLog.InsertAsync(cmdLog); //指令下发 bool ret = UdpCommunication.UpdSendMessage(cmd, ipEndPort); if (ret) { cmdLog.CmdStatus = 1; _commandLog.InsertOrUpdateAsync(cmdLog); dto.IsSuccess = true; dto.TimeStamp = timeStamp; } return(dto); }); taskDto.Start(); return(await taskDto); }