Integrator Resources

The official home for NAI Support

Not sure where to start? Try Quick Start Guide or ask a question below!

Toggle Components with Visual Button
JavaScript Form Processing

RTD BasicOps

RTD BasicOps Sample Application (SSK 1.x)

Overview

The RTD BasicOps sample application demonstrates how to configure and read Resistance Temperature Detector (RTD) channels using the NAI Software Support Kit (SSK 1.x). It covers the core RTD operations you will need in your own application: configuring wire modes (2-wire, 3-wire, and 4-wire), setting measurement ranges, reading resistance and temperature values, configuring compensation resistance, setting zero-temperature resistance, managing alert and alarm thresholds, and running built-in self-test (BIT) and open-line diagnostics.

An RTD is a temperature sensor that exploits the predictable relationship between a metal’s electrical resistance and its temperature. A platinum RTD element (the most common type) has a known resistance at 0 degrees Celsius — typically 100, 500, or 1000 ohms — and that resistance increases linearly as temperature rises. The NAI RTD module excites the sensor with a precision current, measures the resulting voltage, and computes the resistance and temperature. The accuracy of this measurement depends heavily on the wiring configuration and compensation settings you select, which this sample helps you exercise.

This sample supports the following RTD module types:

  • G4 — Gen3 6-channel RTD module

  • RT1 — Gen5 8-channel RTD module

  • TR1 / TC1 — Gen5 8-channel RTD/Thermocouple combination modules (when configured for RTD mode)

Gen5 modules (RT1, TR1, TC1) provide a significantly expanded command set compared to Gen3 (G4). The sample detects the board generation at runtime and presents the appropriate command menu. Gen5-only features include: channel status enable/disable, zero-temperature resistance selection, temperature readback, alert/alarm thresholds, offset temperature, power-on BIT checking, background operation suspension, and triggered BIT and open-line checks.

It serves as a practical API reference — each menu command maps directly to one or more naibrd_RTD_*() API calls that you can lift into your own code.

Prerequisites

Before running this sample, make sure you have:

  • An NAI board with an RTD module installed (G4, RT1, TR1, or TC1).

  • SSK 1.x installed on your development host.

  • The sample applications built. Refer to the SSK 1.x build instructions for your platform if you have not already compiled them.

How to Run

Launch the RTD_BasicOps executable from your build output directory. On startup the application looks for a configuration file (default_RTD_BasicOps.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure a board connection, card index, and module slot. You can save this configuration so that subsequent runs skip the menu and connect automatically. Once connected, a command menu lets you exercise each RTD operation.

Board Connection and Module Selection

Note
This startup sequence is common to all NAI sample applications. The board connection and module selection code shown here is not specific to RTD. For details on board connection configuration, see the First Time Setup Guide.

The main() function follows a standard SSK 1.x startup flow:

  1. Call naiapp_RunBoardMenu() to load a saved configuration file (if one exists) or present the interactive board menu. The configuration file (default_RTD_BasicOps.txt) is not included with the SSK — it is created when the user saves their connection settings from the board menu. On the first run, the menu will always appear.

  2. Query the user for a card index with naiapp_query_CardIndex().

  3. Query for a module slot with naiapp_query_ModuleNumber().

  4. Retrieve the module ID with naibrd_GetModuleID() so downstream code can adapt to the specific RTD variant installed.

#if defined (__VXWORKS__)
int32_t RTD_BasicOps(void)
#else
int32_t main(void)
#endif
{
   bool_t stop = FALSE;
   int32_t cardIndex;
   int32_t moduleCnt;
   int32_t module;
   uint32_t moduleID = 0;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
   {
      while (stop != TRUE)
      {
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != TRUE)
            {
               moduleID = naibrd_GetModuleID(cardIndex, module);
               if ((moduleID != 0))
               {
                  Run_RTD_BasicOps(cardIndex, module, moduleID);
               }
            }
         }
      }
   }

   naiapp_access_CloseAllOpenCards();
   return 0;
}
Important

Common connection errors you may encounter at this stage:

  • No board found — verify that the board is powered on and physically connected. Check that the configuration file lists the correct interface and address.

  • Connection timeout — confirm network settings (for Ethernet connections) or bus configuration (for PCI/PCIe). Firewalls and IP mismatches are frequent causes.

  • Invalid card or module index — indices are zero-based for cards and one-based for modules. Ensure the values you pass match your hardware setup.

  • Module not present at selected slot — the slot you selected does not contain an RTD module. Use the board menu to verify which slots are populated.

Program Structure

Entry Point

On standard platforms the entry point is main(). On VxWorks the entry point is RTD_BasicOps() — the SSK 1.x build system selects the correct variant via a preprocessor guard:

#if defined (__VXWORKS__)
int32_t RTD_BasicOps(void)
#else
int32_t main(void)
#endif

The startup flow is the same in both cases:

  1. Attempt to load the saved configuration file via naiapp_RunBoardMenu(CONFIG_FILE). If the file does not yet exist, the interactive board menu is presented instead.

  2. Enter a loop that queries for card index and module slot.

  3. Call Run_RTD_BasicOps() to enter the interactive command loop for the selected module.

  4. On exit, close all open board connections with naiapp_access_CloseAllOpenCards().

Application Parameters

The Run_RTD_BasicOps() function populates an naiapp_AppParameters_t struct that is passed to every command handler. Your application will need to track these same values to identify which board, module, and channel you are targeting:

rtd_basicOps_params->cardIndex = cardIndex;
rtd_basicOps_params->module = module;
rtd_basicOps_params->channel = 1;
rtd_basicOps_params->maxChannels = naibrd_RTD_GetChannelCount(modid);
rtd_basicOps_params->modId = modid;
rtd_basicOps_params->displayHex = FALSE;
  • cardIndex — identifies which board in a multi-board system.

  • module — the slot number where the RTD module is installed.

  • channel — the currently selected channel (defaults to 1).

  • maxChannels — total channel count for the detected module, retrieved by calling naibrd_RTD_GetChannelCount() with the module ID (6 for G4, 8 for RT1/TR1/TC1).

  • modId — the module identifier returned by naibrd_GetModuleID(). API functions use this to apply module-specific behavior.

The function also detects the board generation by calling naibrd_GetBoardGen(), which determines whether Gen3 or Gen5 commands are available. For TR1/TC1 modules, the sample configures each channel for RTD mode by calling naibrd_RTD_SetConfiguration() with NAI_RTD_CONFIG:

naibrd_GetBoardGen(cardIndex, &generation);

for (chanNum = 1; chanNum <= g_MaxRTDChannels; chanNum++)
{
   check_status(naibrd_RTD_SetConfiguration(cardIndex, module, chanNum, NAI_RTD_CONFIG));
}

Command Loop

Run_RTD_BasicOps() drives the interactive command loop. The top-level menu offers two commands:

Command Description

CFG

RTD Configuration Functions

OPS

RTD Basic Operations (read resistance, temperature, and status)

The CFG command opens a configuration submenu whose contents depend on the board generation. The OPS command displays the current operational data (resistance, temperature, and status) for all channels.

Gen3 Configuration Commands (G4 Module)

Command Description

RANGE

Set measurement range

SET COMP

Set compensation resistance

WIRE

Set wire mode (2/3/4-wire)

CLEAR

Clear RTD statuses for one channel

ALL CLEAR

Clear RTD statuses for all channels

Gen5 Configuration Commands (RT1, TR1, TC1 Modules)

Command Description

ENABLE

Enable/disable channel status reporting

ZEROTEMP

Set transducer’s 0 degree Celsius resistance

RES

Set compensation resistance

WIRE

Set wire mode (2/3/4-wire)

STAT

Clear RTD statuses for one channel

ALL CLEAR

Clear RTD statuses for all channels

POWER ON BIT

Check power-on BIT completion and results

CHAN THRESH

Set alert/alarm lo/hi thresholds for one channel

THRESH

Set alert/alarm lo/hi thresholds for all channels

OFFSET

Set offset temperature

DISABLE

Suspend BIT/open-line background tests

LINE OPEN

Trigger an open-line check

BIT

Trigger a BIT test

The menu-driven structure is a convenience of the sample application. In your own application, you would call the same underlying naibrd_RTD_*() API functions directly — for example, calling naibrd_RTD_SetWireMode() instead of navigating to the "WIRE" menu command.

Reading and Configuration

This section covers the API calls used to configure RTD channel behavior: setting the measurement range, selecting the wire mode, configuring compensation resistance, and setting the zero-temperature resistance. Understanding these settings is essential because they directly affect the accuracy of your temperature measurements.

Set Range (Gen3 Only)

To configure the measurement range on a channel in your own application, call naibrd_RTD_SetRange() with the desired resistance range value.

The range determines the maximum resistance the module can measure. Selecting a range that is too low will clip readings from high-resistance (high-temperature) sensors; selecting a range that is too high wastes measurement resolution on the low end. Choose the smallest range that fully encompasses your sensor’s operating resistance.

float64_t range;

/* Set the measurement range for the specified channel */
naibrd_RTD_SetRange(cardIndex, module, channel, range);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel to configure.

  • range — the full-scale resistance range as a floating-point value. Consult your module’s manual for supported range values.

Note
Range setting is available on Gen3 (G4) modules. On Gen5 modules, the range is determined automatically based on the zero-temperature resistance and wire mode configuration.

Set Wire Mode

To select the wire mode on a channel in your own application, call naibrd_RTD_SetWireMode(). The wire mode must match the physical wiring of your RTD sensor — using the wrong mode will produce inaccurate readings.

