Net Core How Get Values from all tags on a PLC with libplctag? (AB Micro 820)

Viewed 134

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($"{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);

        }

    }

after that I get info like:

Id Type Name Length Dimensions
1 0xC1 _IO_EM_DO_00 1 0,0,0
2 0xC1 _IO_EM_DO_01 1 0,0,0
3 0xC1 _IO_EM_DO_02 1 0,0,0
4 0xC1 _IO_EM_DO_03 1 0,0,0
5 0xC1 _IO_EM_DO_04 1 0,0,0
6 0xC1 _IO_EM_DO_05 1 0,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.

0 Answers
Related