Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: arhimedoffs on March 19, 2018, 03:50:49 PM
-
How much Lua interpreters run in Mach4?
As I check by module loading M-commands scripting and loading the same module in Screen load. Module loaded both even with check
if package.loaded.EWelder == nil then
ew = require "EWelder"
mc.mcCntlSetLastError(inst, "load_modules. EWelder loaded")
else
mc.mcCntlSetLastError(inst, "load_modules. EWelder already loaded")
end
That is why question: there are two separate threads for UI and G-code execution? Or more. And where PLC script and Signal script executed, in UI thread?
-
Hi,
yes there are two Lua chunks at runtime, of course only one can run at a time.
All of the separate scripts including Screen Load, Screen Unload, PLC and so on get pulled into one file and compiled.
The big file is called simply Lua Script. You have a read only version under Operator/Lua Script.
Craig
-
yes there are two Lua chunks at runtime, of course only one can run at a time.
- why only one at a time? Does this mean that M command execution freeze PLC script? As I assume this two interpreters run in separate threads, one - for UI and PLC staff, other - machine interpreter (MDI or File).
-
Hi,
I'm not sufficiently confident that I can answer definitively. I think there is only one interpreter at it operates on one chunk at any given instant.
You can see this if you call a long running Gcode from a macro with mc.CntlGcodeExecuteWait() then the GUI will freeze until the code is finished at the the Lua
interpreter is free to run the GUI script again and update it.
Craig
-
This is very strange. I use script
function m101()
if not ew.isMachineInSpotMode() then
ew.onIncorrectCommand()
return
end
ew.sigVars['tbToUp'] = 1
repeat
wx.wxMilliSleep(100)
until (ew.sigVars['tbIsUp'] == 1) or not ew.isWorking()
end
if (mc.mcInEditor() == 1) then
m101()
end
This script turn on table up valve and wait upper position responce. And it work! No freeze UI and it realy wait table upper position or machine stopped. If I disconnect position switch it wait infinitely, and UI responce OK.