Closed beena26g closed 1 year ago
Could the issue be that it's catching LibPlcTagException
instead of AggregateException
when awaiting tasks
,
Tried using Aggregrate but below is screen shot of error I am getting for where it is looking for Libplctag.LibPlcTagException for ErrorOutofBounds. From my sample, it is happening for BoolTag1000 (which is a wrong tag type that is created as TagDint)
Thank you.
I just formatted your code so I could read it more easily.
To me, this is looks like a problem with incorrect async code, as opposed to an issue with libplctag.NET.
Some pointers:
readResults
) from within multithreaded code.Hi @beena26g - I hope that the above has been helpful, if you would like more assistance please create an issue that takes into account my earlier comments. Thanks for using libplctag.NET
I am trying to use exception handling with tags. My scenario is to use a string array to read a list of tags. All tags need to be of the same data type. For example, my sample below will be of type TagDint . I would like to do some error handling on these tags for If the list of tags contains a different tag type or if the IPAddress is wrong for connection. I am using Task.WhenAll to run all tags at the same time, but also get exceptions and put them in result list - which would tell me what the exceptiona are. Currently the tag error I have been able to work with is ErrorNotFound which is when a TagDint does not exist in the plc. I am running into issue when I have Erroroutofbounds error or I have giving a wrong IPAddress. The code fails to recognize the exception and does not handle it correctly.
Below is my sample code
Expected result set would show tagName = "Tag1001" isValid = false ErrorMessage = "ErrorNotFound" Value = null , tagName = "Tag2000", isValid = true ErrorMessage = "" Value = 111 , tagName = "Tag3000", isValid = true ErrorMessage = "" Value = 222 ,
tagName = "BoolTag1000" isValid = false ErrorMessage = "ErrorOutofBound" Value = null , tagName = "Tag5679[2,0]", isValid = true ErrorMessage = "" Value = 2 ,
This code works fine if I don't have erroroutofbound error - i.e. all tags are tagDint but I would like to handle situations where wrong tag types are sent to read.
Your help is appreciated.
Thank you