hi there
I almost have the same problem but mine seems to be worst
I am trying to get a the delay working in the signal script and up to now i have not succeeded.
as soon as i saw the wait function i wen ahead and used it but right after that i got an error.
i also tried using the wx.wxMilliSecond(), but it forces me to shut down the Mach 4
wx.wxMilliSleep(), not wx.wxMilliSecond().
Anyway, waiting 5 seconds in a script that is supposed to take nanoseconds to execute is
GOING to cause problems. The signal script is processed from a GUI messaging event. The Windows GUI has
ONE event queue. So a signal changes in the core and that fires one event to the GUI. Just like pressing a button sends a "clicked" event to the GUI. Well, while your signal event is waiting for 5 seconds, no other event is processed. This means no DROs get updated, no buttons will work on the screen, and the whole GUI just seems frozen. So even if your script didn't produce an error, it would have not worked well.
So what to do to solve the problem? Well, there are several ways to solve the issue gracefully. You can split the process up and let the PLC script count down and fire the second output signal signal (OSIG_OUTPUT6). This is the old school multi thread model. It is probably the most flexible but also the hardest to implement and really not needed for your application but I thought I would share it in case you or others may find it useful in the future:
1. Create a global flag variable and a global counter variable in the screen load script.
2. Set this global flag variable and initialize the counter variable In the signal script when ISIG_INPUT1 drives OSIG_OUTPUT5 high in the signal script.
3. In the PLC script, look for this flag and if it is set, start decrementing the counter variable by the refresh time of the screen (default of 50 milliseconds).
4. When the counter variable reaches zero, fire the OSIG_OUTPUT6 signal.
Next, there is the PMC. A simple PMC object can do this with a single rung. Attached are the sample PMC file and screen shot. You just have to change the output to match your system as the ones I used were from the Sim plugin. It is dead nuts simple and probably my favorite way of handling these logic oriented tasks.
And finally, there are the screen timer objects. Drop one on the screen, set the properties according to the attached screen shot (enabled all states, 5000ms, oneshot, and the name property to 'tmrOutput6Delay'), switch to the timer control's event properties and provide an event scrip[t that turns on your Output6, and modify your signal script to the following:
if (ISigFDBK == 1)then
mc.mcSignalSetState(hsignal,1)
scr.SetProperty('tmrOutput6Delay', 'Command', 'START'); -- start the one shot timer.
else
mc.mcSignalSetState(hsignal,0)
mc.mcSignalSetState(hsignale,0)
end
But again, I like the PMC method the best.
Steve