LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

order of execution

Solved!
Go to solution

Hi,

 

Thank you for your thought on my problem. However, I think I may oversimplify it. Here it my actual program that I wrote( autosnapshot.vi). If you take a look at the last for loop, that for loop contains two part, the first part (the upper one) opens an window and upload a picture on that window and the second part ( the lower one) comands  a camera to take a picture. I want the first part be excuted before the second part, how can I do that?

Download All
0 Kudos
Message 11 of 20
(1,235 Views)

@Toan_Le wrote:

Hi,

 

Thank you for your thought on my problem. However, I think I may oversimplify it. Here it my actual program that I wrote( autosnapshot.vi). If you take a look at the last for loop, that for loop contains two part, the first part (the upper one) opens an window and upload a picture on that window and the second part ( the lower one) comands  a camera to take a picture. I want the first part be excuted before the second part, how can I do that?


In this case, just use the error cluster to force the order with data flow.  You will also want to use the Error In and Error Out on the File Dialogs to make sure they come up only when you are ready for them to.

 

BTW, this is not an exception to my rule.  All of these functions do something with the error.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 12 of 20
(1,232 Views)

Would you mind elaborating on how to use error cluster to force the flow? (I am sorry, I am a littile bit slow since I am new to labView)

0 Kudos
Message 13 of 20
(1,212 Views)
Solution
Accepted by Toan_Le

@Toan_Le wrote:

Would you mind elaborating on how to use error cluster to force the flow? (I am sorry, I am a littile bit slow since I am new to labView)


Wire Error Out of function A to Error In of function B and down the line.  By doing this, you are creating a data dependancy between function A and B and then another data dependancy between B and C.  This will force A to finish be B can start, and B must finish before C can start.  So if you wire the last Error Out of your top function to the first Error In of the bottom, then the top must complete before the bottom can start.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 14 of 20
(1,208 Views)

It works out perfect. Thanks alot

0 Kudos
Message 15 of 20
(1,200 Views)

@Toan_Le wrote:

Thanks alot


Thanks are given with Kudos and Marked Solutions (Unofficial Forum Rules and Guidelines)


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 16 of 20
(1,190 Views)

Yes, the error wire is important here, because the second part of the code should be skipped if the first part completes with an error.

 

Depending on your experiment, you might even need to include a small delay to make sure that the everything is ready for the second part. In the more general case, you could even implement it as a state machine.

0 Kudos
Message 17 of 20
(1,183 Views)

@crossrulz wrote:

@billko wrote:

@crossrulz wrote:

@amitwadje wrote:

Thank you Altebench and Rolfk for your thought on my view,

 

How about?

 

If there is no necessity of serialization then we can connect the ‘Error Wire’ in parallel and merge the errors after execution, this way we avoid unnecessary serialization and improve the execution speed.

 

Thank you.


If you are just adding in the error cluster to VIs that cannot generate an error, then you are limiting the compiler.  Let normal data flow do its thing.

 

But two paths that need to run in parallel and both can cause errors, then you will want to use Merge Error when the parallel section is done.


Unless of course, that VI is a wait with an error passthrough to aid in dataflow execution.


Which I have found is RARE that you actually need.  I used to put the error terminals on everything and then one day I just realized I was cuasing slow downs in my code for no good reason.  If your code does not do anything with the error, then it does not need to have it.  So it runs in parallel with something else.  That is the point of data flow.

 

The only times I have found an exception to this is when I am using global variables or something else that breaks data flow.


I have to disagree about rarity.  At least in testing.  I often need this if I am communicating with "dumb" equipment that doesn't know how to acknowledge a command.  The wait HAS to follow the command.  The wait can't happen when it wants to.  And it sure beats enclosing the wait inside a sequence structure every time I want to do this.

 

On the other hand, I do a lot of branching of error wires and re-merge them later if I can imagine errors happening but want parallel execution.  Also, properties that I don't care when they get set won't even have error wiring if I don't care when it happens AND I am sure it won't generate an error.  (For instance, setting the color of something in my "Init" state.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 18 of 20
(1,164 Views)

billko wrote:
I have to disagree about rarity.  At least in testing.  I often need this if I am communicating with "dumb" equipment that doesn't know how to acknowledge a command.  The wait HAS to follow the command.  The wait can't happen when it wants to.  And it sure beats enclosing the wait inside a sequence structure every time I want to do this.

Ok, I'll give you the wait needing error lines.  As many instrument communications I have done, you would think that would be the first thing that pops in my head.  But I would would still argue that your wait should be conditional based on the error wire, so it technically is not an exception since it does something with the error wire.  Splitting hairs there.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 19 of 20
(1,159 Views)

@crossrulz wrote:

billko wrote:
I have to disagree about rarity.  At least in testing.  I often need this if I am communicating with "dumb" equipment that doesn't know how to acknowledge a command.  The wait HAS to follow the command.  The wait can't happen when it wants to.  And it sure beats enclosing the wait inside a sequence structure every time I want to do this.

Ok, I'll give you the wait needing error lines.  As many instrument communications I have done, you would think that would be the first thing that pops in my head.  But I would would still argue that your wait should be conditional based on the error wire, so it technically is not an exception since it does something with the error wire.  Splitting hairs there.


Yeah, I am splitting hairs also because I definitely agree with the main theme of your post.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 20 of 20
(1,150 Views)