1
Mach4 Toolbox / Re: Lua coding for External Controls
« on: September 12, 2015, 07:58:31 PM »
Thanks for your reply
the loop counter has fixed it
the loop counter has fixed it
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.
SigLib = {
-- Enable
[mc.OSIG_MACHINE_ENABLED] = function(state)
machEnabled = state
end,
-- Enable Button
[mc.ISIG_INPUT1] = function(state)
mc.mcCntlSetLastError(mc.mcGetInstance(), "1 - M4 Enable NOT YET - " .. state)
if (state == 1) then
local inst = mc.mcGetInstance()
local reg = mc.mcSignalGetHandle(inst, mc.OSIG_MACHINE_ENABLED)
machine_active = mc.mcSignalGetState(reg)
if (machine_active == 1) then
input_on_off = 0
mc.mcCntlSetLastError(inst, "1 - M4 Enable Pressed (OFF)")
else
input_on_off = 1
mc.mcCntlSetLastError(inst, "1 - M4 Enable Pressed (ON)")
end
mc.mcCntlEnable(inst, input_on_off)
end
end;
-- Cycle Start
[mc.ISIG_INPUT2] = function(state)
mc.mcCntlSetLastError(mc.mcGetInstance(), "2 - Cycle Start NOT YET - " .. state)
if (state == 1) then
local inst = mc.mcGetInstance()
mc.mcCntlSetLastError(inst, "2 - Cycle Start Pressed - " .. state)
mc.mcCntlCycleStart(inst)
end
end;
-- Feed Hold
[mc.ISIG_INPUT3] = function(state)
mc.mcCntlSetLastError(mc.mcGetInstance(), "3 - Feed Hold NOT YET - " .. state)
if (state == 1) then
local inst = mc.mcGetInstance()
mc.mcCntlSetLastError(inst, "3 - Feed Hold Pressed")
mc.mcCntlFeedHold(inst)
end
end;
1 - M4 Enable NOT YET - 0
2 - Cycle Start NOT YET - 0
3 - Feed Hold NOT YET - 0
1 - M4 Enable NOT YET - 0
1 - M4 Enable NOT YET - 1
1 - M4 Enable Pressed (ON)
2 - Cycle Start NOT YET - 0
2 - Cycle Start NOT YET - 1
2 - Cycle Start Pressed - 1
3 - Feed Hold NOT YET - 0
3 - Feed Hold NOT YET - 1
3 - Feed Hold Pressed
1 - M4 Enable NOT YET - 0
2 - Cycle Start NOT YET - 0
3 - Feed Hold NOT YET - 0