11-30-2012 01:25 AM
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
11-30-2012 01:33 AM
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.
11-30-2012 01:36 AM
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
11-30-2012 01:44 AM
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?
11-30-2012 02:07 AM
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.
11-30-2012 02:16 AM
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.
11-30-2012 03:18 AM
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
01-10-2013 01:33 PM
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)
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.
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.
01-10-2013 02:47 PM
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)
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.
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?
01-10-2013 03:00 PM
Interesting, I have tried the SetRef and GetRef method but always got errors.
What kind of references can be used in these methods?
/J