网核如何从libplctag的PLC上从所有标签中获取值? (AB Micro 820)

发布于 2025-02-07 23:33:50 字数 2400 浏览 0 评论 0原文

我正在使用net core和 libplctag ,我试图以PLC的最佳方式读取所有标签,因为我想发布值以在图表上实时模拟的值,PLC有大约500个标签,我想制作backgroundTask循环读取标签。我一直在寻找信息,发现最好的方法是仅在一个连接或类似的连接中阅读全部。

我想知道在执行下一个时是否有一种方法可以获取标签的实际值。

的所有标签

static class ExampleListTags
    {
        public static void Run()
        {
            //This example will list all tags at the controller-scoped level

            var tags = new Tag<TagInfoPlcMapper, TagInfo[]>()
            {
                Gateway = "10.29.56.31",
                //Path = "1,0",
                PlcType = PlcType.Micro800,
                Protocol = Protocol.ab_eip,
                Name = "@tags"
            };

            tags.Read();
            Console.WriteLine($"{tags.Value}");
            foreach(var tag in tags.Value)
            {
                Console.WriteLine($"tag: {tag.Name} Time: {DateTime.Now}");
           //     ExampleRW.Run( tag.Name, PlcType.Micro800 , Protocol.ab_eip);
            }


            ConsoleTable
                .From(tags.Value.Select(t => new
                {
                    t.Id,
                    Type = $"0x{t.Type:X}",
                    t.Name,
                    t.Length,
                    Dimensions = string.Join(',', t.Dimensions)
                }))
                .Configure(o => o.NumberAlignment = Alignment.Right)
                .Write(Format.Default);

        }

    }

一个

找到存储库中获取PLClibplctag示例
可以
20xc1_io_em_do_0110,0,0
30xc1_IO_EEM_DO_0210,0,0
40xC1_IO_IO_EM_DO_0310,0,0,0
50xC1_IO_IO_EM_EM_EEM_DO_DO0410,0,0,0
60xC1_IO_IO_______________________ERDERITIA0,0,0

​使用文档中的另一种方法,但我想同时阅读所有标签,因为如果我在标签上迭代,则列出了该列表中至少500个标签的阅读时间来迭代。

I'm using Net core and libplctag, I'm trying to read all tags in a PLC on the best way cause I want to publish the values to simulate real time on a chart, the plc have around 500 tags and I want to make a backgroundtask that loops the reading of the tags. I was looking for info and I found that the best way is to read all in just one connection or something like that.

I wanna know if there is a way to get the actual value of the tag when doing the next.

I found an example to get all the tags on plc In libplctag repo but it only get the tag's info and I also want the actual value:

static class ExampleListTags
    {
        public static void Run()
        {
            //This example will list all tags at the controller-scoped level

            var tags = new Tag<TagInfoPlcMapper, TagInfo[]>()
            {
                Gateway = "10.29.56.31",
                //Path = "1,0",
                PlcType = PlcType.Micro800,
                Protocol = Protocol.ab_eip,
                Name = "@tags"
            };

            tags.Read();
            Console.WriteLine(
quot;{tags.Value}");
            foreach(var tag in tags.Value)
            {
                Console.WriteLine(
quot;tag: {tag.Name} Time: {DateTime.Now}");
           //     ExampleRW.Run( tag.Name, PlcType.Micro800 , Protocol.ab_eip);
            }


            ConsoleTable
                .From(tags.Value.Select(t => new
                {
                    t.Id,
                    Type = 
quot;0x{t.Type:X}",
                    t.Name,
                    t.Length,
                    Dimensions = string.Join(',', t.Dimensions)
                }))
                .Configure(o => o.NumberAlignment = Alignment.Right)
                .Write(Format.Default);

        }

    }

after that I get info like:

IdTypeNameLengthDimensions
10xC1_IO_EM_DO_0010,0,0
20xC1_IO_EM_DO_0110,0,0
30xC1_IO_EM_DO_0210,0,0
40xC1_IO_EM_DO_0310,0,0
50xC1_IO_EM_DO_0410,0,0
60xC1_IO_EM_DO_0510,0,0

I can read the tag with another method that is in the documentation but I wanna read all tags at the same time, cause if I iterate over a tags lists the reading time its to slow, at least 500 tags in that list to iterate.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文