-
Notifications
You must be signed in to change notification settings - Fork 59
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
Handling libplctag exceptions when using alternative to mappers #425
Comments
@MountainKing91 - I can't see any reason that Decode would be called from that code alone. Are you able to follow the stack trace to see what is calling it? All the usual stuff will help, particularly logs and a repro. |
And you're right, I was looking in the wrong direction - that code is not calling Decode, this one is (in another part of my app):
Commenting out the above code the exception is not thrown. I guess before I try to access the tag value I must make sure it is correctly initialized and its status is not < 0 ? That is also what I actually did with mappers: looping over my tag list, I used a try-catch to initialize each tag and kept trying until GetStatus() returned 0. |
Yes you do need to initialize a tag before using it. |
@timyhac Is there any reason not to do something like this (in BaseTag.cs)?
I'm thinking that doing this for every method that should be called only if the tag has been properly initialized (that is, the plc was "connected" successfully at least once) would make sure that decode/encode are called only if actually possible without throwing exceptions. The goal is to share the tag value across other part of an application without having to consider each time if the tag has been initialized or not. |
Feel free to modify the example code to suit your needs! |
Hi,
I am giving a try to the approach recently added to the examples as an alternative to the mappers system. I am using version 1.5.2.
I instantiated a few tags using the "TagDint" class defined in Definitions.cs:
At this time the PLC is not connected and whenever I instantiate my Tags class, I get an ErrorNotFound exception from the Decode method of the TagDint class.
While it is expected that the tag isn't to be found, I am not sure how I am supposed to handle this situation, since when using the mappers with version 1.4.0 that exception was not thrown. For reference, this is what I used with mappers:
Can anybody give some insights? Thank you
The text was updated successfully, but these errors were encountered: