2
« on: September 13, 2023, 11:58:05 AM »
I'm still struggling with getting this to work. Until I sort out the runtime error with the MicroLogix, I'm just using the CompactLogix driver. I have a basic indicator tied to a PLC flasher bit and some basic labels tied to different numeric tags (a string, some reals, some dints). When the form first loads, if the PLC is powered up and running, it all works. If I unplug the PLC, they all stop and display the error message (as expected). When the PLC resumes, they seem start working again, but it sometimes takes a bit, especially if the PLC has been off more than a minute or two. That's fine as long as "a bit" isn't too long. So far, it seems ok.
But, if the PLC is off when the program starts, the form controls don't start working when the PLC connects. I have a command button that reads data from the PLC into a local variable. That works fine once the PLC is talking. As a test, I added a timer control that's enabled by the driver's .ComError event. It's tick event has a try/catch that reads a PLC tag. If the read succeeds, it checks a checkbox that's unchecked by the .ComError event and disables the timer. That all works (as long as the timer interval is a lot longer than the driver's timeout), but I can't get the basic indicator or basic labels to start working.
I've tried different things, like <control>.disable when there's a .ComError followed by a <control>.enable when comms are restored, <control>.refresh, <control>.update, <control>.hide/show, nothing gets the form control working. How can I trigger a refresh/restart/whatever of the form controls so they start updating? It's a virtual certainty that at least one of the machines will be powered off any time this program is started. They also tend to spend a long time turned off (during change-overs, when they're not running it that shift, etc.). It's not ideal, but I can add a button to refresh communications for each driver. I'd rather have it automatic, though.