Very nice solution Daz and an excellent video.
I am considering building a complete USB interfaced operator panel and will need over 60 inputs, as I didn't want to tie up almost all the inputs in M4 I found a way to read from the keyboard plugin directly rather than mapping the inputs to the I/O table.
I realized that the PMC script could read directly from the keyboard plugin but was limited as what I could write to so I borrowed the code from the PMC script and put it in the PLC script in the same place you added yours.
Here it is;
local hIo, hReg, hSig, rc
local mInst = 0
local function Read_Io(path)
hIo = 0
rc = mc.MERROR_NOERROR
hIo, rc = mc.mcIoGetHandle(mInst, path)
if (rc == mc.MERROR_NOERROR) then
local state = 0
state, rc = mc.mcIoGetState(hIo)
if (rc == mc.MERROR_NOERROR) then
return state
end
end
return 0
end
if(Read_Io("Keyboard/input0") == 1) then -- "input0" is the name of the mapped key in the keyboard plugin
scr.SetProperty('slideFRO', 'Value', tostring(100)); -- Sets federate override to 100%
end