public void Connect() { try { eipClient = new EIPClient() { IPAddress = Settings.IpAddress, TCPPort = (ushort)Settings.Port }; // omron NX1P2 = "192.168.1.3" eipClient.RegisterSession(); //Parameters from Originator -> Target eipClient.O_T_InstanceID = Settings.AssemblyOut; eipClient.O_T_Length = eipClient.Detect_O_T_Length(); eipClient.O_T_RealTimeFormat = EIP.RealTimeFormat.Header32Bit; //Header Format eipClient.O_T_OwnerRedundant = false; eipClient.O_T_Priority = EIP.Priority.Scheduled; eipClient.O_T_VariableLength = false; eipClient.O_T_ConnectionType = EIP.ConnectionType.Point_to_Point; eipClient.RequestedPacketRate_O_T = Settings.RPI; //RPI (microseconds) //Parameters from Target -> Originator eipClient.T_O_InstanceID = Settings.AssemblyIn; eipClient.T_O_Length = eipClient.Detect_T_O_Length(); eipClient.T_O_RealTimeFormat = EIP.RealTimeFormat.Modeless; eipClient.T_O_OwnerRedundant = false; eipClient.T_O_Priority = EIP.Priority.Scheduled; eipClient.T_O_VariableLength = false; eipClient.T_O_ConnectionType = EIP.ConnectionType.Point_to_Point; eipClient.RequestedPacketRate_T_O = Settings.RPI; //RPI (microseconds) //Forward open initiates the Implicit Messaging eipClient.ForwardOpen(); //System.Threading.Thread.Sleep(500); //updateEeipTmr = new System.Threading.Timer(new System.Threading.TimerCallback(updateEeipStats), null, Settings.RPI / 1000, Settings.RPI / 1000); IsConnected = true; } catch (Exception) { IsConnected = false; } }
public void Disconnect() { if (eipClient != null) { try { if (!IsPaused) { eipClient.ForwardClose(); } eipClient.UnRegisterSession(); eipClient = null; } catch (Exception) { return; } } IsConnected = false; }