From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

AEs/Single Element Queues/Data value references

Solved!
Go to solution

I will have my CLD exam in December, and I just try to "pump up" as much as info as I can from the forum, of course beside the preparation materials...

I also started to read nice and interesting "nuggets" too, and I hope I can get some clarification for some of my questions which emerged. (Sorry if I a question is too noobish, I try to practice for the CLD beside my regular daily work load, and I am a bit slow thinker in the night 🙂 )

 

I often use FGVs (and ActionEngines) in my applications, and during some "surfing/learning" on the NI discussion forum, I have found this post:

http://goo.gl/Cz1d0p

Here the people recommended that, the OP could use wrapper VIs which method has 2 benefits, explained here:

"Wrapping It Up"

http://goo.gl/J4vEIE

 

My 1st question:

I am not really sure what a wrapper VI means? Is it a subVI, where the certain AE subVI is called dynamically? I could not find examples showing how to do this (I read through the entire post, but the later discussion was more about OOP...)

 

2nd question:

In the second community nugget post, there are some closing notes, one of them: "AEs do not require a While Loop." I thought AEs also must use an uninitialized shift register to store info (like FGVs), and I need a while loop to have shift register...No?

 

3rd question:

I fall in the usual dangerous trap, which is jumping through different linked posts, and trying to understand all at once 🙂  But I wonder if out there exist some kind of basic example, which shows three solutions (ActionEngines, SingleElementQueue, Data value refs) for the very same task?

 

Thanks very much for explanations!

 

ps.: sorry for using the google shortened urls, but the forum site gives me error (please enter a valid url) when I try to paste the normal URLs...

 

 

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

Sorry i don't have time to post pics of examples right now but i'll try to follow up later with code:

 

To answer questions

 

#1) A "Wrapper VI" is basically taking one action of your Action Engine and putting that inside of another VI.  This new vi literally wraps your old vi and encapsulates its functionality.  So for example lets say you have an AE called "Data AE" that has three actions, Read, Write, Init, and that you control which action is being used by using a enum constant.  If you were to take this enum and set it to write, then put that inside another vi called "Write", then you would be wrapping your AE and any time you wanted to use the write functionality you would drop this VI instead.  You could do the same thing for your "read" and "init" actions and then you would have 3 separate vi's that represent different actions of your Action Engine.

 

2) I believe this would be referring to a feedback node.  You are able to make a Functional Global/AE using a feedback node instead of a while loop if you wanted.  There used to be some debate oh which was "faster" but i don't know where that ended up

 

3) See above

 

Hopefully this answers some of your questions.  If you do start to look at OOP for action engines there are some benefits.  The OOP version of a Functional Global or AE is sometimes called a Singleton.  In OOP, you defined different methods that perform specific actions on the class data.  Its a different concept that takes some getting used to.  But basically you are developing different vi's for each "action" or method that does work on your class data.  You do this instead of encompassing everything in a un-initialized shift register like you do in an FG.  

Message 2 of 10
(4,329 Views)

#1 and #2 are as above. For #3, this podcast (and the associated presentations/code) will probably help:

http://vishots.com/functional-global-variables-revisited/

It doesn't go over single element queues, but I'm not really sure why you would use them over the other options.

 

This (both the library itself and the presentation PDF that is attached) are both tangential to the topic and a little bit more advanced...but also kind of neat:

https://decibel.ni.com/content/docs/DOC-12813

Message 3 of 10
(4,300 Views)
Solution
Accepted by topic author Blokk

@Blokk wrote:

3rd question:

I fall in the usual dangerous trap, which is jumping through different linked posts, and trying to understand all at once 🙂  But I wonder if out there exist some kind of basic example, which shows three solutions (ActionEngines, SingleElementQueue, Data value refs) for the very same task? 


The Single Element Queue should not be used anymore.  Its purpose has been streamlined with the Data Value Reference.  The concept between the two is exactly the same (reference to a single peice of memory that is locked when read until edited and written back into it).  The DVR just uses the In Place Element Structure to encompass the Read-Edit-Write actions where the SEQ relied on the writer being smart enough to actually write data back into the queue.

 

I like Action Engines.  They are simple and keep everything in a single place.  You read from a shift register (or feedback node), do whatever you have to with it, and write back into the shift register (or feedback node).  The fact that this is inside of a non-reentrant VI acts as your lock.

 

I have personally only used a DVR once in an actual project and it was only to take care of some composition in my Object Oriented setup (multiple objects needed to reference another shared object).  Otherwise, it has been Action Engines all the way for me.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 10
(4,292 Views)

Thank you all for the nice and detailed explanations! Kudos for everyone 🙂

0 Kudos
Message 5 of 10
(4,268 Views)

My 1st question:

I am not really sure what a wrapper VI means? Is it a subVI, where the certain AE subVI is called dynamically? I could not find examples showing how to do this (I read through the entire post, but the later discussion was more about OOP...)


 

 

Lets get into an example:  

Here is a "Special" AE of I style I do often use (You can probably see it elsewhere to) 

!0.png

Note: using an AE this way I have only 1 point of access to the  resources and can easilly find the caller that hosed up my resource as well at troubleshoot the darn hardware!  BONUS you have a single point, correctly scoped, to document what the code does:

 

Capture.PNG

 

 

Works great until the project gets into multi- developer land or you need to really get righteous with your reuse code that might make it into follow on projects. Then you want to wrap up that Resource Module.  The BDs might look like this:

!00.png

This allows me to publish an API for the resource that does protect critical actions on the code (And even has correct error functionality for the close operation) 


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 10
(4,221 Views)

looks very interesting! 🙂

and nice thing also, if there is an incoming error, you still close properly the HW resources...except if there is error in 1 of the 4 hardware, am I right? So if 1 HW (or channel) makes error, it will effect the 3 others?

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

@Blokk wrote:

looks very interesting! 🙂

and nice thing also, if there is an incoming error, you still close properly the HW resources...except if there is error in 1 of the 4 hardware, am I right? So if 1 HW (or channel) makes error, it will effect the 3 others?


I'd have to see the exact code to make sure, but most of the "close" functions in LabVIEW will still operate properly even if there was an error on the error input.  So it might be a non-issue.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 10
(4,188 Views)

The RM has an error/no error case. But close could put the error chain on a auto indexed tunnel followed by a merge errors.

In that app, it was not needed. All tasks were on one cDAQ device. Look closer and you might see some DAQmx ideas... Scales on counter tasks... n ch counter tasks...time elapse since started on counter tasks...Smiley Frustrated


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 10
(4,176 Views)

@crossrulz wrote:

@Blokk wrote:

looks very interesting! 🙂

and nice thing also, if there is an incoming error, you still close properly the HW resources...except if there is error in 1 of the 4 hardware, am I right? So if 1 HW (or channel) makes error, it will effect the 3 others?


I'd have to see the exact code to make sure, but most of the "close" functions in LabVIEW will still operate properly even if there was an error on the error input.  So it might be a non-issue.


Thats right! I just did not pay attention to this fact before 🙂 I opened the BD of the DAQmx Clear, and it does release resource even in case of error...

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