网核如何从libplctag的PLC上从所有标签中获取值? (AB Micro 820)
我正在使用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);
}
}
一个
我 | 找到 | 存储库中获取PLC | libplctag | 示例 |
---|---|---|---|---|
了 | , | 可以 | 上 | 在 |
2 | 0xc1 | _io_em_do_01 | 1 | 0,0,0 |
3 | 0xc1 | _IO_EEM_DO_02 | 1 | 0,0,0 |
4 | 0xC1 | _IO_IO_EM_DO_03 | 1 | 0,0,0,0 |
5 | 0xC1 | _IO_IO_EM_EM_EEM_DO_DO04 | 1 | 0,0,0,0 |
6 | 0xC1 | _IO_IO_______________________ERDERITIA | 0,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:
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论