### Read and Write Sensor Parameters for Keyence NU-EP1 Source: https://github.com/rossmann-engineering/eeip.net/blob/master/README.md Reads and sets sensor parameters like light intensity for a Keyence NU-EP1 device. This example uses explicit messaging to get and set attributes of specific sensors. ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Sres.Net.EEIP; namespace ConsoleApplication1 { class Program { 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(); } } } ``` -------------------------------- ### Implicit Messaging Connection to Keyence NU-EP1 Source: https://github.com/rossmann-engineering/eeip.net/blob/master/README.md This C# code snippet demonstrates setting up an implicit messaging connection (Input Only) to a Keyence NU-EP1. It configures session parameters, originator-to-target and target-to-originator settings, and continuously reads input data. Ensure the EEIP.NET library is referenced. ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Sres.Net.EEIP; //This example demonstrates the usage of Implicit Messaging //whith an Keyence NU-EP1 Network Unit. This is an Input Only connection. //The two received bytes represents the output state of the sensors. //Keyence Users Manual Page 3-6 No. 3 namespace Keyence_NU_RP1_Implicit { class Program { 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(); } } } ``` -------------------------------- ### RegisterSession with String Address Source: https://github.com/rossmann-engineering/eeip.net/wiki/RegisterSession Initiates a session with an Ethernet/IP device using its IP address in string format and a specified port. Returns the session handle. ```APIDOC ## RegisterSession (String Address, UInt16 Port) ### Description Sends a RegisterSession command to a target to initiate a session using an IP address in string format and a specified port. ### Method `public UInt32 RegisterSession(string address, UInt16 port)` ### Parameters #### Path Parameters - **address** (string) - Required - IP-Address in String Format - **port** (UInt16) - Required - Port to access the EIP Device (Standard 0xAF12) ### Returns - **Session Handle** (UInt32) - The Session Handle is stored in the Instance of Class "EEIPClient" ``` -------------------------------- ### RegisterSession with String Address and Default Port Source: https://github.com/rossmann-engineering/eeip.net/wiki/RegisterSession Initiates a session with an Ethernet/IP device using its IP address in string format and the standard port (0xAF12). Returns the session handle. ```APIDOC ## RegisterSession (String Address) ### Description Sends a RegisterSession command to a target to initiate a session using an IP address in string format and the standard port 0xAF12. ### Method `public UInt32 RegisterSession(string address)` ### Parameters #### Path Parameters - **address** (string) - Required - IP-Address in String Format ### Returns - **Session Handle** (UInt32) - The Session Handle is stored in the Instance of Class "EEIPClient" ``` -------------------------------- ### RegisterSession with UInt32 Address Source: https://github.com/rossmann-engineering/eeip.net/wiki/RegisterSession Initiates a session with an Ethernet/IP device using its IP address in UINT32 format and a specified port. Returns the session handle. ```APIDOC ## RegisterSession (UInt32 Address) ### Description Sends a RegisterSession command to a target to initiate a session using a UINT32 IP address and a specified port. ### Method `public UInt32 RegisterSession(UInt32 address, UInt16 port)` ### Parameters #### Path Parameters - **address** (UInt32) - Required - IP-Address in UINT32 Format - **port** (UInt16) - Required - Port to access the EIP Device (Standard 0xAF12) ### Returns - **Session Handle** (UInt32) - The Session Handle is stored in the Instance of Class "EEIPClient" ``` -------------------------------- ### Write Digital Outputs to Ethernet/IP Device Source: https://github.com/rossmann-engineering/eeip.net/blob/master/README.md This snippet demonstrates how to write digital output states to a Wago device using explicit messaging. It shows how to set individual outputs high or low and reset them. ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Sres.Net.EEIP; namespace Explicit_Messaging_Example { class Program { 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.178.66"); //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(); } } } ``` -------------------------------- ### Implicit Messaging Connection to Turck FEN20 Source: https://github.com/rossmann-engineering/eeip.net/blob/master/README.md This C# code configures and establishes an implicit messaging connection to a Turck FEN20-4DIP-4DXP device. It sets up parameters for both sending and receiving data and enters a loop to continuously read inputs and write outputs. ```csharp using System; using Sres.Net.EEIP; //The Following Hardware Configuration is used in this example // Turck FEN20-4DIP-4DXP //Unisversal Digital Channels are used as Digital Outputs // Manual: http://pdb2.turck.de/repo/media/_en/Anlagen/Datei_EDB/edb_6931090_gbr_en.pdf //IP-Address: 192.168.1.254 namespace TurckFEN20 { class Program { 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.1.254"; //A Session has to be registered before any communication can be established eeipClient.RegisterSession(); //Parameters from Originator -> Target eeipClient.O_T_InstanceID = 0x68; //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 = 0x67; eeipClient.T_O_Length = 8; 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.Point_to_Point; 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 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(); } } } ``` -------------------------------- ### ListIdentity() Source: https://github.com/rossmann-engineering/eeip.net/wiki/Get-a-List-of-Available-Ethernet-IP-Devices Retrieves a list of all available Ethernet/IP devices connected to the network. This method scans the network and returns an array of CIPIdentityItem objects, each representing a discovered device. ```APIDOC ## ListIdentity() ### Description Returns a List of Ethernet/IP Devices on the Network. ### Method Public ### Endpoint N/A (SDK Method) ### Parameters None ### Response #### Success Response - **List** - A list of discovered Ethernet/IP devices. ### Datatypes: Encapsulation.CIPIdentityItem - UInt16 ItemTypeCode: Code indicating item type of CIP Identity (0x0C). - UInt16 ItemLength: Number of bytes in item which follow (length varies depending on Product Name string). - UInt16 EncapsulationProtocolVersion: Encapsulation Protocol Version supported. - SocketAddress SocketAddress: Socket Address of the device. - UInt16 VendorID1: Device manufacturers Vendor ID. - UInt16 DeviceType1: Device Type of product. - UInt16 ProductCode1: Product Code assigned with respect to device type. - byte[] Revision1 (2 bytes): Device revision. - UInt16 Status1: Current status of device. - UInt32 SerialNumber1: Serial number of device. - byte ProductNameLength: Length of the product name string. - string ProductName1: Human readable description of device. - byte State1: Current state of device. SocketAddress - UInt16 SIN_family: Socket address family. - UInt16 SIN_port: Socket port. - UInt32 SIN_Address: Socket IP address. - byte[] SIN_Zero (8 bytes): Reserved bytes. ``` -------------------------------- ### Discover Ethernet/IP Devices on the Network Source: https://github.com/rossmann-engineering/eeip.net/blob/master/README.md Scans the network to discover available Ethernet/IP devices. This function returns a list of CIPIdentityItems, each containing details about a found device. ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DescoverDevices { class Program { static void Main(string[] args) { Sres.Net.EEIP.EEIPClient eipClient = new Sres.Net.EEIP.EEIPClient(); List cipIdentityItem = eipClient.ListIdentity(); for (int i = 0; i < cipIdentityItem.Count; i++) { Console.WriteLine("Ethernet/IP Device Found:"); Console.WriteLine(cipIdentityItem[i].ProductName1); Console.WriteLine("IP-Address: " + Sres.Net.EEIP.Encapsulation.CIPIdentityItem.getIPAddress(cipIdentityItem[i].SocketAddress.SIN_Address)); Console.WriteLine("Port: " + cipIdentityItem[i].SocketAddress.SIN_port); Console.WriteLine("Vendor ID: " + cipIdentityItem[i].VendorID1); Console.WriteLine("Product-code: " + cipIdentityItem[i].ProductCode1); Console.WriteLine("Type-Code: " + cipIdentityItem[i].ItemTypeCode); } } } } ``` -------------------------------- ### Read Digital Inputs from Ethernet/IP Device Source: https://github.com/rossmann-engineering/eeip.net/blob/master/README.md This snippet shows how to read digital input states from a Wago device using explicit messaging. It retrieves the state of digital inputs and prints them to the console. ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Sres.Net.EEIP; namespace Explicit_Message_Example2 { class Program { 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.178.66"); //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(); } } } ``` -------------------------------- ### Read Analog Inputs from Ethernet/IP Device Source: https://github.com/rossmann-engineering/eeip.net/blob/master/README.md Reads analog input values (e.g., temperature) from a Wago 750-352 device. Ensure the device IP address is correctly set and the manual is consulted for assembly object instances. ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Sres.Net.EEIP; namespace Explicit_Message_Example_ReadAnalogInput { class Program { 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.178.66"); //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(); } } } ``` -------------------------------- ### Implicit Messaging Connection to Allen-Bradley Point I/O Source: https://github.com/rossmann-engineering/eeip.net/blob/master/README.md This C# code snippet demonstrates how to configure and establish an implicit messaging connection to an Allen-Bradley 1734-AENT Ethernet/IP Coupler. It sets up parameters for both Originator-to-Target (O_T) and Target-to-Originator (T_O) data transfers, including instance IDs, lengths, and connection types. The code then enters a loop to continuously read input states and update output states. ```csharp using System; using Sres.Net.EEIP; //The Following Hardware Configuration is used in this example // Allen-Bradley 1734-AENT Ethernet/IP Coupler // Allen-Bradley 1734-IB4 4-Channel Digital Input Module // Allen-Bradley 1734-IB4 4-Channel Digital Input Module // Allen-Bradley 1734-IB4 4-Channel Digital Input Module // Allen-Bradley 1734-IB4 4-Channel Digital Input Module // Allen-Bradley 1734-OB4E 4-Channel Digital Output Module // Allen-Bradley 1734-OB4E 4-Channel Digital Output Module // Allen-Bradley 1734-OB4E 4-Channel Digital Output Module // Allen-Bradley 1734-OB4E 4-Channel Digital Output Module //IP-Address: 192.168.178.107 (By DHCP-Server) namespace AllenBradleyPointIO { class Program { 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(); } } } ``` -------------------------------- ### getAttributeSingle Source: https://github.com/rossmann-engineering/eeip.net/wiki/Read-Single-Attributes-from-Ethernet-IP-Device Retrieves a single attribute value from an Ethernet/IP device. The access path is determined by the provided classID, instanceID, and attributeID. ```APIDOC ## getAttributeSingle ### Description Returns a single Attribute value. The Access path is determined using the Input parameters "classID", instanceID, attributeID. ### Method Signature public byte[] getAttributeSingle(int classID, int instanceID, int attributeID) ### Parameters #### Path Parameters - **classID** (int) - Required - The ID of the class to read from. - **instanceID** (int) - Required - The ID of the instance to read from. - **attributeID** (int) - Required - The ID of the attribute to read. ### Returns - **byte[]** - The byte array representing the attribute value. ``` -------------------------------- ### UnRegisterSession Source: https://github.com/rossmann-engineering/eeip.net/wiki/UnregisterSession Sends a UnRegisterSession command to a target to terminate the session. ```APIDOC ## UnRegisterSession ### Description Sends a UnRegisterSession command to a target to terminate the session. ### Method public void ### Endpoint N/A (Method call) ### Parameters None ### Request Example N/A (Method call) ### Response None ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.