Hello Guest it is March 28, 2024, 05:25:41 AM

Author Topic: Keyboard Inputs Enabled or Disabled Handle  (Read 5881 times)

0 Members and 1 Guest are viewing this topic.

Keyboard Inputs Enabled or Disabled Handle
« on: January 03, 2017, 06:02:52 PM »
I'm trying to get a handle on the Keyboard Inputs, whether it is enabled or disabled so I can set an output on or off. 

I've seen where there is GetHandle on Keyboard/Enable in the PLC First run but I'm not sure what it is getting a handle on. 

Is there a way to get the handle on whether or not the Keyboard is Enabled or Disabled?
Chad Byrd
Re: Keyboard Inputs Enabled or Disabled Handle
« Reply #1 on: January 03, 2017, 09:48:30 PM »
I found this video by DazTheGas
https://www.youtube.com/watch?v=8KgZ1SYxEdg
Gonna check it out in the morning and see if I can use some of this code.
Chad Byrd
Re: Keyboard Inputs Enabled or Disabled Handle
« Reply #2 on: January 04, 2017, 09:45:19 AM »
In the video from DazTheGas that I posted the buttons he was working with had code in them, now they have drop downs to determine the function. 

I tried to use the code form the video but it isn't working.  So I'm still stuck.   

Any ideas?
Chad Byrd

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Keyboard Inputs Enabled or Disabled Handle
« Reply #3 on: January 04, 2017, 02:12:28 PM »
The keyboard plugin exports an output that can be used to enable/disable the keyboard plugin.  It is not necessarily a reflection of the enabled status as nothing in the keyboard plugin will actually set the value of this output because it is well...  an output.  It is a control mechanism that the GUI can use to enable/disable the keyboard functionality.

Code: [Select]
local inst = mc.mcGetInstance()
local hIo, rc = mc.mcIoGetHandle(inst, "Keyboard/Enable")
if (rc == mc.MERROR_NOERROR) then
    --the keyboard plugin exists and the plugin is enabled and we found the plugin output.
    mc.mcIoSetState(hIo, 1) -- Turn the keyboard enable output on.  The keyboard plugin will now accept keyboard input.
    mc.mcIoSetState(hIo, 0) -- Turn the keyboard enable output off.  The keyboard plugin will not accept keyboard input.
end

But currently, there is nothing that will get the status of the keyboard plugin.  :(  Other than looking the task bar icon.

I will add a status register that can be read to determine the status in a future build. 

Steve

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Keyboard Inputs Enabled or Disabled Handle
« Reply #4 on: January 04, 2017, 03:30:54 PM »
I tried to use the code form the video but it isn't working.  So I'm still stuck.   

Just tried the code myself and all is fine, make sure you have the plugin enabled as the keyboard icon will show in the taskbar wether the plugin is enabled or not.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Keyboard Inputs Enabled or Disabled Handle
« Reply #5 on: January 04, 2017, 03:39:43 PM »
Thanks for the reply Steve.  It would be nice to have a status register to make things easier. 

DazTheGas,
If you don't mind, could you send me the code you used to test that to be sure I'm not making a mistake on my end?
Thanks!
Chad Byrd

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Keyboard Inputs Enabled or Disabled Handle
« Reply #6 on: January 04, 2017, 03:46:56 PM »
If you just want to get the state you can use

Code: [Select]
local inst = mc.mcGetInstance()
local hIo, rc = mc.mcIoGetHandle(inst, "Keyboard/Enable")
if (rc == 0) then
   local KbdState =  mc.mcIoGetState(hIo)
end

wx.wxMessageBox(tostring(KbdState)) -- 0 = Off, 1 = On   Just a test to show returned code

code for the example in video is as posted, nothing more or less, well apart from missing local inst = mc.mcGetInstance() at the beginning.

DazTheGas
New For 2022 - Instagram: dazthegas

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Keyboard Inputs Enabled or Disabled Handle
« Reply #7 on: January 04, 2017, 04:04:23 PM »
Scrap that last post?? local KbdState =  mc.mcIoGetState(hIo), sure that just worked but after cleaning up the code it doesnt??

DazTheGas   :o
New For 2022 - Instagram: dazthegas

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Keyboard Inputs Enabled or Disabled Handle
« Reply #8 on: January 04, 2017, 04:33:05 PM »
Because getting the state of an output is not logical.  You set outputs.  If you get the state of an output, the result is undefined because there isn't really a backing store for the state at the device level.  Meaning if you get the state of an output, it may be different than the actual state of the output on the device.  

I'm adding a register that will allow both getting the status and controlling the keyboard plugin.  A register actually has a backing store for the value.  

Steve
Re: Keyboard Inputs Enabled or Disabled Handle
« Reply #9 on: January 04, 2017, 05:16:50 PM »
I tried the code DazTheGas, I was getting the state of the Keyboard.  

Steve, That will be great when you get the register to control the keyboard plugin.  I am wanting to add a physical Button on the control panel that Lights up when the Keyboard Plugin is enabled and turns off when it's disabled, the button will toggle the keyboard plugin on and off.  This will make it easier for the operator to use, that way they don't have to keep going to the jogging tab to toggle the Keyboard Plugin.
Looking forward to it!!

Thanks for the time and insight guys!!
Chad Byrd