libplctag / libplctag.NET

A .NET wrapper for libplctag.

Home Page:https://libplctag.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using `raw_tag_type_bytes` for dynamic tags

timyhac opened this issue · comments

With the release of libplctag v2.6.0, a new use case has been enabled that allows application code to make use of tag metadata sent by the PLC.

This means that it is possible to have dynamically-typed tags without needing to fetch the entire PLC tag listing, which might be useful for some applications where the user is interactively deciding which tags to monitor.
It is also useful if migrating from another PLC communication package which had this capability.

Below is a prototype of what using this capability could look like.

Notes:

  • It hasn't been tested - I don't have access to any devices.
  • It only supports the simplest of atomic types. Arrays/UDTs/other atomic types are not supported.
  • This only works if the PLC returns the type metadata, and the structure of that metadata is the same.
  • Error handling - if user code sets Value with an inappropriate type (either before initialization or after), when should the error be thrown - as early as possible or only when communicating with PLC? This could happen for example if the PLC type is INT (16bits) but the C# type is int (32bits). Should the value be downcast? Do different applications have different answers to this question?

The example has been added to the repository under the Examples folder here.

Hello gurus, the release is applied also in nuget package for c#? I would like to test it on ControlNet using backplane routing.

@INondas - no its just a code example for now.

You can test it by copying the code into your own project.