08-26-2010 07:44 AM - edited 08-26-2010 07:47 AM
Consider the following diagram:
This VI is intended to be used in a chain of VIs.
This VI copies a file to a folder, and in case of error, tries with another path of the file (located in a "backup" location)
Due to the intrinsic dataflow programming model, how can I manage the error in the arrow place????
The behaviour I want is this:
if (error in == true) --> skips all and propagates error_in to error_out
else { try to copy, and in case of error try with backup copy. If errors again then report the error (custom error code) }
Is it possible???
thanks
Solved! Go to Solution.
08-26-2010 07:47 AM
Add an if-error-frame around the whole thing. Then it's not started if an error arrives first. Link only the output of the copy to folder to the error cluster.
08-26-2010 07:47 AM
I would simply add an other case structure including both your case structure and the "copy file vi", so that "copy file" will be executed if and only if error in is FALSE...
Marco
08-26-2010 07:49 AM
ah yes, it was trivial 🙂
I usually try to propagate the error without introducing if blocks, but it is not always possible
08-26-2010 07:53 AM
Its really simple dude.
Do as per following:
1. Connect the output from "error in" to a case structure. Now when there is "error" case/condition pass the "error in" to "error out". If "no error" case/condition then execute your code.
2.Here important thing in "no error" case is that you should not wire any thing to the "error in" terminal of "copy file to folder.vi"
Hence your actual error will not propagate to the 1st vi itself. So if the file doesn't get copied at 1st VI, it will generate its own error & your job is done.
Kudos are welcomed.
08-26-2010 08:06 AM
Also, wire the error cluster through the "No Error" case rather than using the "Use default if unwired" option. The reason for this is that a warning (error code > 0 and status = False) would be lost the way you have it wired. Using the default would cause the warning to be lost.
Lynn
08-27-2010 01:36 AM
thanks all,
the note about the "lost warning" was really interesting, I never noticed it because I never used warning.
I discovered another source of bug.
Consider the following:
If error_in is true, the error_out would be false.
The reason is that the filename array is EMPTY and the for case is never executed, so error_out takes a default value.
As a consequence the error is not correctly propagated.
I think this is not trivial to see at a first glance.
08-27-2010 07:48 AM
This is a known issue. If a for loop executes zero times, the outputs are set to default values. For the error cluster the default is no error. The work around is to put any signals which need to propagate through the structure into shift registers. The output of the shift register after zero iterations will be the input value rather than the default value.
Lynn