Home AMX User Forum AMXForums Archive Threads Tips and Tricks

React on specific string

Hi guys

I got feedback strings from Lutron to my Netlinx controller - reporting about keypads LED status.

These status feedbacks, I would like to translate to channel feedback - to my 8400i panel.

The strings look like this:

KLS, [01:05:XX], YYYYYYYYYYYYYYYYYYYYYYY

"XX" are the adress of the keypad, and YYYYYYYYYYYYYYYYYYYYYYY are LED stauts (1 or 0)

Now I need to channel react (TP2,821 = 1) if keypad adress 40 - LED number 1 is ON
(KLS, [01:05:40], 100000000000000000000)

How do I pick out adress 40 - and then sniff out LED status characters - and upon that make my channel feedback....?

Regards

Brian Andersen

Comments

  • Vincen shared a module on the forums that is good for reference here: http://www.amxforums.com/showthread.php?1739-Lutron-HWI-with-TCP-IP

    You might want to do some searching using the keywords "parsing". There are several ways to accomplish what you're doing. This thread: http://www.amxforums.com/showthread.php?4406-how-do-you-use-IP_CLIENT_OPEN-to-get-info-from-a-website has some pretty good info stuffed in there somewhere about parsing.

    -John
  • ericmedleyericmedley Posts: 4,177
    bia@jdm.dk wrote: »
    Hi guys

    I got feedback strings from Lutron to my Netlinx controller - reporting about keypads LED status.

    These status feedbacks, I would like to translate to channel feedback - to my 8400i panel.

    The strings look like this:

    KLS, [01:05:XX], YYYYYYYYYYYYYYYYYYYYYYY

    "XX" are the adress of the keypad, and YYYYYYYYYYYYYYYYYYYYYYY are LED stauts (1 or 0)

    Now I need to channel react (TP2,821 = 1) if keypad adress 40 - LED number 1 is ON
    (KLS, [01:05:40], 100000000000000000000)

    How do I pick out adress 40 - and then sniff out LED status characters - and upon that make my channel feedback....?

    Regards

    Brian Andersen

    Brian,
    a couple things...

    firstly, a simple way to do this is create a cell-by-cell conditional (something like a quick for loop will do) and examine each digit.

    But, secondly..
    The AMX Lutron module that's been around since dinosaurs roamed the earth works very well and will do a lot of this heavy lifting for you.

    So, I'd not try and reinvent the wheel unless you're just bursting with curiosity and plenty of time to play around.

    IMHO..
    e
  • viningvining Posts: 4,368
    First of all I don't think you'll ever be able to pick out a KP address of 40 unless you're parsing an RF link since the wired lnks only go up to #32 but anyway.

    Assuming you don't care about the processor or link you can do this which is about as simple a way to do it as possible. No loops or structure but it will require alot of lines of code.

    Note: the "atoi" function will ignore the non numeric ascii characters and covert only the ascii "40" to and interger.
     {
         while(find_string(cHWI_Str,"':'",1))
    	  {//if you don't care about processr number or link number
    	  remove_string(cHWI_Str,"':'",1) ;
    	  }
         if(find_string(find_string(cHWI_Str,"'], '",1))
    	  {
    	  STACK_VAR INTEGER nKP ;
    	  STACK_VAR CHAR cKLS_Str[24] ;
    	  
    	  nKP = atoi(remove_string(cHWI_Str,"'], '",1)) ;
    	  cKLS_Str = cHWI_Str ;//assumes $0D,$0A already removed
    	  SWITCH(nKP)
    	       {
    	       CASE 40://can't be 40 but........
    		    {
    		    [dvHWI_UI_Arry,1] = cKLS_Str[1] == '1' ;
    		    [dvHWI_UI_Arry,2] = cKLS_Str[2] == '1' ;
    		    [dvHWI_UI_Arry,3] = cKLS_Str[3] == '1' ;
    		    
    		     //and so on..........
    		    [dvHWI_UI_Arry,24] = cKLS_Str[24] == '1' ;
    		    }
    	       CASE 30:
    		    {
    		    [dvHWI_UI_Arry,25] = cKLS_Str[1] == '1' ;
    		    [dvHWI_UI_Arry,26] = cKLS_Str[2] == '1' ;
    		    [dvHWI_UI_Arry,27] = cKLS_Str[3] == '1' ;
    		    
    		    //and so on..........
    		    [dvHWI_UI_Arry,48] = cKLS_Str[24] == '1' ;
    		    }
    	       //add more cases for more kps
    	       }
    	  }
         }
    
  • bia@jdm.dkbia@jdm.dk Posts: 20
    Great - you are right - it only goes to 32, it was just to make an example
  • viningvining Posts: 4,368
    Might want to change this:
     if(find_string(find_string(cHWI_Str,"'], '",1))
    	  {
    
    to this:
     if(ind_string(cHWI_Str,"'], '",1))
    	  {
    
    beter chance of working this way.
  • Jorde_VJorde_V Posts: 393
    haha
    vining wrote: »
    Might want to change this:
     if(ind_string(cHWI_Str,"'], '",1))
    	  {
    
    beter chance of working this way.

    It won't work at all if he does that :P
Sign In or Register to comment.