EEIP.NET

2025-12-07 0 354

EEIP.NET

Ethernet/IP compatible library for .NET implementations
Supports IO Scanner and Explicit Message Client functionality
For Data Exchange with Ethernet/IP Devices

  • Support of Explicit Messaging and Implicit Messaging
  • Object Library with CIP-Definined Objects
  • Provides a simple way to access Ethernet/IP Devices without special knowledge about Ethernet/IP

Implementation Guide and documentation

Installation

Usage

Explicit Messaging: Write digital outputs to Ethernet/IP Device

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.w**a*go.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();
        }
    }
}

Explicit Messaging: Read digital inputs from Ethernet/IP Device

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.w**a*go.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();
        }
    }
}

Explicit Messaging: Read Analog Inputs from Ethernet/IP Device

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.w**a*go.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();
        }
    }
}

Explicit Messaging: Read and Write Sensor parameters – Keyence NU-EP1

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();
        }
    }
}

Discover available Ethernet/IP Devices on the Network

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<Sres.Net.EEIP.Encapsulation.CIPIdentityItem> 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);
            }
        }
    }
}

Implicit Messaging connection to Allen-Bradley 1734 Point I/O

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();
        }
    }
}

Implicit Messaging connection to Turck FEN20-4DIP-4DXP

下载源码

通过命令行克隆项目:

git clone https://github.com/rossmann-engineering/EEIP.NET.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 开发教程 EEIP.NET https://www.zuozi.net/31424.html

eShop Website
上一篇: eShop Website
SdvCodeWebsite
下一篇: SdvCodeWebsite
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务