libplctag / libplctag.NET

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

Expose more TagOfT properties to ITag interface #356

Closed Devqon closed 3 months ago

Devqon commented 10 months ago

We use this driver with a generic wrapper to expose the tag functionality. We therefore have a method that looks like this:

public static ITag MapToLibPlcTag(Type type)
{
    return type switch
    {
        Type _ when type == typeof(bool) => new TagBool(),
        Type _ when type == typeof(int) => new TagDint(),
        // .. etc.
        _ => throw new NotSupportedException();
    };
}

This exposes the ITag to our wrapper, but we do need some of the functionality that is 'hidden' in the TagOfT<> for polling mechanisms, like the AutoSyncReadInterval and all of the events (ReadStarted, ReadCompleted etc.).

There is no way to expose a TagOfT<> instead of the ITag, because that needs a compile-time generic where we only have a runtime System.Type.

Is there a reason that these properties aren't exposed through the ITag interface?

EDIT It seems that at the time the ITag interface was introduced (#77), these properties did not exist yet. Is my conclusion correct that when the new properties were introduced they should have been added to the ITag?

timyhac commented 3 months ago

Sorry for not replying to this - I think your detective work is correct also, I will add the extra events and properties shortly.

timyhac commented 3 months ago

Hi @Devqon - this is completed in libplctag.NET v1.4.0