libplctag / libplctag.NET

A .NET wrapper for libplctag.
https://libplctag.github.io/
Mozilla Public License 2.0
214 stars 53 forks source link

Should (some specific) tag parameters be able to be modified after initialization? #337

Closed timyhac closed 11 months ago

timyhac commented 1 year ago

The .NET library bans setting tag parameters after initialization: https://github.com/libplctag/libplctag.NET/blob/master/src/libplctag/NativeTagWrapper.cs#L657

For many parameters this is logical, as the tag handle has resources associated with it that would not make sense if those parameters changed (e.g. name, elem_count). For other parameters, it is not obvious that this is the logical choice (e.g. auto_sync_read_ms).

Should (some specific) tag parameters be able to be modified after initialization?

One use case would be to temporarily suspend auto read by setting the AutoSyncReadInterval property of a tag to null.

Originally posted by @timyhac in https://github.com/libplctag/libplctag.NET/issues/336#issuecomment-1505905641

timyhac commented 1 year ago

It seems that there is already the ability to do this for ReadCacheMillisecondDuration and Timeout - I don't recall the rationale for allowing for these but not other properties.

timyhac commented 11 months ago

It looks like the only way to achieve this is by using the plc_tag_set_int_attribute function available in the core library. The supported attributes of this are documented here.

So it looks like only these three should be supported:

When I created this issue, I was under the impression that the core library already supported suspending auto-read for a period of time. According to the documentation, this is not possible.

The only action here is to make it possible to expose the ability to set the DebugLevel on a tag.

timyhac commented 11 months ago

This was achieved in https://github.com/libplctag/libplctag.NET/commit/b89491423dd7169dd357e287f82f9d31c2c889ec