OPC-UA (PLC) Connection Established

Sometimes when the operator opens an Ignition Client, the screen opens and timers begin and event handlers start prior to the connection with the PLC. So the operator receives the red error box stating “Write to failed. Timed Out.” After they click CLOSE, the client is fine because Ignition and the PLC are now communicating.

Is there a way (in code) to wait for the PLC connection to establish prior to executing any script? Most of my script code is IF/ELSE statements so I was hoping to just add another variable to the IF statement that would wait for the PLC connection.

Thanks!

I just want to make sure: the tags are in a leased scan class, correct?

If so, then you may be able to do something like check the quality as part of your IF statement:

qual = system.tag.getTagValue("_Sim_/RAMP/RAMP1.Quality") if str(qual).lower() == 'good': #proceed...

Regards,

The scan class of all my tags are “Default” and the only other choice is “Default Historical”. Am I missing something? If I double click on the tag I can see the “Quality” parameter you have in your code. So basically, the “Quality” parameter of tags shows whether they are communicating or not? What else will show in the Quality field? “Poor” “None” “Off”

Thanks!

[quote=“creickard”]The scan class of all my tags are “Default” and the only other choice is “Default Historical”. Am I missing something? If I double click on the tag I can see the “Quality” parameter you have in your code. So basically, the “Quality” parameter of tags shows whether they are communicating or not? What else will show in the Quality field? “Poor” “None” “Off”

Thanks![/quote]

He asks because if you are not using a leased scan class your tags are always communicating and the problem lies elsewhere.

Strange…

When the client first opens up, the event handler code runs and opens an error saying “Error writing to tag . Write Time Out [C]”, but the PLC is running and the only event that occurred was the opening of the client. I figured it was the client establishing communication with the OPC tag.

Perhaps I’m writing my script code incorrect. We are using the script “system.tag.getTagValue()” and “system.tag.writeToTag(/)” Am I writing it incorrectly in the script?

Thanks!

When this happens, does the write seem to actually go through? If it happens every time you open a client, perhaps have the designer open and watch the tag that is supposed to be written to.

Also, look at the “wrapper.log” file in the install directory. Do you get any errors indicating a write problem at the times when you open a client?

We have to narrow down whether there really is an error writing, or if the error lies more in the progress/notification system, and the client is simply never getting the write complete message. The “[c]” in that error message is saying that the client is timing out getting a response from the gateway. It could be that the gateway is sending the response before the client is ready for it.

Regards,

It doesn’t happen every time. The Error Msg is usually on the screen in the morning after we arrive and wake up the PCs.

Once we clear it, it seems like it’s fine for the rest of the day. I added the code from the previous posts - watching the Quality of the tag. We’ll see if that makes a difference.

Thanks…