191
Mach4 General Discussion / Re: Mach 4 Exit button for touchscreen
« on: December 17, 2019, 08:11:19 AM »
Try using scr.Exit(true)
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.
local rc = wx.wxMessageBox("This is my Message", "This is my Caption", wx.wxOK + wx.wxICON_ERROR)
wx.wxStaticBitmap:SetBitmap(wx.wxBitmap("imagelocation\\image.jpg", wx.wxBITMAP_TYPE_JPEG))
[mc.ISIG_INPUT18] = function (state) -- Set FRO 100%
if(state == 1) then
local inst = mc.mcGetInstance()
mc.mcCntlSetFRO(inst, 100) --Set FRO value 100%
local hReg = mc.mcRegGetHandle(inst, "iRegs0/cpJogType")
local jogType = mc.mcRegGetValue(hReg)
if (jogType == mc.MC_JOG_TYPE_INC) then --Check that Jog Type is incremental
setCpJogRate(100) --Set jog rate for incremental to 100%
end
end
end,
[mc.ISIG_INPUT19] = function (state) -- Increment Selection 1
if(state == 1) then
setCpJogRate(100) --Adjust speed for increment
setCpJogInc(1)
setCpJogType(mc.MC_JOG_TYPE_INC)
end
end,
[mc.ISIG_INPUT20] = function (state) -- Increment Selection 2
if(state == 1) then
setCpJogRate(100) --Adjust speed for increment
setCpJogInc(0.1)
setCpJogType(mc.MC_JOG_TYPE_INC)
end
end,
[mc.ISIG_INPUT21] = function (state) -- Increment Selection 3
if(state == 1) then
setCpJogRate(100) --Adjust speed for increment
setCpJogInc(0.01)
setCpJogType(mc.MC_JOG_TYPE_INC)
end
end,
[mc.ISIG_INPUT22] = function (state) -- Increment Selection 4
if(state == 1) then
setCpJogRate(100) --Adjust speed for increment
setCpJogInc(0.001)
setCpJogType(mc.MC_JOG_TYPE_INC)
end
end,
[mc.ISIG_INPUT23] = function (state) -- Increment Selection 5
if(state == 1) then
setCpJogRate(100) --Adjust speed for increment
setCpJogInc(0.0001)
setCpJogType(mc.MC_JOG_TYPE_INC)
end
end,
[mc.ISIG_INPUT24] = function (state) -- Jog Rate Selection 1
if(state == 1) then
setCpJogRate(2)
setCpJogType(mc.MC_JOG_TYPE_VEL)
end
end,
[mc.ISIG_INPUT25] = function (state) -- Jog Rate Selection 2
if(state == 1) then
setCpJogRate(5)
setCpJogType(mc.MC_JOG_TYPE_VEL)
end
end,
[mc.ISIG_INPUT26] = function (state) -- Jog Rate Selection 3
if(state == 1) then
setCpJogRate(10)
setCpJogType(mc.MC_JOG_TYPE_VEL)
end
end,
[mc.ISIG_INPUT27] = function (state) -- Jog Rate Selection 4
if(state == 1) then
setCpJogRate(25)
setCpJogType(mc.MC_JOG_TYPE_VEL)
end
end,
[mc.ISIG_INPUT28] = function (state) -- Jog Rate Selection 5
if(state == 1) then
setCpJogRate(50)
setCpJogType(mc.MC_JOG_TYPE_VEL)
end
end,
[mc.ISIG_INPUT29] = function (state) -- Jog Rate Selection 6
if(state == 1) then
setCpJogRate(75)
setCpJogType(mc.MC_JOG_TYPE_VEL)
end
end,
[mc.ISIG_INPUT30] = function (state) -- Jog Rate Selection 7
if(state == 1) then
setCpJogRate(100)
setCpJogType(mc.MC_JOG_TYPE_VEL)
end
end,
[mc.ISIG_INPUT43] = function (state) -- Off --This will stop all current jogging if off is selected
local axisNum
if (state == 1) and (machEnabled == 1) then --Only runs if mach is enabled.
for axisNum=0,5,1 do
if mc.mcJogIsJogging(inst, axisNum) == 1 then --Check to see if the axis is jogging
mc.mcJogVelocityStop(inst, axisNum) --If it is then stop jogging
mc.mcCntlSetLastError(inst, "Jog stopped via Control Panel")
end
end
end
end,
[mc.ISIG_INPUT44] = function (state) -- Select X axis
if(state == 1) then
setCpJogAxis(0)
end
end,
[mc.ISIG_INPUT45] = function (state) -- Select Y axis
if(state == 1) then
setCpJogAxis(1)
end
end,
[mc.ISIG_INPUT46] = function (state) -- Select Z axis
if(state == 1) then
setCpJogAxis(2)
end
end,
[mc.ISIG_INPUT47] = function (state) -- Select 4 axis
if(state == 1) then
setCpJogAxis(3)
end
end,
[mc.ISIG_INPUT48] = function (state) -- Select 5 axis
if(state == 1) then
setCpJogAxis(4)
end
end,
[mc.ISIG_INPUT49] = function (state) -- Select 6 axis
if(state == 1) then
setCpJogAxis(5)
end
end,
[mc.ISIG_INPUT51] = function (state) -- Jog+ Input
local hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT43)
local cpJogEna = mc.mcSignalGetState(hSig) ~= 1 --If signal is not equal to 1, then cpJogEna == True
if (machEnabled == 1) and cpJogEna then --If mach is enabled and cpJogEna == true
if(state == 1) and (machState == mc.MC_STATE_IDLE) then
cpJogAxis(mc.MC_JOG_POS)
else
cpJogAxis(mc.MC_JOG_STOP)
end
end
end,
[mc.ISIG_INPUT52] = function (state) -- Jog- Input
local hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT43)
local cpJogEna = mc.mcSignalGetState(hSig) ~= 1 --If signal is not equal to 1, then cpJogEna == True
if (machEnabled == 1) and cpJogEna then
if (state == 1) and (machState == mc.MC_STATE_IDLE) then
cpJogAxis(mc.MC_JOG_NEG)
else
cpJogAxis(mc.MC_JOG_STOP)
end
end
end,
function setCpJogInc(inc) --Sets value of cpJogInc register
local inst = mc.mcGetInstance()
local hReg = mc.mcRegGetHandle(inst, "iRegs0/cpJogInc")
mc.mcRegSetValue(hReg, inc)
end
function setCpJogRate(rate) --Sets value of cpJogRate register
local inst = mc.mcGetInstance()
local hReg = mc.mcRegGetHandle(inst, "iRegs0/cpJogRate")
mc.mcRegSetValue(hReg, rate)
end
function setCpJogType(mode) --Sets value of cpJogType register
local inst = mc.mcGetInstance()
local hReg = mc.mcRegGetHandle(inst, "iRegs0/cpJogType")
mc.mcRegSetValue(hReg, mode)
end
function setCpJogAxis(axis) --Sets value of cpJogAxis register
local inst = mc.mcGetInstance()
local hReg = mc.mcRegGetHandle(inst, "iRegs0/cpJogAxis")
mc.mcRegSetValue(hReg, axis)
end
function cpJogAxis(dir) --This function starts the jogging
local inst, hReg
inst = mc.mcGetInstance()
--Retrieve values from registers
hReg = mc.mcRegGetHandle(inst, "iRegs0/cpJogAxis")
local jogAxis = mc.mcRegGetValue(hReg)
hReg = mc.mcRegGetHandle(inst, "iRegs0/cpJogRate")
local jogRate = mc.mcRegGetValue(hReg)
hReg = mc.mcRegGetHandle(inst, "iRegs0/cpJogInc")
local jogInc = mc.mcRegGetValue(hReg)
hReg = mc.mcRegGetHandle(inst, "iRegs0/cpJogType")
local jogType = mc.mcRegGetValue(hReg)
--Set Jog Rate
mc.mcJogSetRate(inst, jogAxis, jogRate)
--Jog Axis
if (jogType == mc.MC_JOG_TYPE_INC) and dir ~= mc.MC_JOG_STOP then --If incremental jog
rc = mc.mcJogIncStart(inst, jogAxis, (jogInc*dir)) --Start the inc jog
if (rc ~= mc.MERROR_NOERROR) then
mc.mcCntlSetLastError(inst, string.format("Error %.0f: Unable to start incremental jog", rc))
end
elseif (jogType == mc.MC_JOG_TYPE_VEL) and dir ~= mc.MC_JOG_STOP then --If continuous and not stopping
rc = mc.mcJogVelocityStart(inst, jogAxis, dir)
if (rc ~= mc.MERROR_NOERROR) then
mc.mcCntlSetLastError(inst, string.format("Error %.0f: Unable to start continuous jog", rc))
end
elseif (jogType == mc.MC_JOG_TYPE_VEL) and dir == mc.MC_JOG_STOP then
mc.mcJogVelocityStop(inst, jogAxis)
end
end
[mc.ISIG_INPUT50] = function (state) -- Jog- Input
if (machEnabled == 1) then
local axisNum = getAxisToJog()
if(state == 1) then
jogAxis(axisNum, mc.MC_JOG_NEG)
else
jogAxis(axisNum, mc.MC_JOG_STOP)
end
end
end,