Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: gorf23 on November 27, 2017, 02:55:17 PM

Title: mx.wxMessageBox question
Post by: gorf23 on November 27, 2017, 02:55:17 PM
Would like to know why when I run this in a dialog event function it runs no GUI lockup but have to hit enter or press ok button a lot
But if I remove the MessageBox then I get a GUI lockup...

Thanks

Code: [Select]
[/ mc.mcAxisSetPos(inst,  AxisNumber, 0);                                                                                 --"Zero Dro  (0 is x, 1 y, and so on)
   mc.mcCntlGcodeExecute(inst, 'G90 G0'..AxisLetter .. AxisEnteredDistance..'F1000');  -  Machine will stop at distance set
    local pos = 0
    repeat
    pos = mc.mcAxisGetPos(inst,  AxisNumber)
    wx.wxMessageBox("pos = "..pos.."  AxisEnteredDistance = "..AxisEnteredDistance)
    until pos == tonumber(AxisEnteredDistance)code]
Title: Re: mx.wxMessageBox question
Post by: DBK on December 02, 2017, 07:42:18 PM
When you are running with the MessageBox, does the axis move and does it ever get out of the repeat loop?
Title: Re: mx.wxMessageBox question
Post by: joeaverage on December 02, 2017, 10:01:19 PM
Hi,
I think DBK is on to the right thing.

The way I read the code is that without the intervening wx.wxMessageBox statement there is no time delay between

pos = mc.mcAxisGetPos(inst,  AxisNumber)   and

until pos == tonumber(AxisEnteredDistance)code]

Try removing the wx.wxMessageBox and substituting some sort of delay.

Craig
Title: Re: mx.wxMessageBox question
Post by: DBK on December 02, 2017, 10:18:36 PM
Actually in other programming languages, when you are in a very intensive loop, that may not allow the GUI to do it's housekeeping.  VB for instance has a DoEvents command that you would call every so many iterations of your loop to ensure the GUI could respond to other events in a timely manner.  I'm not up to speed with wxLua to know it's inner workings and whether or not this would be an issue.
Title: Re: mx.wxMessageBox question
Post by: gorf23 on December 05, 2017, 12:30:01 PM
I have tried all the delays I could think of but no good

So I decided to try a event timer, that has worked I set the timer to 1000 for now and all went well.
I checked the pos = mc.mcAxisGetPos(inst,  AxisNumber)
thought the timer function and seems ok the dro moves up and the gui doesn't lockup...

Thanks gary