LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.net Reference and Case Structure

Hello,

 

For some reason my previous mail was classed as solved which it isn't. So I'm posting the problem again.

 

I am trying to pass out a .net reference from a case structure.

 

The .net reference is created in the the false case below in the "Turn on Lamps in LIS" sub VI.

 

Capture False.JPG

 

The case structure then runs again as the True Case but the .net Reference is being passed out of the True Case below as "Default if Unwired".

 

Capture TRUE.JPG

 

The 'CLOSE SC6000' vi outside of the case structure needs to receive the .net reference and not a 'default' passed out of the True Case structure. I could put the  'CLOSE SC6000' .vi inside the True Case but then I still have the problem of passing the default.

 

Another culprit could be that in CLOSE SC6000" I get an invoke node error (1172) so I don't think that the ".net Ref out" from "Turn on Lamps" .vi is being passed correctly to the invoke node in "CLOSE SC6000" .vi.

 

How do I get around this please? Really I am having two problems.

 

Nevica

 

 

0 Kudos
Message 1 of 6
(2,374 Views)

@nevica wrote:

Hello,

 

For some reason my previous mail was classed as solved which it isn't. So I'm posting the problem again.

 

I am trying to pass out a .net reference from a case structure.

 

The .net reference is created in the the false case below in the "Turn on Lamps in LIS" sub VI.

 

Capture False.JPG

 

The case structure then runs again as the True Case but the .net Reference is being passed out of the True Case below as "Default if Unwired".

 

Capture TRUE.JPG

 

The 'CLOSE SC6000' vi outside of the case structure needs to receive the .net reference and not a 'default' passed out of the True Case structure. I could put the  'CLOSE SC6000' .vi inside the True Case but then I still have the problem of passing the default.

 

Another culprit could be that in CLOSE SC6000" I get an invoke node error (1172) so I don't think that the ".net Ref out" from "Turn on Lamps" .vi is being passed correctly to the invoke node in "CLOSE SC6000" .vi.

 

How do I get around this please? Really I am having two problems.

 

Nevica

 



 

You are creating a reference inside the particular case but expect the close reference to work even if you haven't created it. That's not how references work. A default reference is a null reference (0) and is meaningless since you can't work on a reference that doesn't point to anything (that's what is meant by "null"). You should put the Close VI inside the False case of your structure. Only close a reference if you have actually created it. You can also use the comaprison primitive that checks to see if the RefNum is valid and only work on the reference if it is (for example, by closing it).

 

As to the second of your problems - it's very hard to tell without seeing the content of the 1172 error. Typically 1172 represents a summary of a .Net Exception that occurred. The source element has the necessary detail. Post that here and maybe there is something buried in that that might point to the issue. Also - you are taking the reference wire out of the case structure in two places. One on the bottom and another on the right. You shouldn't be closing a reference and using it somewhere else at the same time. Be very wary of using this techqniue, it leads to race conditions that can be exposed by the type of behavioiur you are seeing.

0 Kudos
Message 2 of 6
(2,345 Views)

Hello,

 

What is a comparison primitive as mentioned in your first paragraph?

 

 

0 Kudos
Message 3 of 6
(2,341 Views)

Look in the Comparison palette. By "primitive" I mean built in funciton in LabVIEW (ie. typically coloured yellow), the lowest level available function that is not a SubVI.

0 Kudos
Message 4 of 6
(2,332 Views)

Hey Nevica,

 

As tyk007 has said, unfortunately, that's not how references work. If you think of a case structure as two completely separate pieces of code then whenever you are in your true case the reference will not have been created in the first place.

 

For that reason, you should move your close function inside your false case. I'm assuming that you will be adding more code to your true case, otherwise you can probably just scrap it all together.

 

Best Regards,

 

Chris

National Instruments - Tech Support
0 Kudos
Message 5 of 6
(2,312 Views)

Hey Nevica,

 

As a follow up, after looking at your initial post it seems that you will be running the false case followed by the true case, I'm guessing using a loop.

 

You should take a look at this example on shift registers which will allow you to pass your references around the loop.

 

Best Regards,

 

Chris

National Instruments - Tech Support
0 Kudos
Message 6 of 6
(2,302 Views)