Hello Guest it is April 27, 2024, 04:57:26 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Bill_O

321
Mach4 General Discussion / Re: External Control Panel Jog Buttons
« on: November 05, 2019, 08:22:37 AM »
Steve,

This is not a direct help but it still might help you.
It is not complete but I have not had the time to add to it.

Bill

https://www.machsupport.com/forum/index.php?topic=39763.msg266718#msg266718

322
Mach4 General Discussion / Re: Tool Change / Probe
« on: November 05, 2019, 08:19:06 AM »
B34R

i got this from Steve at New Fangled.
When you are ready to add the message box hope this helps.
Most of the script has been deleted. I left the part about the register that you will need.

Bill



So the issue is that you are launching a wxMessageBox from a macro script.  The macro scripts are run from the G code interpreter which is, in turn, run from the thread that loads the look ahead buffers.  This is NOT the main thread in the application, the core, or the mcLua plugin.  So no GUI functions should ever be launched from a macro script.  Also, the wxMessageBox() call really wants to have a parent window launch it.  There is no parent window in a macro script.  So what modal state does it take on?  The answer is undefined behavior, as in “we won’t know”.  

I understand the allure of wxMessageBox().  It is simple and easy to use.  But It just is never a good idea to use it in a macro script.  In fact, I wish I could take it out of wxLua completely because of this situation.  But what needs to be done is launch the wxMessageBox() from a main thread such as the Mach4GUI’s PLC script. 

1. Replace the wxMessageBox() calls in the macro script with “set and wait on clear” register flags. 
2. In the Mach4GUI’s PLC script, watch for the register to become set and launch the wxMessageBox().
3. Once the user dispenses with the message box, clear the register. 
4. The macro script sees that the register is clear and continues on. 

Here is the semi complete example for the macro script:
function m60()
    inst = mc.mcGetInstance() -- Get the current instance
    local rc -- Check the API return codes!!!!  There are no mysteries if you do.  :)

    --check for manual cut and wait if manual cut on
    local hregC, rc = mc.mcRegGetHandle(inst, 'iRegs0/ManCut')
    if (rc != mc.MERROR_NOERROR) then
        -- this will abort the G code process.  Reset will have to be issues to clear the alarm.
        mc.mcCntlMacroAlarm(inst, 0, "m60: Cannot get the handle to ManCut");
        return
    end
    local waitReg, rc = mc.mcRegGetHandle(inst, 'iRegs0/WaitFlag')
    if (rc != mc.MERROR_NOERROR) then
        -- this will abort the G code process.  This will just stop the file. 
        mc.mcCntlMacroStop(inst, 1, "m60: Cannot get the handle to ManCut");
        return
    end
    -- I will leave the rest of the error checking as your exercise.  :) 

    local ManualCut = mc.mcRegGetValue(hregC)
    if (ManualCut == 1) then
        mc.mcRegSetValue(waitReg, 1) -- set the register.
        --wx.wxMessageBox("Press Manual Cut Button")
        while (mc.mcRegGetValue(waitReg) == 1) do -- wait for it to clear.
            wx.wxMilliSleep(10)
        end
    end
    while (ManualCut == 1) do
        wx.wxMilliSleep(100)
        ManualCut = mc.mcRegGetValue(hregC)
       

Steve


323
Mach4 General Discussion / message box button color
« on: October 25, 2019, 04:33:10 PM »
Is it possible to change the color of the button in a message box?
If so, how?

Thanks,
Bill

324
Mach4 General Discussion / error in mcs file code
« on: October 25, 2019, 04:15:24 PM »
I have a very specialized machine running Mach4.
I have one macro that is to cut the material and return to a starting position.
The operator of the machine has the choice to have the machine cut the material automatically or manual where they must press a button.
I made a message box to pop up when they chose the manual telling them to press the button.
On the first m60 of the program it works perfect.
On the second I get the error screen. If I click No the message box pops up and everything functions.
If I comment out the message box if-then section I do not get the error.
I have attached the error in a picture, the m60 code and the file that I was running.
Any ideas what I am missing?

Bill

325
Jelle,

The best thing I have found to use is registers.
Here is a link to a Lua for Dummies I made.
It has some stuff on registers.
https://www.machsupport.com/forum/index.php?topic=39763.msg266718#msg266718
Hope it helps.

Bill

326
Mach4 General Discussion / Re: Mach 4 Screen Editor GCode Help
« on: October 11, 2019, 03:09:21 PM »
Guess I should have looked closer at the code you gave him.
I see where you are getting the current position.
Not sure why you think it is a bad idea to change between g90 and g91 as long as you put things back where you need it when you are done.

Bill

327
Mach4 General Discussion / Re: Mach 4 Screen Editor GCode Help
« on: October 09, 2019, 03:39:07 PM »
You might want to have a g91 before those moves in case the current position is not at 0 then switch back to g90

328
Mach4 General Discussion / Re: Having trouble with Lua Script
« on: October 09, 2019, 09:50:47 AM »

329
Mach4 General Discussion / Re: luac files
« on: September 11, 2019, 08:27:50 AM »
Steve,

Thanks for the reply.
Guess I will just need to do it the hard way and figure it out myself.

Bill

330
Is there a G20 anywhere in any of the buttons or macros that you use?

Bill