Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: dbt3000files on June 06, 2020, 12:28:01 PM

Title: adding delay to signal script
Post by: dbt3000files 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.
Title: Re: adding delay to signal script
Post by: SwiftyJ 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
Title: Re: adding delay to signal script
Post by: dbt3000files on June 08, 2020, 12:11:43 PM
Thanks for the heads up SwiftyJ! I'll use the wxTimer instead.