static void Main(string[] args) { EEIPClient eeipClient = new EEIPClient { //Ip-Address of the Ethernet-IP Device (In this case Allen-Bradley 1734-AENT Point I/O) IPAddress = "193.168.7.20" }; //A Session has to be registered before any communication can be established eeipClient.RegisterSession(); eeipClient.O_T_InstanceID = 150; //Instance ID of the Output Assembly eeipClient.T_O_InstanceID = 100; var O_T_Length = eeipClient.Detect_O_T_Length(); var T_O_Length = eeipClient.Detect_T_O_Length(); //Parameter from Controlsystem -> PLC //Parameters from Originator -> Target eeipClient.O_T_Length = O_T_Length; //The Method "Detect_O_T_Length" detect the Length using an UCMM Message eeipClient.O_T_RealTimeFormat = RealTimeFormat.Heartbeat; //Header Format eeipClient.O_T_OwnerRedundant = false; eeipClient.O_T_Priority = Priority.Scheduled; eeipClient.O_T_VariableLength = false; eeipClient.O_T_ConnectionType = ConnectionType.Point_to_Point; eeipClient.O_T_IOData = new byte[500]; eeipClient.RequestedPacketRate_O_T = 30000; //30ms: 500ms is the Standard value //Parameter from PLC -> Controlsystem //Parameters from Target -> Originator eeipClient.T_O_Length = T_O_Length; eeipClient.T_O_RealTimeFormat = RealTimeFormat.Heartbeat; eeipClient.T_O_OwnerRedundant = false; eeipClient.T_O_Priority = Priority.Scheduled; eeipClient.T_O_VariableLength = false; eeipClient.T_O_ConnectionType = ConnectionType.Point_to_Point; eeipClient.T_O_IOData = new byte[500]; eeipClient.RequestedPacketRate_T_O = 30000; //30ms: RPI in 500ms is the Standard value //Forward open initiates the Implicit Messaging eeipClient.ForwardOpen(); while (true) { //Read the Inputs Transfered form Target -> Originator Console.WriteLine("State of Input byte: " + eeipClient.T_O_IOData[2]); //write the Outputs Transfered form Originator -> Target eeipClient.O_T_IOData[2] = 0x0F; //Set all Four digital Inputs to High System.Threading.Thread.Sleep(500); } //Close the Session eeipClient.ForwardClose(); eeipClient.UnRegisterSession(); }
static void Main(string[] args) { EEIPClient eeipClient = new EEIPClient(); eeipClient.IPAddress = "192.168.178.107"; eeipClient.RegisterSession(); //Console.WriteLine("Product Name: " + eeipClient.IdentityObject.ProductName); //Console.WriteLine("Product Code: " + eeipClient.IdentityObject.ProductCode); //byte[] data =eeipClient.GetAttributeSingle(0x4, 0x65,3); //for (int i = 0; i < data.Length; i++) // Console.WriteLine(data[i]); //Console.ReadKey(); //UInt32 sessionHandle = eeipClient.RegisterSession("192.168.178.107", 0xAF12); // eipClient.O_T_ConnectionType = Sres.Net.EEIP.ConnectionType.Null; // eipClient.O_T_Length = 0; eeipClient.O_T_InstanceID = 0x64; eeipClient.O_T_Length = eeipClient.Detect_O_T_Length(); eeipClient.O_T_RealTimeFormat = Sres.Net.EEIP.RealTimeFormat.Header32Bit; eeipClient.O_T_OwnerRedundant = false; eeipClient.O_T_Priority = Sres.Net.EEIP.Priority.Scheduled; eeipClient.O_T_VariableLength = false; eeipClient.O_T_ConnectionType = Sres.Net.EEIP.ConnectionType.Point_to_Point; eeipClient.T_O_InstanceID = 0x65; eeipClient.T_O_Length = eeipClient.Detect_T_O_Length(); eeipClient.T_O_RealTimeFormat = Sres.Net.EEIP.RealTimeFormat.Modeless; eeipClient.T_O_OwnerRedundant = false; eeipClient.T_O_Priority = Sres.Net.EEIP.Priority.Scheduled; eeipClient.T_O_VariableLength = false; eeipClient.T_O_ConnectionType = Sres.Net.EEIP.ConnectionType.Multicast; eeipClient.ForwardOpen(); while (true) { Console.Write(eeipClient.LastReceivedImplicitMessage); Console.WriteLine(eeipClient.T_O_IOData[8]); eeipClient.O_T_IOData[0] = (byte)((byte)eeipClient.O_T_IOData[0] + (byte)1); eeipClient.O_T_IOData[1] = (byte)((byte)eeipClient.O_T_IOData[1] - (byte)1); System.Threading.Thread.Sleep(500); } Console.ReadKey(); eeipClient.ForwardClose(); eeipClient.UnRegisterSession(); }