LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing .Net reference through different VIs

Solved!
Go to solution

Hi,

I am trying to build a project that communicates with a device, so I have a vi setting the port, another connecting, other getting the data and etc. And they are all based on a dll. But I thought that passing .net references between these vis was enough to make it work, so in the "invoke node" I wanted, I created an indicator (.net), set as an output and just dragged this reference to others vis. But that doesnt seem to work. How can I make it?

 

I tried this: https://forums.ni.com/t5/LabVIEW/Passing-net-reference-between-different-vi-or-sub-vi-files/td-p/314...

 

But it didnt work too.

 

Thank you in advance!

0 Kudos
Message 1 of 14
(3,245 Views)

As a troubleshooting step (I'm not suggesting this as a final state) does the same code work if you don't have a SubVI? 

 

You have a red coercion dot, which suggests to me that you might not have quite the right type of indicator for that input. Since you have no coercion at the output of the SubVI and since you created it via the Create Indicator option, my first guess is maybe it won't work without the SubVI and there might be a problem with the invoke node you're wiring (for example, are you sure it should be that output wired to the "phys" input?)


GCentral
0 Kudos
Message 2 of 14
(3,211 Views)

Hi cbutcher, thank you for your response.

 

My code works well all in one vi, and the dot is there too (I didnt notice it).

I am new to Labview, so I ll try your sugestion about SubVIs. I ll update it here later!

0 Kudos
Message 3 of 14
(3,187 Views)

If it works without the SubVI, then it's probably a different issue and you can ignore most/all of my previous post.

 

However, just in case, if you hover over the reference wire with Context Help (Ctrl+h) open, does it read the same type in both cases? If you find the right place to hover, it will also tell you the coercion from/to types.


GCentral
0 Kudos
Message 4 of 14
(3,181 Views)

Oh ok, so looking at the types, they are from the same c# interface, I mean, the invoke node receives "...phylayer.PhyLayer" and the reference is "...phylayer.SerialPhyLayer" but the SeriaPhyLayer implements PhyLayer interface. Do you think that s a problem?

0 Kudos
Message 5 of 14
(3,177 Views)

Enzo.Furlan, please post both codes 

1- The whole Vis in only one(That works)

2- The splited Vis (Dont work)

 

 

0 Kudos
Message 6 of 14
(3,166 Views)

Dear Cbutcher, thanks for your reply, I will try to explain what is our objective to add more context to our question.

We have a .net code that implements the DLMS protocol, it has several layers, such as, APP Layer, Link Layer, Phy Layer and so on. We first decided to put the whole process among layers in only one VI, which works pretty well. However, as the whole process takes time and most importantly doing the whole process of connection  is not the correct way to do, we have decided to create different Vis to call whenever we want.

The problem is that the VIs depends each other(the Vis work as layers of the DLMS protocol), and we couldnt find a way to properly pass the vi`s references each other in manner that they work like "one vi".

Basically the whole Vi does this : OpenConnection ->GetParameter -> CloseConnection

Using splited VIs we planned to do like this: OpenConnection, GetParameter many times and whenever we want, Close connection Whenever we want.

 

To be honest with you, I dont really know if the chosen architeture makes sense in matters of LabView, it makes sense in matters of .net.

As me and Enzo are stuck for more than 1 week, now I`m considering to put the whole process in one VI and add triggers that may execute specific parts, e.g. Connect with the Device only once and get parameters many times using a trigger.

0 Kudos
Message 7 of 14
(3,154 Views)

So I'll start with the easy comment - that architecture (Initialize, Do something by reference many times, Close/Release) definitely makes sense in LabVIEW - probably every DAQmx example and many thousands of posts on the forum show exactly that idea.

 

Seeing the working, single, VI and the non-working multiple VIs would possibly be very helpful - it might be that something simple can be changed to make it work. I'm pretty surprised to hear that happening though.

 

If you try creating the subVIs using the Edit > Create SubVI option in the toolbar (after selecting the part to become the new subVI), is the result the same?


GCentral
0 Kudos
Message 8 of 14
(3,142 Views)

I just did that, created all subvis using edit and it seems to work. But there s also another problem here, all my parameters such as port name, baud rate and etc need to be inputs and outputs terminals, because our plan is to set them in TestStand, and existing these terminals, the "main" vi would have to set all these parameters too, so we would have a "single" vi after all. As I said, we want to call these subvis in TestStand, a "connect" subvi, a bunch of different "gets" subvi and then a "disconnect" subvi.

0 Kudos
Message 9 of 14
(3,138 Views)

I'm not sure that I really understand the problem (I'm not familiar with TestStand) but it should be possible to pass the reference into and out of the VIs using the Controls and Indicators by setting them on the Connector Pane (as you've probably seen).

 

In terms of using multiple parameters (and therefore presumably having a lot of Controls/Indicators) I'd instead suggest a Cluster in LabVIEW. This can basically be a custom data type that contains other datatypes (apologies if you're already familiar with this from using the Bundle By Name node and so on).

 

This KnowledgeBase article might be helpful in using clusters via TestStand: How Do I Pass Data Between a TestStand Container and a Cluster in a LabVIEW VI?

 

Does that help, or did I miss the point?

 

Edit: This might also be useful (perhaps you already know this page?) : LabVIEW Data Types in TestStand


GCentral
0 Kudos
Message 10 of 14
(3,134 Views)