LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Feedback Request - Open VI Object Reference.

Suppose I want to use scripting to interact with a compound arithmetic function inside of another diagram.

Open VI Object Ref Feedback #1.jpg

There are a number of ways to obtain a reference to this function with scripting.  I want to talk about one of the basic ways to do so, which might look this:

Open VI Object Ref Feedback #2.jpg

The pictured for loop and compound arithmetic functions do have names, so it's possible to get a reference to them with the Open VI Object Reference function, by providing their name as an argument.  That code might look like this:

Open VI Object Ref Feedback #3.jpg

You can get a reference to a nested front panel object, like a numeric inside of a cluster, by providing an array of strings to the Open VI Object Reference function.  The function currently can not accept an array of strings to navigate through nested block diagram objects, like a compound arithmetic function inside of a for loop.

I wish that the function did work with nested block diagram objects, so that I could write code that looks like this:

Open VI Object Ref Feedback #4.jpg

This brings us to a question, though.  What if you are trying to get a reference to something inside a structure which has multiple pages, like a case structure?

Open VI Object Ref Feedback #5.jpg

I can think of a couple ways for this to work.

1)  Perhaps I would say that you can only use this technique to get a reference to something inside the 'first' page of the structure.  This would be simple to understand, although I don't like how limited it is.  Also, LabVIEW doesn't really do anything to let you reorder pages inside of a case structure.

2)  Perhaps I would say that we search all of your pages in order, and stop when we find an element with the name that you specify.  That means that if you want to be certain to get a reference to the right object, you have to make sure it is uniquely named across all of your structure's pages.  This would be less limited than #1, but it could be annoying to assure unique names in your code...especially considering that every compound arithmetic node starts with the same default name.

3)  Perhaps I could introduce new rules for how the Open VI Object Reference function interprets the array of strings.  Maybe you would decorate the name of your structure to also include the name of the page you want to search:

Open VI Object Ref Feedback #6.jpg

  I think that this is reasonably easy to understand, but I think it introduces room for wierd behavior with wierdly named objects.  If you have a structure named 'Case Structure' with a page 'True', and another structure named 'Case Structure:True' with a page 'Compound Arithmetic'...how can LabVIEW know if you wanted a reference to the one function, or to the other diagram?

4)  Perhaps I could say that multi-page structures require an additional element in the array to describe which specific page you wanted.  That could look like this:

Open VI Object Ref Feedback #7.jpg

  I like that approach, because it means that I don't have to invent exotic rules for building strings to specify pages within a structure.  But I'm worried that it would be confusing to people who want to interact with an item inside a structure without multiple pages (like our for loop in the first example).  Would those people think it strange that you specify 'inside a for loop' with one element, but specify 'inside a case structure' with two elements?  Would they expect to have to provide two elements to specify 'inside a for loop', and just leave one blank?

  I'm kicking around these ideas, trying to decide which makes the most sense for people who use LabVIEW scripting.  Right now I'm leaning towards option #4, but there are still some unanswered questions with that approach.

  I would value any feedback or alternative solutions that anyone cares to provide.

0 Kudos
Message 1 of 3
(4,041 Views)

Hi,

  But I'm worried that it would be confusing to people who want to interact with an item inside a structure without multiple pages (like our for loop in the first example).  Would those people think it strange that you specify 'inside a for loop' with one element, but specify 'inside a case structure' with two elements?  Would they expect to have to provide two elements to specify 'inside a for loop', and just leave one blank?

I don't really see the issue, it is an array you are providing that correctly addresses where to look for such an object.

It would not be very unreasonable to look for an object in 3 or 4 layers code where some might have multiple pages. so the number of elements inside the array can vary a lot.

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 3
(2,731 Views)

Knowing the name of a case structure frame can be tricky. It is easy for the boolean true/false but can be very complicated in other cases where you use strings, ranges for numerics, etc. A simple change to the logic can easily break the scripting code. Are there any ideas on how make it easier to know the frame name? Maybe have labels for frames?

It might be nice to have a version where you specify the frame number instead of the frame name. This is similar to what you currently have where you take the array of frames and index the array by the frame number. This could break if a frame is added, deleted, or just reordered.

Indexing by number would also be useful for structures that do not have labels like the sequence structures.

I don't love idea 4 but that is the one I'm leaning towards.

0 Kudos
Message 3 of 3
(2,731 Views)