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
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
0
Comments
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
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
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 } } }if(find_string(find_string(cHWI_Str,"'], '",1)) {to this:if(ind_string(cHWI_Str,"'], '",1)) {beter chance of working this way.It won't work at all if he does that :P