LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Issues regarding wires through event structure

In my program, I noticed that the Visa resource name got lost after going through an event structure. I didn't wire it through every event case, but at least I wired it through the Exit case. But the link couldn't go through so even though I had the Visa Close in the end of the program, the serial port was not properly closed. To solve the problem, I have to wire the Visa resource name around the event structure.

 

Here what I want to know is that if a wire is going through an event structure, do we have to wire it through every case or we'll have the risk of losing the link. Event structure doesn't behave like a case structure that requires output from every case, so seems that we don't have to have an output/through wire from every event case.

 

Please advise.

0 Kudos
Message 1 of 15
(3,858 Views)

The event structure IS like a case structure.  You do need to wire through all the unused case.  The difference may be that the case structure output tunnels default to NOT Use Default if Unwired while the event structure has the opposite default.

 

Notice that the tunnel on the output of the event structure has a small hollow with a dot at the center if all cases are not wired.  That is the visual indicator for Use Default if Unwired.  If you uncheck that option, the tunnel changes to a hollow box.

 

When Use Default is active, you would get a blank or empty VISA Resource Name any time a case which as not wired executed.

 

Lynn

Message 2 of 15
(3,852 Views)

You're not telling us the whole story and it would help to see some code.

 

Lynn already explained the important parts, but here is an additional comment:

 

If the VISA resource is invalid after the "exit event" executes, it also means that the resource is apparently kept in a shift register. If it were in plain tunnels across the outside while loop, it would not get invalid in the exit case.

What happens if you use a shift register is as follows: Whenever an event case executes that does not have the resource wired out, it will turn into an invalid resource, which is then permanently placed into the shift register for all future itereations. It can only be restored if you create a new resource in one of the event cases, and then it will remain again only valid until the next time an unwired case is encountered.

 

 

 

 

 

Message 3 of 15
(3,849 Views)

Hi Lynn,

 

Thank you for your help.

 

You mentioned about Use Default If Unwired. I have always had concern regarding using it, because I don't know what the default is. I tried it after reading your post, I still feel not clear. I wired a numeric value through a case structure, the default of this control is 2. After going through the case, it shows 0. So seems the default is not about this specific control, it's about this kind of numeric value in general. Is there a general rule that the default value of a numeric is 0, the default of a string is blank, and so on?

 

Best regards,

0 Kudos
Message 4 of 15
(3,843 Views)

Hi altenbach,

 

One reason that I didn't post the vi is because it's tangled with a lot of other things, another reason is that it's not with me at this moment.

 

In my case, I didn't use a shift register. The Visa resource name after created, is wired into the main loop through a tunnel. I think it will get its value from the tunnel for every iteration. What happened is after going through unwired cased, it lost its value. The Visa close didn't give any error, so it's not noticed for a while.

 

Thank you for your help.

0 Kudos
Message 5 of 15
(3,839 Views)

Each datatype has a global default value that it assumes if not otherwise defined

 

"zero" for all numerics

"empty path" for paths

"empty string" for strings

"not a refnum" for refnums

etc...

 

A table of default values for each data type can be found here (look in the last column).

 

If you want more flexibility in the future, feel free to vote for my related idea :D)

Message 6 of 15
(3,838 Views)

 


guangdew1 wrote:

In my case, I didn't use a shift register. The Visa resource name after created, is wired into the main loop through a tunnel. I think it will get its value from the tunnel for every iteration. What happened is after going through unwired cased, it lost its value. The Visa close didn't give any error, so it's not noticed for a while.


A plain input tunnel will statically keep the initial value forever. If an unwired case is encountered, it will only be invalid for the remainder of that iteration and will again be valid at the start of the next iteration. If your exit case is the last thing to execute, the reference will definitely remain valid past the while loop. Either your exit case was not the last case to execute or you aborted the VI with the toolbar button, for example.

 

Message 7 of 15
(3,831 Views)

And speaking of related ideas, you might also wish to vote for this - http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Output-tunnels-from-event-structure-should-default-to-...


___________________
Try to take over the world!
Message 8 of 15
(3,829 Views)

I will check my code on Monday to make sure what is the exact case. But if what you mentioned is true, then we don't have to wire the Visa resource name through every case, we only need to wire it in the cases where we need it and in the exit case. I think this is what I did but later the visa resource name was lost.

 

The visa resource name is very similar to the reference you mentioned in your article, it should be wired in every case by default. Or it doesn't need to be explicitly wired at all because it's not going to be changed during the process.

 

Thank you for your help,

0 Kudos
Message 9 of 15
(3,827 Views)

Hi Altenbach,

 

I carefully examined my code and I have to admit that my earlier claim was wrong. Looks that if we wire the exit case and exit properly, the port should be closed.

 

The conclusion here is that we don't have to wire every case, we wire wherever we need it. Is it right?

 

Thank you for you help and best regards,

 

0 Kudos
Message 10 of 15
(3,783 Views)