04-30-2019 06:34 PM - edited 04-30-2019 06:35 PM
We are working with some proprietary subVIs (i.e. password-protected) that require a cluster of various elements going into them. One of the possible cluster element types is an array, which must contain the exact size (array length) that is necessary for the application in order for the subVI to work.
The problem is that the array lengths for many of these arrays have been changing as our project continues to progress. We have developed code to automatically generate a new typedef based upon a struct file, and it initializes arrays to the correct lengths, however the array lengths do not update in any of the typedefs that currently exist in the project. The only way I've been able to figure out how to do update the array sizes in the typedefs, is to delete and re-add every instance of the affected typedef in the project (which kind of defeats the whole purpose of using a typedef). This is becoming very cumbersome as we now have 100+ typedefs, and each one is used 5+ times in our code.
Anybody have any work arounds? Can I reinitialize all typedefs in a project to default values?
Note: I'm ideally looking for something that doesn't execute at run-time because this is code that is running on a RT target running Linux x64 which has various limitations.
04-30-2019 08:19 PM - edited 04-30-2019 08:22 PM
VI Scripting is probably your best bet here. You can create a script which traverse your VIs looking for the typedef, then update the value with a new default value. Here's a quick and dirty example:
Edit: VI Scripting is enabled under Tools -> Options -> VI Server -> Show VI Scripting functions and methods
05-01-2019 12:43 AM
Thanks, that is what I figured, but I'm pretty new when it comes to VI scripting. Going to give it a go tomorrow.
05-02-2019 06:14 AM
@ajf200 wrote:
Thanks, that is what I figured, but I'm pretty new when it comes to VI scripting. Going to give it a go tomorrow.
That's the spirit! I had a situation where I needed to construct a huge Cluster TypeDef based (I kid you not) on an Excel WorkSheet (the Cluster was going to correspond to the data in each Excel Row, with the Element Name being given by the Column Headers (e.g. "Run Number", "X Position", etc.) and the types deduced from the values found in Row 2 (e.g. an I32 if the element was numeric only with no decimal point, Dbl if numeric with decimal point, Boolean if "True" or "False", otherwise "String"). The Cluster had >50 elements, and the Excel WorkSheet structure kept evolving, so doing this "by hand" was very painful. So I (trial and error) learned how to write a simple LabVIEW script. Have done a few more, but go back to this example to "refresh my memory" ...
Bob Schor
05-02-2019 08:04 AM - edited 05-02-2019 08:05 AM
Yeah we are basically doing that right now using VI scripting to create the typedef, although it’s not a spreadsheet file so parsing is a little more in-depth. That being said I didn’t write those VIs.
I think I got something working yesterday in a small prototype VI. Going to scale it up today.
05-02-2019 12:14 PM
I wrote about the issue of the default values of type def's changing when edited in This Nugget about Type defs (more thatn 12 years ago. How time flies!).
(skip to the bottom of the Nugget to see the images I included)
I suggested creating sub-VIs that explicitly set the values when ever default values are desired.
I think that is worth investigating.
Ben
05-03-2019 09:16 AM
@Ben wrote:
I suggested creating sub-VIs that explicitly set the values when ever default values are desired.
Either create VIs that contain the constants with the correct sizes, or wrap the PW protected VIs. The wrapper could force the correct size.
Of course if the library is a class, you can make child. But most libraries are not that convenient .
05-03-2019 10:32 AM
wiebe@CARYA wrote:
@Ben wrote:
I suggested creating sub-VIs that explicitly set the values when ever default values are desired.
Either create VIs that contain the constants with the correct sizes, or wrap the PW protected VIs. The wrapper could force the correct size.
Of course if the library is a class, you can make child. But most libraries are not that convenient
.
And I BELIEVE you can save defaults to a class constant and they will stick.
Ben
05-03-2019 10:43 AM
@Ben wrote:
wiebe@CARYA wrote:
@Ben wrote:
I suggested creating sub-VIs that explicitly set the values when ever default values are desired.
Either create VIs that contain the constants with the correct sizes, or wrap the PW protected VIs. The wrapper could force the correct size.
Of course if the library is a class, you can make child. But most libraries are not that convenient
.
And I BELIEVE you can save defaults to a class constant and they will stick.
Ben
@Ben wrote:
wiebe@CARYA wrote:
@Ben wrote:
I suggested creating sub-VIs that explicitly set the values when ever default values are desired.
Either create VIs that contain the constants with the correct sizes, or wrap the PW protected VIs. The wrapper could force the correct size.
Of course if the library is a class, you can make child. But most libraries are not that convenient
.
And I BELIEVE you can save defaults to a class constant and they will stick.
Ben
That is correct.