Home AMX User Forum AMX General Discussion

rebuilding a string

Good day...

I am working with an 'old' PLB-AS16 audio router (which BTW, I think is a nicely featured box for us less than expert programmers)

We are doing some basic intercom with the unit and am looking for suggestions.

When user in any given room wants to call ALL the other rooms, they push the ALL button on the keypad (PLK-DMS - another nice little keypad) which simply routes the audio from the keypad mic, to all of the other rooms.

SEND_COMMAND vdvAS16,"'AI16O1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16'" (send input 16 to all outputs)

Of course you don't want to send the 'calling room' audio to itself so for the above case (calling from room 16) you need to drop the calling room from the string.

SEND_COMMAND vdvAS16,"'AI16O1,2,3,4,5,6,7,8,9,10,11,12,13,14,15'"

There must be a simple way to make that string a variable which can be chopped up to remove the calling room section so this will work for any room starting an intercom call.

I figure a bunch of concatenating, left_string, mid_string commands must do it, but I'm open for suggestions.

Basically, the task is to figure out what string is between the AI and the O (to discover the part to remove and then find it in the rest of the string- and remove it.

I figure I'm trying to make this WAY harder than it is.

Thanks!

Comments

  • jjamesjjames Posts: 2,908
    Just a quick thought. You could set up another virtual device that intercepts all the commands that are going to the PLB-AS16, then modify the string and do sort of a pass though.

    Removing a specific set of characters in a string is quite easy. I do it like so:
    REMOVE_STRING(cSearchedString,'AAA',FIND_STRING(cSearchedString,'AAA',1));
    
    This will remove 'AAA' from cSearchedString starting at the point it finds the first AAA. Repeat if necessary.

    There is a function floating around (I'm not on my work computer) that is callsed STRING_REMOVE that is in a strings.axi posted on here somewhere. That'll do the trick as well.

    So you use ' 16' as your string to remove since there is a '16' already in the string. Or you could do something like this, but you'll probably still need to remove the space.
    REMOVE_STRING(cSearchedString,'16',FIND_STRING(cSearchedString,'16',1)+1);
    
  • shr00m-dewshr00m-dew Posts: 394
    I use a for loop in my page all intercom function. Modified form my code, but you get the idea.
    FOR(nCount = 1; nCount <= 16; nCount ++)
    {
      IF(CALL_ZONE!=nCount)
      {
        ZONE_LIST=" ZONE_LIST,ITOA(nCount),',' "
      }
    }
    			
    SEND_COMMAND vdvAS16,"'AI',ITOA(CALL_ZONE),'O',LEFT_STRING(ZONE _LIST,(LENGTH_STRING(ZONE_LIST)-1))"
    

    This goes through all 16 outputs and makes a list, leaving out the initiating keypad.

    You could do the same for page areas, ie: bedrooms, floor 2, etc... (quick code here)
    integer floor2[]=5,6,9,12,16
    
    FOR(nCount = 1; nCount <= length_array(floor2); nCount ++)
    {
      IF(CALL_ZONE!=floor2[nCount])
      {
        ZONE_LIST=" ZONE_LIST,ITOA(floor2[nCount]),',' "
      }
    }
    
    etc...
    
    
  • shr00m-dewshr00m-dew Posts: 394
    Just thought of something on the way to work. My switcher uses spaces instead of comma's and I'm not sure how the AS16 module handles trailing comma's. So change the last line to:

    SEND_COMMAND vdvAS16,"'AI',ITOA(CALL_ZONE),'O',LEFT_STRING(ZONE_LIST,(LENGTH_STRING(ZONE_LIST)-1))"
  • jjamesjjames Posts: 2,908
    shr00m-dew wrote: »
    Just thought of something on the way to work. My switcher uses spaces instead of comma's and I'm not sure how the AS16 module handles trailing comma's. So change the last line to:

    SEND_COMMAND vdvAS16,"'AI',ITOA(CALL_ZONE),'O',LEFT_STRING(ZONE_LIST,(LENGTH_STRING(ZONE_LIST)-1))"

    You'd have to keep track whether or not then if the last zone is two digits or just one. If you subtract the length by one and the last zone is 16, you'll wind up with 1 and not removing 16 completely.

    There's no real one-liner way to do it so it seems. Just have to put some logic to it, but all the suggestions here are quite simple to implement.
  • shr00m-dewshr00m-dew Posts: 394
    I was referring to my sample code, where the last spot will always be a comma. But you are correct, everything will have to be debugged for his setup.

    I've edited the original reply to add the correct line in.

    Kevin D.
  • PyroGuyPyroGuy Posts: 121
    Thanks - some good ideas to play around with - that is next week's project!

    Cheers All!
  • DHawthorneDHawthorne Posts: 4,584
    Keep in mind the AS16 is not a very fast responding device; you have to give it a little bit of time between zone commands or they may not all be active.

    It does, however, support memorizing the current configuration. What I have done for paging is just that:

    1) Memorize current settings
    2) Activate the zones I want for the page
    3) Send audio through
    4) Restore saved settings

    However, I wasn't using live pages, I was using WAV files to indicate the driveway sensor went off, or doorbell rang, or a=something of that nature. You would have to adjust accordingly; if delays are necessary for the saves and restores to take effect, you may have to throw up a pop-up indicating the user needs to hang on a few seconds while the system gets ready.

    I'll be real honest about this though: I was relieved when AMX discontinued the old Phast AS matrixes. MY boss just loved them, and I hated trying to get them "just right" for a NetLinx system. They were better suited to the Landmark system than NetLinx by a long shot; I imagine because we can't talk directly to the hardware, but need to use a module as an interpreter. They are, simply put, way too sluggish, and have issues with dropping commands here and there. You never notice it when only doing one room at a time, but paging groups and audio scenes tend to make it stand out.
Sign In or Register to comment.