Hello Guest it is June 21, 2021, 12:24:35 PM

Author Topic: adding delay to signal script  (Read 247 times)

0 Members and 1 Guest are viewing this topic.

adding delay to signal script
« on: June 06, 2020, 12:28:01 PM »
I was wondering if there is any problem putting a delay in a signal script.  For example, this code would be added to the signal library in the screen load script:

[mc.ISIG_INPUT1] = function (state)
   if (state == 1) then   
      wx.wxMilliSleep(5000)
      mc.mcCntlEStop(inst)
   end
end,

This is just an example for simplicity sake. My question is, will I screw anything up by putting a delay (or a loop) into the signal script. In my mind, this code would receive a signal from input 1 while running some g code, continue running that code for 5 seconds and then trigger an estop. Am I correct in thinking this?
Again, this is just an example to keep my question simple.
Re: adding delay to signal script
« Reply #1 on: June 08, 2020, 10:23:29 AM »
You should avoid using wxMilliSleep as you will freeze the whole GUI especially for delays that long. Instead you should use wxTimer or the PMC
Re: adding delay to signal script
« Reply #2 on: June 08, 2020, 12:11:43 PM »
Thanks for the heads up SwiftyJ! I'll use the wxTimer instead.