Hi.
can't help with all of those questions but I can show you how to do a few of them.
Have you watched the 'Edit Screen' video....you need to watch it.
In edit screen mode have a look at the <Cycle Start> button events. I have posted a screen shot of it. Note that the event has a 'left up script' That means when the screen button
is released the nominated script executes. In this case its not a script per se but rather a Lua function CycleStart().
Just as a matter of interest this is the source code of the function.....its in the screen load script:
---------------------------------------------------------------
-- Cycle Start() function.
---------------------------------------------------------------
function CycleStart()
local rc;
local tab, rc = scr.GetProperty("MainTabs", "Current Tab")
local tabG_Mdione, rc = scr.GetProperty("nbGCodeMDI1", "Current Tab")
local tabG_Mditwo, rc = scr.GetProperty("nbGCodeMDI2", "Current Tab")
--See if we have to do an MDI command and if so, which one
if ((tonumber(tab) == 0 and tonumber(tabG_Mdione) == 1) or (tonumber(tab) == 2 and tonumber(tabG_Mditwo) == 1 )) then
local state = mc.mcCntlGetState(inst);
if (state == mc.MC_STATE_MRUN_MACROH) then
mc.mcCntlCycleStart(inst);
mc.mcCntlSetLastError(inst, "Do Cycle Start");
else
if (tonumber(tab) == 0) then
scr.ExecMdi('mdi1');
mc.mcCntlSetLastError(inst, "Do MDI 1");
else
scr.ExecMdi('mdi2');
mc.mcCntlSetLastError(inst, "Do MDI 2");
end
end
elseif tonumber(tab) > 2 then --No G Code or MDI panel is displayed so Do Nothing
mc.mcCntlSetLastError(inst, "Nothing to Start");
else --Do CycleStart
mc.mcCntlSetLastError(inst, "Do Cycle Start");
mc.mcCntlCycleStart(inst);
end
end
Don't concern yourself with the code....I only mentioned it so that you could see in fact there is a bunch of code that runs when you call what looks like such a simple function call CycleStart().
In order that you can hit a remote button and have the cycle start what you want to do is have an input to Mach from the physical button call CycleStart() as if you'd hit the screen button.
In the ESS or PoKeys plugin assign an input pin to the physical button. Then in the Input Signals page in the ESS plugin (presumably the PoKeys plugin is similar but I'm not familiar with it)
connect that pin to a general purpose input signal ISIG_INPUT10 say.
Now you will need to put in the SigLib table an entry to tell Mach we are interested if the signal ISIG_INPUT10 triggers.
[mc.ISIG_INPUT10]=function(state)
if state==1 then
CycleStart()
end
end
And THAT'S IT! If you put that little piece of code into the SigLib table which is at the top of the screenload script you have coded all that is required to have Mach4 monitor an input
and execute a function when the input triggers. How easy is that?
You might have noticed that I attached a second screenshot of the <FeedHold> button. Note that it has a left up action. An action is internal to Mach and the above method wont work
for that action. I'm sure it can be done but need to think about it a bit more yet.
If in edit screen mode you click on various buttons that about half have either a script or a fuction as an event for which the recipie above will work and the rest have actions as events.
I will do some more thinking and research and get back to you.
Craig