LabVIEW Project Providers

cancel
Showing results for 
Search instead for 
Did you mean: 

Persistent Item IDs or GUIDs

As long as you talk about VIs and Controls, a persistent identifier tag will move with the item when it is renamed (given that the project is open during rename operation).

External documents still have to be identified by their paths though.

/J

0 Kudos
Message 11 of 30
(2,556 Views)

Mellroth wrote:

As long as you talk about VIs and Controls, a persistent identifier tag will move with the item when it is renamed (given that the project is open during rename operation).

External documents still have to be identified by their paths though.

/J

Right - but if I understand correctly, the Provider would have to actively monitor for these rename operations and update the referencing Project Items -- it feels like this could get messy.

0 Kudos
Message 12 of 30
(2,556 Views)

No, as long as the provider only use the ID tag to identify items to be included, the paths does not have to be monitored.

/J 

0 Kudos
Message 13 of 30
(2,556 Views)

OK, I may be missing something then... here's just snapshot of a test I tried when searching for a persistent identifier between sessions, and none of the properties I'm testing were persistent. Am I missing one?

Screen Shot 2012-11-29 at 11.42.22 PM.png

0 Kudos
Message 14 of 30
(2,556 Views)

Sorry, my fault.

I meant a specific ID tag from your provider, that you set on the items you want to include.

/J

PS.

In the provider API I would really like to see a functions to add GUID (if it does not already exist) to a specific item, and to search for items by GUID in the project tree.

This would allow different providers to use the same indentification mechanism. Today each provider has to add their own tag to all necessary items.

0 Kudos
Message 15 of 30
(2,556 Views)

Mellroth wrote:

I meant a specific ID tag from your provider, that you set on the items you want to include.

Got it!

But... as mentioned before, this is not scalable. If I were to tag arbitrary items with GUIDS proprietary to my application, it would be necessary to do a linear search of every project item to query if it has my GUID property or not -- this method does not scale. Without some sort of XPath or similar query method...

Mellroth wrote:

PS.

In the provider API I would really like to see a functions to add GUID (if it does not already exist) to a specific item, and to search for items by GUID in the project tree.

This would allow different providers to use the same indentification mechanism. Today each provider has to add their own tag to all necessary items.

Yes, I would be excited to see this feature also! That would be spectacular.

0 Kudos
Message 16 of 30
(2,556 Views)

I don't think the linear search is too bad, but you can always use the LabVIEW XML functions to search projects with xPath expressions.

You could also store the item type together with the different GUIDs in the provider setup, and then use "Get All Decentents" method with this item type as input.

/J



0 Kudos
Message 17 of 30
(2,556 Views)

Would this work for your use-case? - 

1. Get the NIIM for a Project Item (you can do this using the VI Server Property for a Project Item)

2. Unbundle to get the ItemId

3. Use mxLvSetRefProperty.vi to save this Item ID in the property bag. (You can save it in the parent item or any other project item)

SaveRef.png

4. In the next LV session, you can read this saved Item ID using the mxLVGetRefProperty.vi and get the Project Item Reference by using Item From Item ID method of Project class. You can use provocom_GetObrjectItemFromProjectItem to get the Item further.

ReadRef.png

    

 

If you rename or move the item around, the reference property saved gets updated to point to the new name or the location.

Hope this helps!

-Sumedha

**This solution uses some private methods for access to which I have attached a VI including those. These methods are not guaranteed to work and might not be included in future versions of LabVIEW.

Sumedha Ganjoo | LabVIEW R&D
Message 18 of 30
(2,556 Views)

Sumedha wrote:

Would this work for your use-case? - 

1. Get the NIIM for a Project Item (you can do this using the VI Server Property for a Project Item)

2. Unbundle to get the ItemId

3. Use mxLvSetRefProperty.vi to save this Item ID in the property bag. (You can save it in the parent item or any other project item)

SaveRef.png

4. In the next LV session, you can read this saved Item ID using the mxLVGetRefProperty.vi and get the Project Item Reference by using Item From Item ID method of Project class. You can use provocom_GetObrjectItemFromProjectItem to get the Item further.

ReadRef.png

I have not yet tried this solution since it takes a little while to set up a test, but can confirm a concept past you before trying?

It appears NIIM.Item ID is unique for each LabVIEW session. See this post (https://decibel.ni.com/content/message/44611#44611) for a quick-and-dirty VI that confirms this.

So if NIIM.Item ID from one session is persisted (say, to the project root tag, or even an external file!), in the next LabVIEW session, with the Item From Item ID Project method be able to resolve this old Item ID into a the correct ProjectItem reference? Because if we were to snag NIIM.Item ID from this newly created reference, it would be a different NIIM.Item ID than was persisted.

That's a blunderous, wordy setup, but in a nutshell -- is the Item From Item ID method smart enough to resolve Item ID from a previous session?

0 Kudos
Message 19 of 30
(2,556 Views)

Interesting, I have tried the SetRef and GetRef method but always got errors.

What kind of references can be used in these methods?

/J

0 Kudos
Message 20 of 30
(2,556 Views)