Clear Specific Error in LabVIEW

製品と環境

このセクションは、サンプルの作成に使用された製品およびOSを反映します。

以下に示された製品を含め、NIのソフトウェアをダウンロードするには、ni.com/downloadsをご覧ください。

    ソフトウェア

  • LabVIEW

コードとドキュメント

添付

すべてをダウンロード

Overview

Occasionally, it can be desirable to clear a specific error when we run our VI. The code below will clear a specific error using Clear Specific Error.vi, and is adaptable to be used as a subVI within a larger application.

 

Description

First we use the Error Cluster from Error Code.vi to create two different error clusters, -20 and -20315. (The errors chosen are arbitrary and do not match any of those in the General LabVIEW Error Code list.) Depending on which position the rocker switch is in, the case structure passes one of these errors through for us to check whether the error code matches the error we are looking to clear, whose value is selected on the front panel. We also check that the status of the error is true, in case there is no error or a warning. If the error satisfies both of these conditions, the error is cleared using Clear Errors.vi within a case structure.

 

If however the error is not cleared, it is then shown on the Error out Indicator and a description of the error is displayed in a dialog box by Simple Error Handler.

 

Software requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute code

1. Using the rocker switch, select which error you want to simulate.
2. Run the VI.
3. If the error you are simulating matches 'Error to clear', notice that no error is reported and that 'error out' reports no error.
4. If the error you are simulating does not match 'Error to clear', notice that the Simple Error Handler displays a dialog box and that the 'Error out' indicator shows an error.
5. You can adjust 'error to clear' by changing the value on the Front Panel.

 

Additional information or References

If you were using this as a subVI within your code, you would replace Sections 1 and 2 with an error control and wire the connector pane terminals to allow you to pass your errors in. It would also be best practice to remove the Simple Error Handler in this case and instead to use it in your Main VI.

 

Front Panel of the VI

Front Panel.PNG

 

 Block Diagram of the VI

Clear Specific Error 2012 NIVerified Block Diagram.png

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

Andrew McLennan
Applications Engineer
National Instruments

NIコミュニティのサンプルコード交換のサンプルコードは、MIT Licenseによりライセンス供与されています。

コメント
Rod42
Active Participant
Active Participant

No need to test for 'status' equals True. Just use 'status'

PalanivelThiruvenkadam
Active Participant
Active Participant

Hope clear error itself contains a input node (specific error code to clear (0: all) Seems like invalid statement , Correct me if i am wrong

Pazhanivel Thiruvenkadam,
CertifiedLabVIEWArchitect|| CertifiedTestStandDeveloper,
Currently able to Access LV2015&LV2017