Several more hours wasted with 0 learned and 0 accomplished....tried all of this and nothing works....
--FIGURED IT WOULDNT WORK, BUT TRYING ANYTHING
--DOES NOT WORK> CONTINUOUS MODE JOG+ PRESS AND RELEASED WILL NOT STOP RUNNING
--INC JOG WORKS
-- Add Pokeys Input 51 to Mach4 Input 51 for +Jog on Control Panel
[mc.ISIG_INPUT51] = function (state)
local inc, rc = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_INC);
local joginc = mc.mcSignalGetState(inc)
local cont, rc = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_CONT);
local jogcont = mc.mcSignalGetState(cont)
if(state == 1) then
CPJogPlus()
elseif (jogcont == 0) then
rc=mc.mcJogVelocityStop(inst,0)
rc=mc.mcJogVelocityStop(inst,1)
rc=mc.mcJogVelocityStop(inst,2)
end
end,
--DOES NOT WORK
-- Add Pokeys Input 51 to Mach4 Input 51 for +Jog on Control Panel
[mc.ISIG_INPUT51] = function (state)
local inc, rc = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_INC);
local joginc = mc.mcSignalGetState(inc)
local cont, rc = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_CONT);
local jogcont = mc.mcSignalGetState(cont)
if(state == 1) then
CPJogPlus()
elseif (jogcont == 0) then
rc=mc.mcJogVelocityStop(inst,0)
rc=mc.mcJogVelocityStop(inst,1)
rc=mc.mcJogVelocityStop(inst,2)
end
end,
--Control Panel Jogging +
function CPJogPlus()
local in44, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT44)
local axSelX = mc.mcSignalGetState (in44)
local in45, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT45)
local axSelY = mc.mcSignalGetState (in45)
local in46, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT46)
local axSelZ = mc.mcSignalGetState (in46)
local in47, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT47)
local axSel4 = mc.mcSignalGetState (in47)
local in48, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT48)
local axSel5 = mc.mcSignalGetState (in48)
local in49, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT49)
local axSel6 = mc.mcSignalGetState (in49)
local in19, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT19)
local jogSel1 = mc.mcSignalGetState (in19)
local in20, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT20)
local jogSelx1 = mc.mcSignalGetState (in20)
local in21, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT21)
local jogSelx01 = mc.mcSignalGetState (in21)
local in22, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT22)
local jogSelx001 = mc.mcSignalGetState (in22)
local in23, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT23)
local jogSelx0001 = mc.mcSignalGetState (in23)
local in24, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT24)
local contJog2 = mc.mcSignalGetState (in24)
local in25, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT25)
local contJog5 = mc.mcSignalGetState (in25)
local in26, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT26)
local contJog10 = mc.mcSignalGetState (in26)
local in27, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT27)
local contJog25 = mc.mcSignalGetState (in27)
local in28, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT28)
local contJog50 = mc.mcSignalGetState (in28)
local in29, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT29)
local contJog75 = mc.mcSignalGetState (in29)
local in30, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT30)
local contJog100 = mc.mcSignalGetState (in30)
--get current jog set type and settings here if needed
if axSelX == 1 and jogSel1 == 1 then
local Inc, rc = mc.mcSignalGetHandle (inst, mc.OSIG_JOG_INC)
jogInc = mc.mcSignalGetState (Inc)
rc = mc.mcJogIncStart(inst,0,1)
mc.mcSignalSetState (Inc,1)
elseif axSelX == 1 and jogSelx1 == 1 then
rc = mc.mcJogIncStart(inst,0,.1)
elseif axSelX == 1 and jogSelx01 == 1 then
rc = mc.mcJogIncStart(inst,0,.01)
elseif axSelX == 1 and jogSelx001 == 1 then
rc = mc.mcJogIncStart(inst,0,.001)
elseif axSelX == 1 and jogSelx0001 == 1 then
rc = mc.mcJogIncStart(inst,0,.0001)
elseif axSelY == 1 and jogSel1 == 1 then
rc = mc.mcJogIncStart(inst,1,1)
elseif axSelY == 1 and jogSelx1 == 1 then
rc = mc.mcJogIncStart(inst,1,.1)
elseif axSelY == 1 and jogSelx01 == 1 then
rc = mc.mcJogIncStart(inst,1,.01)
elseif axSelY == 1 and jogSelx001 == 1 then
rc = mc.mcJogIncStart(inst,1,.001)
elseif axSelY == 1 and jogSelx0001 == 1 then
rc = mc.mcJogIncStart (inst,1,.0001)
elseif axSelZ == 1 and jogSel1 == 1 then
rc = mc.mcJogIncStart(inst,2,1)
elseif axSelZ == 1 and jogSelx1 == 1 then
rc = mc.mcJogIncStart(inst,2,.1)
elseif axSelZ == 1 and jogSelx01 == 1 then
rc = mc.mcJogIncStart(inst,2,.01)
elseif axSelZ == 1 and jogSelx001 == 1 then
rc = mc.mcJogIncStart(inst,2,.001)
elseif axSelZ == 1 and jogSelx0001 == 1 then
rc = mc.mcJogIncStart(inst,2,.0001)
elseif axSelX == 1 and contJog2 == 1 then
rc = mc.mcJogSetRate(inst,0,2)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog5 == 1 then
rc = mc.mcJogSetRate(inst,0,5)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog10 == 1 then
rc = mc.mcJogSetRate(inst,0,10)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog25 == 1 then
rc = mc.mcJogSetRate(inst,0,25)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog50 == 1 then
rc = mc.mcJogSetRate(inst,0,50)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog75 == 1 then
rc = mc.mcJogSetRate(inst,0,75)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog100 == 1 then
rc = mc.mcJogSetRate(inst,0,100)
rc = mc.mcJogVelocityStart(inst,0,1)
end
local cont = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_CONT);
local jogcont = mc.mcSignalGetState(cont)
local inc = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_INC);
local joginc = mc.mcSignalGetState(inc)
local mpg = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_MPG);
local jogmpg = mc.mcSignalGetState(mpg)
if (jogcont == 1) then
mc.mcSignalSetState(cont, 0)
mc.mcSignalSetState(inc, 1)
mc.mcSignalSetState(mpg, 0)
else
mc.mcSignalSetState(cont, 1)
mc.mcSignalSetState(inc, 0)
mc.mcSignalSetState(mpg, 0)
end
end
--ADDED A WAIT IN THE FUNCTION FOR ONE OF THE INCREMENTAL JOGS TO TEST
--WHO KNOWS IF SYNTAX IS CORRECT DUE TO BAD API MANUAL
--GIVES AN ERROR, SO I GUESS THE CRAPPY MANUAL STRIKES AGAIN
-- LUA:Error while running chunk
c:\Mach4Hobby\ScreenScript.Lua:575:Expected a 'number'for parameter 2, but got a 'nil'
Function called \: 'mcSignalHandleWait(number,nil,number)'
01.mcSignalHandleWait(number,number,number)
stack trackback:
[C]: in function 'mc.mcSignalHandleWait'
C:\Mach4Hobby\ScreenScript.lua:575:in function 'CPJogPlus'
C:\Mach4Hobby\ScreenScript.lua:114:in field '?'
C:\Mach4Hobby\ScreenScript.lua:858:in function 'Mach_Signal_Script'
-- Add Pokeys Input 51 to Mach4 Input 51 for +Jog on Control Panel
[mc.ISIG_INPUT51] = function (state)
if(state == 1) then
CPJogPlus()
else
rc=mc.mcJogVelocityStop(inst,0)
rc=mc.mcJogVelocityStop(inst,1)
rc=mc.mcJogVelocityStop(inst,2)
end
end,
--Control Panel Jogging +
function CPJogPlus()
local in44, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT44)
local axSelX = mc.mcSignalGetState (in44)
local in45, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT45)
local axSelY = mc.mcSignalGetState (in45)
local in46, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT46)
local axSelZ = mc.mcSignalGetState (in46)
local in47, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT47)
local axSel4 = mc.mcSignalGetState (in47)
local in48, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT48)
local axSel5 = mc.mcSignalGetState (in48)
local in49, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT49)
local axSel6 = mc.mcSignalGetState (in49)
local in19, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT19)
local jogSel1 = mc.mcSignalGetState (in19)
local in20, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT20)
local jogSelx1 = mc.mcSignalGetState (in20)
local in21, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT21)
local jogSelx01 = mc.mcSignalGetState (in21)
local in22, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT22)
local jogSelx001 = mc.mcSignalGetState (in22)
local in23, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT23)
local jogSelx0001 = mc.mcSignalGetState (in23)
local in24, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT24)
local contJog2 = mc.mcSignalGetState (in24)
local in25, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT25)
local contJog5 = mc.mcSignalGetState (in25)
local in26, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT26)
local contJog10 = mc.mcSignalGetState (in26)
local in27, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT27)
local contJog25 = mc.mcSignalGetState (in27)
local in28, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT28)
local contJog50 = mc.mcSignalGetState (in28)
local in29, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT29)
local contJog75 = mc.mcSignalGetState (in29)
local in30, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT30)
local contJog100 = mc.mcSignalGetState (in30)
--get current jog set type and settings here if needed
if axSelX == 1 and jogSel1 == 1 then
rc = mc.mcJogIncStart(inst,0,1)
rc = mc.mcSignalHandleWait (mc.OSIG_JOG_INC,WAIT_MODE_LOW,10)
elseif axSelX == 1 and jogSelx1 == 1 then
rc = mc.mcJogIncStart(inst,0,.1)
elseif axSelX == 1 and jogSelx01 == 1 then
rc = mc.mcJogIncStart(inst,0,.01)
elseif axSelX == 1 and jogSelx001 == 1 then
rc = mc.mcJogIncStart(inst,0,.001)
elseif axSelX == 1 and jogSelx0001 == 1 then
rc = mc.mcJogIncStart(inst,0,.0001)
elseif axSelY == 1 and jogSel1 == 1 then
rc = mc.mcJogIncStart(inst,1,1)
elseif axSelY == 1 and jogSelx1 == 1 then
rc = mc.mcJogIncStart(inst,1,.1)
elseif axSelY == 1 and jogSelx01 == 1 then
rc = mc.mcJogIncStart(inst,1,.01)
elseif axSelY == 1 and jogSelx001 == 1 then
rc = mc.mcJogIncStart(inst,1,.001)
elseif axSelY == 1 and jogSelx0001 == 1 then
rc = mc.mcJogIncStart (inst,1,.0001)
elseif axSelZ == 1 and jogSel1 == 1 then
rc = mc.mcJogIncStart(inst,2,1)
elseif axSelZ == 1 and jogSelx1 == 1 then
rc = mc.mcJogIncStart(inst,2,.1)
elseif axSelZ == 1 and jogSelx01 == 1 then
rc = mc.mcJogIncStart(inst,2,.01)
elseif axSelZ == 1 and jogSelx001 == 1 then
rc = mc.mcJogIncStart(inst,2,.001)
elseif axSelZ == 1 and jogSelx0001 == 1 then
rc = mc.mcJogIncStart(inst,2,.0001)
elseif axSelX == 1 and contJog2 == 1 then
rc = mc.mcJogSetRate(inst,0,2)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog5 == 1 then
rc = mc.mcJogSetRate(inst,0,5)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog10 == 1 then
rc = mc.mcJogSetRate(inst,0,10)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog25 == 1 then
rc = mc.mcJogSetRate(inst,0,25)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog50 == 1 then
rc = mc.mcJogSetRate(inst,0,50)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog75 == 1 then
rc = mc.mcJogSetRate(inst,0,75)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog100 == 1 then
rc = mc.mcJogSetRate(inst,0,100)
rc = mc.mcJogVelocityStart(inst,0,1)
end
end
--DID THE ABOVE AGAIN, but CHANGED THIS LINE from:
rc = mc.mcSignalHandleWait (mc.OSIG_JOG_INC,WAIT_MODE_LOW,10)
--TO
rc = mc.mcSignalHandleWait (mc.OSIG_JOG_INC,0,10):
--Thanks crap manual
--This completely crashes Mach and generates a report to send when you press the Jog+ button
---Changed
rc = mc.mcSignalHandleWait (mc.OSIG_JOG_INC,0,10)
--TO
rc = mc.mcSignalWait (inst,mc.OSIG_JOG_CONT,10 )
--THIS APPEARS TO DO NOTHING, IT DOES NOT WAIT FOR S#|T, IT JUST STOPS MOVING AS SOON AS YOU LET GO OF THE BUTTON
--USED THE WRONG CODE ABOVE ON ACCIDEING "CONT" instead of "INC"
---Changed
rc = mc.mcSignalWait (inst,mc.OSIG_JOG_CONT,10 )
--TO
rc = mc.mcSignalWait (inst,mc.OSIG_JOG_INC,10 )
--THIS GIVE AN ERROR, THINK IT WANTS THE VALUE OF WHAT IT SHOULD BE WAITING FOR
--CHANGED THIS
rc = mc.mcSignalWait (inst,mc.OSIG_JOG_INC,10 )
--TO
rc = mc.mcSignalWait (inst,mc.OSIG_JOG_INC,0,10 )
--THIS STILL DOES NOT WAIT FOR ANYTHING. USELESS! STILL JUST STOPS MOVING IF YOU LET GO OF THE BUTTON
--I DO FIND THAT IT SEEMS LIKE SOME CHANGES DO NOT WORK RIGHT UNLESS YOU EXIT MACH COMPLETELY ARE REOPEN, I HOPE THIS IS
--NOT MAKING ME SKIP OVER SOMETHING THAT MIGHT WORK>>>
--ADDED TO GET THE VALUE OF mc.OSIG_JOG_INC location and try to use that variable instead of directly using it
---CHANGED CODE TO THIS:
local crap, rc = mc.mcSignalGetHandle (inst, mc.OSIG_JOG_INC)
if axSelX == 1 and jogSel1 == 1 then
rc = mc.mcJogIncStart(inst,0,1)
local FinCrapola = mc.mcSignalGetState (crap)
rc = mc.mcSignalWait (inst,FinCrapola,0,10)
--AGAIN THIS DOES NOTHING AND DOES NOT WAIT FOR ANYTHING