キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Reference Functional Global Variable

解決済み
解決策を見る

Hi Mike,

 

My browser can't find the ude_templates repository, is there a new location for that?

0 件の賞賛
メッセージ11/25
3,658件の閲覧回数
Yup, the link was broken. There shouldn't have been an "s" on the end. In any case, it should work now.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 件の賞賛
メッセージ12/25
3,633件の閲覧回数
0 件の賞賛
メッセージ13/25
3,619件の閲覧回数

@gregory

Let me know how this works. It looks interesting, but I can't pull off to mess with it right now.

Glad to answer questions. Thanks for any KUDOS or marked solutions 😉
0 件の賞賛
メッセージ14/25
3,600件の閲覧回数

Regarding the DQMH: It did take me several hours over the weekend before I understood why the scripting tools actually worked. After I got the hang of it though, the scripting tools are very nice. They will make a type def of your event data, add it to the VI which registers for all of the events, add an event for it if you want your main VI to be listening for it, and more. The documentation covers everything well, and they have a nice post on their Walking the Wires blog.

 

Regarding Mike's post: The UDE repo has a nice document as well. If you're already familiar with events you can start to implement this strategy in 15-30 minutes. Adding a new event takes a little more "manual" labor, but still quite quick. If you are going to have a lot of events, then it does take up a bit of screen real estate to obtain/destroy them all, but you could put them all in a SubVI if that's a concern.

 

@Mike: Why do you create a new library for each event, rather than having a library that you just rename? (In the project explorer, not in windows explorer).

 

@No one in particular: So far, if I am going to send a lot of different types of data (i.e. Initialize Instrument, Setting 1, Setting 2, Begin Acquisition...) I find it much quicker to use Queues. I have a re-use library for these as well, but it requires one library per recipient, not per event. If I need the recipient to handle some new action, I add a case to a case structure and configure a typedef for the data. But, based on these champions strong approval of events, I think there is still something about them that I don't get 🙂

0 件の賞賛
メッセージ15/25
3,584件の閲覧回数

Patrick, I forgot to upload a project of what it might look like to register for events in multiple places. I'm sure Crossrulz has a nicer example, but maybe this will be useful in the mean time 🙂

0 件の賞賛
メッセージ16/25
3,569件の閲覧回数
You can certainly copy and rename the library. I basic documented the workflow I use. I like the fact that LabVIEW will automatically vary the color of the icon banner when you create new libraries. It's really a matter of personal preference. If you copy and rename a single library, be sure to remember to edit the icon, or you could end up with a bunch of look-alike VIs.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 件の賞賛
メッセージ17/25
3,546件の閲覧回数

Hello Patric,

 

Thanks for your reply. As you say, I will upload a sample code. The sample code shows the way, with which the old program refresh the value of  the "State Anzeige Element", yes,  with the property node, and the result data will be transfered by notifier.

 

The old program has already worked for more than 15 years, it has been edited by several programmer and has hundreds of cases and events. The basic structure of the old program is the "producer consummer pattern". There are also some global variable and lokale variable.

 

Now I rebuild the program with the Object Oriented Programming, and I have used the " command pattern" as the basic design pattern. I have to use the value from the main frontpanel in the child method. I have choosed the control reference as a solution, and I try to avoid to use the global variable. But as the crossrulz posted, the control reference will slow down the program, so does anyone have any other idea?

 

regards

 

0 件の賞賛
メッセージ18/25
3,512件の閲覧回数

I have just a couple more comments/questions about User Events.

 

@MikePorter: If you register for all of your events at once just outside the event structure (picture below), then the event name in the structure is the same as your event reference (and responds to changes). This seems nicer than registering for the event inside a SubVI and bundling those refnums together trying to get the names how you want them, no?

Reg Events.PNG

 

And for anyone: Where do you destroy the events? It seems a good place would be at the end of the VI that is generating the event, but I was wondering if anyone had a different preference. One use case where the Event seems simpler than a Message Queue would be stopping a program with many parallel processes. With one project I have 7 different instruments so I send 7 "Exit" messages, with the event it is just generating a single Exit event. Thank you all for your help!

 

 

0 件の賞賛
メッセージ19/25
3,488件の閲覧回数
Actually, the naming isn't hard. The name of the indicator on the subVI creating the event reference will be the name of the event. The name of the indicator in the VI registering the event will be added to the beginning of the event name -- sort of like a namespace.

You can leverage this to help organize events. For example all your DAQ events could start with "daq.", all the generic system events (like shutdown) could start with "sys." And so forth.

If you have an event structure handling a bunch of events, these prefixes or namespaces can make it a lot easier to find things.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 件の賞賛
メッセージ20/25
3,460件の閲覧回数