Home AMX User Forum NetLinx Studio

Having trouble combining touchpanels

I'm working on a system with 2 ELO touchpanels driven from TP/I4 devices. But I can't seem to get the panels combined. Here are relevant code snippets:
DEFINE_DEVICE
dvTP1 = 10001:1:0
dvTP2 = 10002:1:0

DEFINE_VARIABLE
DEV dvPanels

DEFINE_COMBINE
(dvPanels, dvTP1, dvTP2)

DEFINE_EVENT
button_event[dvPanels,39] //projector power on
{
  push: 
  { 
      on[dvPanels,39]
      proj_power = 1
   }
}

The above code does not work at all as written. But if I comment out the DEFINE_COMBINE area and change the panel references to dvTP1, it works on that panel just fine.

Remember, I'm a newbie at this stuff, and I'm probably making some simple mistake - do I have the DEFINE_COMBINE in the wrong place or something? ?ny help is greatly appreciated!

Thanks,

Comments

  • jjamesjjames Posts: 2,908
    I haven't combined devices in the longest time, but I think somewhere in code - probably in the DEFINE_START - you'll need a COMBINE_DEVICES. Highlight the word DEFINE_COMBINE in NS2 and hit F1 - this will bring up the help section on combining devices and it'll explain better than I.

    On a side note however, have you considered using DEV arrays rather than combining your devices? There plenty of talk here on the forums on combining devices versus DEV arrays. Check out the usage of DEV arrays. One advantage to the array approach is that you can still control the devices individually.

    Here's how you'd do it:
    DEFINE_DEVICE
    dvTP1 = 10001:01:00
    dvTP2 = 10002:01:00
    
    DEFINE_VARIABLE
    VOLATILE INTEGER proj_power
    DEV dv_TP[] = 
    {
       dvTP1
      ,dvTP2
    }
    
    DEFINE_EVENT
    BUTTON_EVENT[dv_TP,39] //projector power on
    {
      PUSH: 
      { 
          ON[dv_TP,39]
          proj_power = 1
       }
    }
    

    Though, I would change the feedback to take place in DEFINE_PROGRAM.
    BUTTON_EVENT[dv_TP,39]
    {
       PUSH:
       {
         proj_power = 1
       }
    }
    
    DEFINE_PROGRAM
    FOR(nLOOP=1;nLOOP<=LENGTH_ARRAY(dv_TP);nLOOP++)
       [dv_TP[nLOOP],39] = proj_power
    

    I think there's already been discussion on where to put and use touchpanel feedback. This way, if for whatever reason a panel goes offline, when it comes back online, the feedback is still good and the panel won't appear to be nonfunctional. This is also why I put my pop-ups in code - when it comes back online, it will go back to pages it was supposed to be on.
  • jjames wrote:
    DEV dv_TP[] = 
    {
       dvTP1
      ,dvTP2
    }
    

    That's actually what I started out with, and that seems to work for the button events and feedback. But then I get a compile error when I try to use the device in a SYSTEM_CALL to control a DVD/VCR.
  • jjamesjjames Posts: 2,908
    That's actually what I started out with, and that seems to work for the button events and feedback. But then I get a compile error when I try to use the device in a SYSTEM_CALL to control a DVD/VCR.

    Are you referencing the array or the individual panels for the SYSTEM_CALL? My guess would be to reference the individual panel (i.e. dvTP1 or dvTP2) rather than any type of array (i.e. dv_TP or dv_TP[1]).
  • A DEFINE_COMBINE requires a virtual device be used. You tried to use a DEV variable instead of a virtual device.

    This slightly modified code should work fine.
    DEFINE_DEVICE
    dvTP1 = 10001:1:0
    dvTP2 = 10002:1:0
    vdvPanels = 33001:1:0 // virtual device used for Touch Panel combine
    
    DEFINE_COMBINE
    (vdvPanels, dvTP1, dvTP2)
    
    DEFINE_EVENT
    button_event[vdvPanels,39] //projector power on
    {
      push: 
      { 
          on[vdvPanels,39]
          proj_power = 1
       }
    }
    
    


    Chuck
  • jjamesjjames Posts: 2,908
    Out of curiosity - if it were a constant, would it work then?
  • vdvPanels = 33001:1:0 // virtual device used for Touch Panel combine
    

    D'oh! - that's definitely a newbie mistake :-) Thanks for the help - it works great once I define the virtual device.
  • jjames wrote:
    Though, I would change the feedback to take place in DEFINE_PROGRAM.
    DEFINE_PROGRAM
    FOR(nLOOP=1;nLOOP<=LENGTH_ARRAY(dv_TP);nLOOP++)
       [dv_TP[nLOOP],39] = proj_power
    

    OK, I'm interested in this now. I've still got a button state initialization problem that's got me baffled. It's like the Mutually Exclusive doesn't pick up right away. Here's another (hopefully) relevant set of code snippets:
    DEFINE_DEVICE
    vdvPanels = 33001:1:0 // Virtual Panel Device
    
    DEFINE_COMBINE
    (vdvPanels,dvTP1,dvTP2)
    
    DEFINE_MUTUALLY_EXCLUSIVE
    ([vdvPanels,39],[vdvPanels,40])
    
    DEFINE_EVENT
    data_event[dvTP1]
    {
      online:
      {
        // there's a bunch of other stuff here too
        on[vdvPanels,40]
      }
    }
    
    button_event[vdvPanels,39] //Proj ON
    button_event[vdvPanels,40] //Proj OFF
    {
      push:
      {
        switch (button.input.channel)
        {
          case 39:
          {
            on[vdvPanels,39]
            // Other code commented out while working on 1st time button Mu/Ex problem
          }
          case 40:
          {
            on[vdvPanels,40]
          }
        }
      }
    }
    

    So... When the controller is rebooted, the panel comes up with button 1,40 in the ON state and 1,39 in the OFF state. But the first time I push button 39, it fails to turn off button 40. But once I push button 40 again, then the mutually exclusive works correctly. It just doesn't work the very first time.

    It seems like I'm not initializing something correctly, but I don't know what. I'm wondering if moving the feedback down into the DEFINE_PROGRAM area as you suggested will fix my "First Time Mu/Ex doesn't work" problem.

    Thanks!
  • jjames wrote:
    Out of curiosity - if it were a constant, would it work then?

    No. It must be a virtual device. The virtual device brings along all the associations required. A variable or constant DEV do not.
  • DHawthorneDHawthorne Posts: 4,584
    OK, I'm interested in this now. I've still got a button state initialization problem that's got me baffled. It's like the Mutually Exclusive doesn't pick up right away. Here's another (hopefully) relevant set of code snippets:
    DEFINE_DEVICE
    vdvPanels = 33001:1:0 // Virtual Panel Device
    
    DEFINE_COMBINE
    (vdvPanels,dvTP1,dvTP2)
    
    DEFINE_MUTUALLY_EXCLUSIVE
    ([vdvPanels,39],[vdvPanels,40])
    
    DEFINE_EVENT
    data_event[dvTP1]
    {
      online:
      {
        // there's a bunch of other stuff here too
        on[vdvPanels,40]
      }
    }
    
    button_event[vdvPanels,39] //Proj ON
    button_event[vdvPanels,40] //Proj OFF
    {
      push:
      {
        switch (button.input.channel)
        {
          case 39:
          {
            on[vdvPanels,39]
            // Other code commented out while working on 1st time button Mu/Ex problem
          }
          case 40:
          {
            on[vdvPanels,40]
          }
        }
      }
    }
    

    So... When the controller is rebooted, the panel comes up with button 1,40 in the ON state and 1,39 in the OFF state. But the first time I push button 39, it fails to turn off button 40. But once I push button 40 again, then the mutually exclusive works correctly. It just doesn't work the very first time.

    It seems like I'm not initializing something correctly, but I don't know what. I'm wondering if moving the feedback down into the DEFINE_PROGRAM area as you suggested will fix my "First Time Mu/Ex doesn't work" problem.

    Thanks!

    Your online event fires when the virtual devices comes on line, which is significantly sooner than when the physical device comes on line, necessarily making it sooner than the combine itself is active. So your physical devices aren't necessarily getting the event when it happens. The exclusive property does not apply to the physical panel, just the virtual. You need to sync the startup conditions separately for each physical panel with individual online events for each. This is one of the reasons why I generally prefer a device array over a combine.
  • DHawthorne wrote:
    Your online event fires when the virtual devices comes on line, which is significantly sooner than when the physical device comes on line, necessarily making it sooner than the combine itself is active. So your physical devices aren't necessarily getting the event when it happens. The exclusive property does not apply to the physical panel, just the virtual. You need to sync the startup conditions separately for each physical panel with individual online events for each. This is one of the reasons why I generally prefer a device array over a combine.

    The online event posted in the code was tied to an individual panel, not the virtual panel, because I need to default each panel to a different page. Adding another data_event/online for the virtual panel and putting the on[vdvPanels,40] in the online event for the virtual panel actually fixed the 'first mu/ex not working' problem. Now on to my next bug...
  • jjames wrote: »
    I haven't combined devices in the longest time, but I think somewhere in code - probably in the DEFINE_START - you'll need a COMBINE_DEVICES. Highlight the word DEFINE_COMBINE in NS2 and hit F1 - this will bring up the help section on combining devices and it'll explain better than I.

    On a side note however, have you considered using DEV arrays rather than combining your devices? There plenty of talk here on the forums on combining devices versus DEV arrays. Check out the usage of DEV arrays. One advantage to the array approach is that you can still control the devices individually.

    Hi guys,

    very old thread but I found this by searching some information for myself.

    For combining panels you should use - as you wrote - COMBINE_DEVICES. You can also use DEFINE_COMBINE but that one is kind of a "static" combine. By using COMBINE_DEVICES and UNCOMBINE_DEVICES it is possible to combine and uncombine devices on the fly. It is not necessary to combine them in DEFINE_START section unless there isn't a specific need for some kind of a default combination after a system reboot.

    For example, I have a project with multiple meeting rooms side by side. These rooms have a removable wall between them and it's possible to combine/uncombine the panels depending on the actual room combination.

    You are still able to control the devices individually if you define the events and commands for real panels. Only the events and commands for virtual panels are distributed through the panels defined in COMBINE_DEVICE.

    -Kari-
Sign In or Register to comment.