--Ref all home buttons on clicked script WhileIsMoving(RefAllHome) --Screen Load Script --------------------------------------------------------------- -- While Is Moving() function. Added 3-14-17 --------------------------------------------------------------- function WhileIsMoving(FuncName) whileISmoving = coroutine.create(FuncName) end --------------------------------------------------------------- -- Ref All Home() function. --------------------------------------------------------------- function RefAllHome() mc.mcAxisDerefAll(inst) --Just to turn off all ref leds mc.mcAxisHomeAll(inst) coroutine.yield() --yield the calling coroutine so we can do the following after motion stops ----See ref all home button script and plc script for Coroutine whileISmoving resume wx.wxMessageBox('Referencing is complete') end --PLC Script ------------------------------------------------------- -- Coroutine whileISmoving resume ------------------------------------------------------- if (whileISmoving ~= nil) and (machState == 0) then --whileISmoving exist and state == idle local state = coroutine.status(whileISmoving) if state == "suspended" then --whileISmoving is suspended coroutine.resume(whileISmoving) --resume whileISmoving end end