From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding metadata to VIs and objects

Contestant Info:

Péter Kovács

Email: Contact me in PM, if needed

User Group Affiliation:

I'm living in Hungary, and there are no user groups here, so I choose this one:

Austin LabVIEW User Group

Location:

National Instruments

11500 N. Mopac Expwy

Austin, TX 78759

Contact:

Travis Ferguson

travis.ferguson@ni.com

512.683.5701

Meeting Details:

Quarterly meetings, Public,   usually on Wed./Thurs., 11:30 - 1:00

User Group Website:

http://decibel.ni.com/content/groups/austin-labview-user-community

Twitter Account (optional for mainpage ticker feed):

Summary:

I found an lvlib in the LV install folder, specifically <vi.lib>\UserTags\UserTags.lvlib. I never have seen it on any of the LV palettes, and after googling a bit, I came up with nothing. It seemed to be of interest to me, so I started to use it.

With the help of these tools, it is possible to add any custom user data (tags), which is stored in a key-value form to any VIs or objects within them (controls and indicators).

The tags can be added during runtime, but after saving the modified VI, they are saved to disk, so you can add them permanently.

This way it is possible to store data which are specific to individual objects, or related to the VI in question. Using this method the use of hidden controls and indicators (with which I think everybody is familiar) may be avoided.

One can use this method as a sort of IPC (Inter-Process Communication).

It is also possible to use this in place of data passing through control value set methods.

Function:

Suitable for metadata storage in VIs, and a new possible IPC method.

Steps to execute code:

For the 1st example:

  1. Open and run Read_tag_from_VI_on_disk.vi

  2. Open and run Add_tag_to_VI_and_save.vi
  3. Open and run Remove_tag_from_VI_and_save.vi
  4. Observe the size of Test_vi_for_tagging.vi after each steps above

For 2nd example:

  1. Open and run Set_object_tags.vi
  2. Click LOAD READER button
  3. Change the slide and string control values
  4. Observe the changes in the Reader Window
  5. Cick the STOP button in the Set_object_tags.vi
  6. Click the STOP button in the Read_object_tags.vi

For more detailed description, please see the video below:

Screenshots:

Main Front Panels (IPC demonstration, that's why there are 2 VIs):

Front_panel.png

Main Block Diagram (of the data provider):

Block_diagram.png

VI Snippet:

Add (or set) User tag to VI and save it:

Add_tag_to_VI_and_save.png

Read User tag from VI:

Read_tag_from_VI_on_disk.png

VI attached below

Edit: I added a project (UserTags_v9.zip) that is saved to LV 2009.

Download All
Comments
G-Money
NI Employee (retired)
on

Nice code! What would be the benefit of using this instead of an ini file? Do you see any downside to using this method of retaining values?

peter_smith
Member
Member
on

Thanks. It's easier to use than .ini files. There are no sections here. You can add tags to specific elements (not only to VIs) and they can be permanently stored inside the VI file, so they remain hidden from the user.

This means they can't change the "settings" you want to set.

You can also use this method during runtime only, so your tags do not have to be made permanent. This way you can pass different metadata eg. to each instance of a reentrant VI.

Jon_Kokott
Member
Member
on

You have locked/password protected VIs in your submission.  I won't run the code with private VIs.

~Jon

------------------------------------
Jon Kokott
CLA, CLED, CTD, MCP C#
G-Money
NI Employee (retired)
on

Jon,

            Which VIs are locked?

Peter,

            Can you please unlock all VIs that you submit so that the community can learn from your approach overall and there are no black boxes. Thanks!

Jon_Kokott
Member
Member
on

Ack, That is my error.  The VI tags is included with LV2010.  It is not original code, it is provided by NI.

~Jon

------------------------------------
Jon Kokott
CLA, CLED, CTD, MCP C#
peter_smith
Member
Member
on

Grant, the VIs I made are not locked nor password protected.

peter_smith
Member
Member
on

Jon, it is written in the summary, that the user tag VIs are from NI. I just found them and made examples to show how to use them, so I cannot give the password, however I'm pretty sure thye use some dll or something similar - I mean something you cannot duplicate in LV. They are placed in LV's install dir at vi.lib\UserTags\UserTags.lvlib. The project only references this library, it is not even part of the zip file.

I made the VIs in LV2010, however I looked at LV2009, and UserTag is included in that version too. I don't have any earlier versions installed currently, so I can't tell if this is available in earlier versions as well.

P.S. Or did you try to use the code via the VI snippets? I'm not sure if that will work, as the User Tag VIs might not be recognized, because they are not in-built LV functions.

tst
Knight of NI Knight of NI
Knight of NI
on

Tags have been around for a long time (since at least 7.0 and probably earlier), but the functionality has been marked as private. In 8.6 NI added these VIs, which hide the private functionality, so this will work on any installation of LV and as long as you don't want to save the VIs, will work in built executables as well.

You can see more about this here - http://forums.ni.com/t5/LabVIEW/Darren-s-Weekly-Nugget-04-13-2009/m-p/888538#M401396


___________________
Try to take over the world!
peter_smith
Member
Member
on

Hi!

I did not know about this functionality earlier, but as I wrote in the document, I googled for it. It did not gave any useable results.

I looked at the post you referenced now, and followed the discussion to your demo code, which is on resizing controls.

Your code is however a lot different, as it uses scripting. It is not using the library from vi.lib. It does not even document this functionality as that was not your goal with the demo, I think.

Even though I don't think it is a very popular or well known functionality, as there were some interest here in it as I see, and it was even posted on VIShots's twitter.

My goal was to show this functionality to the public, for people to know about it, and show it's usage, which I think I have accomplished.

Of course if the NI representatives think this code is not original or does not suit with the challenge's regulation, I accept their decision.

tst
Knight of NI Knight of NI
Knight of NI
on

I wasn't saying that there's any problem with your code, because there isn't - it's fine and perfectly acceptable as an entry. I was just pointing out more details on those VIs.


___________________
Try to take over the world!
MonicaR
Member
Member
on

Hi!

That's a really interesting functionality! Code looks really nice and commented too.

I'm sure I will find some use of it in upcoming projects.

Thanks,

Monica

peter_smith
Member
Member
on

Sorry, I thought you tried to say, that this is not a "new functionality / original example", as it was around for years. By the way following your link is worth it, as it shows some more possible usages (via scripting).

Peter

peter_smith
Member
Member
on

Thanks, I'm happy you like it, and you are going to use it as well.

PS: If you really liked this code, please vote for it too. Thanks.

Contributors