LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI stuck at Call by Reference

Solved!
Go to solution

Hi there

 

I am currently having a "Call by Reference" subVI problem. I am currently working on a datalog VI that takes a cluster (masked as a variant) and writing the elements to a text string. If the cluster contains a cluster the datalog VI calls itself. When all elements are written to text string it is written to a file and the text string is cleared.

Here i am in need of reentrant execution - so i am currently using "shared clone reentrant execution" VI property and a "Call by Reference" with "Reload at each call" to call the VI from it self. This has been working untill fine, but yesterday after ~5 hours the program got stuck at "Call by Reference". Have I set it up correctly?

 

Regards

Mark

0 Kudos
Message 1 of 13
(4,030 Views)

I don't know if you set it up correctly (and it's certainly not easy to tell without code), but I would suggest using existing code rather than reinventing the wheel. Both OpenG and MGI have open source toolkits for saving clusters to INI files, so I would suggest using those.


___________________
Try to take over the world!
0 Kudos
Message 2 of 13
(4,005 Views)

My Crystal Ball that I normally use to look at Poster's VIs so that I can help them find solutions to their problems is having a "Cloudy Screen of Death" today.  Could you help by posting your VI (or, if you have several, Zip them together and post the .ZIP file)?

 

I've written a number of reentrant VIs (I love recursion, when it is appropriate), but I'm not sure I've ever written one using Call by Reference (and I'm even less certain why I'd do it that way).  When you do post code, be sure to let us know in sufficient detail what you are trying to accomplish.

 

Bob Schor

0 Kudos
Message 3 of 13
(3,986 Views)

My best guess is that you've hit a circumstance that you haven't anticipated in your code and it is recursing indefinitely.

Perhaps an error was thrown and that prevented your recursion from exiting.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 4 of 13
(3,966 Views)

Hi there!

 

I have searched the OpenG library but I couldn't find anything that matched my needs for far 🙂

I have attached my code - it requires the Cluster Toolkit 1.0.0.10 from VI package manager - other required/modified files are attached.

 

There is no check of how many calls it makes but the logging data doesn't change during the operation.

0 Kudos
Message 5 of 13
(3,921 Views)

The OpenG VIs are in the variant configuration VIs package. The MGI ones are called Read/Write Anything. I haven't looked at your code closely (analyzing recursive calls is not my idea of fun and I don't have the package you're using), but one obvious difference between it and the OpenG code is that the OpenG code explicitly manages the VI references (it has to, because it was written years before LV had native recursion).


___________________
Try to take over the world!
0 Kudos
Message 6 of 13
(3,905 Views)

Mark,

 

     This sounds like a straight-forward recursion problem that should be very simple to solve, needs only "simple recursion" with no need for call by reference, no need for OpenG, but could be easily handled by the Hidden Gems in vi.lib (also part of the LabVIEW Tools Network, accessible using VIPM).

 

     Before I dig myself into a hole solving the "wrong problem", can you tell me if this is what you want --

 

Given a Variant, list all of its elements by Name and Type.  If the Type is a Cluster, list all of the elements of the Cluster by Name and Type.

 

     If this is what you want, I think it can easily be accomplished, and will give it a try.

 

Bob Schor

0 Kudos
Message 7 of 13
(3,874 Views)

The input is a cluster of variants. The VI has two functions determined by the LogFunction enum - header and data entries. The header takes the names of the cluster elements and combines it to a tab seperated string. If the cluster contains a cluster the name is seperated by a dot. Data entries just writes the cluster element values as strings.

 

Example: (tabbing in this editor not not possible?)

Time PIDsettings.Kp PIDsettings.Ratelimit.dt

1.0 0.25 1000

 

I haven't had time to look into MGI's read/write anything - will do it later 🙂

0 Kudos
Message 8 of 13
(3,849 Views)

You don't need recursive calls for this, just build up an array. Each loop cycle you pull one element off the array; if it's another cluster, add all those elements back onto the array. I posted some example code that does this here:

https://forums.ni.com/t5/LabVIEW/How-can-I-make-controls-save-their-state-when-the-project-is/m-p/24...

It writes to an INI file, and does the dot-separating as you describe. Wouldn't be hard to write to something other than an INI file.

I haven't looked at your code, I'm still on LabVIEW 2012 here.

 

EDIT: I should add that the linked code uses a mix of variant functions and control references, but I think it could be done purely with the variant analysis functions. Here's another example, with an image, that gets the names without using any references:

http://forums.ni.com/t5/LabVIEW/How-do-I-get-control-names-from-within-nested-clusters-RT/m-p/283704...

0 Kudos
Message 9 of 13
(3,827 Views)

Thanks for the reply - That is a great idea.

 

But my code is running fine and has only glitched once - I'm trying to figure out why 🙂 If I can just reuse the VI I've already written I would save a bunch of time.

0 Kudos
Message 10 of 13
(3,790 Views)