LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Clone" Project Library (.lvlib)

Solved!
Go to solution

We have a study involving sound localization -- we move a speaker with a robotic arm, play sounds through the speaker, ask our subjects to point a laser where they perceive the sound location, and push a button.  We can also turn on LEDs and lasers, adjust parameters of timing, even move the sound source.  The various Trials are "programmed" by entries in an Excel WorkBook with columns for timing, sound position, sound parameters, etc.  Besides the Excel WorkBook, we generate 3 output files -- an XML Header file that describes the recording configuration (Analog and Digital Channel names and scales) and records the parameters of each Trial as it is run, an XML Event file that records all "point-in-time" events, such as Messages, State changes, or Digital I/O changes, and a Samples file that contains the N (typically 16) sampled Analog and Digital channels, sampled at 1KHz.  We control all of this from a LabVIEW Real-Time Project, which also includes the routines to examine, manipulate, and analyze the output data files.

 

The Project is (slowly) evolving -- we are currently at Version 2.0 (Version 1.x was developed in LabVIEW 7.0, this is the 2012/2014 complete rewrite, "Start from Scratch and Do it Right, or at least Better").  We are contemplating adding the ability to study sounds delivered via stereo headphones (varying the left-right loudness or adding a small time discrepancy between the channels), and would call this Version 2.1.

 

To try to prevent "Version Hell", we plan to make Versions "backward-compatible" -- we will add new columns to the Excel WorkBook for the new Headphone parameters, but set up the LabVIEW code to simply "do nothing" (with Headphones) if it reads a Version 2.0 WorkBook where these parameters are lacking.  This lets us use Version 2.1 code to do a Version 2.0 Experiment.

 

One problem we are grappling with is how to read back and analyze or manipulate the resulting Data Files.  For example, the Header File contains Version-specific sets of Data, which get parsed by the XML Parser and converted directly into a LabVIEW Cluster.  Thus a Version 2.0 file needs to be read by code that "knows about" a Version 2.0 Trial Cluster, while a 2.1 File needs a 2.1 Trial Cluster.

 

When I read the Header File, the first thing I encounter is the Version Number (e.g. 2.0 or 2.1).  Knowing this, I could, in principle, use a Case statement to call a Version 2.0 or Version 2.1 Analysis routine.  But I'm trying to "avoid a mess", and Project Libraries seem like a good way to go, if I can figure out how to use them properly.

 

