LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

auto code generation

Hi everyone,

I am new to using LabVIEW (I've come from a background of C/C++, Java, Perl, etc...) and have learned quite a bit about using LabVIEW 7.0.  But what I am finding is that it is horrible about code reuse.  Apparently, from what I can gather, if I wish to reuse code, I need to generate a VI template which is a fancy way of doing copy coding *shiver*.

So fine, if copy coding is the only way to generate reusable code, so be it, but is there a way of automatically replacing a static typedef with another automatically from a referencing VI?  If I was coding this in C, I would use a sed script to search and replace the type name with another in the files, but given the binary nature of the .vi and .vit files, I don't think that this is an option.

I can't wait till we move over to LabVIEW 8.x which supports OOP as this will alleviate much of the problems I am seeing.

Any help anyone can give is greatly appreciated.  Thank you for your time.


Adrian

0 Kudos
Message 1 of 8
(4,229 Views)

Type definitions can be replaced by taking advantage of two properties of LabVIEW.

1) Only one VI with a given name can be in memory at the same time.

2) Callers of VI's will save the relative path and name of all it callers.

How to use this feature.

A) Make sure you have typedef defined and you know its name.

B) Make sure all VI are closed.

C) Open the typedef that you want to use as the replacement of the typdef in your app.

D) Save the replacement using the name of the typdef in the app and keep this replacement open.

E) Open the app. You should get warning meessage about the VI being found in a new location.

F) (Optional step) Save the typdef as a new name.

G) Close all of the VI's in the app and save them.

After completing this proceedure you will have replaced all of the old typedef's with the new.

Note:

Save with options >>> single prompt >>> preserve hierachy gives you options to clone all VI to new location and leave the original un-touched.

'nough for now.

Have Fun!

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 8
(4,218 Views)
Great, I'll give that a try.  One other thing.  Is there a way of separating the icon pictures from the files?  Or perhaps getting the icons changed in a automatic/semi-automatic way?  I would like to generate some default icons via a script.

Suggestions?


Adrian

0 Kudos
Message 3 of 8
(4,203 Views)
No, I was attempting your solution Ben but unfortunately because of the fact that you cannot have two files with the same name open at the same time, this solution is not viable.

Perhaps I need to re-explain.

I have a group of VIs that is going to be the base of some _very_ similar code.  Differences are handled by calling through VI refnums (function pointer equivalent).  Also there are specific data for each group, so I don't want to have to go through each VI in the group and repoint them to new Strict Type Def.

These similar code groups are going to need to be run from the same application, thus, if I understand correctly, I need to have the Strict Type Def files uniquely named.

Is there a way of doing this?


Adrian

0 Kudos
Message 4 of 8
(4,197 Views)
Ben said:

Note:

Save with options >>> single prompt >>> preserve hierachy gives you options to clone all VI to new location and leave the original un-touched.

I couldn't find this option in the options.  Could you tell me exactly where I am to look for this in LabVIEW 7.0?

Thanks,


Adrian


P.S. I find it odd that even though you can have two seperate files in different directories, you still need to give them unique names.

0 Kudos
Message 5 of 8
(4,193 Views)
That should have been
 
File >>> Save with options >>> single prompt >>> preserve hierachy 
 
I wrote a VI that will clone rename and replace a typedef but it is in LV 7.1. Lacking that tool you will have to do the cloning by hand.
 
For your icon you use these methods.
 
 
And to save you asking about other things that will require scripting, see the Rusty nails on LAVA.
 
Ben

Message Edited by Ben on 10-03-2007 12:29 PM

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 8
(4,187 Views)

"
P.S. I find it odd that even though you can have two seperate files in different directories, you still need to give them unique names.

"

That goes back to the LV 1 days when you only had eight character names.

In LV 8+ you can have multiple VI's of the same name in an applcation but in that case LV mangles the names with the libraries containing the VI's

And since I mentioned mangling, here is some mangled Shakespear (sp?)

"A VI by any other name, stinks!"

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 8
(4,173 Views)
Use a method with a Open VI Reference. Use Open VI Reference with the path
to the VI or string with the VI's name (if it is in memory). Then use the
method "VI Icon> Get As Image Data". Use the picture control functions to
save it to jpg, png or bmp.

You can also change it with the method Set From Image Data. So you can read
one VI's icon, and set it to any list of VI's. You can get this list any way
you like, e.g. recurcive calls to VI Callees, List Folder, All VI's in
memory, or an array control with your own selection. Remember that if you
change the icon, the vi needs to be saved! If you don't all changes will be
lost. Since you open the vi with VI server (Open VI Reference), you will not
get a notification. Use the method Save>Instrument.

In LV 8.0 and up you have an option to set an icon template for VI
Libraries. So if you are using libraries (the project library kind, not the
old .llb files), and you should if you like code reuse, that might be
easier.

The is an OpenG (I think) project to edit icons, I'm not sure if there is an
automated batch function to update groups of VI's.

Regards,

Wiebe.


0 Kudos
Message 8 of 8
(4,145 Views)