RTD sensors can be wired in three configurations, each offering a different trade-off between wiring complexity and measurement accuracy:

  • 2-wire — the simplest configuration. Two wires carry both the excitation current and the sense voltage. The module cannot distinguish the RTD’s resistance from the lead wire resistance, so any resistance in the wires adds directly to the reading. Use 2-wire only for short cable runs where lead resistance is negligible, or when wiring constraints prevent additional conductors.

  • 3-wire — adds a third wire that lets the module measure and subtract lead resistance. This works under the assumption that the two current-carrying leads have equal resistance (i.e., they are the same length and gauge). 3-wire is the most common configuration in industrial installations because it provides good accuracy without the cost of a fourth wire.

  • 4-wire — the most accurate configuration. Two wires carry the excitation current and two separate wires carry the sense voltage. Because the sense wires carry virtually no current, lead resistance has no effect on the measurement. Use 4-wire whenever maximum accuracy is required, such as in laboratory or calibration applications.

uint32_t wiremode;

/* Gen5: 0 = 2-wire, 1 = 3-wire, 2 = 4-wire */
/* Gen3: 2 = 2-wire, 3 = 3-wire, 4 = 4-wire */
naibrd_RTD_SetWireMode(cardIndex, module, channel, wiremode);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel to configure.

  • wiremode — the wire mode value. Note that the encoding differs between generations: Gen5 uses 0/1/2 for 2/3/4-wire, while Gen3 uses 2/3/4 directly.

Important

The wire mode encoding differs between Gen3 and Gen5 modules. If you are writing code that must support both generations, check the board generation with naibrd_GetBoardGen() and pass the correct encoding. Passing a Gen3 value to a Gen5 module (or vice versa) will either select the wrong mode or return an error.

Set Compensation Resistance

To configure the compensation resistance on a channel in your own application, call naibrd_RTD_SetCompResistance(). Compensation resistance accounts for known fixed resistance in your wiring or connector that is not part of the RTD sensor itself.

In a real installation, connectors, terminal blocks, and extension cables all add small amounts of resistance to the measurement circuit. If you know the total resistance of these non-sensor elements, you can enter that value as the compensation resistance and the module will subtract it from the raw reading. This is particularly important in 2-wire configurations where lead resistance directly affects the measurement.

float64_t compensation;

/* Set the compensation resistance for the specified channel */
naibrd_RTD_SetCompResistance(cardIndex, module, channel, compensation);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel to configure.

  • compensation — the compensation resistance value in ohms.

Note
This function is available on both Gen3 and Gen5 modules. The compensation value should represent the total lead and connector resistance that you want subtracted from the raw measurement. If you are using 3-wire or 4-wire mode, lead resistance is already compensated by the hardware measurement technique, so you would typically set this to zero unless you have additional fixed resistance in the path.

Set Zero-Temperature Resistance (Gen5 Only)

To configure the zero-temperature resistance type for your RTD sensor on a Gen5 module, call naibrd_RTD_SetZeroTempResistance(). This tells the module what type of RTD sensor is connected so it can correctly convert resistance readings to temperature.

The "zero-temperature resistance" (also called R0 or the ice-point resistance) is the resistance of the RTD element at exactly 0 degrees Celsius. Common standard values are:

  • 100 ohms (Pt100) — the most widely used RTD type. A platinum element with 100 ohms at 0 degrees C.

  • 500 ohms (Pt500) — higher base resistance provides better sensitivity and is less affected by lead resistance.

  • 1000 ohms (Pt1000) — the highest sensitivity of the three. Lead resistance effects are smallest relative to the sensor resistance.

nai_rtd_zero_temp_resistance_type_t zeroTempResistanceType;

/* 0 = 100 ohm, 1 = 500 ohm, 2 = 1000 ohm */
naibrd_RTD_SetZeroTempResistance(cardIndex, module, channel, zeroTempResistanceType);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel to configure.

  • zeroTempResistanceType — one of NAI_RTD_ZERO_TEMP_RESISTANCE_100, NAI_RTD_ZERO_TEMP_RESISTANCE_500, or NAI_RTD_ZERO_TEMP_RESISTANCE_1000.

Note
This setting must match the physical RTD sensor connected to the channel. If you set 100 ohms but have a Pt1000 sensor connected, the temperature calculation will be completely wrong. This function is Gen5 only — Gen3 modules do not provide temperature conversion and do not need this setting.

Reading Operational Data

To read channel data in your own application, call naibrd_RTD_GetResistance() to read the measured resistance and, on Gen5 modules, naibrd_RTD_GetTemperature() to read the computed temperature. The sample’s RTD_DisplayOpData() function demonstrates reading all channels:

float64_t resistance;
float64_t temperature;

/* Read resistance (all generations) */
naibrd_RTD_GetResistance(cardIndex, module, channel, &resistance);

/* Read temperature in Celsius (Gen5 only) */
naibrd_RTD_GetTemperature(cardIndex, module, channel, &temperature);
  • naibrd_RTD_GetResistance() — returns the measured resistance in ohms. Available on all RTD modules.

  • naibrd_RTD_GetTemperature() — returns the computed temperature in degrees Celsius. Available only on Gen5 modules (RT1, TR1, TC1). On Gen3 modules, your application must convert resistance to temperature using the appropriate RTD curve (e.g., the Callendar-Van Dusen equation for platinum RTDs).

The sample also reads status information for each channel. On Gen3, only BIT and open-line status are available. On Gen5, the full set of statuses is displayed: BIT, open, alert lo/hi, alarm lo/hi, and summary, each with real-time and latched values.

Important

Common Errors

  • NAI_ERROR_NOT_SUPPORTED — Returned when calling a Gen5-only function (such as naibrd_RTD_GetTemperature() or naibrd_RTD_SetZeroTempResistance()) on a Gen3 module. Check the board generation before calling these functions.

  • Incorrect resistance readings — The most common cause is a wire mode mismatch between the software configuration and the physical wiring. Verify that the wire mode set in software matches how the sensor is actually connected.

  • Compensation resistance mismatch — If the compensation resistance is set too high, readings will be lower than expected. If set to zero in a 2-wire configuration with long leads, readings will be higher than expected.

Status and Diagnostics

This section covers the status management and diagnostic features available in the RTD BasicOps sample: clearing status registers, enabling channel status reporting, checking power-on BIT results, setting alert and alarm thresholds, triggering BIT and open-line checks, setting offset temperatures, and suspending background operations.

Clear Statuses

To clear one or more latched status flags on a specific channel in your own application, call naibrd_RTD_ClearStatus() with the appropriate status type. Latched status flags remain set after a condition is detected until you explicitly clear them.

On Gen5 modules, the available status types to clear are:

  • NAI_RTD_STATUS_BIT_LATCHED — BIT failure

  • NAI_RTD_STATUS_OPEN_LATCHED — open-line detection

  • NAI_RTD_STATUS_ALERT_LO_LATCHED — temperature below alert-low threshold

  • NAI_RTD_STATUS_ALARM_LO_LATCHED — temperature below alarm-low threshold

  • NAI_RTD_STATUS_ALERT_HI_LATCHED — temperature above alert-high threshold

  • NAI_RTD_STATUS_ALARM_HI_LATCHED — temperature above alarm-high threshold

  • NAI_RTD_STATUS_SUMMARY_LATCHED — aggregate of all status conditions

On Gen3 modules, only BIT and open statuses are available.

/* Clear a single status type on one channel */
naibrd_RTD_ClearStatus(cardIndex, module, channel, NAI_RTD_STATUS_BIT_LATCHED);

/* Clear all latched statuses on one channel (Gen5) */
naibrd_RTD_ClearStatus(cardIndex, module, channel, NAI_RTD_STATUS_BIT_LATCHED);
naibrd_RTD_ClearStatus(cardIndex, module, channel, NAI_RTD_STATUS_OPEN_LATCHED);
naibrd_RTD_ClearStatus(cardIndex, module, channel, NAI_RTD_STATUS_ALERT_LO_LATCHED);
naibrd_RTD_ClearStatus(cardIndex, module, channel, NAI_RTD_STATUS_ALARM_LO_LATCHED);
naibrd_RTD_ClearStatus(cardIndex, module, channel, NAI_RTD_STATUS_ALERT_HI_LATCHED);
naibrd_RTD_ClearStatus(cardIndex, module, channel, NAI_RTD_STATUS_ALARM_HI_LATCHED);
naibrd_RTD_ClearStatus(cardIndex, module, channel, NAI_RTD_STATUS_SUMMARY_LATCHED);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel whose status to clear.

  • The fourth parameter — the specific status type to clear.

Clear Statuses for All Channels

The sample also provides a command to clear statuses across all channels at once. In your own code, loop over all channels and call naibrd_RTD_ClearStatus() for each:

for (chan = 1; chan <= channelCount; chan++)
{
   naibrd_RTD_ClearStatus(cardIndex, module, chan, NAI_RTD_STATUS_BIT_LATCHED);
   naibrd_RTD_ClearStatus(cardIndex, module, chan, NAI_RTD_STATUS_OPEN_LATCHED);
}

Channel Status Enable (Gen5 Only)

To enable or disable status reporting on a per-channel basis in your own application, call naibrd_RTD_SetChanStatusEnable(). When channel status is disabled, the module will not report status conditions for that channel and status-based interrupts will not assert.

/* Enable status reporting on a channel */
naibrd_RTD_SetChanStatusEnable(cardIndex, module, channel, 1);

/* Disable status reporting on a channel */
naibrd_RTD_SetChanStatusEnable(cardIndex, module, channel, 0);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel to enable or disable status reporting on.

  • The fourth parameter — 1 to enable status reporting, 0 to disable it.

Note
Disabling channel status also suppresses any interrupts triggered by status conditions on that channel. Re-enable channel status before relying on status-based interrupt handling. This function is Gen5 only.

Power-On BIT Check (Gen5 Only)

To verify that the module passed its power-on built-in test (PBIT) in your own application, call naibrd_RTD_CheckPowerOnBITComplete() to check whether PBIT has run, then iterate over all channels calling naibrd_RTD_GetStatus() with NAI_RTD_STATUS_BIT_LATCHED to read each channel’s BIT result.

Built-in test (BIT) is a hardware diagnostic that verifies the measurement circuitry is functioning correctly. The module injects a known reference signal into the conversion path and checks whether the result falls within expected tolerances. PBIT runs automatically once at power-on. If it fails on a channel, the measurement hardware on that channel may be faulty.

bool_t pBitComplete = FALSE;
uint32_t bitStatus = 0u;
int32_t channelCount = naibrd_RTD_GetChannelCount(modId);

/* Step 1: Check whether PBIT has completed */
naibrd_RTD_CheckPowerOnBITComplete(cardIndex, module, &pBitComplete);

if (pBitComplete)
{
   /* Step 2: Read BIT status for each channel */
   for (chan = 1; chan <= channelCount; chan++)
   {
      naibrd_RTD_GetStatus(cardIndex, module, chan,
         NAI_RTD_STATUS_BIT_LATCHED, &bitStatus);
      if (bitStatus)
         printf("Channel %d: BIT FAILED\n", chan);
      else
         printf("Channel %d: BIT Passed\n", chan);
   }
}
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • pBitComplete — set to TRUE if PBIT has finished, FALSE otherwise.

  • NAI_RTD_STATUS_BIT_LATCHED — reads the latched BIT status for a channel. Non-zero means the channel failed its BIT.

Note
PBIT only executes once, at power-on. If the module has not been power-cycled since it was installed, PBIT may not have completed — this is normal and does not indicate a hardware failure.

Set BIT Thresholds (Gen5 Only)

To configure alert and alarm temperature thresholds on a channel in your own application, call naibrd_RTD_SetThreshold() with the desired threshold type and value. Thresholds let the module flag when a temperature reading goes outside your expected operating range without requiring your application to poll continuously.

There are four threshold types, forming a two-level alarm system:

  • Alert Low / Alert High — early-warning thresholds. The temperature is approaching your limits but has not yet reached a critical level.

  • Alarm Low / Alarm High — critical thresholds. The temperature has exceeded your acceptable operating range.

Typically you would set the alarm thresholds outside the alert thresholds (e.g., alert low at -10 degrees C, alarm low at -20 degrees C, alert high at 80 degrees C, alarm high at 100 degrees C).

float64_t threshVal;

/* Set a single threshold type on one channel */
naibrd_RTD_SetThreshold(cardIndex, module, channel,
   NAI_RTD_THRESH_ALERT_LO, threshVal);

/* Set all four thresholds on one channel */
naibrd_RTD_SetThreshold(cardIndex, module, channel, NAI_RTD_THRESH_ALERT_LO, threshVal);
naibrd_RTD_SetThreshold(cardIndex, module, channel, NAI_RTD_THRESH_ALARM_LO, threshVal);
naibrd_RTD_SetThreshold(cardIndex, module, channel, NAI_RTD_THRESH_ALERT_HI, threshVal);
naibrd_RTD_SetThreshold(cardIndex, module, channel, NAI_RTD_THRESH_ALARM_HI, threshVal);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel to configure.

  • The fourth parameter selects the threshold type: NAI_RTD_THRESH_ALERT_LO, NAI_RTD_THRESH_ALARM_LO, NAI_RTD_THRESH_ALERT_HI, or NAI_RTD_THRESH_ALARM_HI.

  • threshVal — the threshold value in degrees Celsius.

The sample also provides a command to set thresholds across all channels at once by looping over every channel.

Trigger BIT (Gen5 Only)

To manually trigger a built-in test on a specific channel in your own application, call naibrd_RTD_TriggerBackgroundOperation() with NAI_RTD_BACKGROUND_OP_BIT. This is useful for periodic health checks during operation — unlike PBIT, which only runs at power-on, a triggered BIT can be run at any time.

/* Trigger a BIT test on the specified channel */
naibrd_RTD_TriggerBackgroundOperation(cardIndex, module, channel,
   NAI_RTD_BACKGROUND_OP_BIT);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel to test.

  • NAI_RTD_BACKGROUND_OP_BIT — selects the BIT operation.

After triggering, read the BIT status with naibrd_RTD_GetStatus() using NAI_RTD_STATUS_BIT_LATCHED to see the result.

Trigger Open-Line Check (Gen5 Only)

To check whether an RTD sensor is physically connected to a channel, call naibrd_RTD_TriggerBackgroundOperation() with NAI_RTD_BACKGROUND_OP_OPEN. Open-line detection verifies that the excitation current path through the sensor is intact — if a wire is broken or disconnected, the module will flag the channel as open.

This is a critical diagnostic in deployed systems where sensor cables may be damaged by vibration, thermal cycling, or physical impact. An open sensor will produce either a full-scale or erratic reading, which could be misinterpreted as a valid temperature if you are not checking the open-line status.

/* Trigger an open-line check on the specified channel */
naibrd_RTD_TriggerBackgroundOperation(cardIndex, module, channel,
   NAI_RTD_BACKGROUND_OP_OPEN);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel to check.

  • NAI_RTD_BACKGROUND_OP_OPEN — selects the open-line check operation.

After triggering, read the open-line status with naibrd_RTD_GetStatus() using NAI_RTD_STATUS_OPEN_LATCHED.

Set Offset Temperature (Gen5 Only)

To apply a fixed temperature offset to a channel’s reading in your own application, call naibrd_RTD_SetOffsetTemperature(). The offset is added to the computed temperature value, which lets you compensate for known systematic errors such as self-heating effects or a sensor that has drifted from its calibration curve.

float64_t temp;

/* Set the offset temperature for the specified channel */
naibrd_RTD_SetOffsetTemperature(cardIndex, module, channel, temp);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel to configure.

  • temp — the offset value in degrees Celsius. Can be positive or negative.

Suspend Background Operations (Gen5 Only)

To suspend or resume background BIT and open-line tests on a specific channel in your own application, call naibrd_RTD_SetBackgroundOpSuspend(). Background operations run periodically and may briefly disrupt normal measurements. If your application requires uninterrupted sampling during a critical period, you can suspend these tests and resume them later.

/* Suspend background operations on a channel */
naibrd_RTD_SetBackgroundOpSuspend(cardIndex, module, channel, TRUE);

/* Resume background operations on a channel */
naibrd_RTD_SetBackgroundOpSuspend(cardIndex, module, channel, FALSE);
  • cardIndex — identifies the board.

  • module — the slot containing the RTD module.

  • channel — the channel to configure.

  • The fourth parameter — TRUE to suspend background tests, FALSE to resume them.

Note
While background operations are suspended, BIT and open-line statuses will not update. Remember to resume background operations when your critical sampling period is complete so that hardware health monitoring continues.
Important

Common Errors

  • PBIT not complete — The power-on BIT test only runs when the module is first powered on. If the module has not been power-cycled, naibrd_RTD_CheckPowerOnBITComplete() will report that PBIT has not completed. This is not a hardware failure.

  • BIT failure on a channel — A BIT failure can indicate a faulty measurement circuit, an open input, or incorrect configuration. Consult your module’s manual for diagnostic procedures.

  • Open-line detection triggering unexpectedly — Check your wiring connections. In 2-wire mode, high lead resistance can sometimes mimic an open circuit. Verify that your wire mode matches the physical wiring and that the compensation resistance is set correctly.

  • Thresholds not triggering — Verify that channel status reporting is enabled via naibrd_RTD_SetChanStatusEnable(). If status is disabled, threshold crossings will not be reported.

Troubleshooting Reference

This table summarizes common errors and symptoms covered in the sections above. For detailed context on each entry, refer to the relevant section. Consult your module’s manual for hardware-specific diagnostic procedures.

Error / Symptom Possible Causes Suggested Resolution

No board found or connection timeout

Board not powered, incorrect or missing configuration file, network issue

Verify hardware is powered and connected. If default_RTD_BasicOps.txt exists, check that it lists the correct interface and address. If it does not exist, the board menu will appear — configure and save your connection settings.

Module not detected at selected slot

No module installed at the specified slot, incorrect module number entered

Verify hardware configuration and module slot assignment.

NAI_ERROR_NOT_SUPPORTED

Calling a Gen5-only function (temperature, thresholds, BIT trigger, etc.) on a Gen3 module, or feature not supported by this module type

Check the board generation with naibrd_GetBoardGen(). Use only Gen3-compatible functions on G4 modules.

Incorrect resistance readings

Wire mode mismatch between software configuration and physical wiring, incorrect compensation resistance

Verify that the wire mode set in software (2/3/4-wire) matches the actual sensor wiring. Check that compensation resistance is set appropriately.

Incorrect temperature readings

Wrong zero-temperature resistance type selected (e.g., Pt100 setting with a Pt1000 sensor), incorrect wire mode, offset temperature misconfigured

Verify that the zero-temperature resistance matches your sensor type. Check wire mode and offset temperature settings.

Open-line detection triggering unexpectedly

Loose or corroded wiring connections, high lead resistance in 2-wire mode, intermittent cable fault

Inspect all wiring connections. If using 2-wire mode with long cable runs, consider upgrading to 3-wire or 4-wire to eliminate lead resistance effects.

BIT failure on a channel

Hardware fault in the measurement circuit, open input, incorrect range (Gen3)

Check input wiring. On Gen3, verify the range setting. Consult your module’s manual for diagnostic procedures.

PBIT not complete

Module has not been power-cycled since last boot

Power-cycle the module and re-run the PBIT check.

Gen5 commands not appearing in menu

Board/module is Gen3 (G4), which does not support Gen5 features

The sample automatically detects the generation. Gen5-only features require an RT1, TR1, or TC1 module.

Wire mode encoding error

Passing Gen3 wire mode values (2/3/4) to a Gen5 module or Gen5 values (0/1/2) to a Gen3 module

Check the board generation and use the correct encoding. Gen5: 0=2-wire, 1=3-wire, 2=4-wire. Gen3: 2=2-wire, 3=3-wire, 4=4-wire.

Compensation resistance mismatch

Compensation value set too high or too low relative to actual lead resistance

Measure the actual lead resistance with an ohmmeter and set the compensation value to match. In 3-wire and 4-wire mode, set to zero unless you have additional fixed resistance in the path.

Full Source

The complete source for this sample is provided below for reference. The sections above explain each part in detail.

Full Source — RTD_BasicOps.c (SSK 1.x)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>

/* Common Sample Program include files */
#include "include/naiapp_boardaccess_menu.h"
#include "include/naiapp_boardaccess_query.h"
#include "include/naiapp_boardaccess_access.h"
#include "include/naiapp_boardaccess_display.h"
#include "include/naiapp_boardaccess_utils.h"

/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_rtd.h"
#include "advanced/nai_ether_adv.h"

static const int8_t *CONFIG_FILE = (const int8_t *)"default_RTD_BasicOps.txt";

/* Function prototypes */
static bool_t Run_RTD_BasicOps( int32_t cardIndex, int32_t module, uint32_t modid);

static nai_status_t Handle_RTD_Configuration(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_BasicOperation(int32_t paramCount, int32_t* p_params);

static nai_status_t Handle_RTD_ChanStatusEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_Range(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_WireMode(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_CompRes(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_ZeroTempResistance(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_ClearStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_ClearStatusAllChannels(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_CheckPowerOnBIT(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_Thresholds(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_Thresholds_All_Channels(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_OffsetTemp(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_BackgroundOpSuspension(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_TriggerOpenCheck(int32_t paramCount, int32_t* p_params);
static nai_status_t Handle_RTD_TriggerBIT(int32_t paramCount, int32_t* p_params);

void RTD_DisplayCfg( int32_t cardIndex, int32_t module, int32_t maxchan );
void RTD_DisplayOpData( int32_t cardIndex, int32_t module, int32_t maxchan );

static const int32_t DEF_RTD_CHANNEL       = 1;

static int32_t g_MaxRTDChannels = 0;
static uint32_t g_RTDModId;
static uint32_t generation; /* generation of the board/module */
static char zeroTempOhms[][5] = { "100", "500", "1000" }; /* Zero Temp Resistance Options */

/****** Command Table *******/
enum rtd_basicops_commands
{
   RTD_BASICOP_CMD_CONFIG,
   RTD_BASICOP_CMD_BASICOPS,
   RTD_BASICOP_CMD_COUNT
};

enum rtd_gen3_config_commands
{
   RTD_GEN3_CONFIG_CMD_RANGE,
   RTD_GEN3_CONFIG_CMD_COMPRES,
   RTD_GEN3_CONFIG_CMD_WIRE,
   RTD_GEN3_CONFIG_CMD_CLEAR_STATUS,
   RTD_GEN3_CONFIG_CMD_CLEAR_STATUS_ALL_CHANS,
   RTD_GEN3_CONFIG_CMD_COUNT
};

enum rtd_gen5_config_commands
{
   RTD_GEN5_CONFIG_CMD_CHAN_STATUS_ENABLE,
   RTD_GEN5_CONFIG_CMD_ZERO_TEMP_RESISTANCE,
   RTD_GEN5_CONFIG_CMD_COMPRES,
   RTD_GEN5_CONFIG_CMD_WIRE,
   RTD_GEN5_CONFIG_CMD_CLEAR_STATUS,
   RTD_GEN5_CONFIG_CMD_CLEAR_STATUS_ALL_CHANS,
   RTD_GEN5_CONFIG_CMD_CHECK_POWER_ON_BIT,
   RTD_GEN5_CONFIG_CMD_SET_THRESH,
   RTD_GEN5_CONFIG_CMD_SET_THRESH_ALL_CHANS,
   RTD_GEN5_CONFIG_CMD_SET_OFFSET_TEMP,
   RTD_GEN5_CONFIG_CMD_SET_BACKGROUND_OP_SUSPEND,
   RTD_GEN5_CONFIG_CMD_TRIGGER_OPEN_CHECK,
   RTD_GEN5_CONFIG_CMD_TRIGGER_BIT,
   RTD_GEN5_CONFIG_CMD_COUNT
};

/****** Command Tables *******/
naiapp_cmdtbl_params_t RTD_BasicOpMenuCmds[] =
{
   {"CFG", "RTD Configuration Functions",         RTD_BASICOP_CMD_CONFIG,           Handle_RTD_Configuration},
   {"OPS", "RTD Basic Operations",                RTD_BASICOP_CMD_BASICOPS,         Handle_RTD_BasicOperation},
};

naiapp_cmdtbl_params_t RTD_Gen3_ConfigMenuCmds[] =
{
   {"RANGE",     "Set Range",                                     RTD_GEN3_CONFIG_CMD_RANGE,                  Handle_RTD_Range},
   {"SET COMP",  "Set Compensation Resistance",                   RTD_GEN3_CONFIG_CMD_COMPRES,                Handle_RTD_CompRes},
   {"WIRE",      "Set Wire Mode",                                 RTD_GEN3_CONFIG_CMD_WIRE,                   Handle_RTD_WireMode},
   {"CLEAR",     "Clear RTD Statuses",                            RTD_GEN3_CONFIG_CMD_CLEAR_STATUS,           Handle_RTD_ClearStatus},
   {"ALL CLEAR", "Clear RTD Statuses All Channels",               RTD_GEN3_CONFIG_CMD_CLEAR_STATUS_ALL_CHANS, Handle_RTD_ClearStatusAllChannels}
};

naiapp_cmdtbl_params_t RTD_Gen5_ConfigMenuCmds[] =
{
   {"ENABLE",       "Enable/Disable Channel Status Reporting",           RTD_GEN5_CONFIG_CMD_CHAN_STATUS_ENABLE,               Handle_RTD_ChanStatusEnable},
   {"ZEROTEMP",     "Set Transducer's 0 degree Celsius Resistance",      RTD_GEN5_CONFIG_CMD_ZERO_TEMP_RESISTANCE,             Handle_RTD_ZeroTempResistance},
   {"RES",          "Set Compensation Resistance",                       RTD_GEN5_CONFIG_CMD_COMPRES,                          Handle_RTD_CompRes},
   {"WIRE",         "Set Wire Mode",                                     RTD_GEN5_CONFIG_CMD_WIRE,                             Handle_RTD_WireMode},
   {"STAT",         "Clear RTD Statuses",                                RTD_GEN5_CONFIG_CMD_CLEAR_STATUS,                     Handle_RTD_ClearStatus},
   {"ALL CLEAR",    "Clear RTD Statuses All Channels",                   RTD_GEN5_CONFIG_CMD_CLEAR_STATUS_ALL_CHANS,           Handle_RTD_ClearStatusAllChannels},
   {"POWER ON BIT", "Check Power-On BIT",                                RTD_GEN5_CONFIG_CMD_CHECK_POWER_ON_BIT,               Handle_RTD_CheckPowerOnBIT},
   {"CHAN THRESH",  "Set RTD Alert/Alarm Lo/Hi Thresholds",              RTD_GEN5_CONFIG_CMD_SET_THRESH,                       Handle_RTD_Thresholds},
   {"THRESH",       "Set RTD Alert/Alarm Lo/Hi Thresholds All Channels", RTD_GEN5_CONFIG_CMD_SET_THRESH_ALL_CHANS,             Handle_RTD_Thresholds_All_Channels},
   {"OFFSET",       "Set Offset Temperature",                            RTD_GEN5_CONFIG_CMD_SET_OFFSET_TEMP,                  Handle_RTD_OffsetTemp},
   {"DISABLE",      "Suspend BIT/Open tests",                            RTD_GEN5_CONFIG_CMD_SET_BACKGROUND_OP_SUSPEND,        Handle_RTD_BackgroundOpSuspension},
   {"LINE OPEN",    "Trigger Open-Line Check",                           RTD_GEN5_CONFIG_CMD_TRIGGER_OPEN_CHECK,               Handle_RTD_TriggerOpenCheck},
   {"BIT",          "Trigger BIT",                                       RTD_GEN5_CONFIG_CMD_TRIGGER_BIT,                      Handle_RTD_TriggerBIT}
};

/**************************************************************************************************************/
/**
<summary>
The purpose of the RTD_BasicOps is to illustrate the methods to call in the naibrd library to perform basic
 operations with the RTD modules for configuration setup, controlling the drive outputs, and reading
 the channels.

The following system configuration routines from the nai_sys_cfg.c file are called to assist with the configuration
setup for this program prior to calling the naibrd RTD routines.
 - ConfigDevice
 - DisplayDeviceCfg
 - GetBoardSNModCfg
 - CheckModule
</summary>
*/
/**************************************************************************************************************/
#if defined (__VXWORKS__)
int32_t RTD_BasicOps(void)
#else
int32_t main(void)
#endif
{
   bool_t stop = FALSE;
   int32_t cardIndex;
   int32_t moduleCnt;
   int32_t module;
   uint32_t moduleID = 0;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
   {
      while (stop != TRUE)
      {
         /* Query the user for the card index */
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));

            /* Query the user for the module number */
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != TRUE)
            {
               moduleID = naibrd_GetModuleID(cardIndex, module);
               if ((moduleID != 0))
               {
                  Run_RTD_BasicOps(cardIndex, module, moduleID);
               }
            }
         }

         printf("\nType Q to quit or Enter key to restart application:\n");
         stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      }
   }

   printf("\nType the Enter key to exit the program: ");
   naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   naiapp_access_CloseAllOpenCards();

   return 0;
}

/**************************************************************************************************************/
/**
<summary>
This function asks for the channel number, checks if it is valid, and if it is, calls Configuration() or
BasicOperation(), depending on what the user specifies.
</summary>
*/
/**************************************************************************************************************/
static bool_t Run_RTD_BasicOps( int32_t cardIndex, int32_t module, uint32_t modid)
{
   bool_t bQuit = FALSE;
   bool_t bContinue = TRUE;
   bool_t bCmdFound = FALSE;
   int32_t cmd;
   int32_t chanNum = 0;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   naiapp_AppParameters_t  rtd_basicops_params;
   p_naiapp_AppParameters_t rtd_basicOps_params = &rtd_basicops_params;
   rtd_basicOps_params->cardIndex = cardIndex;
   rtd_basicOps_params->module = module;
   rtd_basicOps_params->channel = 1;
   rtd_basicOps_params->maxChannels = naibrd_RTD_GetChannelCount(modid);
   rtd_basicOps_params->modId = modid;
   rtd_basicOps_params->displayHex = FALSE;

   /* Get the Maximum RTD Channels */
   g_MaxRTDChannels = naibrd_RTD_GetChannelCount(modid);
   /* Get the generation of the board and module */
   naibrd_GetBoardGen( cardIndex, &generation );

   for (chanNum = 1; chanNum <= g_MaxRTDChannels; chanNum++)
   {
      check_status(naibrd_RTD_SetConfiguration(cardIndex, module, chanNum, NAI_RTD_CONFIG));
   }

   while (bContinue)
   {
      naiapp_utils_LoadParamMenuCommands( RTD_BASICOP_CMD_COUNT, RTD_BasicOpMenuCmds );
      while (bContinue)
      {
         naiapp_utils_LoadParamMenuCommands( RTD_BASICOP_CMD_COUNT, RTD_BasicOpMenuCmds ); /* reload main menu */
         naiapp_display_ParamMenuCommands( (int8_t *)"RTD Basic Operation Menu" );
         printf( "\nType RTD command or %c to quit : main >", NAI_QUIT_CHAR );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
         if (!bQuit)
         {
            if (inputResponseCnt > 0)
            {
               bCmdFound = naiapp_utils_GetParamMenuCmdNum( inputResponseCnt, inputBuffer, &cmd );
               if (bCmdFound)
               {
                  switch (cmd)
                  {
                  case RTD_BASICOP_CMD_CONFIG:
                  case RTD_BASICOP_CMD_BASICOPS:
                     RTD_BasicOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)rtd_basicOps_params);
                     break;
                  default:
                     printf( "Invalid command entered\n" );
                     break;
                  }
               }
               else
                  printf( "Invalid command entered\n" );
            }
         }
         else
            bContinue = FALSE;
      }
   }
   return bQuit;
}

/**************************************************************************************************************/
/**
<summary>
This function is called if the user chooses to configure the RTD module or to read the configuration data.
There are options to read configuration data, set zero temperature resistance (Gen5) or range (Gen3),
set wire mode, set compensation resistance, clear statuses, set thresholds, set offset temperature,
suspend background operations, and trigger background operations (BIT and Open-Line tests).
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_Configuration(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   bool_t bContinue = TRUE;
   bool_t bCmdFound = FALSE;
   int32_t cmd;
   p_naiapp_AppParameters_t p_ad_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_ad_params->cardIndex;
   int32_t module = p_ad_params->module;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   if ( generation == NAI_XILINX_GEN5_ID )
   {
      while (bContinue)
      {
         naiapp_utils_LoadParamMenuCommands( RTD_GEN5_CONFIG_CMD_COUNT, RTD_Gen5_ConfigMenuCmds );
         while (bContinue)
         {
            RTD_DisplayCfg( cardIndex, module, g_MaxRTDChannels );
            naiapp_display_ParamMenuCommands( (int8_t *)"RTD Configuration Menu" );
            printf( "\nType RTD command or %c to go back : cfg >", BACK_CHAR );
            bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), BACK_CHAR, inputBuffer, &inputResponseCnt );
            if (!bQuit)
            {
               if (inputResponseCnt > 0)
               {
                  bCmdFound = naiapp_utils_GetParamMenuCmdNum( inputResponseCnt, inputBuffer, &cmd );
                  if (bCmdFound)
                  {
                     switch (cmd)
                     {
                     case RTD_GEN5_CONFIG_CMD_CHAN_STATUS_ENABLE:
                     case RTD_GEN5_CONFIG_CMD_ZERO_TEMP_RESISTANCE:
                     case RTD_GEN5_CONFIG_CMD_COMPRES:
                     case RTD_GEN5_CONFIG_CMD_WIRE:
                     case RTD_GEN5_CONFIG_CMD_CLEAR_STATUS:
                     case RTD_GEN5_CONFIG_CMD_CLEAR_STATUS_ALL_CHANS:
                     case RTD_GEN5_CONFIG_CMD_CHECK_POWER_ON_BIT:
                     case RTD_GEN5_CONFIG_CMD_SET_THRESH:
                     case RTD_GEN5_CONFIG_CMD_SET_THRESH_ALL_CHANS:
                     case RTD_GEN5_CONFIG_CMD_SET_OFFSET_TEMP:
                     case RTD_GEN5_CONFIG_CMD_SET_BACKGROUND_OP_SUSPEND:
                     case RTD_GEN5_CONFIG_CMD_TRIGGER_OPEN_CHECK:
                     case RTD_GEN5_CONFIG_CMD_TRIGGER_BIT:
                        RTD_Gen5_ConfigMenuCmds[cmd].func(APP_PARAM_COUNT, p_params);
                        break;
                     default:
                        printf( "Invalid command entered\n" );
                        break;
                     }
                  }
                  else
                     printf( "Invalid command entered\n" );
               }
            }
            else
               bContinue = FALSE;
         }
      }
   }
   else
   {
      while (bContinue)
      {
         naiapp_utils_LoadParamMenuCommands( RTD_GEN3_CONFIG_CMD_COUNT, RTD_Gen3_ConfigMenuCmds );
         while (bContinue)
         {
            RTD_DisplayCfg( cardIndex, module, g_MaxRTDChannels );
            naiapp_display_ParamMenuCommands( (int8_t *)"RTD Configuration Menu" );
            printf( "\nType RTD command or %c to go back : cfg >", BACK_CHAR );
            bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), BACK_CHAR, inputBuffer, &inputResponseCnt );
            if (!bQuit)
            {
               if (inputResponseCnt > 0)
               {
                  bCmdFound = naiapp_utils_GetParamMenuCmdNum( inputResponseCnt, inputBuffer, &cmd );
                  if (bCmdFound)
                  {
                     switch (cmd)
                     {
                     case RTD_GEN3_CONFIG_CMD_RANGE:
                     case RTD_GEN3_CONFIG_CMD_COMPRES:
                     case RTD_GEN3_CONFIG_CMD_WIRE:
                     case RTD_GEN3_CONFIG_CMD_CLEAR_STATUS:
                     case RTD_GEN3_CONFIG_CMD_CLEAR_STATUS_ALL_CHANS:
                        RTD_Gen3_ConfigMenuCmds[cmd].func(APP_PARAM_COUNT, p_params);
                        break;
                     default:
                        printf( "Invalid command entered\n" );
                        break;
                     }
                  }
                  else
                     printf( "Invalid command entered\n" );
               }
            }
            else
               bContinue = FALSE;
         }
      }
   }
      return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function is called if the user chooses to perform RTD basic operations checks to retrieve the
resistance, BIT status, and Open status.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_BasicOperation(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_ad_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_ad_params->cardIndex;
   int32_t module = p_ad_params->module;
   int32_t channel = g_MaxRTDChannels;
#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   RTD_DisplayOpData( cardIndex, module, channel );
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the channel status enabled/disabled state to the value specified by the user
and then displays all of the configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_ChanStatusEnable(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   bool_t bQuit = FALSE;
   bool_t chanStatEnable = 0u;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif
   bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
   if (!bQuit)
   {
      printf( "Type Channel Status Enabled/Disabled setting to set ('0' = DISABLED, '1' = ENABLED): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            chanStatEnable = (bool_t)atoi( (const char *)inputBuffer );
            if ((chanStatEnable == 0) || (chanStatEnable == 1))
            {
               check_status( naibrd_RTD_SetChanStatusEnable( cardIndex, module, chan, chanStatEnable ) );
            }
            else
            {
               printf("\nInvalid value entered!\n");
            }
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the range to the value specified by the user and then displays all of the configuration
data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_Range(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   float64_t range;
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif
   bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
   if (!bQuit)
   {
      printf( "Type Range value to set: " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            range = atof( (const char *)inputBuffer );
            check_status( naibrd_RTD_SetRange( cardIndex, module, chan, range ) );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the wire mode to the value specified by the user and then displays all of the configuration
data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_WireMode(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   bool_t bQuit = FALSE;
   uint32_t wiremode;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif
   bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
   if (!bQuit)
   {
      if ( generation == NAI_XILINX_GEN5_ID )
      {
         printf( "Type Wire Mode value to set ('0' = 2-wire, '1' = 3-wire, '2' = 4-wire): " );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
         if (!bQuit)
         {
            if (inputResponseCnt > 0)
            {
               wiremode = atoi( (const char *)inputBuffer );
               check_status( naibrd_RTD_SetWireMode( cardIndex, module, chan, wiremode ) );
            }
         }
      }
      else
      {
         printf( "Type Wire Mode value to set ('2' = 2-wire, '3' = 3-wire, '4' = 4-wire): " );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
         if (!bQuit)
         {
            if (inputResponseCnt > 0)
            {
               wiremode = atoi( (const char *)inputBuffer );
               check_status( naibrd_RTD_SetWireMode( cardIndex, module, chan, wiremode ) );
            }
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the compensation resistance to the value specified by the user and then displays
all of the configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_CompRes(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   float64_t compensation;
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif
   bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
   if (!bQuit)
   {
      printf( "Type Compensation Resistance value to set: " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            compensation = atof( (const char *)inputBuffer );
            check_status( naibrd_RTD_SetCompResistance( cardIndex, module, chan, compensation ) );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the compensation resistance to the value specified by the user and then displays
all of the configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_ZeroTempResistance(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif
   if ( generation == NAI_XILINX_GEN5_ID )
   {
      bool_t bQuit = FALSE;
      nai_rtd_zero_temp_resistance_type_t zeroTempResistanceType;

      bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
      while (!bQuit)
      {
         printf( "Type transducer's 0 degree Celsius Resistance ('0' = 100ohm, '1' = 500ohm, '2' = 1000ohm).\n" );
         printf( "Selection (0, 1 or 2):" );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
         if (!bQuit)
         {
            if (inputResponseCnt > 0)
            {
               zeroTempResistanceType = (nai_rtd_zero_temp_resistance_type_t)atoi( (const char *)inputBuffer );

               if ( zeroTempResistanceType < NAI_RTD_ZERO_TEMP_TYPE_ENUM_COUNT )
               {
                  check_status( naibrd_RTD_SetZeroTempResistance( cardIndex, module, chan, zeroTempResistanceType ) );
                  bQuit = TRUE;
               }
               else
               {
                  printf( "\nInvalid selection!\n" );
               }
            }
         }
      }
   }
   else
   {
      printf( "This feature is not supported by this module.\n" );
   }

   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function clears the RTD statuses specified by the user of the channel specified by the user.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_ClearStatus(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   uint32_t statnum;
   nai_rtd_status_type_t type;
   bool_t bQuit = FALSE;
   bool_t errFlag = FALSE;
   bool_t clearAllFlag = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif
   if ( generation == NAI_XILINX_GEN5_ID )
   {
      printf( "Type Status type to be cleared ('0' = Bit, '1' = Open, '2' = Alert Lo, '3' = Alarm Lo, '4' = Alert Hi, '5' = Alarm Hi, '6' = Summary, '7' = All Statuses): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      statnum = atoi( (const char *)inputBuffer );
      switch (statnum)
      {
      case 0:
         type = NAI_RTD_STATUS_BIT_LATCHED;
         break;
      case 1:
         type = NAI_RTD_STATUS_OPEN_LATCHED;
         break;
      case 2:
         type = NAI_RTD_STATUS_ALERT_LO_LATCHED;
         break;
      case 3:
         type = NAI_RTD_STATUS_ALARM_LO_LATCHED;
         break;
      case 4:
         type = NAI_RTD_STATUS_ALERT_HI_LATCHED;
         break;
      case 5:
         type = NAI_RTD_STATUS_ALARM_HI_LATCHED;
         break;
      case 6:
         type = NAI_RTD_STATUS_SUMMARY_LATCHED;
         break;
      case 7:
         clearAllFlag = TRUE;
         type = 99;
         break;
      default:
         errFlag = TRUE;
         type = 100;
         printf( "\nError! Invalid Status Type\n" );
         break;
      }
      if ( (!bQuit) && (inputResponseCnt > 0) && (errFlag == FALSE) && (clearAllFlag == FALSE) )
      {
         bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
         if (!bQuit)
         {
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, type ) );
         }
      }
      else if ( (!bQuit) && (inputResponseCnt > 0) && (errFlag == FALSE) && (clearAllFlag == TRUE) )
      {
         bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
         if (!bQuit)
         {
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_BIT_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_OPEN_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_LO_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_LO_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_HI_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_HI_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_SUMMARY_LATCHED ) );
         }
      }
   }
   else
   {
      printf( "Type Status type to be cleared ('0' = Bit, '1' = Open, '2' = All Statuses): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      statnum = atoi( (const char *)inputBuffer );
      switch (statnum)
      {
      case 0:
         type = NAI_RTD_STATUS_BIT_LATCHED;
         break;
      case 1:
         type = NAI_RTD_STATUS_OPEN_LATCHED;
         break;
      case 2:
         clearAllFlag = TRUE;
         type = 99;
         break;
      default:
         errFlag = TRUE;
         type = 100;
         printf( "\nError! Invalid Status Type\n" );
         break;
      }
      if ( (!bQuit) && (inputResponseCnt > 0) && (errFlag == FALSE) && (clearAllFlag == FALSE) )
      {
         bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
         if (!bQuit)
         {
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, type ) );
         }
      }
      else if ( (!bQuit) && (inputResponseCnt > 0) && (errFlag == FALSE) && (clearAllFlag == TRUE) )
      {
         bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
         if (!bQuit)
         {
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_BIT_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_OPEN_LATCHED ) );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function clears the RTD statuses specified by the user of all of the channels on the RTD module.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_ClearStatusAllChannels(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   uint32_t statnum;
   nai_rtd_status_type_t type;
   bool_t bQuit = FALSE;
   bool_t errFlag = FALSE;
   bool_t clearAllFlag = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   if ( generation == NAI_XILINX_GEN5_ID )
   {
      printf( "Type Status type to be cleared ('0' = Bit, '1' = Open, '2' = Alert Lo, '3' = Alarm Lo, '4' = Alert Hi, '5' = Alarm Hi, '6' = Summary, '7' = All Statuses): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      statnum = atoi( (const char *)inputBuffer );
      switch (statnum)
      {
      case 0:
         type = NAI_RTD_STATUS_BIT_LATCHED;
         break;
      case 1:
         type = NAI_RTD_STATUS_OPEN_LATCHED;
         break;
      case 2:
         type = NAI_RTD_STATUS_ALERT_LO_LATCHED;
         break;
      case 3:
         type = NAI_RTD_STATUS_ALARM_LO_LATCHED;
         break;
      case 4:
         type = NAI_RTD_STATUS_ALERT_HI_LATCHED;
         break;
      case 5:
         type = NAI_RTD_STATUS_ALARM_HI_LATCHED;
         break;
      case 6:
         type = NAI_RTD_STATUS_SUMMARY_LATCHED;
         break;
      case 7:
         clearAllFlag = TRUE;
         type = 99;
         break;
      default:
         errFlag = TRUE;
         type = 100;
         printf( "\nError! Invalid Status Type\n" );
         break;
      }
      if ( (!bQuit) && (inputResponseCnt > 0) && (errFlag == FALSE) && (clearAllFlag == FALSE) )
      {
         for ( chan = 1; chan <= g_MaxRTDChannels; chan++ )
         {
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, type ) );
         }
      }
      else if ( (!bQuit) && (inputResponseCnt > 0) && (errFlag == FALSE) && (clearAllFlag == TRUE) )
      {
         for ( chan = 1; chan <= g_MaxRTDChannels; chan++ )
         {
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_BIT_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_OPEN_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_LO_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_LO_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_HI_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_HI_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_SUMMARY_LATCHED ) );
         }
      }
   }
   else
   {
      printf( "Type Status type to be cleared ('0' = Bit, '1' = Open, '2' = All Statuses): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      statnum = atoi( (const char *)inputBuffer );
      switch (statnum)
      {
      case 0:
         type = NAI_RTD_STATUS_BIT_LATCHED;
         break;
      case 1:
         type = NAI_RTD_STATUS_OPEN_LATCHED;
         break;
      case 2:
         clearAllFlag = TRUE;
         type = 99;
         break;
      default:
         errFlag = TRUE;
         type = 100;
         printf( "\nError! Invalid Status Type\n" );
         break;
      }
      if ( (!bQuit) && (inputResponseCnt > 0) && (errFlag == FALSE) && (clearAllFlag == FALSE) )
      {
         for ( chan = 1; chan <= g_MaxRTDChannels; chan++ )
         {
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, type ) );
         }
      }
      else if ( (!bQuit) && (inputResponseCnt > 0) && (errFlag == FALSE) && (clearAllFlag == TRUE) )
      {
         for ( chan = 1; chan <= g_MaxRTDChannels; chan++ )
         {
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_BIT_LATCHED ) );
            check_status( naibrd_RTD_ClearStatus( cardIndex, module, chan, NAI_RTD_STATUS_OPEN_LATCHED ) );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function checks the RTD power-on BIT completed state and then, if the power-on BIT has completed,
checks the Latched BIT Status of each RTD channel.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_CheckPowerOnBIT(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   int32_t channelCount = 0;
   bool_t pBitComplete = FALSE;
   uint32_t bitStatus = 0u;
   char strBitStatus[12] = "";
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   channelCount = naibrd_RTD_GetChannelCount(g_RTDModId);

   /* Check to see if PBIT ran for the module. */
   printf("Checking if the Power-On BIT test has run...\n");
   check_status(naibrd_RTD_CheckPowerOnBITComplete(cardIndex, module, &pBitComplete));
   switch (pBitComplete)
   {
      case 0u:
         printf("\nPBIT Complete: NOT COMPLETED\n");
      break;
      case 1u:
         printf("\nPBIT Complete: COMPLETED\n");
      break;
      default:
         printf("\nPBIT Complete: UNKNOWN\n");
      break;
   }

   if (pBitComplete)
   {
      /* Read the BIT status */
      printf("Checking the result of the Power-on BIT test...\n");
      for (chan = 1; chan <= channelCount; chan++)
      {
         check_status(naibrd_RTD_GetStatus(cardIndex, module, chan, NAI_RTD_STATUS_BIT_LATCHED, &bitStatus));
         switch (bitStatus)
         {
            case 0:
               sprintf(strBitStatus, "BIT Passed");
            break;
            case 1:
               sprintf(strBitStatus, "BIT FAILED");
            break;
            default:
               sprintf(strBitStatus, "Unknown");
            break;
         }
         printf("Ch. %d: %s\n", chan, strBitStatus);
      }
   }

   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the RTD alert/alarm lo/hi threshold(s) specified by the user of the channel specified
by the user to the value specified by the user.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_Thresholds(int32_t paramCount, int32_t* p_params)
{
   uint32_t statnum;
   float64_t threshVal;
   nai_rtd_thresh_type_t type;
   bool_t bQuit = FALSE;
   bool_t errFlag = FALSE;
   bool_t setAllFlag = FALSE;
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   printf( "Type Alert/Alarm Threshold to set ('0' = Alert Lo, '1' = Alarm Lo, '2' = Alert Hi, '3' = Alarm Hi, '4' = All Alert/Alarm Thresholds): " );
   bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
   statnum = atoi( (const char *)inputBuffer );
   switch (statnum)
   {
   case 0:
      type = NAI_RTD_THRESH_ALERT_LO;
      break;
   case 1:
      type = NAI_RTD_THRESH_ALARM_LO;
      break;
   case 2:
      type = NAI_RTD_THRESH_ALERT_HI;
      break;
   case 3:
      type = NAI_RTD_THRESH_ALARM_HI;
      break;
   case 4:
      setAllFlag = TRUE;
      type = 99;
      break;
   default:
      errFlag = TRUE;
      type = 100;
      printf( "\nError! Invalid Threshold Type\n" );
      break;
   }
   if ( (!bQuit) && (inputResponseCnt > 0) && (errFlag == FALSE) )
   {
      if (setAllFlag == FALSE)
      {
         bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
         if (!bQuit)
         {
            printf( "Type floating point value in degrees Celsius to set the threshold to: " );
            bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
            threshVal = atof( (const char *)inputBuffer );
            if (!bQuit)
            {
               check_status( naibrd_RTD_SetThreshold( cardIndex, module, chan, type, threshVal ) );
            }
         }
      }
      else if (setAllFlag == TRUE)
      {
         bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
         if (!bQuit)
         {
            printf( "Type floating point value in degrees Celsius to set the thresholds to: " );
            bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
            threshVal = atof( (const char *)inputBuffer );
            if (!bQuit)
            {
               check_status( naibrd_RTD_SetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALERT_LO, threshVal ) );
               check_status( naibrd_RTD_SetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALARM_LO, threshVal ) );
               check_status( naibrd_RTD_SetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALERT_HI, threshVal ) );
               check_status( naibrd_RTD_SetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALARM_HI, threshVal ) );
            }
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the RTD alert/alarm lo/hi threshold(s) specified by the user of all of the channels
on the RTD module to the value specified by the user.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_Thresholds_All_Channels(int32_t paramCount, int32_t* p_params)
{
   uint32_t statnum;
   float64_t threshVal;
   nai_rtd_thresh_type_t type;
   bool_t bQuit = FALSE;
   bool_t errFlag = FALSE;
   bool_t setAllFlag = FALSE;
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   printf( "Type Alert/Alarm Threshold to set ('0' = Alert Lo, '1' = Alarm Lo, '2' = Alert Hi, '3' = Alarm Hi, '4' = All Alert/Alarm Thresholds): " );
   bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
   statnum = atoi( (const char *)inputBuffer );
   switch (statnum)
   {
   case 0:
      type = NAI_RTD_THRESH_ALERT_LO;
      break;
   case 1:
      type = NAI_RTD_THRESH_ALARM_LO;
      break;
   case 2:
      type = NAI_RTD_THRESH_ALERT_HI;
      break;
   case 3:
      type = NAI_RTD_THRESH_ALARM_HI;
      break;
   case 4:
      setAllFlag = TRUE;
      type = 99;
      break;
   default:
      errFlag = TRUE;
      type = 100;
      printf( "\nError! Invalid Threshold Type\n" );
      break;
   }
   if ( (!bQuit) && (inputResponseCnt > 0) && (errFlag == FALSE) )
   {
      if (setAllFlag == FALSE)
      {
         printf( "Type floating point value in degrees Celsius to set the thresholds to (write to all channels): " );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
         threshVal = atof( (const char *)inputBuffer );
         if (!bQuit)
         {
            for ( chan = 1; chan <= g_MaxRTDChannels; chan++ )
            {
               check_status( naibrd_RTD_SetThreshold( cardIndex, module, chan, type, threshVal ) );
            }
         }
      }
      else if (setAllFlag == TRUE)
      {
         printf( "Type floating point value in degrees Celsius to set the thresholds to (write to all channels): " );
         bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
         threshVal = atof( (const char *)inputBuffer );
         if (!bQuit)
         {
            for ( chan = 1; chan <= g_MaxRTDChannels; chan++ )
            {
               check_status( naibrd_RTD_SetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALERT_LO, threshVal ) );
               check_status( naibrd_RTD_SetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALARM_LO, threshVal ) );
               check_status( naibrd_RTD_SetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALERT_HI, threshVal ) );
               check_status( naibrd_RTD_SetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALARM_HI, threshVal ) );
            }
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the offset temperature to the value specified by the user and then displays
all of the configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_OffsetTemp(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   float64_t temp;
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
   if (!bQuit)
   {
      printf( "Type Offset Temperature value to set (Celsius): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            temp = atof( (const char *)inputBuffer );
            check_status( naibrd_RTD_SetOffsetTemperature( cardIndex, module, chan, temp ) );
         }
         else
         {
            printf( "\n\n\nInvalid Response\n\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the BIT/Open-Line test suspended/enabled state to the value specified by the user
and then displays all of the configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_BackgroundOpSuspension(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   bool_t disable = FALSE;
   bool_t failed = FALSE;
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
   if (!bQuit)
   {
      printf( "Suspend or enable BIT/Open-Line tests? (1 - Suspend, 0 - Enable): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            int response = atoi( (const char *)inputBuffer );
            switch (response)
            {
               case 0:
                  disable = FALSE;
                  break;
               case 1:
                  disable = TRUE;
                  break;
               default:
                  printf( "\n\n\nInvalid Response\n\n" );
                  failed = TRUE;
                  break;
            }
            if (failed == FALSE)
            {
               check_status( naibrd_RTD_SetBackgroundOpSuspend( cardIndex, module, chan, disable ) );
            }
         }
         else
         {
            printf( "\n\n\nInvalid Response\n\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function triggers an Open-Line check and then displays all of the configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_TriggerOpenCheck(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
   if (!bQuit)
   {
      printf( "Trigger Open-Line Check? (1 - Yes, 0 - No): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            int response = atoi( (const char *)inputBuffer );
            switch (response)
            {
               case 0:
                  break;
               case 1:
                  check_status( naibrd_RTD_TriggerBackgroundOperation( cardIndex, module, chan, NAI_RTD_BACKGROUND_OP_OPEN ) );
                  break;
               default:
                  printf( "\n\n\nInvalid Response\n\n" );
                  break;
            }
         }
         else
         {
            printf( "\n\n\nInvalid Response\n\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function triggers the BIT and then displays all of the configuration data.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_RTD_TriggerBIT(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = FALSE;
   p_naiapp_AppParameters_t p_rtd_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_rtd_params->cardIndex;
   int32_t module = p_rtd_params->module;
   int32_t chan = p_rtd_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   bQuit = naiapp_query_ChannelNumber( g_MaxRTDChannels, DEF_RTD_CHANNEL, &chan );
   if (!bQuit)
   {
      printf( "Trigger BIT? (1 - Yes, 0 - No): " );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            int response = atoi( (const char *)inputBuffer );
            switch (response)
            {
               case 0:
                  break;
               case 1:
                  check_status( naibrd_RTD_TriggerBackgroundOperation( cardIndex, module, chan, NAI_RTD_BACKGROUND_OP_BIT ) );
                  break;
               default:
                  printf( "\n\n\nInvalid Response\n\n" );
                  break;
            }
         }
         else
         {
            printf( "\n\n\nInvalid Response\n\n" );
         }
      }
   }
   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
This function displays the RTD Configuration settings.
</summary>
*/
/**************************************************************************************************************/
void RTD_DisplayCfg( int32_t cardIndex, int32_t module, int32_t maxchan )
{
   float64_t range;
   bool_t chanStatusEnabled;
   uint32_t wiremoderaw;
   uint32_t wiremode;
   float64_t compres;
   float64_t threshAlertLo;
   float64_t threshAlarmLo;
   float64_t threshAlertHi;
   float64_t threshAlarmHi;
   float64_t offsetTemp;
   bool_t suspendBackgroundOps;
   int32_t chan;
   uint32_t bitstat_latched;
   uint32_t openstat_latched;
   uint32_t alertlostat_latched;
   uint32_t alarmlostat_latched;
   uint32_t alerthistat_latched;
   uint32_t alarmhistat_latched;
   uint32_t summarystat_latched;
   uint32_t bitstat_realtime;
   uint32_t openstat_realtime;
   uint32_t alertlostat_realtime;
   uint32_t alarmlostat_realtime;
   uint32_t alerthistat_realtime;
   uint32_t alarmhistat_realtime;
   uint32_t summarystat_realtime;
   nai_status_t status;
   char strChanStatusEnable[20] = "";

   printf( "\n\nRTD Configuration:\n" );
   if ( generation == NAI_XILINX_GEN5_ID )
   {
      printf( "   Channel  Zero Temp    Compensation       Offset      Alert Lo     Alarm Lo     Alert Hi     Alarm Hi      Bit     Open   Alert Lo  Alarm Lo  Alert Hi  Alarm Hi  Summary  Suspend\n" );
      printf( "   Status   Resistance    Resistance  Wire  Temperature Threshold    Threshold    Threshold    Threshold    Status  Status   Status    Status    Status    Status   Status   Background\n" );
      printf( "Ch Enabled    (Ohms)        (Ohms)    Mode  (degrees C) (degrees C)  (degrees C)  (degrees C)  (degrees C)  (R/L)   (R/L)    (R/L)     (R/L)     (R/L)     (R/L)     (R/L)   Operations\n" );
      printf( "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n" );
   }
   else
   {
      printf( "                  Compensation  Wire\n" );
      printf( "Ch      Range      Resistance   Mode\n" );
      printf( "--------------------------------------\n" );
   }

   for ( chan = 1; chan <= maxchan; chan++ )
   {
      if ( generation == NAI_XILINX_GEN5_ID )
      {
         nai_rtd_zero_temp_resistance_type_t zeroTempResistanceType;
         check_status( naibrd_RTD_GetChanStatusEnable( cardIndex, module, chan, &chanStatusEnabled ) );
         switch (chanStatusEnabled)
         {
            case TRUE:
               sprintf(strChanStatusEnable, "Enabled ");
            break;
            case FALSE:
               sprintf(strChanStatusEnable, "Disabled");
            break;
            default:
               sprintf(strChanStatusEnable, "Unknown ");
            break;
         }
         check_status( naibrd_RTD_GetZeroTempResistance( cardIndex, module, chan, &zeroTempResistanceType ) );
         check_status( naibrd_RTD_GetCompResistance( cardIndex, module, chan, &compres ) );
         status = check_status( naibrd_RTD_GetOffsetTemperature( cardIndex, module, chan, &offsetTemp ) );
         if (status != NAI_SUCCESS)
         {
            offsetTemp = 0.0;
         }
         status = check_status( naibrd_RTD_GetBackgroundOpSuspend( cardIndex, module, chan, &suspendBackgroundOps ) );
         if (status != NAI_SUCCESS)
         {
            suspendBackgroundOps = 0u;
         }
         else
         {
            suspendBackgroundOps &= 0x1u;
         }
         check_status( naibrd_RTD_GetWireMode( cardIndex, module, chan, &wiremoderaw ) );
         switch (wiremoderaw)
         {
            case NAI_RTD_GEN5_WIRE_MODE_2:
               wiremode = 2;
               break;
            case NAI_RTD_GEN5_WIRE_MODE_3:
               wiremode = 3;
               break;
            case NAI_RTD_GEN5_WIRE_MODE_4:
               wiremode = 4;
               break;
            default:
               wiremode = 100;
               break;
         }

         check_status( naibrd_RTD_GetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALERT_LO, &threshAlertLo ) );
         check_status( naibrd_RTD_GetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALARM_LO, &threshAlarmLo ) );
         check_status( naibrd_RTD_GetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALERT_HI, &threshAlertHi ) );
         check_status( naibrd_RTD_GetThreshold( cardIndex, module, chan, NAI_RTD_THRESH_ALARM_HI, &threshAlarmHi ) );

         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_BIT_LATCHED, &bitstat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_OPEN_LATCHED, &openstat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_LO_LATCHED, &alertlostat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_LO_LATCHED, &alarmlostat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_HI_LATCHED, &alerthistat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_HI_LATCHED, &alarmhistat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_SUMMARY_LATCHED, &summarystat_latched ) );

         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_BIT_REALTIME, &bitstat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_OPEN_REALTIME, &openstat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_LO_REALTIME, &alertlostat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_LO_REALTIME, &alarmlostat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_HI_REALTIME, &alerthistat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_HI_REALTIME, &alarmhistat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_SUMMARY_REALTIME, &summarystat_realtime ) );
         if ( zeroTempResistanceType == NAI_RTD_ZERO_TEMP_RESISTANCE_1000 )
         {
            printf( "%2d %s    %s     %12.4f %1d-wire    %7.3f    %7.3f      %7.3f      %7.3f      %7.3f    (%1d/%1d)   (%1d/%1d)    (%1d/%1d)     (%1d/%1d)     (%1d/%1d)     (%1d/%1d)     (%1d/%1d)       %1d\n",
               chan, strChanStatusEnable, zeroTempOhms[zeroTempResistanceType], compres, wiremode, offsetTemp, threshAlertLo, threshAlarmLo, threshAlertHi, threshAlarmHi, bitstat_realtime, bitstat_latched, openstat_realtime, openstat_latched,
               alertlostat_realtime, alertlostat_latched, alarmlostat_realtime, alarmlostat_latched, alerthistat_realtime, alerthistat_latched, alarmhistat_realtime, alarmhistat_latched, summarystat_realtime, summarystat_latched, suspendBackgroundOps );
         }
         else
         {
            printf( "%2d %s    %s      %12.4f %1d-wire    %7.3f    %7.3f      %7.3f      %7.3f      %7.3f    (%1d/%1d)   (%1d/%1d)    (%1d/%1d)     (%1d/%1d)     (%1d/%1d)     (%1d/%1d)     (%1d/%1d)       %1d\n",
               chan, strChanStatusEnable, zeroTempOhms[zeroTempResistanceType], compres, wiremode, offsetTemp, threshAlertLo, threshAlarmLo, threshAlertHi, threshAlarmHi, bitstat_realtime, bitstat_latched, openstat_realtime,
               openstat_latched, alertlostat_realtime, alertlostat_latched, alarmlostat_realtime, alarmlostat_latched, alerthistat_realtime, alerthistat_latched, alarmhistat_realtime, alarmhistat_latched, summarystat_realtime, summarystat_latched, suspendBackgroundOps );
         }
      }
      else
      {
         check_status( naibrd_RTD_GetRange( cardIndex, module, chan, &range ) );
         check_status( naibrd_RTD_GetWireMode( cardIndex, module, chan, &wiremoderaw ) );
         check_status( naibrd_RTD_GetCompResistance( cardIndex, module, chan, &compres ) );
         printf( "%2d  %12.4f  %12.4f %d-wire\n", chan, range, compres, wiremoderaw );
      }
   }
}

/**************************************************************************************************************/
/**
<summary>
This function displays the RTD Basic Operations data.
</summary>
*/
/**************************************************************************************************************/
void RTD_DisplayOpData( int32_t cardIndex, int32_t module, int32_t maxchan )
{
   float64_t res;
   uint32_t bitstat_latched;
   uint32_t openstat_latched;
   uint32_t alertlostat_latched;
   uint32_t alarmlostat_latched;
   uint32_t alerthistat_latched;
   uint32_t alarmhistat_latched;
   uint32_t summarystat_latched;
   uint32_t bitstat_realtime;
   uint32_t openstat_realtime;
   uint32_t alertlostat_realtime;
   uint32_t alarmlostat_realtime;
   uint32_t alerthistat_realtime;
   uint32_t alarmhistat_realtime;
   uint32_t summarystat_realtime;
   float64_t temperature;
   int32_t chan;

   printf( "\n\nRTD Standard Operation Readings:\n" );
   if ( generation == NAI_XILINX_GEN5_ID )
   {
      printf("                                 Bit     Open     Alert      Alarm      Alert      Alarm    Summary\n");
      printf("     Resistance   Temperature   Status  Status  Lo Status  Lo Status  Hi Status  Hi Status  Status\n");
      printf("Ch     (Ohms)     (degrees C)   (R/L)   (R/L)     (R/L)      (R/L)      (R/L)      (R/L)     (R/L)\n");
      printf("---------------------------------------------------------------------------------------------------\n");
   }
   else
   {
      printf("     Resistance   BIT Status  Open Status\n");
      printf("Ch     (Ohms)       (R/L)        (R/L)\n");
      printf("------------------------------------------\n");
   }

   for ( chan = 1; chan <= maxchan; chan++ )
   {
      check_status( naibrd_RTD_GetResistance( cardIndex, module, chan, &res ) );

      if ( generation == NAI_XILINX_GEN5_ID )
      {
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_BIT_LATCHED, &bitstat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_OPEN_LATCHED, &openstat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_LO_LATCHED, &alertlostat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_LO_LATCHED, &alarmlostat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_HI_LATCHED, &alerthistat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_HI_LATCHED, &alarmhistat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_SUMMARY_LATCHED, &summarystat_latched ) );

         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_BIT_REALTIME, &bitstat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_OPEN_REALTIME, &openstat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_LO_REALTIME, &alertlostat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_LO_REALTIME, &alarmlostat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALERT_HI_REALTIME, &alerthistat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_ALARM_HI_REALTIME, &alarmhistat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_SUMMARY_REALTIME, &summarystat_realtime ) );
         check_status( naibrd_RTD_GetTemperature( cardIndex, module, chan, &temperature ) );
         if (temperature < 0)
         {
            printf("%2d  %12.4f    %8.3f    (%1d/%1d)   (%1d/%1d)     (%1d/%1d)      (%1d/%1d)      (%1d/%1d)      (%1d/%1d)     (%1d/%1d)\n",
               chan, res, temperature, bitstat_realtime, bitstat_latched, openstat_realtime, openstat_latched, alertlostat_realtime, alertlostat_latched,
               alarmlostat_realtime, alarmlostat_latched, alerthistat_realtime, alerthistat_latched, alarmhistat_realtime, alarmhistat_latched,
               summarystat_realtime, summarystat_latched);
         }
         else
         {
            printf("%2d  %12.4f    %8.3f    (%1d/%1d)   (%1d/%1d)     (%1d/%1d)      (%1d/%1d)      (%1d/%1d)      (%1d/%1d)     (%1d/%1d)\n",
               chan, res, temperature, bitstat_realtime, bitstat_latched, openstat_realtime, openstat_latched, alertlostat_realtime, alertlostat_latched,
               alarmlostat_realtime, alarmlostat_latched, alerthistat_realtime, alerthistat_latched, alarmhistat_realtime, alarmhistat_latched,
               summarystat_realtime, summarystat_latched);
         }
      }
      else
      {
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_BIT_LATCHED, &bitstat_latched ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_OPEN_LATCHED, &openstat_latched ) );

         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_BIT_REALTIME, &bitstat_realtime ) );
         check_status( naibrd_RTD_GetStatus( cardIndex, module, chan, NAI_RTD_STATUS_OPEN_REALTIME, &openstat_realtime ) );
         printf("%2d  %12.4f     %1d %1d          %1d %1d\n", chan, res, bitstat_realtime, bitstat_latched, openstat_realtime, openstat_latched);
      }

   }
}

Help Bot

X