11-12-2014 10:52 AM
LV 2013, Win 7, & LVRT 2013, PharLap OS
I have a situation where I create an ARRAY of User Events, one for each "domain" .
A "domain" is an area of DAQ: there is a SCXI domain, a CDAQ domain, an EtherCAT domain, several domains dealing with TCP instruments etc., about 25 domains all told. The name of the event is "New Channels This Domain".
When a new configuration comes to the PXI from the host, I sort out the channels by their domain and generate a user event for whichever domains have channels that have changed: more channels, fewer channels, differences. If a domain has no channels that have changed, I do not generate an event for it.
There is a handler for each domain: in that handler, I pick out the event for this domain from the array, and register to receive it. I have an event structure that responds to the NEW CHANNELS THIS DOMAIN event. Since it is an array, then no matter which domain I select, the name of the array is "New Channels This Domain".
All this works fine.
Now I have a situation where it makes sense to have one handler for TWO domains.
I can pick out TWO elements of the array just fine, and register them both. (See attached pic) But now, in the EDIT EVENTS FOR THIS CASE list, I have TWO events called "New Channels This Domain". I can select one for one case, and the other for the other case and it seems to work.
--- Is there any heartache ahead with this scheme?
--- If I change the events in the clusters before, is it going to confuse LabVIEW?
--- Is there something I can do to change the name of the event after I pick it out of the array?
--- Is there something I SHOULD do at that point?
Like I said, it seems to work, but I'm leery of it staying that way - I've had event structures disturbed before (LV2010) when changing cluster order.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
11-12-2014 11:08 AM
Amazing what the POST button will do for your thinking...
Here's one way: Since the REGISTER function will accept a cluster, then I can bundle the event and THEN register it. I give the bundles different names, and now the event case shows "Domain 1.New Chans" and "Domain 2.New Chans". That seems enough to avoid LV getting them confused.
Is there a better way? Is it even necessary?
Blog for (mostly LabVIEW) programmers: Tips And Tricks
11-12-2014 08:17 PM
11-13-2014 05:39 AM
Thanks, Greg for that link. I gave kudos to the idea of the COERCE TO TYPE function, and it seems like it would do the trick, but as of LV2014 it's still not on the palette. I downloaded the snippet, but asking for detailed help makes the help engine complain.
I am loath to incorporate a hidden function, and have to explain to my customer where I got it, and why.
My question still remains: is it necessary? Will the event structure remember that it's supposed to use the SECOND event named "X", through all edits and recompiles? My guess is no, but I'll listen to alternative stories.
In the meantime, I'll stick to the bundle-and-rename trick.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
11-14-2014 08:12 AM
@CoastalMaineBird wrote:
Thanks, Greg for that link. I gave kudos to the idea of the COERCE TO TYPE function, and it seems like it would do the trick, but as of LV2014 it's still not on the palette.
My question still remains: is it necessary? Will the event structure remember that it's supposed to use the SECOND event named "X", through all edits and recompiles? My guess is no, but I'll listen to alternative stories.
I've been using the Coerce to type for this and enums in versions 2011 through 2014 since learning about it. I've seen no issue using it in these cases. I'm guessing it doesn't behave in an expected way for extreame uses which is why NI doesn't release it yet.
As for would it always know to go to the second event if they are named the same? My guess is yes. They maybe named the same but they have different references. I would think it would be just like having two controls with the same label. You should never do this, but if you did, and made a local variables on one and wrote to it, it would always write to the correct control. It would never write to the different control with the same name. Now even if this is the case it could be confusing to a developer looking at the code, which is why I strongly suggest having unique names. But if you don't I suspect every thing would work fine, just have a bold comment or something explaining what each case actually is handling.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
11-14-2014 09:04 AM
As for would it always know to go to the second event if they are named the same? My guess is yes.
My reason for guessing "no" is history - I have had bad luck .
If I register a CLUSTER of events, and have a case for each event, and then add / remove an event from that CLUSTER, then I have ended up with events going to the wrong cases - it acts like it connects the events to "item 5 in the cluster", and if item 5 shifts around, then I'm hosed.
In THAT case, I would want it to connect by name, but in this case, I want it to connect by number. I guess we customers want everything, right?
Blog for (mostly LabVIEW) programmers: Tips And Tricks