----Test comment ---------------------------------------------------------------------------- -- Handle the radio button action of the Jog increment buttons - My code! ---------------------------------------------------------------------------- currentInc = 0 -- my global var to track the current increment defined above function UpdateJogRadioButtons() --called from the PLC script local inst = mc.mcGetInstance() --VERY MUCH required local increment local rc increment, rc = mc.mcJogGetInc(inst, mc.X_AXIS) if (rc ~= mc.MERROR_NOERROR) then mc.mcCntlSetLastError(inst, 'JogGetInc failed') return; end if (increment ~= currentInc) then --so we don't unnecessarily update anything mc.mcCntlSetLastError(inst, "currentInc=" .. tostring(currentInc)) mc.mcCntlSetLastError(inst, "increment=" .. tostring(increment)) scr.SetProperty("btn1000micron", "Bg Color", "");--"ControlName", "PropertyName", "Value" scr.SetProperty("btn100micron", "Bg Color", "");--"ControlName", "PropertyName", "Value" scr.SetProperty("btn10micron", "Bg Color", "");--"ControlName", "PropertyName", "Value" scr.SetProperty("btn1micron", "Bg Color", "");--"ControlName", "PropertyName", "Value" if (increment == 1) then mc.mcCntlSetLastError(inst,'Jog Increment=1') scr.SetProperty("btn1000micron", "Bg Color", "#00FF00");--"ControlName", "PropertyName", "Value" elseif (increment == 0.1) then mc.mcCntlSetLastError(inst,'Jog Increment=0.1') scr.SetProperty("btn100micron", "Bg Color", "#00FF00");--"ControlName", "PropertyName", "Value" elseif (increment == 0.01) then mc.mcCntlSetLastError(inst,'Jog Increment=0.01') scr.SetProperty("btn10micron", "Bg Color", "#00FF00");--"ControlName", "PropertyName", "Value" elseif (increment == 0.001) then mc.mcCntlSetLastError(inst,'Jog Increment=0.001') scr.SetProperty("btn1micron", "Bg Color", "#00FF00");--"ControlName", "PropertyName", "Value" end --scr.SetProperty("btnContinuousMode", "Bg Color", "");--"ControlName", "PropertyName", "Value" currentInc = increment --remember what the new increment is end end function SetJogIncrement(incr) local inst = mc.mcGetInstance() --VERY MUCH required local rc local cinc = 0 incr = tonumber(incr) -- make sure incr is a number. -- Since we know that cycling the jog button on the screen also calls mc.mcJogSetInc(), -- just cycle the increments programatically. -- first, get our current increment. cinc, rc = mc.mcJogGetInc(inst, mc.X_AXIS) if (rc ~= mc.MERROR_NOERROR) then mc.mcCntlSetLastError(inst, 'SetJogIncrement() failed') return; end -- WARNING!!! This assumes that we actually have increments that match our values setup in the increments table!!! -- Meaning, we are expecting a match at some point. If not, this will loop forever. while (cinc ~= incr) do scr.DoFunctionName("Cycle Jog Increment") cinc, rc = mc.mcJogGetInc(inst, mc.X_AXIS) -- get the new increment. if (rc ~= mc.MERROR_NOERROR) then mc.mcCntlSetLastError(inst, 'SetJogIncrement() failed') return; end end end UpdateJogRadioButtons() SetJogIncrement(1) UpdateJogRadioButtons() SetJogIncrement(.1) UpdateJogRadioButtons() SetJogIncrement(.01) UpdateJogRadioButtons() SetJogIncrement(.001) --mobdebug = require('mobdebug') --mobdebug.onexit = mobdebug.done --mobdebug.start()