09-16-2010 02:23 PM
In LabVIEW 2010 I am registering a User Event at runtime using the Reg Events function, but I want to set the name of the User Event based upon runtime data. LV says " If you wire a cluster to the user event data type input, LabVIEW uses the type name of the cluster as the name of the user event." But I need to set the name of the event based upon data that is generated at runtime.
How can I pragmatically set the name of a User Event with cluster data at runtime?
Can I do this by changing the Cluster's Label text before I use Reg Events function?
How can I tell which name the User Ever was given?
Thanks.
Solved! Go to Solution.
09-16-2010 02:29 PM - edited 09-16-2010 02:29 PM
Hi dbaechtel,
why do you need to set this info at runtime? What would be the result for you, if you could do it?
Mike
09-16-2010 02:42 PM
@MikeS81 wrote:
Hi dbaechtel,
why do you need to set this info at runtime? What would be the result for you, if you could do it?
Mike
I am creating some VI's dynamically during runtime to work as Agents to do some activity. I don't know ahead of time how many are needed, so they are created dynamically as needed. TheseAagents are uniquely identified by a GUID that is shared between the Agent and the VI that created them. I can use the GUID to create a unique User Event for each Agent so that the Agent can send some data back as needed. But the event names need to be set dynamically at runtime. Each defined User Event has a unique name, I just don't know how I can specify what it is at runtime.
Do you know of any approach that would do this?
09-16-2010 02:55 PM
Changing the name of a cluster at run time...
You can set the name of a cluster if it is not resrved to run using a properry node, so...
1) Create template taht you will use to create the event.
2) open a ref to it and set the cluster name.
3) Run the template and let it create the event using the re-named cluster.
4) Keep the ref to the template open so the event does not get cleaned-up.
Will that approach work?
Don't know.
Will it work in an exe?
Still don't know.
If that does work please share with us, since we are all in this game together.
Ben
09-16-2010 02:58 PM
Hi dbaechtel,
how would you react on this event? You have to create the events at development time to react on it. What about working with queues or notifiers or to send user defined (specific) data per event, instead of making the event itself specific? Why do you think the event has to be specific. From your description i think all your agents are different vi's so the events will be send to different vi's and this is also possible if they have the same name.
Mike
09-16-2010 03:00 PM
@MikeS81 wrote:
Hi dbaechtel,
how would you react on this event? You have to create the events at development time to react on it. What about working with queues or notifiers or to send user defined (specific) data per event, instead of making the event itself specific? Why do you think the event has to be specific. From your description i think all your agents are different vi's so the events will be send to different vi's and this is also possible if they have the same name.
Mike
I really like that suggestion since we can use "Named Queues".
Ben
09-16-2010 03:02 PM
Hi Ben,
what do you mean? I'm not sure if i understand.
Mike
09-16-2010 03:06 PM
The Obtain Queue primative wiill accept a name when you create the queue.
If you pass the flag say do NOT create if it does not exist, LV willlook-up the queu by the name it was created with and return that ref. so it is not required to create the queue in on place and pass the ref around.
The only trick is to make sure the "sender" and the "reciever" of the queue agree on what the name and data types are.
Ben
09-16-2010 03:19 PM
Hi Ben,
yes that's a great point. I didn't thought about this option when i wrote it. Normally i send the Refs, per Queue or i set it per VI Server.
Mike
09-17-2010 08:31 PM - edited 09-17-2010 08:31 PM
I have found a workable solution. I can create one User Event with a known name. The Event Data that is sent with the Event will include a unique Source Name string that will identify the Sender of the Event. The Event Handler can then handle each Event based Upon the Source Name. This will be equivalent to having multiple uniquely named Events, is just they all will share a common Event Data format, which in my case is OK.
This will work fine.
THANKS for all of the suggestions.