Home AMX User Forum NetLinx Studio

COMBINE_DEVICES and TP Online events

Greetings...

I have searched and searched the documentation for this but can't find. I thought I read once where a touch panel would be updated with variable information from the virtual device when a combine is executed...

For example, at some point in time when the device is offline...

SEND_COMMAND vTP, "'^TXT-1,1&2,Somthing New'"

then in the ONLINE event...

COMBINE_DEVICES (vTP, someRealTP)

Channel 1 on the device someRealTP needs to be set to 'Something New', but it doesn't work with this set of commands. I do an UNCOMBINE when the TP goes offline, but functionally there doesn't appear to be any difference.

If this doesn't happen automatically, then I guess I need to write a big update routine to be called when a/the device comes online. Not really inviting meaning I must store real-time values of all data in data structures.

Any ideas??

Comments

  • Reese JacobsReese Jacobs Posts: 347
    COMBINE_DEVICES and TP Online events

    Sonny,

    Check out Tech Note 478 - I recall seeing this note a long time ago and it stuck in my mind since it drove how I coded my touchpanel ONLINE handlers for those systems that use variable text on the touchpanels.

    As you can see from the note, variable text sent to a panel that is OFFLINE will not be retained/remembered and therefore the variable text information for the panel when it comes ONLINE is not current (assuming vartext was updated while the panel was OFFLINE). When a panel comes ONLINE, only channels and levels are updated - not variable text. The ONLINE handler for the touchpanel is responsible for refreshing any variable text fields on the touchpanel. This is true regardless of whether or not a COMBINE is used for the touchpanel.

    I have always coded my TP ONLINE handlers to refresh all variable text information for the panel as a result.

    Hope this helps (even though the answer was probably not what you were looking for) :).

    Reese
  • Chip MoodyChip Moody Posts: 727
    Ah, yes - but - if you're working with a combine group, you won't get online events for individual panels, and as long as one member of the group is online, the online event for the combined "panel" won't re-trigger from any other group members coming online. (Or am I not remembering this correctly?)

    Another argument for grouping panels using DEV arrays instead of combines...

    - Chip
  • Reese JacobsReese Jacobs Posts: 347
    COMBINE_DEVICES and TP Online events

    Chip,

    Not sure of the answer regarding your question - I do not use COMBINE devices as I prefer DEV arrays as you suggested so I get the ONLINE and OFFLINE events for all my devices. For touchpanels, this allows me to handle the variable text accordingly. Independent of the COMBINE device portion of the question, I just wanted to confirm what Sonny found out the hard way regarding panels in the offline state with respect to vartext.

    Reese
  • sonnysonny Posts: 208
    Thanks for the help...couple of follow-up questions

    From the vartext perspective, what is your preference for storing data locally? If I need data in a module from a program standpoint I will keep a local copy of it, otherwise I just set the text on the button and move on (guess I need to rethink that practice). I would think writing a refresh routine in the module that "produces" the data would be the most efficient route, then do a "SEND_STRING" or button push to flag the refresh function to run when the panel ONLINE event occurs. I really don't like writing the same piece of data from multiple places...can get messy if you alter the format. I guess one thought would be to create a two-dimensional array where a DEVCHAN and the current text are the entries. Then just run through it in a loop. Although not sure what this would do to performance.

    I haven't used a device array as most of my jobs are residential with just a panel or two, and they are usually independant. How do you remove a device from the array, write 0:0:0 to it? Also, assuming your program permits panels to come and go, are you doing array compression...i.e. panel 2 of 5 goes offline, remove 2 and shift down? or do you have a search routine that finds the first open slot to insert a panel coming online?

    Again...thanks, Sonny
  • Reese JacobsReese Jacobs Posts: 347
    COMBINE_DEVICES and TP Online events

    Sonny,

    I can't speak for others but here is what I do in my programs/modules for the two specific cases you noted:

    1. Variable Text - I generally write a DEFINE_CALL/DEFINE_FUNCTION which handles all variable text for my touchpanels (one per module). If it is a simple module with a small amount of variable text, the routine will write all variable text fields when called. In more complex modules, I pass flags to the function that tell it which groups of text to write so it is more efficient. In the ONLINE case for a touchpanel, I call the routine to refresh all of the text fields. This of course means that all of the information required for the variable text is maintained in some sort of data structure so it can be reproduced as needed. I have just gotten into a habit of implementing variable text this way. Then, when a touchpanel needs to be updated, I can update it selectively or I can update the entire panel at ONLINE time. Note, since I use modules extensively, each module has an ONLINE handler for a touchpanel and each module is responsible for updating its variable text fields on the TP.

    2. Regarding your second question, I wrote a series of routines some take back that will add and delete DEV entries to an array. I use this for device arrays for a variety of purposes. Since my delete routine does compaction (moves all DEVs up in the array to fill empty slots), adding a device is easy since an add always places a DEV at the end of the array and increases the size by 1 entry. I have found that this works well for me.

    Reese
  • sonnysonny Posts: 208
    Thanks Reese...I too use modules extensively. In fact, my main module typically only contains DEFINE_MODULE statements. I also typically don't have anything under DEFINE_PROGRAM in a module, so every thing is event driven.
  • DHawthorneDHawthorne Posts: 4,584
    I do exactly what Reese described, but with one twist: if I have multiple panels controlling a single device, I have found there are times when it is more convenient to do a DEVICE_COMBINE on the array and send all my processing to a virtual. So my routine starts by uncombining the virtual device, updating the array just as Reese described, then recombing the array with the virtual as a final step.

    I've largely gotten away from the DEVICE_COMBINE thing with modero panels; thge times when this is a convenient way to di it is when dealing with older G3 panels that have far more limited channel and device numbers, necessitating using the same devchans for multiple functions. Sending all the processing through the virtual makes it possible to use the same devchan combinations for multiple devices, since they only act when the COMBINE is active.
  • sonnysonny Posts: 208
    I like to use COMBINE_DEVICES from the code re-usability standpoint. I can write a device module that updates a virtual UI, then just worry about the graphics on the panel itself. Not much coding required for each panel on a project. I can update a module and propogate it across multiple projects without having to re-visit the panel code (at least thats the goal)
Sign In or Register to comment.