LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pragmatically set the User Event name?

Solved!
Go to solution

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.

0 Kudos
Message 1 of 10
(4,448 Views)

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

0 Kudos
Message 2 of 10
(4,442 Views)

@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?

 

 

 

0 Kudos
Message 3 of 10
(4,430 Views)

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 10
(4,422 Views)

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

Message 5 of 10
(4,417 Views)

@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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 10
(4,411 Views)

Hi Ben,

what do you mean? I'm not sure if i understand.

 

Mike

0 Kudos
Message 7 of 10
(4,399 Views)

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 10
(4,395 Views)

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

0 Kudos
Message 9 of 10
(4,387 Views)
Solution
Accepted by topic author dbaechtel

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.

0 Kudos
Message 10 of 10
(4,340 Views)