I have a toggle switch set up to to change the value of a register when the switch is up its a 1 and when the switch is down its a 0, that value is written to the profile ini.
Heres the button code, down sets it to 0 and up, a 1.
local inst = mc.mcGetInstance() -- Get the instance of Mach4
local setter = 0
mc.mcProfileWriteString(inst, "Tool Setter", "Probe", string.format (setter))
The register value is used in my M6 to either use the tool setter or a movable touch plate.
What I would like to do is to read that register value and change the state of the toggle switch based on that value during Mach4 startup, if its a 1 the switch state is up and visa versa.
I tried putting the following code in the screen load script
local setter = mc.mcProfileGetString(inst, "Tool Setter", "Probe", "setter")
setter = tonumber(setter)
if setter == 1 then
scr.SetProperty('tog_setter','Botton State', 'Up')
else
scr.SetProperty('tog_setter','Botton State', 'Down')
end
But that failed to change the state of the button. As it stands there is a possibility that the feedback from the toggle switch and the actual value of the register are not the same and the machine can act differently then what the operator expects. Any insight would be appreciated.
Thanks
Josh