Hello Guest it is March 29, 2024, 12:41:09 AM

Author Topic: Disable button unless Idle  (Read 9876 times)

0 Members and 1 Guest are viewing this topic.

Disable button unless Idle
« on: May 08, 2014, 08:40:34 AM »
Hey folks,
 I inadvertently hit my G28 button WHILE GCode was running .... disastrous results. Blew its mind and locked up.

--G28 "Go to Machine Zeros, Z First"
        local inst = mc.mcGetInstance()
        local code = "G0 G53 Z0.0\n"
        code = code .. string.format("G0 G53 X0 Y0 A0\n")    
        mc.mcCntlGcodeExecute(inst, tostring(code))



Looking for an example of how, where and what to do to isolate, or disable a button while it should NOT be allowed to execute.

Looked through the sc script but am not sure what I'm looking for or where a lot of it is editable.

Add something to the button script ? or ?

Clues, hints or examples appreciated.

Thanks folks,
Russ
 :)
Re: Disable button unless Idle
« Reply #1 on: May 08, 2014, 09:06:52 AM »
might try something like this in the PLC script, just change the button name to what yours  is named

if (mc.mcCntlIsInCycle(inst) == 1) then
      scr.SetProperty('btnGotoZero', 'Enabled', '0');
else
      scr.SetProperty('btnGotoZero', 'Enabled', '1');
end
Re: Disable button unless Idle
« Reply #2 on: May 08, 2014, 10:16:27 AM »
Hi Craig,
  Can't seem to get this to work.
Is there a difference between a custom button and what looks like "assigned function" buttons/labels ?
Thanks,
Russ
Re: Disable button unless Idle
« Reply #3 on: May 08, 2014, 10:42:12 AM »
I did put that above code in the (if statement below) and it worked fine for that button
you might start with that first to prove that one works
what is your button Name? make sure you typed it the same, it is case sensitive.
 
other than that, not quite following you on the custom button and assigned function reference.

There are lots of tidbits to glean from by looking at the PLC script and the Cycle start Button Script

The only other thing is to post the whole "Lua Script" and we can look at it.
You can to use the right mouse button to select all and copy or Ctrl-A Ctrl-C
paste and save as a text file.

if ((machState ~= machStateOld) or (machEnable ~= machWasEnabled)) then

« Last Edit: May 08, 2014, 10:49:33 AM by Ya-Nvr-No »
Re: Disable button unless Idle
« Reply #4 on: May 08, 2014, 11:37:35 AM »
Hey, that graphic cleared it right up !
I had G28 as the Name AND the Label, but had btnG28 in your script.
Changed the Name to btnG28 and all is well ... Great, Thanks !

I thought maybe certain button names were reserved and already had associated functions assigned to them, but looks like you just make them up as you go. (just don't "mix n' match")

I'll try to figure this out on my own, but next I'd like to add isolation for when the control is Disabled. Like the Go to Zero and the Jogging.

Thanks a bunch !
Russ  8)
Re: Disable button unless Idle
« Reply #5 on: May 08, 2014, 01:34:59 PM »
There are several buttons/ops that will jam up the works if hit while the file is runnung.
I guess they could all be stacked like this ?

--From Craig to isolate G28 button, and others
    if (mc.mcCntlIsInCycle(inst) == 1) then
      scr.SetProperty('btnG28', 'Enabled', '0');
      scr.SetProperty('btnGotoZero', 'Enabled', '0');
      scr.SetProperty('tabFileOps', 'Enabled', '0');
    else
      scr.SetProperty('btnG28', 'Enabled', '1');
      scr.SetProperty('btnGotoZero', 'Enabled', '1');
      scr.SetProperty('tabFileOps', 'Enabled', '1');
    end

I wanted to try....   if ((mc.mcCntlIsInCycle(inst) == 1) or (mc.mc Call for Enabled or Disabled (inst) == 1(or0)) then .....
but could not determine what would go here --------------------------------------^
IsInCycle, IsStill, State .... I found. Is there one appropriate for this ?

Turns out, the axis' are disabled when in reset anyway, so that part is OK, just wondering what to call in tha case above.
Cool, thanks again Craig,
Russ

Re: Disable button unless Idle
« Reply #6 on: May 08, 2014, 01:46:39 PM »
Notice in the included photo that what your addressing is a field in the button options your just changing the state of it.
the checked box = 0 when not checked, and 1 when checked.
you could use the Hidden option

So Good job Russ that's kind of what I'd had planned too about the buttons
Re: Disable button unless Idle
« Reply #7 on: May 08, 2014, 01:56:54 PM »
Well I'll be ding danged, right there under my nose, just couldn't smell it.
(wondered what they were for ::) )

I'm anxious to get a manual on this ...... before pestering you folks to the point of being qualified to author it.  ;D

Thanks once more,
Russ
Re: Disable button unless Idle
« Reply #8 on: May 08, 2014, 02:23:32 PM »
I'll clarify...
 (mc.mcCntlIsInCycle(inst) == 1)   a file is running, ==0 would be not running   right ?

if so, what is the call for the following ?
 (mc.mc__________(inst) == 1)   control is enabled, ==0 control is disabled
or is there one?
Russ

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Disable button unless Idle
« Reply #9 on: May 08, 2014, 04:51:18 PM »
HIYA guys these are things that should be fixed in the core.

(;-) TP