Home NetLinx Studio

Panels are combined, but I need one separate function

I have 2 TPI4 panels, and have them combined with a virtual device. This is working fine, except now I've run into one instance where I need to tell which panel a button click is coming from, and provoke a different popup page depending on which panel it comes from (sigh).

When I trap for a button_event on TP1 or TP2, I get nothing. When I trap for VirtualTP, I see the button event. When I watch the device notifications, I see a button event coming from TP1 or TP2, then coming from the VirtualTP, but the program doesn't pick up the button event from the individual panels.

Is there any way to sense which panel the button event is coming from when the panels are combined, without ripping apart all my combined stuff and reprogramming for separate panels? Please?

Thanks,

Comments

  • dchristodchristo Junior Member Posts: 177
    This is the perfect use for device arrays. Try this:
    Define_Device
    dvTp1 = 10001:1:0
    dvTp2 = 10002:1:0
    
    
    Define_Variable
    dev Tp[] = {dvTp1, dvTp2}
    
    
    Define_Event
    
    Button_event[Tp,1]
    {
       // This will receive events from both panels. 
       // You can use Button.Input.Device to see what panel pushed the button
    }
    
    Button_event[dvTp1,2]
    {
       // This will only receive pushes from Panel 1
    }
    
    Button_event[dvTp2,2]
    {
       // This will only receive pushes from Panel 2
    }
    
    

    --D
  • fogled@mizzou[email protected] h4x354x0r Posts: 549
    dchristo wrote:
    Button_event[Tp,1]
    {
       // This will receive events from both panels. 
       // You can use Button.Input.Device to see what panel pushed the button
    }
    

    But that doesn't work for feedback (i.e. on[Tp,1]), does it? Don't I end up having to run through the Tp array for feedback?
    foreach dev[Tp] { on[Tp,1] }
    
    ... and yeah, I know that's not quite the right syntax; I'll have to go look it up.
  • But that doesn't work for feedback (i.e. on[Tp,1]), does it? Don't I end up having to run through the Tp array for feedback?

    Sure Does.

    ON[TP,1] will turn on channel 1 on ALL of the Panels defined in the array.
  • yuriyuri Junior Member Posts: 861

    When I trap for a button_event on TP1 or TP2, I get nothing.

    how is this possible? how can you trap BUTTON_EVENTs for the virtual combined device then?
  • mpullinmpullin Obvious Troll Account, Marked for Deletion Posts: 949
    It's not possible yuri. I think the suggestion is to use a device array INSTEAD of combine_device.
  • fogled@mizzou[email protected] h4x354x0r Posts: 549
    ON[TP,1] will turn on channel 1 on ALL of the Panels defined in the array.

    That's right. But now I remember why I combined the panels to begin with, instead of using an array. I could not get DVD or CD system calls to work with the panel array. When I combined the panels into a virtual panel, the DVD and CD system calls worked OK.

    So now I need to ask: should a DVD system call work with a panel array? When I use a device array of panels, I get a compile error of "Type mismatch in call for parameter [PANEL]" in
    SYSTEM_CALL [dvDVDVCR] 'DVD1' (dvDVDVCR,dvPANELS,10,11,12,13,14,15,16,0)
    
    whereas this works OK when I have dvPANELS defined as a combined virtual device.

    If anyone can tell me how to get around this one glitch with the system call, I can convert over to using the device array and all will be good.
  • matt95gsrmatt95gsr Junior Member Posts: 164
    I'm not 100% sure that this will work as far as actual use of the system call is concerned as I have no chance to test it at the moment, but it will compile fine. You can try just declaring the system call twice using the unique elements of the DEV array:
    SYSTEM_CALL [dvDVDVCR] 'DVD1' (dvDVDVCR,dvPANELS[1],10,11,12,13,14,15,16,0)
    SYSTEM_CALL [dvDVDVCR] 'DVD1' (dvDVDVCR,dvPANELS[2],10,11,12,13,14,15,16,0)
    

    I don't recall having done this with system calls exactly, but I have used that method to overcome other similar compile errors with success.
  • fogled@mizzou[email protected] h4x354x0r Posts: 549
    matt95gsr wrote:
    I'm not 100% sure that this will work
    SYSTEM_CALL [dvDVDVCR] 'DVD1' (dvDVDVCR,dvPANELS[1],10,11,12,13,14,15,16,0)
    SYSTEM_CALL [dvDVDVCR] 'DVD1' (dvDVDVCR,dvPANELS[2],10,11,12,13,14,15,16,0)
    

    This was what I was going to try anyway, and I'm rolling out the code update tomorrow afternoon. I'm just a little nervous about the feedback working correctly. I'll post back and let everyone know how it went.

    As for the combined virtual panel vs individual panels, I have no explanation why I can see the individual panel's button event show up in the Device Notifications, but only button events that look at the virtual combined panel actually trigger from the button event. But AMX's documentation indicates this - that the code only 'sees' the button event from the combined panel.
  • alexanboalexanbo Junior Member Posts: 282
    Oops missed that this was a TPI... nevermind.


    If you have only one button that's different out of the two panels, perhaps putting that button on a different port of the touchpanel would work.

    I'm assuming you've only say combined 128:1:0 and 132:1:0 and thus could put the different button on 128:2:0 and 132:2:0.
  • fogled@mizzou[email protected] h4x354x0r Posts: 549
    Well, using a device array does NOT, NOT, NOT work. In most cases, my button feedback will only work on the 2nd panel in the array. In some cases though, the feedback does work on both panels.

    The only common thing I can discern between feedback commands that work and ones that don't is that if I have a stack of button events and then a switch/case to trap the specific buttons, either the feedback works for that entire stack, or it doesn't. But in both cases, the code is essentially the same.
    // THIS SAMPLE CODE MIGHT WORK AND THE BUTTON WILL GO ON
    button_event [dvpanels,10]
    button_event [dvpanels,11]
    button_event [dvpanels,12]
    {
     push: 
     { 
       switch (button.input.channel)
       {
         case 10: 
         {
          on[dvpanels,10]
         }
         case 11: 
         {
          on[dvpanels,11]
         }
         case 12: 
         {
          on[dvpanels,12]
         }
       }
     }
    }
    
    // BUT THIS SAMPLE CODE STACK MIGHT NOT WORK, NO FEEDBACK
    button_event [dvpanels,20]
    button_event [dvpanels,21]
    button_event [dvpanels,22]
    {
     push: 
     { 
       switch (button.input.channel)
       {
         case 20: 
         {
          on[dvpanels,20]
         }
         case 21: 
         {
          on[dvpanels,21]
         }
         case 22: 
         {
          on[dvpanels,22]
         }
       }
     }
    }
    

    This makes absolutely no sense at all. If I use a virtual panel and combine the touchpanels that way, the feedback always works correctly on both panels.

    So, what's a guy to do? Why doesn't the feedback work consistenly with a device array?
  • dchristodchristo Junior Member Posts: 177
    I tried your code with two panels in the array dvPanels and it worked as expected. I can't explain why this doesn't work for you. Is it possible that those feedback channels are being controlled in some other section of your program or in a system call?

    I use panel arrays in every program (even when there's only one panel), and I've never run across a situation where the feedback didn't work on all of the panels. However, I don't use system calls much (ever), so I can't comment on how arrays might or might not work with them.

    --D
  • viningvining X Member Posts: 4,368
    dchristo wrote:
    I use panel arrays in every program (even when there's only one panel),
    Ditto. I always use arrays for TPs and if there's only one too. Then either feedback goes to the array or to just the panel that initiated the event via [Button.Input.Device,XX] where xx is usually obtained by a nVar = GET_LAST(nSomeButtonArray) kind of a thing.

    The only time I've ever had issues is when something else, somewhere else in the code was working against me.
  • fogled@mizzou[email protected] h4x354x0r Posts: 549
    vining wrote:
    The only time I've ever had issues is when something else, somewhere else in the code was working against me.

    I don't doubt that it's something else in my code working against me, although I haven't pinned down what yet. I've never had problems using panel arrays before. But I can switch back and forth between a combined virtual device and a device array by changing 4 lines of code, and I always get the same result: some sets of buttons won't get feedback on the first device in the device array (and I've swapped which device is first and last to verify it's not just one or the other, but always the first that fails and the last that works), but all buttons always get feedback when using a combined virtual panel. So I'll work through a few things - commenting out sections of code at a time - to see if I can pin down the problem.

    If it turns out to be the system calls for DVD/VCR control, is there a repository of code that will control a DVD/VCR without using the built-in system calls?
  • DHawthorneDHawthorne Junior Member Posts: 4,584
    I've never felt the need to use a system call for simple IR devices; they have no real feedback anyway, and faking it will show false results if the customer walks up top the thing and hits a front panel button (which is real likely if they have to walk up to it to load the media in the first place).

    So I make an array of numbers, 1-100. Then I make a BUTTON_EVENT for the device that looks something like this:
    BUTTON_EVENT [dvTP, iButtons]    // iButtons = integer array containing 1 through 100
    {
         PUSH :
         {
              SEND_COMMAND dvIR_Device, "'SP', BUTTON.INPUT.CHANNEL" ;
         }
    }
    

    On the touch panel screens, the buttons have the same channel as the IR code they are to send. So, for a standard PLAY IR, which is indexed as channel 1, the play button will also be channel 1. Of course, this is a bit simplified, sometimes you need to do some tests because not all devices behave the same (some need you to hold FWD to scan forward, some are single press, etc.). But that's the gist of it. If the device changes and the IR codes are different, you can just load the new IR and edit the panel itself, no need to change any code. I generally edit IR files so everything is under channel 100, but you could as easily expand the array instead if you dedicate the panel port.
  • viningvining X Member Posts: 4,368
    [email protected] wrote:
    If it turns out to be the system calls for DVD/VCR control, is there a repository of code that will control a DVD/VCR without using the built-in system calls?
    I've never used a system call and it actually took me a few seconds to remember what they are.

    Do something similar to what Dave suggest or what ever floats your boat.
  • fogled@mizzou[email protected] h4x354x0r Posts: 549
    Is there any way to sense which panel the button event is coming from when the panels are combined, without ripping apart all my combined stuff and reprogramming for separate panels?

    Sorry to bring up an old thread, but I realized I found an answer to this a while ago and it works really well: BUTTON.INPUT.DEVICE and BUTTON.INPUT.DEVICE.NUMBER. Vining pointed this out in a post, but I missed it at the time.

    I can pass the DEVICE (or it's NUMBER index) off to a call or function and I know which panel the button push came from, and provoke the correct popups (and feedback) on the appropriate panels accordingly.

    At this point, I definitely agree with the advice to use panel arrays rather than combining panels, and roll your own control/feeback of IR-based DVD/VCR's instead of relying on system calls.
  • jjamesjjames Just another dude Posts: 2,902
    At this point, I definitely agree with the advice to use panel arrays rather than combining panels, and roll your own control/feeback of IR-based DVD/VCR's instead of relying on system calls.

    Woo-hoo! You've seen the light! :D

    Happy hacking! ;)
Sign In or Register to comment.