Hello Guest it is March 28, 2024, 04:34:55 AM

Author Topic: mx.wxMessageBox question  (Read 1889 times)

0 Members and 1 Guest are viewing this topic.

Offline gorf23

*
  •  183 183
    • View Profile
mx.wxMessageBox question
« 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]

Offline DBK

*
  •  9 9
    • View Profile
Re: mx.wxMessageBox question
« Reply #1 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?
Re: mx.wxMessageBox question
« Reply #2 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
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline DBK

*
  •  9 9
    • View Profile
Re: mx.wxMessageBox question
« Reply #3 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.

Offline gorf23

*
  •  183 183
    • View Profile
Re: mx.wxMessageBox question
« Reply #4 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