Hello Guest it is May 14, 2021, 04:21:39 AM

Author Topic: If is running lua code  (Read 577 times)

0 Members and 1 Guest are viewing this topic.

If is running lua code
« on: October 31, 2018, 02:48:52 PM »

Hello,

I need a lua code for check if the gcode is running or not.

I try set one led on screen with (File Running, File Feed Hold), and this work on led, while start ou pause run the led is on, if stop the led turm off.


I create a lua script that ckeck is this led is on or off:

State = scr.GetProperty("RunningLed","Value")
if State == 1 then
   print ("led on")
   else
   print ("led Off")
   end


for some reason (I think that is a bug)  return always ON.

The same script for other diferente led, work OK


Any tip??





Offline DazTheGas

*
  •  753 753
  • DazTheGas
    • View Profile
Re: If is running lua code
« Reply #1 on: October 31, 2018, 05:34:31 PM »
You can do it by using an output signal IE


Code: [Select]
hSig, rc = mc.mcSignalGetHandle( inst, mc.OSIG_RUNNING_GCODE )
if rc == 0 then
GC_State = mc.mcSignalGetState(hSig)
if GC_State == 1 then
wx.wxMessageBox('GCode is running')
else
wx.wxMessageBox('GCode is not running')
end
else
wx.wxMessageBox('rc returned '..tostring(rc))
end

Place this in a button to test the effect with and without gcode running

DazTheGas
Theres always time for a choccy biccy
Re: If is running lua code
« Reply #2 on: November 02, 2018, 04:33:50 AM »


Thank you,

This script work if is running, but is  is Pause this return false, I need if is runnin and if is pause.

By the away, the led on the screen (return true) is a bug right?

Thnaks

Offline DazTheGas

*
  •  753 753
  • DazTheGas
    • View Profile
Re: If is running lua code
« Reply #3 on: November 02, 2018, 04:44:10 AM »
Probably better for you then is to use the states of the machine (MC_STATE_FRUN and MC_STATE_FRUN_FH)

DazTheGas
Theres always time for a choccy biccy