Jump to content

Change Connectors in VI


KoBe

Recommended Posts

Hi People,

since a few days I`ve been working with Xnodes and VI Scripting. I managed to create a Xnode which adapts its input according to the input data type like the example "Enqueue Array of Elements" which can be found in the Discussion "Xnode Wrapper for Preview Queue Element"here.

Enqueue Array of Elements uses a Template VI, which has no Controls and indicators but just a ForLoop (with terminals) and it is not functioning because of broken wires. By adding the right controls and indicators with xnode routines a functioning block diagram is created an inserted in the xnode which then can be used like a VI with the appropriate controls and indicators on the connector pane.

But I would like to go a step further. Instead of using a non functioning VI template I want to use a functioning VI as template for the "generate coode.vi" of my xnode. The example "Preview Queue Element" is a wrapper and can in my opinion only be used for LV internal VI's, because of the style input for "New VI Object".

I need help for this work:

Steps:

1) Make copy of diagram and make xnode owner of it

2) Retrieve controls and indicators of the diagram, which are connected to the connector pane of the originating VI template.

3) replace data type of a specific control

Differnt solution possibilities for 3):

a) replace data type of control or

b) replace control by control with appropriate data type

c) delete control, insert and wire up control with appropriate data type

Can anyone help me please? I'm working on LV8.6

Link to comment

Enqueue Array of Elements uses a Template VI, which has no Controls and indicators but just a ForLoop (with terminals) and it is not functioning because of broken wires. By adding the right controls and indicators with xnode routines a functioning block diagram is created an inserted in the xnode which then can be used like a VI with the appropriate controls and indicators on the connector pane.

But I would like to go a step further. Instead of using a non functioning VI template I want to use a functioning VI as template for the "generate coode.vi" of my xnode. The example "Preview Queue Element" is a wrapper and can in my opinion only be used for LV internal VI's, because of the style input for "New VI Object".

I managed it with a small workaround to get my desired data type adaption out of a functioning VI template which had all Controls and Indicators connected to its Connector Pane before "GenerateCode.vi" was called. The workaround is to insert a Flat Sequence around the block diagram of my *.vit. That shouldn't have much impact on runtime. Then with Generate Code I take the Flat Sequence Reference and use it like the ForLoop Reference in the "Enqueue Array of Elements" example to generate my adapted Xnode.

Nevertheless this is not as elegant as I wanted to have it, because for all VI's I want to use as templates for my Xnodes, I have to insert manually the Flat Sequence around the code. So if anyone has an idea of a solution without the "Flat Sequence workaround" I would appreciate that.

Without Flat Sequence: When I look which classes are contained in my diagram by reading the ClassName of all Generic objects in a diagram I get classes like SubVI, Function, ... and ControlTerminal. Then I selected the Control Terminals by ClassName and typecasted the class type to more specific "ControlTerminal". Then I tried to delete the Controls. That didn't work because i didn't have the permission. How can I get the permission to delete parts out of a diagram?

Next steps would be: Before deleting the controls, get references of the wires, to which the ControlTerminals are connected to. The delete. Then connect the new controls and indicators defined in "GetTerms3.vi" of my Xnode to the open wires in the right order.

Did anyone try something like that allready? Thanks

Link to comment

I managed it with a small workaround to get my desired data type adaption out of a functioning VI template which had all Controls and Indicators connected to its Connector Pane before "GenerateCode.vi" was called. The workaround is to insert a Flat Sequence around the block diagram of my *.vit. That shouldn't have much impact on runtime. Then with Generate Code I take the Flat Sequence Reference and use it like the ForLoop Reference in the "Enqueue Array of Elements" example to generate my adapted Xnode.

Nevertheless this is not as elegant as I wanted to have it, because for all VI's I want to use as templates for my Xnodes, I have to insert manually the Flat Sequence around the code. So if anyone has an idea of a solution without the "Flat Sequence workaround" I would appreciate that.

New Problem: It can happen, that I'm not able to connect my Controls to the right FlatSequence Terminal because of same names.

Until now I connected the Terminals of my Control and the Terminals of my FlatSequence by combining those Terminals, which have the same Terms.Id String with FlatSequence.Terminals.Name. But FlatSeqence.Terminals[].Name is not unique!!

Therefore I did describe my wires inside the flat sequence on my block diagram with the same string like I use for ID in GetTerms3.vi

Further steps:

1) Compare FlatSequence.Frames[].OuterTunnels[].InnerTerminal[x].ConnectedWire.Description == Terms.Id

2) if String matches, use FlatSequence.Frames[].OuterTunnels[x] and conneconnect Terms it.

That works because FlatSequence.Terminals[] is the same Reference like FlatSequence.Frames[].OuterTunnels[]

Now everything works, so you get a summary of my topic:

How to adapt inputs of a VI with Xnodes??

1) Take VI and make a FlatSequence around all this in the Block Diagram. Let the Controls and Indicators outside.

2) Name the Controls/Indicators like you want (String)

3) Right click on each wire, which is connected to a Control/Indicator outside and type as Description and Tip the String corresponding to the connected Control/Indicator

4) Save this VI as a template *.vit in the folder "MyNewXnode\"

5) Create Xnode with all necessary Ability-VI's

6) Adapt GetTerms3.vi to your purpose: ID has to have the same String like the Controls/Indicators of your *vit, the same String like your Wire Descriptions inside the FlatSequence of your *.vit

7) Then you can use the FlatSequence out of your *.vit and run the above mentioned 2 steps to connect the FlatSequence Terminals to the Controls/Indicators defined in GetTerms3.vi

If anyone should be interested, I can post also the source code. Thank you all for the source provided in this Forum although I got 0 replies until now. My life is now easier since I have adaptable controls on my VI's.

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.