public virtual void WriteInstance(byte instanceid, DataType dataType, byte[] sendData, bool isString, ushort tcpport = 44818) { try { //IPアドレスはフォームで選択したものを使用 //TCPポートは特に変更していない場合はこれで固定 EEIP.dll内の既定値 eEIPClient.TCPPort = tcpport; eEIPClient.IPAddress = Encapsulation.CIPIdentityItem.getIPAddress(IpAddressList[0]); eEIPClient.RegisterSession(); //CIPメッセージ Assembly(0x04)を使って引数のInstanceIDのIOの値を読み出す //戻り値のバッファサイズはPLC側で設定したタグのサイズとなっているので一定ではない byte[] code = eEIPClient.SetAttributeSingle(0x04, instanceid, 0xFFFF, sendData); if (code != null) { MessageBox.Show(code.ToString()); } } catch (Exception e) { MessageBox.Show(e.Message); } finally { eEIPClient.UnRegisterSession(); } }
static void Main(string[] args) { EEIPClient eeipClient = new EEIPClient(); eeipClient.IPAddress = "192.168.0.123"; eeipClient.RegisterSession(); byte[] response = eeipClient.GetAttributeSingle(0x66, 1, 0x325); Console.WriteLine("Current Value Sensor 1: " + (response[1] * 255 + response[0]).ToString()); response = eeipClient.GetAttributeSingle(0x66, 2, 0x325); Console.WriteLine("Current Value Sensor 2: " + (response[1] * 255 + response[0]).ToString()); Console.WriteLine(); Console.Write("Enter intensity for Sensor 1 [1..100]"); int value = int.Parse(Console.ReadLine()); Console.WriteLine("Set Light intensity Sensor 1 to " + value + "%"); eeipClient.SetAttributeSingle(0x66, 1, 0x389, new byte [] { (byte)value, 0 }); Console.Write("Enter intensity for Sensor 2 [1..100]"); value = int.Parse(Console.ReadLine()); Console.WriteLine("Set Light intensity Sensor 2 to " + value + "%"); eeipClient.SetAttributeSingle(0x66, 2, 0x389, new byte[] { (byte)value, 0 }); Console.WriteLine(); Console.WriteLine("Read Values from device to approve the value"); response = eeipClient.GetAttributeSingle(0x66, 1, 0x389); Console.WriteLine("Current light Intensity Sensor 1 in %: " + (response[1] * 255 + response[0]).ToString()); response = eeipClient.GetAttributeSingle(0x66, 2, 0x389); Console.WriteLine("Current light Intensity Sensor 2 in %: " + (response[1] * 255 + response[0]).ToString()); eeipClient.UnRegisterSession(); Console.ReadKey(); }
private void button1_Click(object sender, EventArgs e) { EEIPClient eeipClient = new EEIPClient(); eeipClient.IPAddress = "192.168.255.1"; eeipClient.RegisterSession(); int B = 1; while (B == 1) { double value = 0; int[] V2 = { 9876543, 0 }; byte[] bb = BitConverter.GetBytes(V2[0]); eeipClient.SetAttributeSingle(0x78, 2701, 1, new byte[] { 255 }); eeipClient.SetAttributeSingle(0x7F, 2, 1, new byte[] { 16, 0, 0, 0 });// set P002 to base type //eipClient.SetAttributeSingle(0x7F(P-var), Var no. 2, arrtibute 1, data send new byte[] { 16, 0, 0, 0 }); // X,Y,Z 0.000 byte[] A = eeipClient.SetAttributeSingle(0x7F, 2, 6, new byte[] { bb[0], bb[1], bb[2], bb[3] }); // 1st axis IN{BYTE SEND}SEPARATE DOUBLE DATA TO BINARY} eeipClient.SetAttributeSingle(0x7F, 2, 7, new byte[] { 15, 39, (byte)value, 0 }); // 2nd axis eeipClient.SetAttributeSingle(0x7F, 2, 8, new byte[] { 15, 39, (byte)value, 0 }); // 3rd axis // degree is 0.0000 eeipClient.SetAttributeSingle(0x7F, 2, 9, new byte[] { 15, 39, (byte)value, 0 }); // 4th axis eeipClient.SetAttributeSingle(0x7F, 2, 10, new byte[] { 15, 39, (byte)value, 0 }); // 5th axis eeipClient.SetAttributeSingle(0x7F, 2, 11, new byte[] { 15, 39, (byte)value, 0 }); // 6th axis eeipClient.SetAttributeSingle(0x7A, 2, 1, new byte[] { 255 }); // byte[] response = eeipClient.GetAttributeSingle(0x78, 2701, 1); //byte[] response = eeipClient.GetAttributeSingle(0x78, 1001, 1); eeipClient.UnRegisterSession(); //if (response[0] <= 1) // Environment.Exit(0); B = 0; } }
static void Main(string[] args) { EEIPClient eeipClient = new EEIPClient(); //Register Session (Wago-Device 750-352 IP-Address: 192.168.178.66) //we use the Standard Port for Ethernet/IP TCP-connections 0xAF12 eeipClient.RegisterSession("192.168.1.3"); //We write an Output to the Wago-Device; According to the Manual of the Device //Instance 0x66 of the Assembly Object contains the Digital Output data //The Documentation can be found at: http://www.wago.de/download.esm?file=%5Cdownload%5C00368362_0.pdf&name=m07500352_xxxxxxxx_0en.pdf //We set the first output "High" eeipClient.AssemblyObject.setInstance(0x66, new byte[] { 0x01 }); System.Threading.Thread.Sleep(1000); //We set the secoond output "High" eeipClient.AssemblyObject.setInstance(0x66, new byte[] { 0x02 }); System.Threading.Thread.Sleep(1000); //We set the secoond output "High" eeipClient.AssemblyObject.setInstance(0x66, new byte[] { 0x03 }); System.Threading.Thread.Sleep(1000); //We reset the outputs eeipClient.AssemblyObject.setInstance(0x66, new byte[] { 0x00 }); //When done, we unregister the session 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) 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) { //https://www.youtube.com/watch?v=fg58H-ZZit0 EEIPClient eeipClient = new EEIPClient(); eeipClient.RegisterSession("192.168.1.3"); byte[] readAllRegisters = eeipClient.GetAttributeAll(0x6b, 1); Console.WriteLine(readAllRegisters); //When done, we unregister the session eeipClient.UnRegisterSession(); Console.ReadKey(); }
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(); }
static void Main(string[] args) { EEIPClient eeipClient = new EEIPClient(); //Register Session (Wago-Device 750-352 IP-Address: 192.168.178.66) //we use the Standard Port for Ethernet/IP TCP-connections 0xAF12 eeipClient.RegisterSession("192.168.1.3"); //Get the State of Analog Inputs According to the Manual //Instance 0x6D of the Assembly Object contains the Analog Input data //The Documentation can be found at: http://www.wago.de/download.esm?file=%5Cdownload%5C00368362_0.pdf&name=m07500352_xxxxxxxx_0en.pdf //Page 202 shows the documentation for instance 6D hex byte[] analogInputs = eeipClient.AssemblyObject.getInstance(0x6D); Console.WriteLine("Temperature of Analog Input 1: " + (EEIPClient.ToUshort(new byte[] { analogInputs[0], analogInputs[1] }) / 10.0) + "°C"); Console.WriteLine("Temperature of Analog Input 2: " + (EEIPClient.ToUshort(new byte[] { analogInputs[2], analogInputs[3] }) / 10.0) + "°C"); //When done, we unregister the session eeipClient.UnRegisterSession(); Console.ReadKey(); }
/// <summary> /// Initializes a new instance of the <see cref="Host"/> Class. /// </summary> public Host() { _client = new EEIPClient() { IPAddress = "192.168.125.1" }; try { _client.RegisterSession(); //ReadWriteToIntegerRegister(); //ReadWriteStringRegister(); ReadWritePositionRegister(); _client.UnRegisterSession(); } catch (Exception ex) { Console.WriteLine($"{ex.Message}"); } }
static void Main(string[] args) { EEIPClient eeipClient = new EEIPClient(); //Register Session (Wago-Device 750-352 IP-Address: 192.168.178.66) //we use the Standard Port for Ethernet/IP TCP-connections 0xAF12 eeipClient.RegisterSession("192.168.1.3"); //Get the State of a digital Input According to the Manual //Instance 0x6C of the Assembly Object contains the Digital Input data //The Documentation can be found at: http://www.wago.de/download.esm?file=%5Cdownload%5C00368362_0.pdf&name=m07500352_xxxxxxxx_0en.pdf byte[] digitalInputs = eeipClient.AssemblyObject.getInstance(0x6c); Console.WriteLine("State of Digital Input 1: " + (EEIPClient.ToBool(digitalInputs[0], 0))); Console.WriteLine("State of Digital Input 2: " + (EEIPClient.ToBool(digitalInputs[0], 1))); Console.WriteLine("State of Digital Input 3: " + (EEIPClient.ToBool(digitalInputs[0], 2))); Console.WriteLine("State of Digital Input 4: " + (EEIPClient.ToBool(digitalInputs[0], 3))); //When done, we unregister the session eeipClient.UnRegisterSession(); Console.ReadKey(); }
static void Main(string[] args) { try { ParseArgs(args); } catch (Exception x) { Console.Error.WriteLine("Failed to parse arguments: {0}", x.Message); Console.Error.WriteLine("ERR_INVALID_ARGS"); Environment.Exit(1); } Console.CancelKeyPress += Console_CancelKeyPress; client = new EEIPClient() { IPAddress = host, TCPPort = port }; Console.Error.WriteLine($"Connecting to {host}:{port}..."); try { client.RegisterSession(); } catch (Exception x) { Console.Error.WriteLine("Failed to connect: {0}", x.Message); Console.Error.WriteLine("ERR_CONNECTION_FAILURE"); Environment.Exit(1); } while (!IsCancelled()) { try { Run(); } catch (Exception x) { if (IsCancelled()) { Console.Error.WriteLine("ERR_CANCELLED"); } else if (x.Message.StartsWith("ERR_")) { Console.Error.WriteLine(x.Message); } else { Console.Error.WriteLine(x.Message); Console.Error.WriteLine("ERR_EXCEPTION"); } if (repeat == 0) { Environment.Exit(1); } } if (repeat == 0) { break; } if (!IsCancelled()) { Thread.Sleep(repeat); } Console.Error.WriteLine(); } try { Console.Error.WriteLine("Closing the connection..."); client.UnRegisterSession(); client = null; } catch (Exception) { } if (result != null) { var json = new StringBuilder(); json.Append("{"); json.Append(@"""program"":"); json.Append(result.ProgramNoDuringJudgement); json.Append(@",""result"":"); json.Append(result.OverallJudgement ? "true" : "false"); json.Append(@",""processingTime"":"); json.Append(result.ProcessingTime); if (tools > 0) { json.Append(@",""tools"":["); for (var no = 1; no <= tools; ++no) { var tool = result.Tools[no - 1]; json.Append("{"); json.Append(@"""result"":"); json.Append(tool.Result ? "true" : "false"); json.Append(@",""matchingRate"":"); json.Append(tool.MatchingRate); json.Append(@",""lowerThreshold"":"); json.Append(tool.LowerThreshold); json.Append(@",""upperThreshold"":"); json.Append(tool.UpperThreshold); json.Append("}"); if (tool.No < tools) { json.Append(","); } } json.Append("]"); } json.Append("}"); Console.WriteLine(json.ToString()); } }
/// <summary> /// Disconnects the PLC. /// </summary> public void Disconnect() { eeipClient.UnRegisterSession(); }