Jump to content

Working with cursors in sub-VI


germ

Recommended Posts

Hello,

I could not find an answer to this (I tried a search).

I have a main VI with an IntensityGraph with cursors. I want to read and change the positions of the cursors (among other things) in a Sub-VI. The reason for doing that is that the block diagram is already huge and very complicated, so I want to move some of the tasks to a Sub-VI.

So I wire the IntensityGraph to one terminal of the Sub-VI connector. But when I read the cursor position with a Property Node inside the Sub-VI, I get the cursor positions of the "fake" IntensityGraph that I put in the FrontPanel of the Sub-VI, NOT the the cursor positions of the original graph in the main panel that I wired to the connector of the Su-VI.

I hope I made myself clear.

I am miffed by this behavior, which is not how all other "normal" variables behave when you pass them to a Sub-VI.

My workaround now is to extract the cursors' positions in the main VI and pass those in a cluster to the Sub-VI.

Is there a way to do it?

Thanks.

Link to comment

Hello,

I could not find an answer to this (I tried a search).

I have a main VI with an IntensityGraph with cursors. I want to read and change the positions of the cursors (among other things) in a Sub-VI. The reason for doing that is that the block diagram is already huge and very complicated, so I want to move some of the tasks to a Sub-VI.

So I wire the IntensityGraph to one terminal of the Sub-VI connector. But when I read the cursor position with a Property Node inside the Sub-VI, I get the cursor positions of the "fake" IntensityGraph that I put in the FrontPanel of the Sub-VI, NOT the the cursor positions of the original graph in the main panel that I wired to the connector of the Su-VI.

I hope I made myself clear.

I am miffed by this behavior, which is not how all other "normal" variables behave when you pass them to a Sub-VI.

My workaround now is to extract the cursors' positions in the main VI and pass those in a cluster to the Sub-VI.

Is there a way to do it?

Thanks.

You need to pass the "reference" of the control to the sub VI. By wiring the graph control you are only passing the "data" that the graph contains,

Link to comment

Thanks very much ShaunR.

It actually occurred to me to try a reference, but when I quickly tried it, it didn't work (I didn't know how to create the correct property node).

Now I found the example where this is shown and it works perfectly.

This was my first post here and I am impressed by the helpfulness and quality of this forum rolleyes.gifthumbup1.gif

Link to comment
I am miffed by this behavior, which is not how all other "normal" variables behave when you pass them to a Sub-VI.

You can be miffed all you like, but it's actually *exactly* how it works with all "normal" varaibles - when you pass something on a wire into a subvi through its' connector pane you're passing the value of the data on the wire, not a reference to something that was the source of the wire. The connector pane of a VI goes to a front panel node (like the graph you put on your subVI's front panel) <- there's nothing fake about that graph - it's a real graph, it's *not* a reference to the graph in the caller VI. ShaunR's right - if you want to pass a reference to something in a caller VI, then you need to do exactly that - pass a reference to it, not it's data.

Link to comment

You can be miffed all you like, but it's actually *exactly* how it works with all "normal" varaibles - when you pass something on a wire into a subvi through its' connector pane you're passing the value of the data on the wire, not a reference to something that was the source of the wire.

crelf, I disagree with your statement. When I wire a variable to a Sub-VI, upon entry into the Sub-VI the placeholder control that was on the Sub-VI front panel assumes the value of the incoming wire. So if I wire a graph I expected EVERYTHING from the graph to be transferred as well. Now I know that only the DATA are passed to the Sub-VI. IMHO this breaks the concept of passing an object.

Link to comment

When I wire a variable to a Sub-VI, upon entry into the Sub-VI the placeholder control that was on the Sub-VI front panel assumes the value of the incoming wire. So if I wire a graph I expected EVERYTHING from the graph to be transferred as well.

There's a disconnect in your own logic - if you have a numeric control on your FP, the wire coming out of it is only its value; not its radix, display format, color, size - any of that. Control and indicators are not variables, and while they are objects, their wire doesn't contain the object itself.

Link to comment

crelf, I disagree with your statement. When I wire a variable to a Sub-VI, upon entry into the Sub-VI the placeholder control that was on the Sub-VI front panel assumes the value of the incoming wire. So if I wire a graph I expected EVERYTHING from the graph to be transferred as well. Now I know that only the DATA are passed to the Sub-VI. IMHO this breaks the concept of passing an object.

I'm guessing you were a C++ programmer in an earlier life (I also suspect you haven't been using LV since 1998 as your profile suggests).

Labview passes data. Not pointers, objects or lemons (unless you specifically tell it too and even then its just smoke and mirrors). All functions in LV are designed to operate on data. It is a data-centric,data-flow paradigm. Moreover it is a "strictly typed", data-centric, data-flow language. When you connect two VI's together, you are passing a value, not an object. When you use a reference, you are also passing a value, however, the property nodes know (by the type) that they need to "look up" and de-reference in order to obtain the data. They are,if you like, a "special" case of data rather than the "norm" and require special functions (property and method nodes) to operate on. If you were to inspect the value of a reference, you would find a a pointer sized Int. However, if you looked at the memory location you would not find your control or indicator or even its data..

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.