07-08-2011 05:29 AM
hello everyone..
i must admit the behaviour of the following program somewhat blew my mind and made me doubt whether i had ever understood anything about programming in labview.
please have a look at the attached vi and it's subvi. i probe the output of debug.vi (result path) two times. once when it is connected as an indicator on the connector pane and once when it is not. then i run test.vi.
the prize question:
why don't i get identical values?
in the case "result path" is connected i get an empty path at some point. in the case "result path" is not connected i always get a value, something i thought should always be the case. what is happening?
07-08-2011 09:14 AM
I couldn't replicate what you're describing. I even put a check for an empty path on the wire that leads to the "result path" terminal and had that control a case structure to display a message box if the path is empty. It never fired.
As an aside, you appear to be trying to create a state machine. In a bit of a peculiar way. Have you read over the KB article: Application Design Patterns: State Machines
You can also create a state machine template directly from File -> New... and then select VI >> From Template >> Frameworks >> Design Patterns.
07-09-2011 01:25 PM
The most likely explanation I can think of at the moment is that you made a mistake or that I'm misunderstanding what you're describing.
This issue (values changing based on whether an indicator is on the CP or not) can happen if the indicator is inside a case structure. In the cases where the frame the indicator is in does not execute, the indicator should return its default value (an empty path, in this case). In your case, this could possibly happen if you added the other indicator as well to the CP, which I'm guessing is the mistake you've made.
This is a corner case which can be easily confusing, which is another reason why you should generally have indicators which are connected to the CP on the outer-most layer of the BD, so that you can ensure they always get a known value.
07-09-2011 03:26 PM - edited 07-09-2011 03:30 PM
There are a lot of questionable conde constructs that make very little sense.
Please provide an exact step-by-step procedure on what we should do to reproduce your observations. How can you possibly get a value in an indicator if it is not connected to anything?
07-09-2011 06:09 PM
thank you for replying you guys.
you are right tst, i made a mistake, the mistake was in describing what is happening:
i probe the indicator "result path" in debug.vi two times. once when "appended path" is connected as an indicator on the connector pane and once when it is not. then i run test.vi. the state "idle" is chosen the entire time the vi is running.
when "appended path" is not connected on the cp i always get the default path i chose "C:\measurment folder" on the probe.
when "appended path" is connected on the cp i get "C:\measurment folder" on the probe the first two times the vi runs but afterwards it shows an empty path.
i do understand that the code i attached is far from any form of programming one should adopt because it is lousy programming, but i coincientally came acoss this behaviour and constructed the attached vis in order to explain the matter
07-09-2011 06:38 PM
You might also want to set the execution options to "clear indicators when called", else disconnected indicators keep whatever they had from previous runs or previous edit session.
07-09-2011 10:15 PM - edited 07-09-2011 10:17 PM
Also, double check your spelling. The correct spelling is "measurement".
07-10-2011 01:58 AM
@labviewette wrote:
i probe the indicator "result path" in debug.vi two times. once when "appended path" is connected as an indicator on the connector pane and once when it is not.
First, you should note that you're probing the wire wired into the indicator, not the indicator. Usually, there's no difference, but there are cases where there can be, so it's important to understand you're probing a wire.
Second, since the indicator on the CP is the one inside the case structure, that brings you back to the situation I described, coupled with the use of a local, which makes it even more difficult to understand. Personally, I have to say that I wouldn't know how to predict the result in such cases, which is why I would again highly suggest always putting the CP indicator on the outer-most layer of the diagram.