public void PushSendCmd(ITcpCommand tcpCmd) { lock (_sendCmdQueue) { _sendCmdQueue.Enqueue(tcpCmd); } }
internal VisionSensorIVHSeries( IDataRepository dataRepository, IErrorRepository errorRepository, ITcpCommand command) : base(dataRepository, errorRepository, command) { }
public void PushAutoCmd(ITcpCommand tcpCmd) { lock (_recvAutoCmdQueue)//Todo:可以验证这种Lock方式是否正确 { _recvAutoCmdQueue.Enqueue(tcpCmd); } }
internal VisionSensor( IDataRepository dataRepository, IErrorRepository errorRepository, ITcpCommand command) { this.Command = command; this.DataRepository = dataRepository; this.ErrorRepository = errorRepository; try { this.Sequencer = new CommandSequencer(dataRepository, command); this.AutoCommunicator = new AutoCommunicator(dataRepository, command); this.Sequencer.VerifyTargetJustAfterConnectionConfirmed(); } catch (ConnectionLostException ex) { this.Dispose(); throw; } this.AutoCommunicator.ImageAcquired += new ImageAcquiredEventHandler(this.MediateImageAcquiredEvent); this.AutoCommunicator.ResultUpdated += new ToolResultUpdatedEventHandler(this.MediateToolResultUpdatedEvent); errorRepository.ErrorStatusUpdated += new ErrorDetectedEventHandler(this.MediateErrorDetectedEvent); this.Sequencer.ProgramSettingsUpdated += new ProgramSettingsUpdatedEventHandler(this.MediateProgramSettingsUpdatedEvent); this.AutoCommunicator.ProgramSettingsUpdated += new ProgramSettingsUpdatedEventHandler(this.MediateProgramSettingsUpdatedEvent); }
public IConnection CreateConnection(IPAddress ipAddress, ushort portNo) { this._connection = (IConnection) new VisionSensorConection(this._startAddress, ipAddress, portNo); this._command = (ITcpCommand) new CheckedTcpCommand(this._connection); this._dataRepository = (IDataRepository) new Keyence.IV.Sdk.Communication.DataRepository(); this._errorRepository = (IErrorRepository) new Keyence.IV.Sdk.Communication.ErrorRepository(this._command); return(this._connection); }
public void SendOneCmd(string serverip, ITcpCommand cmd) { _rwLock.EnterReadLock(); var clientIO = _clientIODir.Where(clientPair => clientPair.Key.IpAddr.Equals(IPAddress.Parse(serverip))) .Select(clientPair => clientPair.Value).FirstOrDefault(); _rwLock.ExitReadLock(); clientIO.PushSendCmd(cmd); }
public bool IsAutoCmd(ITcpCommand tcpCmd) { var getCmd = tcpCmd.GetCmdCode(); if (getCmd == CmdCode.Heart) { return(true); } return(false); }
public ITcpCommand GetRecvResponseCmd(CmdCode cmdCode) { ITcpCommand resultTcpCmd = _recvResponseCmdList .Where(tcpCmd => tcpCmd.GetCmdCode() == cmdCode).FirstOrDefault(); if (resultTcpCmd == null) { return(null); } _recvResponseCmdList.Remove(resultTcpCmd); return(resultTcpCmd); }
public void FreshPacket(ITcpCommand tcpCmd) { base._Pack_Data = null; //直接使用命令数据而不是数组 if (tcpCmd.GetNetStream() == null) { base._Pack_Length = (uint)(_minSize); } else { base._Pack_Length = (uint)(_minSize + tcpCmd.GetNetStream().Length); } base._Pack_CmdID = _cmdIdCount++; this._Pack_CmdCode = tcpCmd.GetCmdCode(); this._tcpCmd = tcpCmd; InitNetStream(); }
private void ProcessRecvPacket() { UInt32 recvedCmdId = _recvPacket.GetCurrentCmdId(); byte[] recvedData = _recvPacket.GetCurrentCmdData(); CmdCode recvedCmdCode = _CmdIdToCodeDir[recvedCmdId]; _CmdIdToCodeDir.Remove(recvedCmdId); ITcpCommand repTcpCmd = TcpCommandConstructer.Create(recvedCmdCode, recvedData); lock (_recvedCmdQueue) { _recvedCmdQueue.Enqueue(repTcpCmd); } }
//发送一条命令 public void SendOneCmd(ITcpCommand tcpCmd) { int oneSendSizeMax = 1024; //每次发送的最大大小 int processCount = 1; //过程计数,1个单位表示10% byte[] sendBuf = new byte[oneSendSizeMax]; _sendPacket.FreshPacket(tcpCmd); var packetStream = _sendPacket.GetNetStream(); var netStream = _client.GetStream(); //记录该条发送的命令号与命令码的绑定 _CmdIdToCodeDir.Add(_sendPacket.GetCurrentCmdId(), tcpCmd.GetCmdCode()); MainForm.SetOutPutText(String.Format("SendOneCmd:start to send:cmd={0},size={1}", tcpCmd.GetCmdCode(), packetStream.Length)); while (true) { //发送数据 int retSize = packetStream.Read(sendBuf, 0, oneSendSizeMax); if (retSize == 0) { break; } netStream.Write(sendBuf, 0, retSize); //打印传输的进度 if (tcpCmd.GetCmdCode() == CmdCode.UpLoadApp) { if (packetStream.Position == (packetStream.Length / 1024) * processCount / 10 * 1024) { MainForm.SetOutPutText(string.Format("SendOneCmd:process {0}%", processCount * 10)); processCount++; } } } MainForm.SetOutPutText("SendOneCmd:send over"); //MainForm.SetOutPutText(_sendPacket.ToString()); }
internal ErrorRepository(ITcpCommand command) { this._command = command; command.GetError += new EventHandler <SensorErrorCollection>(this.AddError); }
internal AutoCommunicator(IDataRepository repository, ITcpCommand command) { this._repository = repository; this._command = command; }
public void AddRecvResponseCmd(ITcpCommand tcpCmd) { _recvResponseCmdList.Add(tcpCmd); }
public void ProcAutoCmd(ITcpCommand tcpCmd) { MainForm.SetOutPutText(String.Format("TcpAutoCmdProcer_Log:cmdCode = {0}", tcpCmd.GetCmdCode().ToString())); }
internal CommandSequencer(IDataRepository repository, ITcpCommand command) { this._repository = repository; this._command = command; }