281
Mach4 General Discussion / Re: Mach4 Lua for Dummies
« on: August 04, 2020, 12:17:43 PM »
new version
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.
-------------------------------------------------------
-- Cycle time label update
-------------------------------------------------------
--Requires a static text box named "CycleTime" on the screen
if (machEnabled == 1) then
local running = mc.mcCntlIsInCycle(inst)
if (running == 1) then
local cycletime = mc.mcCntlGetRunTime(inst, time)
scr.SetProperty("CycleTime", "Label", SecondsToTime(cycletime))
end
end
function m7()
local inst = mc.mcGetInstance()
--Get Mist On and Mister Auto handles
local hMist = mc.mcSignalGetHandle(inst, mc.OSIG_MISTON)
local hreg = mc.mcRegGetHandle(inst, 'iRegs0/MisterAuto')
--Get Mister Auto value
local MistVal = mc.mcRegGetValue(hreg)
if (MistVal == 0) then
mc.mcSignalSetState(hMist, 0)
--wx.wxMessageBox('Mist OFF')
else
mc.mcSignalSetState(hMist, 1)
--wx.wxMessageBox('Mist ON')
end
end
if (mc.mcInEditor() == 1) then
m7()
end
function m3()
local inst = mc.mcGetInstance()
--Get Spindle On and Spindle Auto handles
local hSpin = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON)
local hreg = mc.mcRegGetHandle(inst, 'iRegs0/SpindleAuto')
--Get spindle on state
local SpinOn = mc.mcSignalGetState(hSpin)
--Get Spindle Auto value
local SpinVal = mc.mcRegGetValue(hreg)
if (SpinVal == 0) then
mc.mcSignalSetState(hSpin, 0)
--wx.wxMessageBox('Spindle OFF')
else
if (SpinOn == 0) then
mc.mcSignalSetState(hSpin, 1)
wx.wxMilliSleep(5500)
--wx.wxMessageBox('Spindle ON')
end
end
end
if (mc.mcInEditor() == 1) then
m3()
end
function M07()
--wx.wxMessageBox('In M07')
mc.mcCntlSetLastError(inst, "In M07")
local inst = mc.mcGetInstance()
--Get Mist On and Mister Auto handles
local hMist = mc.mcSignalGetHandle(inst, mc.OSIG_MISTON)
local hreg = mc.mcRegGetHandle(inst, 'iRegs0/MisterAuto')
--Get Mister Auto value
local MistVal = mc.mcRegGetValue(hreg)
if (MistVal == 0) then
mc.mcSignalSetState(hMist, 0)
--wx.wxMessageBox('Mist OFF')
else
mc.mcSignalSetState(hMist, 1)
--wx.wxMessageBox('Mist ON')
end
end
if (mc.mcInEditor() == 1) then
M07()
end