-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dispose Tag #98
Comments
This is a good pickup, according to once of my go-to sources:
FYI Internally, IsInitialized is separate to IsDisposed - the tag handle creation does some communication with the PLC, and libplctag core library has the concept of an async constructor. Of course in C# there is no such thing as an async constructor, so we decided to separate the initialization, so it can be lazily initialized (or if you wanted to create several hundred tags at once, you could do them all at once, asynchronously, rather than one after the other). |
Btw @romanka5150 - what you've done is fine. You don't need to call |
@romanka5150 - it also looks like you're using the lower level (native) class for Tag. That's fine by all means, but there is also an implementation that handles types and offsets for you. It looks like your setting up a length read in order to eventually retrieve a string. Here's an example of the higher level syntax, in this case writing an array of strings: var stringTag = new Tag<StringPlcMapper, string[]>()
{
Name = "MY_STRING_1D[0]",
Gateway = gateway,
Path = path,
Protocol = Protocol.ab_eip,
PlcType = PlcType.ControlLogix,
ArrayDimensions = new int[] { 100 },
};
var r = new Random((int)DateTime.Now.ToBinary());
for (int ii = 0; ii < stringTag.Value.Length; ii++)
stringTag.Value[ii] = r.Next().ToString();
stringTag.Write(); More examples here: https://github.com/libplctag/libplctag.NET/tree/master/src/Examples/CSharp%20DotNetCore |
This should be closed by #99. |
Hi.
I started to uses your wrapper. In that time libplctag.0.0.27-alpha13 were latest release so is still in use on my side
Today I have some doubts if understand your examples, or there is some bug.
On simple example bellow I see that tag after .Dispose() has still status .isInitialized = true.
Is there a way how to Dispose, Release Tag ? Am i doing this in correct way ?
The text was updated successfully, but these errors were encountered: