LAVA: Position a SubVI relative to a wire in a container - LAVA

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Position a SubVI relative to a wire in a container I'm inserting the JKI Add State(s) to Queue VI Rate Topic: -----

#1 User is offline   jcarmody 

  • Very Active
  • Group: Premium Member
  • Posts: 460
  • Joined: 18-January 07
  • Location:North Carolina, United (by force) States, Earth
  • Version:LabVIEW 2009
  • Since:2007

Posted 13 January 2010 - 09:41 PM

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

Attached File(s)


Want a better way to work with Case Structures? Try my CaseSelect plugin for the JKI Right-Click Framework.
Don't just post pictures of your code.  Post Snippets!  Use the  Code Capture Tool for all of your code-sharing needs.

~ In God we trust. Everybody else keep your hands where I can see them.
~ Tu ne cede malis sed contra audentior ito (do not give in to evil but proceed ever more boldly against it) ~ Virgil
0

#2 User is online   François Normandin 

  • The 500 club
  • Group: Moderators
  • Posts: 836
  • Joined: 18-January 08
  • Location:Montréal, QC
  • Version:LabVIEW 2009
  • Since:1999

Posted 13 January 2010 - 11:12 PM

View Postjcarmody, on 13 January 2010 - 04:41 PM, said:

If I could only find the position of the wires owner I think I could finish this.



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.

Attached Image: BDMinion_BD.png
François [frɑ̃swa]
0

#3 User is offline   jcarmody 

  • Very Active
  • Group: Premium Member
  • Posts: 460
  • Joined: 18-January 07
  • Location:North Carolina, United (by force) States, Earth
  • Version:LabVIEW 2009
  • Since:2007

Posted 14 January 2010 - 12:43 PM

View PostFrançois Normandin, on 13 January 2010 - 06:12 PM, said:

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.

Attachment BDMinion_BD.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.

Attached Image: InsertAS2Q.png
Want a better way to work with Case Structures? Try my CaseSelect plugin for the JKI Right-Click Framework.
Don't just post pictures of your code.  Post Snippets!  Use the  Code Capture Tool for all of your code-sharing needs.

~ In God we trust. Everybody else keep your hands where I can see them.
~ Tu ne cede malis sed contra audentior ito (do not give in to evil but proceed ever more boldly against it) ~ Virgil
1

#4 User is offline   Black Pearl 

  • Very Active
  • PipPipPip
  • Group: Members
  • Posts: 208
  • Joined: 12-April 09
  • Location:Freiburg, Germany
  • Version:LabVIEW 7.1
  • Since:2002

Posted 14 January 2010 - 01:10 PM

You could use the move method, it has an input 'owner' and uses the coordinate of that owner if it's wired (so use case structure as the owner).

Felix
0

#5 User is online   François Normandin 

  • The 500 club
  • Group: Moderators
  • Posts: 836
  • Joined: 18-January 08
  • Location:Montréal, QC
  • Version:LabVIEW 2009
  • Since:1999

Posted 14 January 2010 - 01:31 PM

View Postjcarmody, on 14 January 2010 - 07:43 AM, said:

... is the Terminal's owner's owner.


I had never seen double " 's " used before... :D
François [frɑ̃swa]
0

#6 User is offline   vugie 

  • Very Active
  • Group: Moderators
  • Posts: 209
  • Joined: 08-January 07
  • Version:LabVIEW 8.2
  • Since:2006

Posted 14 January 2010 - 02:07 PM

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)
0

#7 User is offline   jcarmody 

  • Very Active
  • Group: Premium Member
  • Posts: 460
  • Joined: 18-January 07
  • Location:North Carolina, United (by force) States, Earth
  • Version:LabVIEW 2009
  • Since:2007

Posted 14 January 2010 - 05:50 PM

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

Attached File(s)


Want a better way to work with Case Structures? Try my CaseSelect plugin for the JKI Right-Click Framework.
Don't just post pictures of your code.  Post Snippets!  Use the  Code Capture Tool for all of your code-sharing needs.

~ In God we trust. Everybody else keep your hands where I can see them.
~ Tu ne cede malis sed contra audentior ito (do not give in to evil but proceed ever more boldly against it) ~ Virgil
0

#8 User is offline   jcarmody 

  • Very Active
  • Group: Premium Member
  • Posts: 460
  • Joined: 18-January 07
  • Location:North Carolina, United (by force) States, Earth
  • Version:LabVIEW 2009
  • Since:2007

Posted 15 January 2010 - 12:41 AM

It doesn't behave well if I use it in the Idle state (inside the Event Structure), even after I change the To More Specific Class.  Back to the drawing board.

Attached Image: Example_VI_BD.png
Want a better way to work with Case Structures? Try my CaseSelect plugin for the JKI Right-Click Framework.
Don't just post pictures of your code.  Post Snippets!  Use the  Code Capture Tool for all of your code-sharing needs.

~ In God we trust. Everybody else keep your hands where I can see them.
~ Tu ne cede malis sed contra audentior ito (do not give in to evil but proceed ever more boldly against it) ~ Virgil
0

#9 User is offline   vugie 

  • Very Active
  • Group: Moderators
  • Posts: 209
  • Joined: 08-January 07
  • Version:LabVIEW 8.2
  • Since:2006

Posted 15 January 2010 - 08:58 AM

View Postjcarmody, on 14 January 2010 - 06:50 PM, said:

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

#10 User is offline   jcarmody 

  • Very Active
  • Group: Premium Member
  • Posts: 460
  • Joined: 18-January 07
  • Location:North Carolina, United (by force) States, Earth
  • Version:LabVIEW 2009
  • Since:2007

Posted 15 January 2010 - 12:54 PM

View Postvugie, on 15 January 2010 - 03:58 AM, said:

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.

Attached File(s)


Want a better way to work with Case Structures? Try my CaseSelect plugin for the JKI Right-Click Framework.
Don't just post pictures of your code.  Post Snippets!  Use the  Code Capture Tool for all of your code-sharing needs.

~ In God we trust. Everybody else keep your hands where I can see them.
~ Tu ne cede malis sed contra audentior ito (do not give in to evil but proceed ever more boldly against it) ~ Virgil
0

#11 User is offline   vugie 

  • Very Active
  • Group: Moderators
  • Posts: 209
  • Joined: 08-January 07
  • Version:LabVIEW 8.2
  • Since:2006

Posted 15 January 2010 - 02:42 PM

View Postjcarmody, on 15 January 2010 - 01:54 PM, said:

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.

Attached File(s)


1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic