How Do I Manage Errors and Warnings in the NI-RFSA .NET Class Library?

NI RF Vector Signal Analyzers (NI-RFSA 18.1) Help

Edition Date: June 2018

Part Number: 372058U-01

View Product Info

Download Help (Windows Only)


NI-RFSA 18.1 Help
NI-RFSA 18.2.1 Help
NI-RFSA 19.1 Help

The underlying NI-RFSA driver reports errors or warning through the method return values. Negative return values indicate errors whereas positive values indicate warnings.

How Do I Manage Errors in the NI-RFSA .NET Class Library?

The NI-RFSA .NET class library converts the error codes into exceptions. All exceptions are either .NET defined or IVI defined; none of them are custom exceptions. The exception message for driver errors has the driver error code appended at the end.

How Do I Manage Warnings in the NI-RFSA .NET Class Library?

The NI-RFSA .NET class library converts the warning codes into events. To receive warnings, you must subscribe to the Warning event as follows:

VB.NET
session.DriverOperation.Warning += New EventHandler(Of RfsaWarningEventArgs)(DriverOperation_Warning)

Private Sub DriverOperation_Warning(ByVal sender As Object, ByVal e As RfsaWarningEventArgs)
'User code goes here
End Sub
C#
session.DriverOperation.Warning += new EventHandler<RfsaWarningEventArgs>(DriverOperation_Warning);

void DriverOperation_Warning(object sender, RfsaWarningEventArgs e)
{
//User code goes here
}
Note:
National Instruments recommends subscribing to the warning event immediate after creating the NIRfsa object, in order to avoid missing any warnings that might occur.

The RfsaWarningEventArgs class contains a read-only property to get the RfsaWarning object out. For ease-of-use, it also gives direct access to the warning’s Code and Message.

RfsaWarning is an immutable class and hence its Equals method and the == operator are overloaded to compare values and not references.

The warning message for a particular warning code is dynamically generated by the driver, so it is possible for a warning with same code to have different messages. Even though the default behavior of Equals is to check value equality of both the Code and the Message, there exists an overload of the Equals method, which allows the user to ignore the Message while comparing two warnings.

WAS THIS ARTICLE HELPFUL?

Not Helpful