Jump to content

DereferenceByName Xnode ( -> operator in C)


Recommended Posts

Property nodes already do this? Granted it requires implementing the property, but I'm generally not a fan of pulling data from class wires via the cluster primitives as it makes it hard to track where data is consumed. 

Link to comment

The above bit is what gets tedious to setup for all of those property VIs, this would get used inside those VIs for outside access but for a lot of stuff I do I try to avoid the overhead of an additional VI call just to pull out a data value. Here's a clarification of the boilerplate I'm eliminating:

 

DerefBoilerplate.png

Link to comment

Well the nice thing about his is that you dont have to copy the entire data structure, just the portions you care about. Note that he unbundles inside the IPE structure. For known names that you want to support (like always unbundle the thing called "waveform") the VIM would work, but its not arbitrary like the xnode could be.

Edited by smithd
Link to comment

I think it's extremely useful. I added DVR support to the latest version of LV-Signals which does something very similar:

LV-Signals.png

It only works with DVRs of clusters, and it looks like yours works with DVRs in general. Check out LV-Signals if you get a chance, the original use was to use it with LV-Create-Signals.xnode, which creates a DVR and a value change event for each element in the cluster.

https://github.com/erdosmiller/lv-signals

Edited by DTaylor
  • Like 1
Link to comment
On 7/15/2017 at 0:25 PM, UnlikelyNomad said:

Then I get the daunting task of scripting up the GenerateCode ability >_>

When you do this give LV-Scripting a chance: https://github.com/erdosmiller/lv-scripting

It has similar functionality to the LAVA Scripting Library: https://lavag.org/files/file/54-scripting-tools/ , but with a heavy emphasis on ease of use for code generation. The package has a dozen or so examples which likely cover everything you need for your XNode.

Link to comment

Oh sorry it was renamed Maleable VI, official feature in 2017 but was implemented as a custom XNode shipped with LabVIEW since around 8.2.

http://zone.ni.com/reference/en-XX/help/371361P-01/lvupgrade/labview_features/

VI Macro discussion before 2017 made VIMs official.

https://lavag.org/topic/19163-vi-macros/

It has some shared functionality with XNodes (type propagation for inputs and outputs) but other custom things like right click, adding removing terminals, and changing node size and icon at edit time can only be done as an XNode, not a VIM.

Link to comment
18 hours ago, infinitenothing said:

Maybe VIM could help?

 

Read DVR example.png

Read DVR.png

I use a lot of reference applications for things like buffers, etc. where pulling out everything everytime would become prohibitive. (As others have stated about my unbundle being inside the IPE). Perhaps the compiler would see the other items aren't pulled out and not copy everything, but if it copied my two gigs of full rate 50khz data when all I wanted was the current data size: boom. Memory fault.

Ultimately this XNode is going to become part of a palette of functionality that aids in development of by-reference designs that go beyond just type matching and maybe even someday others start using these and I never have to inherit code where a class instance stores state data in a FG, especially when that FG isn't part of the class. Preview of other coming attractions: Generics in LabVIEW. (With type restrictions!) All of these features will build on what I learn getting this "simple" introduction to XNodes working.

Link to comment

Was debugging enabled on the VI when it was ran?  I assume probing the cluster wire would force the string to be copied into another memory location.  Anyway that does sound good since one VIM that takes a few minutes to write could perform some of the same functionality as the XNode.  Still would require an unbundle by name, but a Read-Only DVR function could be pretty useful.  I think I made one during the 2017 beta replacing the icon now that I think about it.

Link to comment

Interesting, the same holds even if you do the following:

  • Pull out the string and read array size
  • pull out string and use split string (at char 0xFF) but only read offset
  • Inside of top (writing loop) in-place manipulate data of string (convert to byte array, replace element 0, byte array to string, rebundle)

To force labview to do an allocation, I had to go so far as to pull the data out of the DVR and manipulate it and use the manipulated data (I used the same byte array replace index + split string) . They really did a solid job with the optimization here.

1 hour ago, UnlikelyNomad said:

Was the compiler smart enough that it never put the string into the cluster in the first place? /snicker

Yes it actually did. And in typical labview fashion there are two copies (one for the data after the for loop, one to bundle it). You can get rid of the unnecessary copy through this embarrassing scheme:

sad.PNG

As impressive as the DVR optimization is, this is far more common and far more sad :(

Edited by smithd
Link to comment

I was testing a buffer I wrote for an application some months ago and pushed nearly 2 gigs of data into it 200 rows at a time and then read back the row count. LabVIEW's memory never went above 350megs. Definitely tricky to benchmark in LabVIEW sometimes. LabVIEW is great because it does a lot of stuff for you. LabVIEW sucks because it does a lot of stuff for you.

Edited by UnlikelyNomad
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.