Home AMX User Forum AMX General Discussion

Help with feedback to a text box

Hi all,
I'm fairly new to this and am getting stuck on sending feedback from an AP400 to a text box.

Here is the code.

data_event[AP400]

{
string:
{
find_string(data.text,"'#30 GAIN T I',13",1) (* Tel *)
{
TelinVOL_LEVEL = data.text
SEND_COMMAND dvTP_1,"'TEXT88-',ITOA(TelinVOL_LEVEL)"
}
}
}

I have tried all different ways from posts here but can't get it to work.
I have been able to ramp up and down an interger, but would like to have the actual feedback from the device.

anu help would be appreciated.

Comments

  • HedbergHedberg Posts: 671
    jgillich wrote: »
    Hi all,
    I'm fairly new to this and am getting stuck on sending feedback from an AP400 to a text box.

    Here is the code.

    data_event[AP400]

    {
    string:
    {
    find_string(data.text,"'#30 GAIN T I',13",1) (* Tel *)
    {
    TelinVOL_LEVEL = data.text
    SEND_COMMAND dvTP_1,"'TEXT88-',ITOA(TelinVOL_LEVEL)"
    }
    }
    }

    I have tried all different ways from posts here but can't get it to work.
    I have been able to ramp up and down an interger, but would like to have the actual feedback from the device.

    anu help would be appreciated.


    Ok. You're trying to do several things:

    1. trigger some code depending on the response to a find_string function

    2. depending on that, extract a value from the string

    3. send that value as text to a touch panel.

    First, the function is going to return either a 1 or a 0 depending on the string search. You need to format that correctly and code it as conditional. The code you posted doesn't do either correctly.

    Then, you need to parse the string (when your conditional passes) and extract the value.

    Then, you need to send this as text to the touch panel which must have a button properly configured to receive the text. That is, the button must have it's address port and address code properly set.

    First, your conditional Your not searching for the proper response string for a gain value. The carriage return is extraneous and you'll never get a string from a Gentner that matches.

    Then, the Gentner will return a signed float and you need to extract it.

    Then, you need to properly format your send_command to a proper button. Like so:
    string:
    {
      sBuffer1 = data.text
      if(find_string(sBuffer1,'#30 GAIN T I', 1))//no carriage return necessary.
      {
          sBuffer2 = remove_string((sBuffer1,'#30 GAIN T I', 1))//  now the float value is ready to be extracted.
          flTransmitGain = atof(sBuffer1)//no need to worry about the cr/lf, atof handles that.
          send_command dvTP_1,"'^TXT,1,0, ',ftoa(flTransmitGain)"//for a g4 panel-see the doc
      }
    }
    

    You should be able to figure it out from there, even if I made a mistake. You'll obviously need some variables either global, local, or stack as appropriate.

    Also, you should take into consideration that a gentner may send multiple replies in the same text string so you'll have to separate them out. There are technotes and lots of forum posts about how to do this with a while searching for the cr/lf (13,10) that gentner strings terminate with.

    Consider a parsing function rather than cluttering up the data_event.

    Consider using arrays of strings and arrays of floats for storing your search strings and response values so your code will be easier to apply to other problems. Look at structures, some people are all structure crazy and can't go to the restroom without one.
  • Removed - Hedberg did a much better job explaining it than I did.
  • HedbergHedberg Posts: 671
    I was just watching a video of a Civil War documentary about Gettysburg which, for some reason, reminded me of a thread from a couple years ago. In that thread, AMXJeff posted a pretty good example of how to analyze ClearOne responses in Netlinx. Also found a reference to TN616 which will help. See this thread:
    http://www.amxforums.com/showthread.php?4455-XAP-800-data-parsing

    It may contain a lot more information than you're looking for right now, but it's pretty darn good code, in my opinion.
  • Thanks all for the replies.
    It'll definitely send me in the right direction.
Sign In or Register to comment.