[At this time, I should say that I tried a small experiment -- I created a new Project, built Library1 inside a Library1 Folder with a "Hello" and "Testing", built Library2 (inside folder Library2) with "Hello" and "Testing" (different), and called them from the Top Level.  Worked fine.  I then "took a short cut", and copied the Library1 folder (outside of LabVIEW) to Library3.  When I told the Project to add Library 3, I got a mess of Conflicts, which I couldn't resolve.  And I "broke" LabVIEW -- even after deleting all of the .lvlib and the .lvproj files, I could not create a Project and do an Add Folder (Snapshot) without an Missing File error popping up.  I made the Experiment using LabVIEW 2012 -- this problem affected not only LabVIEW 2012, but also LabVIEW 2013 and LabVIEW 2014, but not LabVIEW 2011.  I've talked with NI Support, who also are mystified.  I'm currently working in a new VM until I can get LabVIEW "repaired"].

 

What I would like to do is to identify all of the Version-specific routines in my Analysis folder, and include in this folder the TypeDefs for the Version-specific parts of the Data.  I would then "encapsulate" all of this into a Version 2.0 Project Library.  The code "on the Outside" would have its own copy of the TypeDefs (it could use the "latest Version", as the outer routines are supposed to be "backward-compatible".

 

So here are my questions.

  1. Assume I've restructured my Project so that I have a Folder, both "Real" and "Virtual" (in the Project) called Analysis, and it contains a sub-folder called Version 2.0 that contains both the Version-specific TypeDefs and most of the Analysis code.  Is there an easy way to turn the Version 2.0 Folder into a Version 2.0 Library so that when I call functions within this Library, they will use the Version 2.0 TypeDefs from the Library, regardless of the TypeDefs declared in the main routine?
  2. Assuming I have a working Version 2.0 Folder and Library, is there an easy way to "clone" it to make a Version 2.1 Folder and Library?  If so, all I'd need to do to make the code "work" for Version 2.1 would be to (a) replace the Version 2.0 TypeDefs within the Version 2.1 folder with the "correct" TypeDefs, and (b) add whatever additional analysis code is needed for the new Features of the new Version.

I apologize for the long-winded nature of this question.  I did look for tutorials on Project Libraries (there are some), but none covered this topic.  To repay your patience, I'm happy to write this up and submit it to NI for a future White Paper on Project Libraries -- whom would I contact?

 

Bob Schor

 

P.S. -- Moderator -- if this belongs in another Forum, feel free to move it.

 

 

 

0 Kudos
Message 1 of 10
(6,003 Views)

a "Save As" of the library from Project Explorer should be the first thing you try.  Never from Windows explorer!  the lvlib will not know the member's locations changed, the members will think they belong to the parent lvlib, and you'll break thingsSmiley Wink

 

Altrnately,  if you are going to do a lot of these, use a library template and stick it in New...


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 10
(5,989 Views)

Boy, did I ever Break Things!  I think I know how I broke them, but haven't (yet) found how to "repair" my 2012, 13, and 14 versions of LabVIEW.  At least it isn't "contagious" (the files, with the .lvlib and .lvproj removed, can be safely opened on other LV2012 installations).

0 Kudos
Message 3 of 10
(5,981 Views)

Jeff,  am I correct that this is the answer to Question 2, namely "Now that I have one library, how to I make a copy as another Library that I can modify as appropriate?"?  (I rarely get the chance to have two Question marks in a row ...)

 

BS

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

@Bob_Schor wrote:

Boy, did I ever Break Things!  I think I know how I broke them, but haven't (yet) found how to "repair" my 2012, 13, and 14 versions of LabVIEW.  At least it isn't "contagious" (the files, with the .lvlib and .lvproj removed, can be safely opened on other LV2012 installations).


Just remember that the lvlib knows its members and where they reside.  and library members know the library they belong to.  Auto-populating folders are not your friend!  use only virtual folders!  if you do want to make some sub folders on disk "save as"...the source files to the new project/lvlib first, then move the members from the Project Explorer files view (That way the lvlib and the members get updated with the new locations)  Better yet, do a source distro of the original lvlib.

 

Resolving those conflicts you created is not easilly done.  You are likely better off deleting them and starting again the right way. AND Don't forget to stop using auto-populating folders!  Even project templates don't work right with Auto-pop folders (Unless that got fixed in 2014)

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 10
(5,959 Views)

@JÞB wrote:

Just remember that the lvlib knows its members and where they reside.  and library members know the library they belong to.  Auto-populating folders are not your friend!  use only virtual folders!  if you do want to make some sub folders on disk "save as"...the source files to the new project/lvlib first, then move the members from the Project Explorer files view (That way the lvlib and the members get updated with the new locations)  Better yet, do a source distro of the original lvlib.

 

Resolving those conflicts you created is not easilly done.  You are likely better off deleting them and starting again the right way. AND Don't forget to stop using auto-populating folders!  Even project templates don't work right with Auto-pop folders (Unless that got fixed in 2014) 


I never use auto-populating folders!  Let me see if I understand the steps you are outlining.

 

  1. Start with a "real" folder, Version1, that I want to make into a Library.
  2. Create a Virtual folder, Version1, and do a Add Folder (Snapshot) to get the Version1 Folder in there.
  3. Convert the Version1 Virtual Folder into a Version1 Library (I'm a little fuzzy on how to do this, but with your hints, I can probably figure it out).
  4. Now click on the Version1 Library and do a Save As, call it Version2.  I'm not sure if it will ask where to put it, but never mind, for now.
  5. I ultimately want the VIs in the Version2 Library to be in a Version2 physical folder (so their names won't change, only their content, perhaps).  Assuming I have a physical Version2 folder (empty), I repeat Step 2, make a Virtual Version2 folder and Add Folder the physical Version2 (again, empty) folder.
  6. Finally, from Project Explorer, I move the Version2 Library from whereever it is into the Version2 Virtual Folder.

Does that sound right?  I'm actually getting ready to do something like this (in a VM, so I don't hurt myself too badly), but if there's a detail I've missed, now would be a good time to hear about it ...

 

It's actually pretty logical and consistent, so once I do it the "right way", I'm unlikely to make this mistake again!

 

BS

0 Kudos
Message 6 of 10
(5,949 Views)
Solution
Accepted by topic author Bob_Schor

On the money Bob!  Save As... Duplicate heirarchy to new location (Requires that the new library has a new name)

 

To convert a virtual folder to a lvlib just create a new lvlib in the project and move the desired project members into the new lvlib Project Explorer does the rest of the nitty gritty work about saving the lvlib members with the new ownership information.  (You will be promted to save the members when the membership changes)

 

And yes, That's the kind of mistake you don't make twice.  And, believe it or not, I've had this type of issue used to justify not using projects! "they are too much of a hassle when you muck around in windows explorer"  Then I asked them if the ever borrowed their father's car and didn't tell him you parked it over on the next street.  They use projects now.Smiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 10
(5,940 Views)

Thanks, Jeff.  I always learn something from you (and a few others, it shouldn't go to your head ...).

 

BS

0 Kudos
Message 8 of 10
(5,929 Views)

@Bob_Schor wrote:

Thanks, Jeff.  I always learn something from you (and a few others, it shouldn't go to your head ...).

 

BS


I won't let it swell my head but, its not often that I get a solution from a forum heavy hitter  so, I'll cherish the mark.  Stay well!


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

Thanks to all,

This idea let me do something I have had trouble with. I have an instrument driver where all of the functions reside in a library. I want to use the entire project to seed a new driver for a different instrument, as some but not all functions are common. 

 

It is three steps along the same the same lines as the above discussion to achieve this.

 

Step one:

Save the project: Save as\Duplicate LVPROG file and all its contents... This creates a new project with the existing library.

Step two:

Open the new project and right click the library. Select save as\copy and click the add this copy to the project check box. Now you have the two copies of the VIs in two separate libraries

Step three:

Right click the old library and select remove from project. Now I can modify VIs in the new library as required without affecting VIs that reference the old library.

 

Can't tell you how much time I wasted trying other ways to achieve this. Thanks for the idea.

Andrew

Message 10 of 10
(4,250 Views)