Home AMX User Forum NetLinx Studio
Options

Storing akeyp data

Hello All,
Just wondering if there is a way to store, in a netlinx processor, the keys entered from either a akeyp or akeyb?

In other words, without having to create my own keyboard and channel numberts, if I type the numbers 1234 on the internal keypad of either a TP3 or TP4 touchpanel can I see, on my processor that someone just typed 1234?

Thanks,
Tim

Comments

  • Options
    Joe HebertJoe Hebert Posts: 2,159
    Hi Tim,

    Yes, the user results from AKEYP or AKEYB entries can be trapped with the STRING handler of the DATA_EVENT for the TP and it can be read in with DATA.TEXT.

    Data from the touch panel that is generated from a keypad entry will start with ?KEYP-?
    Data from the touch panel this is generated from a keyboard entry will start with ?KEYB-?

    For example:
    DEFINE_DEVICE
    dvTP=10001:1:0
    
    DEFINE_EVENT
    
    DATA_EVENT[dvTP] {
       STRING: {
    
          SELECT {
          
    	 ACTIVE(FIND_STRING(DATA.TEXT,'KEYP-',1)): {
    	 
    	    //do what you want with the keypad data that has arrived
    	    //if the user pressed 1234 then DATA.TEXT='KEYP-1234'
    	    
    	 }
    
    	 ACTIVE(FIND_STRING(DATA.TEXT,'KEYB-',1)): {
    	 
    	    //do what you want with the keyboard data that has arrived
    	    //if the user pressed ABCD then DATA.TEXT='KEYB-ABCD'
    	    
    	 }
    	 
          }
       }
    }
    
    BUTTON_EVENT[dvTP,1] {
       PUSH: {
          SEND_COMMAND dvTP, 'AKEYP'
       }
    }
    
    BUTTON_EVENT[dvTP,2] {
       PUSH: {
          SEND_COMMAND dvTP, 'AKEYB'
       }
    }
    
    

    I hope this gets you started in the right direction.

    Joe
  • Options
    Storing AKEYP Data

    And to add to Joe's posting, you can initialize the keypad or keyboard with a unique string that will also be returned to you in the DATA_EVENT STRING handler. This can be useful for determining which keypad or keyboard popup was used if you use multiple keypads or keyboards in your TP files and Netlinx programs.

    For example,
    BUTTON_EVENT[dvTP,1] 
    {
       PUSH:
       {
          SEND_COMMAND dvTP, 'AKEYP-ONE'
       }
    }
    

    will generate STRINGs that start with 'AKEYP-ONE' and this can be used in your STRING handler parser to determine which keypad/keyboard was used and then what you want to do with the data.
  • Options
    Joe HebertJoe Hebert Posts: 2,159
    As a caveat, it?s true you can initialize the keyboard or keypad with a string of your choice, however, there?s no guarantee that that string will be returned to you in the STRING handler. All the user has to do is hit backspace, clear, or abort and that initialization string will be altered or wiped out.

    Joe
  • Options
    If you have a G4 panel, you can get a keyword back from the Beyboard/Keypad.

    1) copy a keypad/keyboard popup page from the panel template into your panelfile
    -> keep in mind that this is a popup page now; if necessary to open from the master, use like SEND_COMMAND PANEL,'@PPN-MYKEYPAD'
    2) in TPD4, on this popup, mark the textfield and have a look at its general properties
    3) the NAME is the keyword which is sent from the panel into the master when DONE is pressed on the keypad popup. Rename the button like you want
  • Options
    Can the AKEYB be adjusted to send string on a different port?

    Is there a way that i can cause the AKEYB to report it's information on Modero Port 14 instead of 1. I need the data on port 14. Is this possible without redirecting the string with netlinx code?
  • Options
    AlexArtist wrote:
    Is there a way that i can cause the AKEYB to report it's information on Modero Port 14 instead of 1. I need the data on port 14. Is this possible without redirecting the string with netlinx code?

    No, this is a limitation in firmware. The keypad/keyboard responses will only come on port 1. But if you rename the textfield like described before, you can differ by name from where the data was sent. And because port 14 must also be only if port 1 is online, it should not be a problem but only if you work with the port 14 within a module or similar.
  • Options
    I am working within a module unfortunetly. Darn, i have to make a keyboard now, but it shouldn't be that bad.
  • Options
    Then we really need a workaround..... maybe this work:
    MODULE_NAME='MyModule'(DEV dvPanelReal,DEV vdvPanelPort14)
    
    DEFINE_EVENT
    DATA_EVENT[dvPanelReal.Number:1:0] // pick up ANY Port 1 action
    {
      STRING:
      {
        IF(FIND_STRING(DATA.TEXT,'P14KEYB-',1)) // textfield of the keyboard must be definde accordingly
        {
          SEND_STRING vdvPanelPort14,DATA.TEXT
        }
      }
    }
    
  • Options
    Spire_JeffSpire_Jeff Posts: 1,917
    I dealt with this issue by creating a variable array that indicates the current operation of each touchpanel. Something like:
    DEFINE_CONSTANT
    NUM_OF_TPs = 4
    
    DEFINE_DEVICE
    dvTP_PORT1 = 10001:1:0
    
    DEFINE_VARIABLE
    nCURRENT_OP[NUM_OF_TPs] 
    
    DEFINE_CALL 'Show Keyboard' (INTEGER TP, INTEGER OPERATION, CHAR INITIAL_TEXT[20], CHAR PROMPT[50])
    {
    nCURRENT_OP[TP] = OPERATION
    SEND_COMMAND dvTP_PORT1[TP],"'@AKB-',INITIAL_TEXT,';',PROMPT"
    
    // ADD Code to handle timeouts if desired
    }
    
    DEFINE_EVENT
    DATA_EVENT[dvTP_PORT1[NUM_OF_TPs]]
    {
    STRING:
    	{
        STACK_VAR INTEGER TPINDEX 
        TPINDEX = GET_LAST(dvTP_PORT1) 
    		IF(FIND_STRING(DATA.TEXT,'KEYB-CANCEL',1)
    		  nCURRENT_OP[TPINDEX] = 0
    		ELSE
    		{
    			SWITCH(nCURRENT_OP[TPINDEX])
    			{
    				CASE 1: //store new password
    				{
    					IF(FIND_STRING(DATA.TEXT,'KEYB-',1))
    						{
    							REMOVE_STRING(DATA.TEXT,'KEYB-',1)
    							
    							password = DATA.TEXT
    							nCURRENT_OP[TPINDEX] = 0
    						}
    				}
    				CASE 2: //Store new room name
    				{
    					IF(FIND_STRING(DATA.TEXT,'KEYB-',1))
    						{
    							REMOVE_STRING(DATA.TEXT,'KEYB-',1)
    							
    							Roomname = DATA.TEXT
    							nCURRENT_OP[TPINDEX] = 0
    						}
    				}
    			}
    		}
    	}
    }
    


    If you use the same code in your module, you shouldn't have any issues. You could also add timeouts to the call that would close the keyboard and reset the nCURRENT_OP variable to zero after 30 seconds or whatever.

    Jeff
  • Options
    Hey marc,

    In the line,
    DATA_EVENT[dvPanelReal.Number:1:0]

    If dvPanelReal was defined as 10001:14:1 would the DATA_EVENT above really occur for device 10001:1:1? If so, THAT"S AWESOME! I've never seen that before, That's totally COOol! What if device 10001:1:1 wasn't even defined anywhere in the code (inside or outside the mod), would this event still work?

    Wow, i feel like i'm a serious pro every now and then; but then somehow, i end up learning something totally new to me. If the above DATA_EVENT works, that's coolness man. FINESSE, i tell ya!

    Anyway, can't wait to get a response.
    Alex
  • Options
    AlexArtist wrote:
    Hey marc,

    In the line,
    DATA_EVENT[dvPanelReal.Number:1:0]

    If dvPanelReal was defined as 10001:14:1 would the DATA_EVENT above really occur for device 10001:1:1? If so, THAT"S AWESOME! I've never seen that before, That's totally COOol! What if device 10001:1:1 wasn't even defined anywhere in the code (inside or outside the mod), would this event still work?

    Wow, i feel like i'm a serious pro every now and then; but then somehow, i end up learning something totally new to me. If the above DATA_EVENT works, that's coolness man. FINESSE, i tell ya!

    Anyway, can't wait to get a response.
    Alex

    Works pretty fine :eek:

    Port 1 of a device is always available. So in our module, we just pick the Device number from the outside panel, and use it to pick up any strings from its port 1. It doesn't matter if I'm using device names or if I'm working with the device structure.

    Yeah, it's cool :D

    Find attached an working example and have fun!
  • Options
    DHawthorneDHawthorne Posts: 4,584
    I believe the caveat to that is that it won't work across masters. If you only have one master, it's fine. If your module uses port 14, to stick to the existing examples, and the panel is defined in the module's master with port 14, but is connected to a different master, your port 14 will work. But a 10001:1:2 reference won't work on master 1 unless that DEV is explicitly defined on master 1.
  • Options
    DHawthorne wrote:
    I believe the caveat to that is that it won't work across masters. If you only have one master, it's fine. If your module uses port 14, to stick to the existing examples, and the panel is defined in the module's master with port 14, but is connected to a different master, your port 14 will work. But a 10001:1:2 reference won't work on master 1 unless that DEV is explicitly defined on master 1.

    OK, that's corrent.
    But if we modify the module in the way
    MODULE_NAME='MyModule'(DEV dvPanelReal,DEV vdvPanelPort14)
    
    DEFINE_EVENT
    DATA_EVENT[dvPanelReal.Number:1:dvPanelReal.System] // <== now we also have attention to the System number of the panel passed into the module
    {
      STRING:
      {
        IF(FIND_STRING(DATA.TEXT,'P14KEYB-',1)) // textfield of the keyboard must be definde accordingly
        {
          SEND_STRING vdvPanelPort14,DATA.TEXT
        }
      }
    }
    
    it should work some more flexible.....
    But, of course, we need a correct setup of the M2M network.
  • Options
    OK, since you guys have figured out some cool ways around the akeyb port1 problem, i'd like to give you another situation, just to see if there is any possiblity of solving it. (I personally don't see any easy way out on this one)

    What if the real device of the module. the dvRealPanel = 10001:14:1, wasn't defined as 10001:14:1 and wasn't real, but instead was a virtual device combined with many other devices. For Example.

    vdvThePanel = 36001:1:1
    COMBINE_DEVICES(vdvThePanel , 10001:14:1, 10002:14:1, 10003:14:1)

    DEFINE_MODULE 'TheAKeybCatcher' inst1(vdvThePanel.....

    Once vdvThePanel is passed to the module, is there no way to get the port 1 akeyb data from each panel combined in the vdvThePanel?
  • Options
    DHawthorneDHawthorne Posts: 4,584
    AlexArtist wrote:
    OK, since you guys have figured out some cool ways around the akeyb port1 problem, i'd like to give you another situation, just to see if there is any possiblity of solving it. (I personally don't see any easy way out on this one)

    What if the real device of the module. the dvRealPanel = 10001:14:1, wasn't defined as 10001:14:1 and wasn't real, but instead was a virtual device combined with many other devices. For Example.

    vdvThePanel = 36001:1:1
    COMBINE_DEVICES(vdvThePanel , 10001:14:1, 10002:14:1, 10003:14:1)

    DEFINE_MODULE 'TheAKeybCatcher' inst1(vdvThePanel.....

    Once vdvThePanel is passed to the module, is there no way to get the port 1 akeyb data from each panel combined in the vdvThePanel?
    No, once you combine a panel with a virtual, everything goes to the virtual. Everything is going to show as port 1 on the virtual. I don't know of any way to access the combined elements after you've combined them. However, in most cases you can just make an array of your devices and use the array instead of a combined virtual. You can extract the base port out of array elements just fine, and EVENT definitions accept an array name in place of a single device.
  • Options
    From the moment devices are combined, only the 1st device in list, the virtual device, will send you the strings, pushes, etc (exception: the ONLINE and OFFLINE will still work for every panel separately).

    But - if on the first panel is a textbox named KEYB_P1- and on the second panel a textbox is named KEYB_P2-, you'll get different strings thru the virtual device..... :D
  • Options
    Using a seperate port for kbd cmds

    Hi all,

    I've worked around this by just building a keyboard. What I do is open the System Project properties and just copy the internal keyboard. Then I paste it into the touchpanel file as pop-up. First I change all the STRING port numbers to my desired port say 14. Then I go to each individual button and assign the string output. First time I did this was a Kaliedescape server so my string output was like "KSCAPE_KBD-a". That string is then sent out to the port 14 via the button press. Then I just parse the DATA.TEXT in the STRING: handler. Yet another way to accomplish the same thing....gotta love code.
Sign In or Register to comment.