pageId = 0 screenId = 0 testcount = 0 machState = 0 machStateOld = -1 machEnabled = 0 machWasEnabled = 0 function IsAxisEnabled(axis) local inst = mc.mcGetInstance(); local ena = mc.mcAxisIsEnabled(inst, axis); -- mc.mcCntlSetLastError(0, 'in IsAxisEnable() ena = ' .. tostring(ena)); return tostring(ena); end function AxisEnable() local inst = mc.mcGetInstance(); local ena ena = IsAxisEnabled(0); scr.SetProperty('xPos', 'Enabled', ena); scr.SetProperty('xNeg', 'Enabled', ena); scr.SetProperty('btnZeroX', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroX2', 'Enabled', tostring(ena)); scr.SetProperty('btnRefX', 'Enabled', tostring(ena)); ena = IsAxisEnabled(1); scr.SetProperty('yPos', 'Enabled', tostring(ena)); scr.SetProperty('yNeg', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroY', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroY2', 'Enabled', tostring(ena)); scr.SetProperty('btnRefY', 'Enabled', tostring(ena)); ena = IsAxisEnabled(2); scr.SetProperty('zPos', 'Enabled', tostring(ena)); scr.SetProperty('zNeg', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroZ', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroZ2', 'Enabled', tostring(ena)); scr.SetProperty('btnRefZ', 'Enabled', tostring(ena)); ena = IsAxisEnabled(3); scr.SetProperty('aPos', 'Enabled', tostring(ena)); scr.SetProperty('aNeg', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroA', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroA2', 'Enabled', tostring(ena)); scr.SetProperty('btnRefA', 'Enabled', tostring(ena)); end scr.SetProperty('btnEnable', 'Label', 'Enable'); AxisEnable(); 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; -- Cycle Stop [mc.ISIG_INPUT4] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "4 - Cycle Stop NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() mc.mcCntlSetLastError(inst, "4 - Cycle Stop Pressed") mc.mcCntlCycleStop(inst) end end; -- Reset [mc.ISIG_INPUT5] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "5 - Reset NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() mc.mcCntlSetLastError(inst, "5 - Reset Pressed") mc.mcCntlReset(inst); end end; -- Rewind GCode [mc.ISIG_INPUT6] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "6 - Rewind GCode NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() mc.mcCntlSetLastError(inst, "6 - Rewind GCode Pressed") mc.mcCntlRewindFile(inst) end end; -- Reverse Run GCode [mc.ISIG_INPUT7] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "7 - Reverse Run GCode NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() mc.mcCntlSetLastError(inst, "7 - Reverse Run GCode Pressed") -- Code needed to Run GCode in Reverse end end; -- Feed Rate Over-ride + [mc.ISIG_INPUT8] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "8 - Feed Rate Over-ride + NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() mc.mcCntlSetLastError(inst, "8 - Feed Rate Override + Pressed") -- Code needed to adjust Feed Rate + end end; -- Feed Rate Over-Ride - [mc.ISIG_INPUT9] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "9 - Feed Rate Over-ride - NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() mc.mcCntlSetLastError(inst, "9 - Feed Rate Override - Pressed") -- Code needed to adjust Feed Rate - end end; -- Feed Rate Over-Ride Reset [mc.ISIG_INPUT10] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "10 - Feed Rate Over-ride Reset NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() mc.mcCntlSetLastError(inst, "10 - Feed Rate Override Reset Pressed") -- Code needed to Reset Feed Rate end end; -- Limit Switch Over-ride [mc.ISIG_INPUT11] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "11 - Limit Switch Over-ride NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() mc.mcCntlSetLastError(inst, "11 - Limit Switch Override Pressed") -- Code needed to over-ride hard limit switch end end; -- Zero X [mc.ISIG_INPUT12] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "12 - Zero X NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() local Axis = 0 mc.mcCntlSetLastError(inst, "12 - Zero X Pressed") -- Code needed to move axis to work edge mc.mcAxisSetPos(inst, Axis, 0.0) mc.mcToolPathGenerate(inst) end end; -- Zero Y [mc.ISIG_INPUT13] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "13 - Zero Y NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() local Axis = 1 mc.mcCntlSetLastError(inst, "13 - Zero Y Pressed") -- Code needed to move axis to work edge mc.mcAxisSetPos(inst, Axis, 0.0) mc.mcToolPathGenerate(inst) end end; -- Zero Z [mc.ISIG_INPUT14] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "14 - Zero Z NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() local Axis = 2 mc.mcCntlSetLastError(inst, "14 - Zero Z Pressed") -- Code needed to move axis to work edge mc.mcAxisSetPos(inst, Axis, 0.0) mc.mcToolPathGenerate(inst) end end; -- Zero All at any location [mc.ISIG_INPUT15] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "15 - Zero All NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() mc.mcCntlSetLastError(inst, "15 - Zero All Pressed") for Axis = 0,5 do mc.mcAxisSetPos(inst, Axis, 0.0) end mc.mcToolPathGenerate(inst) end end; -- Goto Zero [mc.ISIG_INPUT16] = function(state) mc.mcCntlSetLastError(mc.mcGetInstance(), "16 - Goto Zero NOT YET - " .. state) if (state == 1) then local inst = mc.mcGetInstance() mc.mcCntlSetLastError(inst, "16 - Goto Zero Pressed") mc.mcCntlGotoZero(inst) end end; }