Jump to content

Position a SubVI relative to a wire in a container


jcarmody

Recommended Posts

I've written a VI to insert the Add State(s) to Queue SubVI and wire it into the States string of a JKI State Machine.  My problem is that I can't figure out how to calculate the position relative to the owner of the wire, so I've hard coded an offset.  It works well enough, but I don't like it.

Could you look at what I've done and see if you can help me position the SubVI properly?  If I could only find the position of the wires owner I think I could finish this.

To test this: download the BD Minion, run it, go to a VI with a string wire, select the string wire then press the "Add States to Queue" button.

Jim

BDMinion.vi

Link to comment

You already have everything you need. The average position between terminals is certainly not what you want, but you can get the terminals' position easily from your wire property node.

post-10515-126342422673_thumb.png

Almost, but it doesn't give me the position of the terminals relative to the wire's owner.  This is what I worked out after I found that the Case Structure is the Terminal's owner's owner.

post-7534-126347295903_thumb.png

  • Like 1
Link to comment

I do nor understand exactly what do you search for, but this is what I know:

- wire's owner is always a diagram (so this is why wire's owner's owner is case structure)

- diagram is also positioned against its owner

- I don't know exactly what wire's position means but I didn't find it useful

- exact wiring point is TerminalPosition + (TerminalSize modulo 2)

Link to comment

I've made this into a JKI RCF plugin to simplify (my) life when writing a VI with a JKI State Machine.  I don't often duplicate cases to make a new one, and I use Linked Tunnels so my tunnels are all wired, but I have to put the Add State(s) to Queue.vi into the new case manually.  I've resorted to leaving it outside the State Machine (initializing the Shift Register) so I have one handy to ctrl-click/copy/drag.  I suspect that's why JKI put it there in the first place.  It only takes a few seconds but I've wanted a RCF plugin for a long time.  (This was one of the first RCF ideas I had.)

You install this like you would any other RCF plugin.  To use it, select the State String wire, activate the RCF and select "Insert AS2Q" and it'll insert the SubVI eight pixels from the output tunnel (just where my OCD likes it :)).

Two questions:

1) How can I test the data type of the wire?  I don't want to activate this plugin unless a String wire is selected.

2) Am I the only one that thinks this will be useful?

Thanks,

Jim

Insert_AS2Q.llb

Link to comment

How can I test the data type of the wire? I don't want to activate this plugin unless a String wire is selected.

The wire datatype is always a datatype of its source terminal, which is always first element of Terminals[] property of the wire. And Terminal has Data Type property (variant) and Type Descriptor property (which is not exposed in scripting, so you have to use Scripting Workbench or PMS Assistant to get it).

What concerns not centered wire - I can't open your code (please save in 8.2) but I belive that you should use Create Described Wire method providing as wire description start and end points which should be center terminal points (see my previous post). Remember that coordinates should be provided in reversed form (y,x). Check out how I do it in my Weird Wires plugin.

  • Like 1
Link to comment

The wire datatype is always a datatype of its source terminal, which is always first element of Terminals[] property of the wire. And Terminal has Data Type property (variant) and Type Descriptor property (which is not exposed in scripting, so you have to use Scripting Workbench or PMS Assistant to get it).

What concerns not centered wire - I can't open your code (please save in 8.2) but I belive that you should use Create Described Wire method providing as wire description start and end points which should be center terminal points (see my previous post). Remember that coordinates should be provided in reversed form (y,x). Check out how I do it in my Weird Wires plugin.

The Data Type property seems to hold the data, not the type.  The Data Type of the States wire contains the Variant "".  I've managed to get the data type, having found a reference that said it is found in the low byte of the first element in the Type Descriptor array.  This turns out to be 26 in most cases, but not all, so I still need help.

Here's an 8.2 version.

Insert_AS2Q.llb

Link to comment

The Data Type property seems to hold the data, not the type. The Data Type of the States wire contains the Variant "". I've managed to get the data type, having found a reference that said it is found in the low byte of the first element in the Type Descriptor array. This turns out to be 26 in most cases, but not all, so I still need help.

Here is version which properly (I hope) tests the data type. I used Compare Data Type (private) method of Application. There is also Compare Type method which compares type descriptors.

I also added automatic calculation of proper offset to center the wire (for y coordinate). You could also think of calculating x coordinate from cursor position.

Insert_AS2Q_vug.llb

  • Like 1
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.