Home AMX User Forum NetLinx Studio

Updating workspace code for an identical touch panel

Hi All,

Our customer just requested that we program a second identical TP for a DGX16 system. Since I have already used DEV arrays and DEVCHANs in my code for one TP, I am confused now. How can alter the structure in the attached so a second TP (and if needed a third one in the future) can be added without duplicating the code?



Thanks,
Sinan

Comments

  • rfletcherrfletcher Posts: 217
    While perhaps not optimal for future projects one quick way out might be to create some virtual devices for your touch panel, do a find-replace to convert all the references in your code to the virtual devices, and then use define_combine or combine_devices to tie the two touchpanels' devices to the virtual devices. This may or may not actually work for you however, depending on what you've done in your code and what your exact requirements are.

    Another option might be to create another set of devchans for the new touchpanel, and just add Button_events for the new devchans to all the events you already have programmed for the old panel. You would also have to go through and add duplicate entries for all your feedback to the touchpanel.
  • stopuzstopuz Posts: 15
    rfletcher wrote: »
    This may or may not actually work for you however, depending on what you've done in your code and what your exact requirements are.

    rfletcher,

    I'd appreciate it if you could take a quick look at the attached Main.axs file to see if that is the case for me?

    Thanks,
    Sinan
  • ericmedleyericmedley Posts: 4,177
    I just did a quick cursory look at the code and you should just need to add a new device declaration in the DEFINE_DEVICE section for the new TPs and then add those devices to the DEV array. I personally wouldn't do the whole virtual devices/combine devices thing. There is so many more options available when you use a DEV array.
  • rfletcherrfletcher Posts: 217
    stopuz wrote: »
    rfletcher,

    I'd appreciate it if you could take a quick look at the attached Main.axs file to see if that is the case for me?

    Thanks,
    Sinan

    I don't see anything that jumps out at me as being a problem. Just keep in mind that if you want the two panels to always be on the same screen in addition to showing the same feedback you are going to have to turn on page notifications, and you may have to do some additional programming.
  • rfletcherrfletcher Posts: 217
    ericmedley wrote: »
    I just did a quick cursory look at the code and you should just need to add a new device declaration in the DEFINE_DEVICE section for the new TPs and then add those devices to the DEV array. I personally wouldn't do the whole virtual devices/combine devices thing. There is so many more options available when you use a DEV array.

    That would work too, though you would also have to either create a new dev array containing the two dvTP_Switch devices and then replace the device in your devchans with that array or make a second set of devchans with the new device and add button events with the new devchan above each of the existing button events.
  • champchamp Posts: 261
    I'm no DEVCHAN fan, preferring INTEGER and DEV arrays.

    Here's an example where I have an array of touch panels and an array of buttons.
    If I want all the touch panels in the array to do the same thing I just address the touch panel array, or I can individually address each device in the array.
    DEFINE_DEVICE
    dvTP1 = 10001:1:0;
    dvTP2 = 10002:1:0;
    
    DEFINE_CONSTANT
    INTEGER btnArray[] = {1,2,3,4,5,6};
    
    DEFINE_VARIABLE
    DEV dvTPArray[] = {dvTP1,dvTP2};
    
    DEFINE_FUNCTION doStuff(INTEGER nTPIndex, INTEGER nBtnIndex)
    {
    }
    
    DEFINE_EVENT
    BUTTON_EVENT[dvTPArray, btnArray]
    {
    	PUSH: doStuff(GET_LAST(dvTPArray), GET_LAST(btnArray));
    }
    
    This beats combining touch panels because combining touch panels makes it impossible to have even a single button different. I often have multiple panels where most buttons are the same but a couple of buttons need to perform completely different actions.
Sign In or Register to comment.