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(); //Ip-Address of the Ethernet-IP Device (In this case Allen-Bradley 1734-AENT Point I/O) eeipClient.IPAddress = "192.168.178.107"; //A Session has to be registered before any communication can be established eeipClient.RegisterSession(); //Parameters from Originator -> Target eeipClient.O_T_InstanceID = 0x64; //Instance ID of the Output Assembly eeipClient.O_T_Length = 4; //The Method "Detect_O_T_Length" detect the Length using an UCMM Message eeipClient.O_T_RealTimeFormat = Sres.Net.EEIP.RealTimeFormat.Header32Bit; //Header Format 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.RequestedPacketRate_O_T = 500000; //500ms is the Standard value //Parameters from Target -> Originator eeipClient.T_O_InstanceID = 0x65; eeipClient.T_O_Length = 16; 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.RequestedPacketRate_T_O = 500000; //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 first Input byte: " + eeipClient.T_O_IOData[8]); Console.WriteLine("State of second Input byte: " + eeipClient.T_O_IOData[9]); //write the Outputs Transfered form Originator -> Target eeipClient.O_T_IOData[0] = (byte)(eeipClient.O_T_IOData[0] + 1); eeipClient.O_T_IOData[1] = (byte)(eeipClient.O_T_IOData[1] - 1); eeipClient.O_T_IOData[2] = 1; eeipClient.O_T_IOData[3] = 8; System.Threading.Thread.Sleep(500); } //Close the Session eeipClient.ForwardClose(); eeipClient.UnRegisterSession(); }
static void Main(string[] args) { EEIPClient eeipClient = new EEIPClient(); //Ip-Address of the Ethernet-IP Device (In this case Keyence-NU-EP1) eeipClient.IPAddress = "192.168.0.123"; //A Session has to be registered before any communication can be established eeipClient.RegisterSession(); //Parameters from Originator -> Target eeipClient.O_T_InstanceID = 0xfe; //Instance ID of the Output Assembly eeipClient.O_T_Length = 0; eeipClient.O_T_RealTimeFormat = Sres.Net.EEIP.RealTimeFormat.Header32Bit; //Header Format eeipClient.O_T_OwnerRedundant = false; eeipClient.O_T_Priority = Sres.Net.EEIP.Priority.Low; eeipClient.O_T_VariableLength = false; eeipClient.O_T_ConnectionType = Sres.Net.EEIP.ConnectionType.Point_to_Point; eeipClient.RequestedPacketRate_O_T = 500000; //RPI in 500ms is the Standard value //Parameters from Target -> Originator eeipClient.T_O_InstanceID = 0x66; eeipClient.T_O_Length = 2; 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.RequestedPacketRate_T_O = 500000; //RPI in 500ms is the Standard value //Forward open initiates the Implicit Messaging eeipClient.ForwardOpen(); while (true) { //Read the Inputs Transfered from Target -> Originator Console.WriteLine("State of first Input byte: " + eeipClient.T_O_IOData[0]); Console.WriteLine("State of second Input byte: " + eeipClient.T_O_IOData[1]); 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(); }
//これ使えねー public async void TagDataLink(int destination, byte instanceid, ushort length, uint rpi) { ushort tcpport = 44818; eEIPClient.T_O_InstanceID = instanceid; eEIPClient.T_O_Length = length; eEIPClient.T_O_RealTimeFormat = RealTimeFormat.Modeless; eEIPClient.T_O_ConnectionType = ConnectionType.Point_to_Point; eEIPClient.T_O_Priority = Priority.Scheduled; eEIPClient.T_O_VariableLength = false; eEIPClient.T_O_OwnerRedundant = false; eEIPClient.RequestedPacketRate_T_O = rpi; eEIPClient.O_T_VariableLength = false; eEIPClient.O_T_Priority = Priority.Scheduled; eEIPClient.O_T_RealTimeFormat = RealTimeFormat.Modeless; eEIPClient.O_T_InstanceID = 0x64; eEIPClient.O_T_ConnectionType = ConnectionType.Point_to_Point; eEIPClient.RequestedPacketRate_O_T = rpi; eEIPClient.TCPPort = tcpport; eEIPClient.IPAddress = Encapsulation.CIPIdentityItem.getIPAddress(IpAddressList[destination]); eEIPClient.RegisterSession(); var test = eEIPClient.Detect_T_O_Length(); eEIPClient.ForwardOpen(); while (DataLinkEnable) { DatalinkResponse = eEIPClient.T_O_IOData; } if (!DataLinkEnable) { eEIPClient.ForwardClose(); eEIPClient.UnRegisterSession(); } }