LVDT BasicOpsMenu
Edit this on GitLab
LVDT BasicOpsMenu
Explanation
#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_lvdt.h"
#include "advanced/nai_ether_adv.h"
static const int8_t *CONFIG_FILE = (const int8_t *)"default_LVDT_BasicOps.txt";
/* Function prototypes */
static bool_t LVDTBasicMenu_Run(int32_t cardIndex, int32_t module, uint32_t modid);
static void LVDTBasicMenu_displayMeasurements(int32_t cardIndex, int32_t module, uint32_t modid);
static void LVDTBasicMenu_displayMode(nai_lvdt_format_t mode);
/*Future use*/
/*static void LVDTBasicMenu_displayStatus(nai_status_bit_t BitStatus, nai_status_bit_t SigLoss, nai_status_bit_t RefLoss);*/
/* LVDT Basic Ops Command Functions */
static nai_status_t LVDTBasicMenu_SetMode(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_SetChanStatusEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_ClearStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_SetDeltaPosition(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_InitDeltaPosition(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_SetBandwidth(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_SetBandwidthSelect(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_SetLVDTScale(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_SetLatch(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_SetTRValue(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_SetSignalInversion(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_ThresholdMenu(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_FloatingPointMenu(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_TestMenu(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_InterruptMenu(int32_t paramCount, int32_t* p_params);
static void LVDTBasicMenu_DisplayInterruptData(int32_t cardIndex, int32_t module, uint32_t modid);
static nai_status_t LVDTBasicMenu_FIFOMenu(int32_t paramCount, int32_t* p_params);
static void LVDTBasicMenu_DisplayFIFOData(int32_t cardIndex, int32_t module, uint32_t modid);
static nai_status_t LVDTBasicMenu_AdvancedOptionsMenu(int32_t paramCount, int32_t* p_params);
//static bool_t LVDTBasicMenu_SetSigLossThreshold(int32_t cardIndex, int32_t module, int32_t channel);
//static bool_t LVDTBasicMenu_SetRefLossThreshold(int32_t cardIndex, int32_t module, int32_t channel);
static nai_status_t LVDTTestMenu_ClearBITStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTTestMenu_SetBITErrorLimit(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTTestMenu_SetTestPosition(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTTestMenu_SetD0TestEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTTestMenu_SetD3TestEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTTestMenu_CheckPowerOnBIT(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTInterruptMenu_SetInterruptEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTInterruptMenu_SetEdgeLevelInterrupt(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTInterruptMenu_SetInterruptVector(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTInterruptMenu_SetInterruptSteering(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOMenu_SetFIFOThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOMenu_SetFIFOSize(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOMenu_SetFIFODataType(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOMenu_SetFIFOSampleRate(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOMenu_SetFIFODelay(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOMenu_ClearFIFO(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOMenu_SetFIFOTrigCtrl(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOMenu_SoftwareTrigger(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOMenu_ClearFIFOStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOMenu_FIFOInterruptMenu(int32_t paramCount, int32_t* p_params);
static void LVDTFIFOMenu_DisplayFIFOInterruptData(int32_t cardIndex, int32_t module, uint32_t modid);
static nai_status_t LVDTFIFOIntMenu_SetFIFOIntEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOIntMenu_SetFIFOEdgeLevelInt(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOIntMenu_SetFIFOIntVector(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTFIFOIntMenu_SetFIFOIntSteering(int32_t paramCount, int32_t* p_params);
static bool_t DisplayAsHex = FALSE;
/****** Command Table *******/
enum lvdt_basicOpsMenu_commands
{
LVDT_BASICMENU_CMD_SET_MODE,
LVDT_BASICMENU_CMD_SET_CHAN_STATUS_ENABLE,
LVDT_BASICMENU_CMD_CLEAR_STATUS,
LVDT_BASICMENU_CMD_SET_DELTA_POSITION,
LVDT_BASICMENU_CMD_INIT_DELTA_POSITION,
LVDT_BASICMENU_CMD_BANDWIDTH,
LVDT_BASICMENU_CMD_BANDWIDTH_SELECT,
LVDT_BASICMENU_CMD_SET_LVDT_SCALE,
LVDT_BASICMENU_CMD_SET_LATCH,
LVDT_BASICMENU_CMD_SET_TR_VALUE,
LVDT_BASICMENU_CMD_SET_SIGNAL_INVERSION,
LVDT_BASICMENU_CMD_THRESHOLD,
LVDT_BASICMENU_CMD_FLOATING_POINT,
LVDT_BASICMENU_CMD_TEST,
LVDT_BASICMENU_CMD_INTERRUPT,
LVDT_BASICMENU_CMD_FIFO,
LVDT_BASICMENU_CMD_DISPLAY_CONVERTED,
LVDT_BASICMENU_CMD_DISPLAY_HEX,
LVDT_BASICMENU_CMD_ADVANCED_OPTIONS,
LVDT_BASICMENU_CMD_COUNT
};
enum lvdt_basicOpsMenu_test_commands
{
LVDT_TESTMENU_CMD_CLEAR_BIT_STATUS,
LVDT_TESTMENU_CMD_SET_BIT_ERROR_LIMIT,
LVDT_TESTMENU_CMD_SET_TEST_POSITION,
LVDT_TESTMENU_CMD_ENABLE_D0_TEST,
LVDT_TESTMENU_CMD_ENABLE_D3_TEST,
LVDT_TESTMENU_CMD_CHECK_PBIT,
LVDT_TESTMENU_CMD_DISPLAY_CONVERTED,
LVDT_TESTMENU_CMD_DISPLAY_HEX,
LVDT_TESTMENU_CMD_COUNT
};
enum lvdt_basicOpsMenu_interrupt_commands
{
LVDT_INTERRUPTMENU_CMD_SET_INTERRUPT_ENABLE,
LVDT_INTERRUPTMENU_CMD_SET_EDGE_LEVEL_INTERRUPT,
LVDT_INTERRUPTMENU_CMD_SET_INTERRUPT_VECTOR,
LVDT_INTERRUPTMENU_CMD_SET_INTERRUPT_STEERING,
LVDT_INTERRUPTMENU_CMD_COUNT
};
enum lvdt_basicOpsMenu_fifo_commands
{
LVDT_FIFOMENU_CMD_SET_THRESHOLD,
LVDT_FIFOMENU_CMD_SET_SIZE,
LVDT_FIFOMENU_CMD_SET_DATA_TYPE,
LVDT_FIFOMENU_CMD_SET_SAMPLE_RATE,
LVDT_FIFOMENU_CMD_SET_DELAY,
LVDT_FIFOMENU_CMD_CLEAR_FIFO,
LVDT_FIFOMENU_CMD_SET_TRIGGER_CTRL,
LVDT_FIFOMENU_CMD_SOFTWARE_TRIGGER,
LVDT_FIFOMENU_CMD_CLEAR_FIFO_STATUS,
LVDT_FIFOMENU_CMD_FIFO_INTERRUPT_MENU,
LVDT_FIFOMENU_CMD_DISPLAY_CONVERTED,
LVDT_FIFOMENU_CMD_DISPLAY_HEX,
LVDT_FIFOMENU_CMD_COUNT
};
enum lvdt_basicOpsMenu_fifo_interrupt_commands
{
LVDT_FIFOINTMENU_CMD_SET_INT_ENABLE,
LVDT_FIFOINTMENU_CMD_SET_EDGE_LEVEL_INT,
LVDT_FIFOINTMENU_CMD_SET_INT_VECTOR,
LVDT_FIFOINTMENU_CMD_SET_INT_STEERING,
LVDT_FIFOINTMENU_CMD_COUNT
};
naiapp_cmdtbl_params_t LVDT_BasicOpMenuCmds[] = {
{"0", "Set LVDT Mode", LVDT_BASICMENU_CMD_SET_MODE, LVDTBasicMenu_SetMode },
{"1", "Enable/Disable Channel Status Reporting", LVDT_BASICMENU_CMD_SET_CHAN_STATUS_ENABLE, LVDTBasicMenu_SetChanStatusEnable},
{"2", "Clear Latched Status", LVDT_BASICMENU_CMD_CLEAR_STATUS, LVDTBasicMenu_ClearStatus },
{"3", "Set LVDT Delta Position Value", LVDT_BASICMENU_CMD_SET_DELTA_POSITION, LVDTBasicMenu_SetDeltaPosition },
{"4", "Initialize Delta Position Status Reporting", LVDT_BASICMENU_CMD_INIT_DELTA_POSITION, LVDTBasicMenu_InitDeltaPosition },
{"5", "Set LVDT Bandwidth", LVDT_BASICMENU_CMD_BANDWIDTH, LVDTBasicMenu_SetBandwidth },
{"6", "Set LVDT Bandwidth Select Mode", LVDT_BASICMENU_CMD_BANDWIDTH_SELECT, LVDTBasicMenu_SetBandwidthSelect },
{"7", "Set LVDT/RVDT Scale", LVDT_BASICMENU_CMD_SET_LVDT_SCALE, LVDTBasicMenu_SetLVDTScale },
{"8", "Set LVDT Track and Hold Latch Control", LVDT_BASICMENU_CMD_SET_LATCH, LVDTBasicMenu_SetLatch },
{"9", "Set LVDT Transformation Ratio (TR) Value", LVDT_BASICMENU_CMD_SET_TR_VALUE, LVDTBasicMenu_SetTRValue },
{"A", "Set LVDT Signal Inversion Control", LVDT_BASICMENU_CMD_SET_SIGNAL_INVERSION, LVDTBasicMenu_SetSignalInversion },
{"B", "Set LVDT Threshold Menu", LVDT_BASICMENU_CMD_THRESHOLD, LVDTBasicMenu_ThresholdMenu },
{"C", "LVDT Floating-Point Menu", LVDT_BASICMENU_CMD_FLOATING_POINT, LVDTBasicMenu_FloatingPointMenu },
{"D", "LVDT BIT Test Menu", LVDT_BASICMENU_CMD_TEST, LVDTBasicMenu_TestMenu },
{"E", "LVDT Interrupt Menu", LVDT_BASICMENU_CMD_INTERRUPT, LVDTBasicMenu_InterruptMenu },
{"F", "LVDT FIFO Menu", LVDT_BASICMENU_CMD_FIFO, LVDTBasicMenu_FIFOMenu },
{"G", "Display Values with Conversion", LVDT_BASICMENU_CMD_DISPLAY_CONVERTED, NULL },
{"H", "Display Values as Hex", LVDT_BASICMENU_CMD_DISPLAY_HEX, NULL },
{"I", "Advanced Options", LVDT_BASICMENU_CMD_ADVANCED_OPTIONS, LVDTBasicMenu_AdvancedOptionsMenu}
};
naiapp_cmdtbl_params_t LVDT_TestMenuCmds[] = {
{"0", "Clear BIT Latched Status", LVDT_TESTMENU_CMD_CLEAR_BIT_STATUS, LVDTTestMenu_ClearBITStatus },
{"1", "Set BIT Error Limit", LVDT_TESTMENU_CMD_SET_BIT_ERROR_LIMIT, LVDTTestMenu_SetBITErrorLimit },
{"2", "Set LVDT D0 (UBIT) Test Position", LVDT_TESTMENU_CMD_SET_TEST_POSITION, LVDTTestMenu_SetTestPosition },
{"3", "Enable or Disable D0 Test (UBIT)", LVDT_TESTMENU_CMD_ENABLE_D0_TEST, LVDTTestMenu_SetD0TestEnable },
{"4", "Enable or Disable D3 Test (IBIT)", LVDT_TESTMENU_CMD_ENABLE_D3_TEST, LVDTTestMenu_SetD3TestEnable },
{"5", "Check Power-On BIT", LVDT_TESTMENU_CMD_CHECK_PBIT, LVDTTestMenu_CheckPowerOnBIT },
{"6", "Display Values with Conversion", LVDT_TESTMENU_CMD_DISPLAY_CONVERTED, NULL },
{"7", "Display Values as Hex", LVDT_TESTMENU_CMD_DISPLAY_HEX, NULL }
};
naiapp_cmdtbl_params_t LVDT_InterruptMenuCmds[] = {
{"0", "Enable/Disable Interrupts", LVDT_INTERRUPTMENU_CMD_SET_INTERRUPT_ENABLE, LVDTInterruptMenu_SetInterruptEnable },
{"1", "Set Edge/Level Interrupt Trigger Setting", LVDT_INTERRUPTMENU_CMD_SET_EDGE_LEVEL_INTERRUPT, LVDTInterruptMenu_SetEdgeLevelInterrupt},
{"2", "Set Interrupt Vector", LVDT_INTERRUPTMENU_CMD_SET_INTERRUPT_VECTOR, LVDTInterruptMenu_SetInterruptVector },
{"3", "Set Interrupt Steering", LVDT_INTERRUPTMENU_CMD_SET_INTERRUPT_STEERING, LVDTInterruptMenu_SetInterruptSteering }
};
naiapp_cmdtbl_params_t LVDT_FIFOMenuCmds[] = {
{"0", "Set FIFO Threshold", LVDT_FIFOMENU_CMD_SET_THRESHOLD, LVDTFIFOMenu_SetFIFOThreshold },
{"1", "Set FIFO Size", LVDT_FIFOMENU_CMD_SET_SIZE, LVDTFIFOMenu_SetFIFOSize },
{"2", "Set FIFO Data Type", LVDT_FIFOMENU_CMD_SET_DATA_TYPE, LVDTFIFOMenu_SetFIFODataType },
{"3", "Set FIFO Sample Rate", LVDT_FIFOMENU_CMD_SET_SAMPLE_RATE, LVDTFIFOMenu_SetFIFOSampleRate },
{"4", "Set FIFO Delay", LVDT_FIFOMENU_CMD_SET_DELAY, LVDTFIFOMenu_SetFIFODelay },
{"5", "Clear FIFO", LVDT_FIFOMENU_CMD_CLEAR_FIFO, LVDTFIFOMenu_ClearFIFO },
{"6", "Set FIFO Trigger Control", LVDT_FIFOMENU_CMD_SET_TRIGGER_CTRL, LVDTFIFOMenu_SetFIFOTrigCtrl },
{"7", "FIFO Software Trigger", LVDT_FIFOMENU_CMD_SOFTWARE_TRIGGER, LVDTFIFOMenu_SoftwareTrigger },
{"8", "Clear FIFO Status", LVDT_FIFOMENU_CMD_CLEAR_FIFO_STATUS, LVDTFIFOMenu_ClearFIFOStatus },
{"9", "FIFO Interrupt Menu", LVDT_FIFOMENU_CMD_FIFO_INTERRUPT_MENU, LVDTFIFOMenu_FIFOInterruptMenu },
{"A", "Display Values with Conversion", LVDT_FIFOMENU_CMD_DISPLAY_CONVERTED, NULL },
{"B", "Display Values as Hex", LVDT_FIFOMENU_CMD_DISPLAY_HEX, NULL }
};
naiapp_cmdtbl_params_t LVDT_FIFOInterruptMenuCmds[] = {
{"0", "Enable/Disable FIFO Interrupts", LVDT_FIFOINTMENU_CMD_SET_INT_ENABLE, LVDTFIFOIntMenu_SetFIFOIntEnable },
{"1", "Set FIFO Edge/Level Interrupt Trigger Setting", LVDT_FIFOINTMENU_CMD_SET_EDGE_LEVEL_INT, LVDTFIFOIntMenu_SetFIFOEdgeLevelInt},
{"2", "Set FIFO Interrupt Vector", LVDT_FIFOINTMENU_CMD_SET_INT_VECTOR, LVDTFIFOIntMenu_SetFIFOIntVector },
{"3", "Set FIFO Interrupt Steering", LVDT_FIFOINTMENU_CMD_SET_INT_STEERING, LVDTFIFOIntMenu_SetFIFOIntSteering }
};
/*****************************************************************************/
/**
<summary>
The purpose of the LVDT_BasicOpsMenu is to illustrate the methods to call in the
naibrd library to perform basic operations with the LVDT modules for
configuration setup 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 LVDT routines.
- ConfigDevice
- DisplayDeviceCfg
- GetBoardSNModCfg
- CheckModule
</summary>
*/
/*****************************************************************************/
#if defined (__VXWORKS__)
int32_t LVDT_BasicOpsMenu(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))
{
LVDTBasicMenu_Run(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>
LVDTBasicMenu_Run illustrates the channel configuration and prepares the menu
which will handle user command requests. Returns TRUE if the user enters
the Quit Command at any point within its scope.
</summary>
*/
/*****************************************************************************/
static bool_t LVDTBasicMenu_Run(int32_t cardIndex, int32_t module, uint32_t modid)
{
bool_t bQuit = FALSE;
bool_t bCmdFound = FALSE;
int32_t MAX_CHANNELS = naibrd_LVDT_GetChannelCount(modid);
int32_t cmd;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
naiapp_AppParameters_t LVDT_basicops_params;
p_naiapp_AppParameters_t LVDT_basicOps_params = &LVDT_basicops_params;
LVDT_basicOps_params->cardIndex = cardIndex;
LVDT_basicOps_params->module = module;
LVDT_basicOps_params->modId = modid;
do
{
naiapp_utils_LoadParamMenuCommands(LVDT_BASICMENU_CMD_COUNT, LVDT_BasicOpMenuCmds);
LVDTBasicMenu_displayMeasurements(cardIndex, module, modid);
naiapp_display_ParamMenuCommands((int8_t*)"LVDT Basic Operations");
printf("\n Type command or %c to quit : ", NAI_QUIT_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit && inputResponseCnt > 0)
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound)
{
if (cmd == LVDT_BASICMENU_CMD_DISPLAY_CONVERTED)
DisplayAsHex = FALSE;
else if (cmd == LVDT_BASICMENU_CMD_DISPLAY_HEX)
DisplayAsHex = TRUE;
else
{
if ((cmd == LVDT_BASICMENU_CMD_SET_MODE) || (cmd == LVDT_BASICMENU_CMD_THRESHOLD) ||
(cmd == LVDT_BASICMENU_CMD_SET_CHAN_STATUS_ENABLE) || (cmd == LVDT_BASICMENU_CMD_CLEAR_STATUS) ||
(cmd == LVDT_BASICMENU_CMD_FLOATING_POINT) || (cmd == LVDT_BASICMENU_CMD_SET_DELTA_POSITION) ||
(cmd == LVDT_BASICMENU_CMD_INIT_DELTA_POSITION) || (cmd == LVDT_BASICMENU_CMD_BANDWIDTH) ||
(cmd == LVDT_BASICMENU_CMD_BANDWIDTH_SELECT) || (cmd == LVDT_BASICMENU_CMD_SET_LVDT_SCALE) ||
(cmd == LVDT_BASICMENU_CMD_SET_TR_VALUE) || (cmd == LVDT_BASICMENU_CMD_SET_SIGNAL_INVERSION) ||
(cmd == LVDT_BASICMENU_CMD_SET_LATCH))
{
naiapp_query_ChannelNumber(MAX_CHANNELS, 1, &LVDT_basicOps_params->channel);
}
else
{
LVDT_basicOps_params->channel = 1;
}
LVDT_BasicOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)LVDT_basicOps_params);
}
}
else
printf(" Invalid command entered\n");
}
} while (!bQuit);
return bQuit;
}
/*****************************************************************************/
/**
<summary>
LVDTBasicMenu_displayMeasurements illustrates the methods to call in the naibrd library
to retrieve the basic operation configuration states and status states
as well as the current lvdt reading for all channels.
</summary>
*/
/*****************************************************************************/
static void LVDTBasicMenu_displayMeasurements(int32_t cardIndex, int32_t module, uint32_t modid)
{
int32_t channel = 0, MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modid);
nai_lvdt_format_t mode = 0u;
uint32_t chanStatusEnable = 0u;
uint32_t positionRaw = 0u, frequencyRaw = 0u, vaRaw = 0u, vbRaw = 0u, vaVbRaw = 0u, sigVoltRaw = 0u, refVoltRaw = 0u, deltaPosRaw = 0u;
uint32_t positionBRaw = 0u, velocityRaw = 0u, velocityBRaw = 0u, trA = 0u, trB = 0u;
float64_t position = 0.0, frequency = 0.0, sigvolt = 0.0, refvolt = 0.0, va = 0.0, vb = 0.0, deltaPos = 0.0;
float64_t positionB = 0.0, velocity = 0.0, velocityB = 0.0, vaVb = 0.0;
uint32_t bandwidth = 0u;
nai_lvdt_bandwidth_select_t bwSelect = 0u;
uint32_t lvdtScale = 0u;
uint32_t latchCtrl = 0u;
naibrd_lvdt_signal_inversion_resp_value_type_t invVaCtrl = NAIBRD_LVDT_RESP_NON_INVERTED_VA;
naibrd_lvdt_signal_inversion_resp_value_type_t invVbCtrl = NAIBRD_LVDT_RESP_NON_INVERTED_VB;
naibrd_lvdt_signal_inversion_resp_value_type_t invRefCtrl = NAIBRD_LVDT_RESP_NON_INVERTED_REF;
naibrd_lvdt_signal_inversion_resp_value_type_t invVaVbCtrl = NAIBRD_LVDT_RESP_DIFF_VA_VB;
uint32_t BitStatusRealtime = NAI_STATUS_BIT_LO, BitStatusLatched = NAI_STATUS_BIT_LO;
uint32_t SigLossRealtime = NAI_STATUS_BIT_LO, SigLossLatched = NAI_STATUS_BIT_LO;
uint32_t RefLossRealtime = NAI_STATUS_BIT_LO, RefLossLatched = NAI_STATUS_BIT_LO;
uint32_t SigFaultHiRealtime = NAI_STATUS_BIT_LO, SigFaultHiLatched = NAI_STATUS_BIT_LO;
uint32_t RefFaultHiRealtime = NAI_STATUS_BIT_LO, RefFaultHiLatched = NAI_STATUS_BIT_LO;
uint32_t OpenRealtime = NAI_STATUS_BIT_LO, OpenLatched = NAI_STATUS_BIT_LO;
uint32_t ShortRealtime = NAI_STATUS_BIT_LO, ShortLatched = NAI_STATUS_BIT_LO;
uint32_t SummaryRealtime = NAI_STATUS_BIT_LO, SummaryLatched = NAI_STATUS_BIT_LO;
uint32_t DeltaPosRealtime = NAI_STATUS_BIT_LO, DeltaPosLatched = NAI_STATUS_BIT_LO;
bool_t gen5 = FALSE;
char strChanStatusEnable[20] = "";
char strBwSelect[12] = "";
char strInvVaCtrl[14] = "";
char strInvVbCtrl[14] = "";
char strInvRefCtrl[14] = "";
char strInvVaVbCtrl[37] = "";
switch (modid)
{
case NAI_MODULE_ID_LD1:
case NAI_MODULE_ID_LD2:
case NAI_MODULE_ID_LD3:
case NAI_MODULE_ID_LD4:
case NAI_MODULE_ID_LD5:
case NAI_MODULE_ID_LR2:
printf("\n\n===================================================================================================================================================================\n");
printf("%18s%10s%13s%11s%72s%11s%17s%10s\n", "", "Chan Stat", "", "Pos B (2-", "", "Delta", "", "Vel B (2-");
printf("%7s%5s%14s%14s%13s%11s%8s%12s%14s%14s%12s%13s%13s%13s\n", "Chan", "Mode", "Enable", "Position", "Wire Only)", "Frequency", "Va", "Vb", "Va+Vb", "SigVolt", "RefVolt", "Position", "Velocity", "Wire Only)");
printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------\n");
gen5 = TRUE;
break;
default:
printf("\n\n=========================================================================================== \n");
printf("%7s%5s%17s%12s%12s%12s%6s%10s%10s\n", "Chan", "Mode", "Position", "Frequency", "SigVolt", "RefVolt", "BIT", "SigLoss", "RefLoss");
gen5 = FALSE;
break;
}
for( channel = 1; channel <= MAX_CHANNEL; channel++)
{
printf("%4d ", channel);
check_status(naibrd_LVDT_GetChanMode(cardIndex, module, channel, &mode));
LVDTBasicMenu_displayMode(mode);
// uint32_t positionRaw, frequencyRaw, vaRaw, vbRaw, sigVoltRaw, refVoltRaw;
if (DisplayAsHex)
{
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_POSITION, &positionRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
if (gen5)
{
check_status(naibrd_LVDT_GetChanStatusEnable(cardIndex, module, channel, &chanStatusEnable));
switch (chanStatusEnable)
{
case TRUE:
sprintf(strChanStatusEnable, "Enabled ");
break;
case FALSE:
sprintf(strChanStatusEnable, "Disabled");
break;
default:
sprintf(strChanStatusEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_POSITION_2WIRE_B, &positionBRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_VA, &vaRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_VB, &vbRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_VA_VB, &vaVbRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_DELTA_POSITION, &deltaPosRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_VELOCITY, &velocityRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_VELOCITY_2WIRE_B, &velocityBRaw));
printf("%-10s0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X",
strChanStatusEnable, positionRaw, positionBRaw, frequencyRaw, vaRaw, vbRaw, vaVbRaw, sigVoltRaw, refVoltRaw,
deltaPosRaw, velocityRaw, velocityBRaw);
}
else
{
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_BIT_LATCHED, &BitStatusLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_SIGNAL_LATCHED, &SigLossLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_REF_LATCHED, &RefLossLatched));
printf("0x%08X 0x%08X 0x%08X 0x%08X%5d%8d%8d", positionRaw, frequencyRaw, sigVoltRaw, refVoltRaw, BitStatusLatched, SigLossLatched, RefLossLatched);
}
}
else
{
check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigvolt));
check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refvolt));
if (gen5)
{
check_status(naibrd_LVDT_GetChanStatusEnable(cardIndex, module, channel, &chanStatusEnable));
switch (chanStatusEnable)
{
case TRUE:
sprintf(strChanStatusEnable, "Enabled ");
break;
case FALSE:
sprintf(strChanStatusEnable, "Disabled");
break;
default:
sprintf(strChanStatusEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetTwoWirePosition(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, &positionB));
check_status(naibrd_LVDT_GetVaSignal(cardIndex, module, channel, NAI_LVDT_SIGNAL, &va));
check_status(naibrd_LVDT_GetVbSignal(cardIndex, module, channel, NAI_LVDT_SIGNAL, &vb));
check_status(naibrd_LVDT_GetVaVbSignal(cardIndex, module, channel, &vaVb));
check_status(naibrd_LVDT_GetDeltaPosition(cardIndex, module, channel, &deltaPos));
check_status(naibrd_LVDT_GetVelocity(cardIndex, module, channel, &velocity));
check_status(naibrd_LVDT_GetTwoWireVelocity(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, &velocityB));
printf("%-10s%10.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f",
strChanStatusEnable, position, positionB, frequency, va, vb, vaVb, sigvolt, refvolt, deltaPos, velocity, velocityB);
}
else
{
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_BIT_LATCHED, &BitStatusLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_SIGNAL_LATCHED, &SigLossLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_REF_LATCHED, &RefLossLatched));
printf("%10.4f%12.4f%12.4f%12.4f%5d%8d%8d", position, frequency, sigvolt, refvolt, BitStatusLatched, SigLossLatched, RefLossLatched);
}
}
printf("\n");
}
if (gen5)
{
printf("\n\n================================================================================================================================================================ \n");
printf("%7s%11s%13s%10s%10s%12s%14s%17s%14s%14s%14s\n", "Chan", "Bandwidth", "Bandwidth", "LVDT", "Track", "TR", "TR", "Invert Va", "Invert Vb", "Invert Ref", "Invert Va-Vb");
printf("%7s%11s%11s%13s%11s%13s%14s%13s%14s%13s%13s\n", "", "", "Select", "Scale", "and Hold", "Value A", "Value B", "Control", "Control", "Control", "Control");
printf("----------------------------------------------------------------------------------------------------------------------------------------------------------------\n");
for (channel = 1; channel <= MAX_CHANNEL; channel++)
{
printf("%4d ", channel);
check_status(naibrd_LVDT_GetLatch(cardIndex, module, channel, &latchCtrl));
check_status(naibrd_LVDT_GetSignalInversion(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_INV_VA, &invVaCtrl));
switch (invVaCtrl)
{
case NAIBRD_LVDT_RESP_NON_INVERTED_VA:
sprintf(strInvVaCtrl, "Non-Inverted");
break;
case NAIBRD_LVDT_RESP_INVERTED_VA:
sprintf(strInvVaCtrl, " Inverted ");
break;
default:
sprintf(strInvVaCtrl, " Unknown ");
break;
}
check_status(naibrd_LVDT_GetSignalInversion(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_INV_VB, &invVbCtrl));
switch (invVbCtrl)
{
case NAIBRD_LVDT_RESP_NON_INVERTED_VB:
sprintf(strInvVbCtrl, "Non-Inverted");
break;
case NAIBRD_LVDT_RESP_INVERTED_VB:
sprintf(strInvVbCtrl, " Inverted ");
break;
default:
sprintf(strInvVbCtrl, " Unknown ");
break;
}
check_status(naibrd_LVDT_GetSignalInversion(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_INV_REF, &invRefCtrl));
switch (invRefCtrl)
{
case NAIBRD_LVDT_RESP_NON_INVERTED_REF:
sprintf(strInvRefCtrl, "Non-Inverted");
break;
case NAIBRD_LVDT_RESP_INVERTED_REF:
sprintf(strInvRefCtrl, " Inverted ");
break;
default:
sprintf(strInvRefCtrl, " Unknown ");
break;
}
check_status(naibrd_LVDT_GetSignalInversion(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_INV_DIFF, &invVaVbCtrl));
switch (invVaVbCtrl)
{
case NAIBRD_LVDT_RESP_DIFF_VA_VB:
sprintf(strInvVaVbCtrl, "Non-Inverted ((Va - Vb) / (Va + Vb))");
break;
case NAIBRD_LVDT_RESP_DIFF_VB_VA:
sprintf(strInvVaVbCtrl, "Inverted ((Vb - Va) / (Va + Vb)) ");
break;
default:
sprintf(strInvVaVbCtrl, " Unknown ");
break;
}
check_status(naibrd_LVDT_GetTRValue(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_A, &trA));
check_status(naibrd_LVDT_GetTRValue(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, &trB));
check_status(naibrd_LVDT_GetBandwidthSelect(cardIndex, module, channel, &bwSelect));
switch (bwSelect)
{
case NAI_LVDT_BW_MANUAL:
sprintf(strBwSelect, " Manual ");
break;
case NAI_LVDT_BW_AUTOMATIC:
sprintf(strBwSelect, "Automatic");
break;
default:
sprintf(strBwSelect, " Unknown ");
break;
}
check_status(naibrd_LVDT_GetLVDTScale(cardIndex, module, channel, &lvdtScale));
if (DisplayAsHex)
{
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_BANDWIDTH, &bandwidth));
printf("0x%08X%13s 0x%08X%6s%1d%8s0x%08X 0x%08X %12s %12s %12s %-37s\n", bandwidth, strBwSelect, lvdtScale, "",
latchCtrl, "", trA, trB, strInvVaCtrl, strInvVbCtrl, strInvRefCtrl, strInvVaVbCtrl);
}
else
{
check_status(naibrd_LVDT_GetBandwidth(cardIndex, module, channel, &bandwidth));
printf("%10u%13s %10u%6s%1u%7s%10u %10u %12s %12s %12s %-37s\n", bandwidth, strBwSelect, lvdtScale, "", latchCtrl,
"", trA, trB, strInvVaCtrl, strInvVbCtrl, strInvRefCtrl, strInvVaVbCtrl);
}
}
printf("\n\n====================================== Status ====================================== \n");
printf("%7s%5s%9s%8s%8s%8s%6s%8s%9s%16s\n", "Chan", "BIT", "Sig Lo", "Ref Lo", "Sig Hi", "Ref Hi", "Open", "Short", "Summary", "Delta Position");
printf("%7s%6s%7s%8s%8s%8s%8s%7s%8s%12s\n", "", "(R/L)", "(R/L)", "(R/L)", "(R/L)", "(R/L)", "(R/L)", "(R/L)", "(R/L)", "(R/L)");
printf("------------------------------------------------------------------------------------\n");
for (channel = 1; channel <= MAX_CHANNEL; channel++)
{
printf("%4d ", channel);
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_BIT_REALTIME, &BitStatusRealtime));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_BIT_LATCHED, &BitStatusLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_SIGNAL_REALTIME, &SigLossRealtime));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_SIGNAL_LATCHED, &SigLossLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_REF_REALTIME, &RefLossRealtime));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_REF_LATCHED, &RefLossLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_SIGNAL_HIGH_REALTIME, &SigFaultHiRealtime));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_SIGNAL_HIGH_LATCHED, &SigFaultHiLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_REF_HIGH_REALTIME, &RefFaultHiRealtime));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_REF_HIGH_LATCHED, &RefFaultHiLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_OPEN_REALTIME, &OpenRealtime));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_OPEN_LATCHED, &OpenLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_SHORT_REALTIME, &ShortRealtime));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_SHORT_LATCHED, &ShortLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_SUMMARY_REALTIME, &SummaryRealtime));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_SUMMARY_LATCHED, &SummaryLatched));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_DELTA_POS_REALTIME, &DeltaPosRealtime));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_DELTA_POS_LATCHED, &DeltaPosLatched));
printf("(%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d)\n",
BitStatusRealtime, BitStatusLatched, SigLossRealtime, SigLossLatched, RefLossRealtime, RefLossLatched, SigFaultHiRealtime,
SigFaultHiLatched, RefFaultHiRealtime, RefFaultHiLatched, OpenRealtime, OpenLatched, ShortRealtime, ShortLatched,
SummaryRealtime, SummaryLatched, DeltaPosRealtime, DeltaPosLatched);
}
}
}
/*****************************************************************************/
/**
<summary>
LVDTBasicMenu_displayMode prints mode value.
</summary>
*/
/*****************************************************************************/
static void LVDTBasicMenu_displayMode(nai_lvdt_format_t mode)
{
if (mode == NAI_LVDT_4WIRE)
printf("4-wire(%d) ", mode);
else if (mode == NAI_LVDT_2WIRE)
printf("2-wire(%d) ", mode);
else
printf("UNKNOWN(%d) ", mode);
}
/*****************************************************************************/
/**
<summary>
LVDTBasicMenu_displayStatus prints to stdin the BIT status, Signal Loss and
Reference Loss Status.
</summary>
*/
/*****************************************************************************/
/*Future use*/
/*
static void LVDTBasicMenu_displayStatus(nai_status_bit_t BitStatus, nai_status_bit_t SigLoss, nai_status_bit_t RefLoss)
{
if (BitStatus == NAI_STATUS_BIT_HI)
printf(" 1 ");
else if (BitStatus == NAI_STATUS_BIT_LO)
printf(" 0 ");
else
printf(" Error ");
if (SigLoss == NAI_STATUS_BIT_HI)
printf(" 1 ");
else if (SigLoss == NAI_STATUS_BIT_LO)
printf(" 0 ");
else
printf(" Error ");
if (RefLoss == NAI_STATUS_BIT_HI)
printf(" 1\n");
else if (RefLoss == NAI_STATUS_BIT_LO)
printf(" 0\n");
else
printf(" Error\n");
}
*/
static nai_status_t LVDTBasicMenu_SetMode(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_lvdt_format_t mode;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Select LVDT Mode to set: [2 (2-wire) or 4 (4-wire)]: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
if ((inputBuffer[0] == '2') || (inputBuffer[0] == '4'))
{
if (inputBuffer[0] == '2')
mode = NAI_LVDT_2WIRE;
else
mode = NAI_LVDT_4WIRE;
check_status(naibrd_LVDT_SetChanMode(cardIndex, module, channel, mode));
}
else
printf("\nInvalid LVDT Mode Entered\n");
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_SetChanStatusEnable(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
uint32_t enable = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Select Channel Status Enabled/Disabled Setting to set: [0 (Disabled) or 1 (Enabled)]: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
if ((inputBuffer[0] == '0') || (inputBuffer[0] == '1'))
{
if (inputBuffer[0] == '1')
{
enable = 1u;
}
check_status(naibrd_LVDT_SetChanStatusEnable(cardIndex, module, channel, enable));
}
else
{
printf("\nInvalid Setting Entered\n");
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_ClearStatus(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_lvdt_status_type_t statusTypeToClear = 0u;
char statusTypeStr[18] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Select Latched Status Type to clear: (0 for BIT, 1 for Signal Fault Low, 2 for Ref Fault Low, 3 for Signal Fault High, 4 for Ref Fault High, 5 for Open, 6 for Short, 7 for Summary, 8 for Delta Position, q for quit): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
statusTypeToClear = NAI_LVDT_STATUS_BIT_LATCHED;
sprintf(statusTypeStr, "BIT");
break;
case '1':
statusTypeToClear = NAI_LVDT_STATUS_SIGNAL_LOW_LATCHED;
sprintf(statusTypeStr, "Signal Fault Low");
break;
case '2':
statusTypeToClear = NAI_LVDT_STATUS_REF_LOW_LATCHED;
sprintf(statusTypeStr, "Ref Fault Low");
break;
case '3':
statusTypeToClear = NAI_LVDT_STATUS_SIGNAL_HIGH_LATCHED;
sprintf(statusTypeStr, "Signal Fault High");
break;
case '4':
statusTypeToClear = NAI_LVDT_STATUS_REF_HIGH_LATCHED;
sprintf(statusTypeStr, "Ref Fault High");
break;
case '5':
statusTypeToClear = NAI_LVDT_STATUS_OPEN_LATCHED;
sprintf(statusTypeStr, "Open");
break;
case '6':
statusTypeToClear = NAI_LVDT_STATUS_SHORT_LATCHED;
sprintf(statusTypeStr, "Short");
break;
case '7':
statusTypeToClear = NAI_LVDT_STATUS_SUMMARY_LATCHED;
sprintf(statusTypeStr, "Summary");
break;
case '8':
statusTypeToClear = NAI_LVDT_STATUS_DELTA_POS_LATCHED;
sprintf(statusTypeStr, "Delta Position");
break;
case 'q':
case 'Q':
bQuit = TRUE;
break;
default:
bQuit = TRUE;
printf("\nInvalid status type entered\n");
break;
}
if (!bQuit)
{
printf("\nAre you sure you want to clear the %s status? (Y for Yes or N for No): ", statusTypeStr);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0) && (toupper(inputBuffer[0]) == 'Y'))
{
check_status(naibrd_LVDT_ClearStatus(cardIndex, module, channel, statusTypeToClear));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_SetDeltaPosition(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
float64_t deltaPos = 0.0;
uint32_t deltaPosRaw = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
if (DisplayAsHex)
{
printf("Type Raw Hex Delta Position Value to set: 0x");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
deltaPosRaw = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (deltaPosRaw == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_DELTA_POSITION, deltaPosRaw));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_DELTA_POSITION, deltaPosRaw));
}
}
}
else
{
printf("Type Delta Position Value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
deltaPos = atof((const char*)inputBuffer);
if (deltaPos == 0.0)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetDeltaPosition(cardIndex, module, channel, deltaPos));
}
else
{
printf("\nInvalid Delta Position value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetDeltaPosition(cardIndex, module, channel, deltaPos));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_InitDeltaPosition(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Do you want to enable or disable Delta Position Status reporting for channel %d? (1 for Enable, 0 for Disable): ", channel);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
if (inputBuffer[0] == '0')
{
status = check_status(naibrd_LVDT_SetInitDeltaPosition(cardIndex, module, channel, (bool_t)0x0u));
if (status == NAI_SUCCESS)
{
printf("\nDelta Position Status reporting has been disabled for channel %d.\n", channel);
}
}
else if (inputBuffer[0] == '1')
{
status = check_status(naibrd_LVDT_SetInitDeltaPosition(cardIndex, module, channel, (bool_t)0x1u));
if (status == NAI_SUCCESS)
{
printf("\nDelta Position Status reporting has been enabled for channel %d.\n", channel);
}
}
else
{
printf("\nInvalid selection entered\n");
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_SetBandwidth(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
uint32_t bandwidth = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
if (DisplayAsHex)
{
printf("Type Raw Hex Bandwidth Value to set: 0x");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
bandwidth = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (bandwidth == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_BANDWIDTH, bandwidth));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_BANDWIDTH, bandwidth));
}
}
}
else
{
printf("Type Bandwidth Value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
bandwidth = (uint32_t)strtoul((const char*)inputBuffer, NULL, 10);
if (bandwidth == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetBandwidth(cardIndex, module, channel, bandwidth));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetBandwidth(cardIndex, module, channel, bandwidth));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_SetBandwidthSelect(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Type Bandwidth Select mode setting to set (0 for Manual, 1 for Automatic): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetBandwidthSelect(cardIndex, module, channel, NAI_LVDT_BW_MANUAL));
}
else if (inputBuffer[0] == '1')
{
check_status(naibrd_LVDT_SetBandwidthSelect(cardIndex, module, channel, NAI_LVDT_BW_AUTOMATIC));
}
else
{
printf("\nInvalid selection entered\n");
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_SetLVDTScale(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
uint32_t lvdtScale = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
if (DisplayAsHex)
{
printf("Type Raw Hex LVDT Scale Value to set: 0x");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
lvdtScale = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (lvdtScale == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetLVDTScale(cardIndex, module, channel, lvdtScale));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetLVDTScale(cardIndex, module, channel, lvdtScale));
}
}
}
else
{
printf("Type LVDT Scale Value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
lvdtScale = (uint32_t)strtoul((const char*)inputBuffer, NULL, 10);
if (lvdtScale == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetLVDTScale(cardIndex, module, channel, lvdtScale));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetLVDTScale(cardIndex, module, channel, lvdtScale));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_SetLatch(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Do you want to enable or disable the Position Data Track and Hold Latch for channel %d? (1 to enable, 0 to disable): ", channel);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
status = check_status(naibrd_LVDT_SetLatch(cardIndex, module, channel, 0x0u));
if (status == NAI_SUCCESS)
{
printf("Track and Hold Latch for channel %d has been disabled.", channel);
}
break;
case '1':
status = check_status(naibrd_LVDT_SetLatch(cardIndex, module, channel, 0x1u));
if (status == NAI_SUCCESS)
{
printf("Change the Position for channel %d and then read it once. It should retain the original value it had before you changed it.\n", channel);
printf("Once the channel %d Position is read once, the Track and Hold Latch for channel %d will be reset to 0.\n", channel, channel);
printf("Press enter when you are ready to continue. This will read the Position for all channels, which will reset\n");
printf("the Track and Hold Latch for all channels.");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
break;
default:
printf("\nInvalid selection entered\n");
break;
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_SetTRValue(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
uint32_t trValue = 0u;
naibrd_lvdt_2_wire_t trValueTypeToSet = NAIBRD_LVDT_TWO_WIRE_A;
char strTrValueTypeToSet[8] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Type Transformation Ratio Value type to set (a for A-Side TR Value, b for B-Side TR Value, q for quit): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case 'a':
case 'A':
trValueTypeToSet = NAIBRD_LVDT_TWO_WIRE_A;
sprintf(strTrValueTypeToSet, "A-Side");
break;
case 'b':
case 'B':
trValueTypeToSet = NAIBRD_LVDT_TWO_WIRE_B;
sprintf(strTrValueTypeToSet, "B-Side");
break;
default:
bQuit = TRUE;
printf("\nInvalid selection entered\n");
break;
}
if (!bQuit)
{
if (DisplayAsHex)
{
printf("Type Raw Hex Transformation Ratio %s Value to set: 0x", strTrValueTypeToSet);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
trValue = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (trValue == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetTRValue(cardIndex, module, channel, trValueTypeToSet, trValue));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetTRValue(cardIndex, module, channel, trValueTypeToSet, trValue));
}
}
}
else
{
printf("Type Transformation Ratio %s Value to set: ", strTrValueTypeToSet);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
trValue = (uint32_t)strtoul((const char*)inputBuffer, NULL, 10);
if (trValue == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetTRValue(cardIndex, module, channel, trValueTypeToSet, trValue));
}
else
{
printf("\nInvalid Transformation Ratio Value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetTRValue(cardIndex, module, channel, trValueTypeToSet, trValue));
}
}
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_SetSignalInversion(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
naibrd_lvdt_signal_inversion_type_t sigType = NAIBRD_LVDT_SIGNAL_INV_VA;
char strSigType[10] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("*Note: If the signal inversion control for Va-Vb is set to non-inverted, the algorithm used for position measurement is ");
printf("(Va - Vb) / (Va + Vb), and if the signal inversion control for Va-Vb is set to inverted, the algorithm used for position ");
printf("measurement is (Vb - Va) / (Va + Vb).\n");
printf("Select Signal Type to set signal inversion control for (0 for Va, 1 for Vb, 2 for Reference, 3 for Va-Vb, q for quit): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
sigType = NAIBRD_LVDT_SIGNAL_INV_VA;
sprintf(strSigType, "Va");
break;
case '1':
sigType = NAIBRD_LVDT_SIGNAL_INV_VB;
sprintf(strSigType, "Vb");
break;
case '2':
sigType = NAIBRD_LVDT_SIGNAL_INV_REF;
sprintf(strSigType, "Reference");
break;
case '3':
sigType = NAIBRD_LVDT_SIGNAL_INV_DIFF;
sprintf(strSigType, "Va-Vb");
break;
default:
bQuit = TRUE;
printf("\nInvalid signal type entered\n");
break;
}
if (!bQuit)
{
printf("\nDo you want to set the signal inversion control for the %s signal to inverted or non-inverted? ", strSigType);
printf("(1 for inverted, 0 for non-inverted): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
switch (sigType)
{
case NAIBRD_LVDT_SIGNAL_INV_VA:
check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_NON_INVERTED_VA));
break;
case NAIBRD_LVDT_SIGNAL_INV_VB:
check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_NON_INVERTED_VB));
break;
case NAIBRD_LVDT_SIGNAL_INV_REF:
check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_NON_INVERTED_REF));
break;
case NAIBRD_LVDT_SIGNAL_INV_DIFF:
check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_DIFF_VA_VB));
break;
}
break;
case '1':
switch (sigType)
{
case NAIBRD_LVDT_SIGNAL_INV_VA:
check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_INVERTED_VA));
break;
case NAIBRD_LVDT_SIGNAL_INV_VB:
check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_INVERTED_VB));
break;
case NAIBRD_LVDT_SIGNAL_INV_REF:
check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_INVERTED_REF));
break;
case NAIBRD_LVDT_SIGNAL_INV_DIFF:
check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_DIFF_VB_VA));
break;
}
break;
default:
bQuit = TRUE;
printf("\nInvalid selection entered\n");
break;
}
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;;
}
static nai_status_t LVDTBasicMenu_ThresholdMenu(int32_t paramCount, int32_t* p_params)
{
int32_t chan = 0;
float64_t sigThreshold = 0.0, refThreshold = 0.0, sigHiThres = 0.0, refHiThres = 0.0, openThreshold = 0.0, shortThreshold = 0.0;
bool_t bQuit = FALSE;
bool_t bContinue = TRUE;
int sigOrRef = 0;
float64_t threshold = 0;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
while (bQuit == FALSE)
{
bContinue = TRUE;
printf("\n\n==========================================================================================\n");
printf("%7s%13s%13s%14s%14s%14s%15s\n", "Chan", "SigLoThresh", "RefLoThresh", "SigHiThresh", "RefHiThresh", "OpenThresh", "ShortThresh");
for( chan = 1; chan <= 4; chan++)
{
check_status(naibrd_LVDT_GetSigLossThreshold(cardIndex, module, chan, &sigThreshold));
check_status(naibrd_LVDT_GetRefLossThreshold(cardIndex, module, chan, &refThreshold));
check_status(naibrd_LVDT_GetThreshold(cardIndex, module, chan, NAIBRD_LVDT_SIG_FAULT_HI_THRESHOLD, &sigHiThres));
check_status(naibrd_LVDT_GetThreshold(cardIndex, module, chan, NAIBRD_LVDT_REF_FAULT_HI_THRESHOLD, &refHiThres));
check_status(naibrd_LVDT_GetOpenThreshold(cardIndex, module, chan, &openThreshold));
check_status(naibrd_LVDT_GetShortThreshold(cardIndex, module, chan, &shortThreshold));
printf("%4d", chan);
printf(" %15.4f %12.4f %13.4f %13.4f %13.4f %14.4f\n", sigThreshold, refThreshold, sigHiThres, refHiThres, openThreshold, shortThreshold);
}
printf("\nSelect threshold type to change for channel %d (0 for signal low, 1 for reference low, 2 for signal high, 3 for reference high, 4 for open, 5 for short, q for quit): ", channel);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if((!bQuit) && (inputResponseCnt > 0))
{
if (inputBuffer[0] == '0')
{
sigOrRef = 0;
}
else if (inputBuffer[0] == '1')
{
sigOrRef = 1;
}
else if (inputBuffer[0] == '2')
{
sigOrRef = 2;
}
else if (inputBuffer[0] == '3')
{
sigOrRef = 3;
}
else if (inputBuffer[0] == '4')
{
sigOrRef = 4;
}
else if (inputBuffer[0] == '5')
{
sigOrRef = 5;
}
else
{
bContinue = FALSE;
}
if (bContinue)
{
printf("Enter a threshold: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
threshold = atof((const char*)inputBuffer);
if (threshold > 0)
{
if(sigOrRef == 0)
check_status(naibrd_LVDT_SetSigLossThreshold(cardIndex, module, channel, threshold));
else if (sigOrRef == 1)
check_status(naibrd_LVDT_SetRefLossThreshold(cardIndex, module, channel, threshold));
else if (sigOrRef == 2)
check_status(naibrd_LVDT_SetThreshold(cardIndex, module, channel, NAIBRD_LVDT_SIG_FAULT_HI_THRESHOLD, threshold));
else if (sigOrRef == 3)
check_status(naibrd_LVDT_SetThreshold(cardIndex, module, channel, NAIBRD_LVDT_REF_FAULT_HI_THRESHOLD, threshold));
else if (sigOrRef == 4)
check_status(naibrd_LVDT_SetOpenThreshold(cardIndex, module, channel, threshold));
else if (sigOrRef == 5)
check_status(naibrd_LVDT_SetShortThreshold(cardIndex, module, channel, threshold));
}
else if (threshold == 0)
{
if (inputBuffer[0] == '0')
{
if(sigOrRef == 0)
check_status(naibrd_LVDT_SetSigLossThreshold(cardIndex, module, channel, threshold));
else if (sigOrRef == 1)
check_status(naibrd_LVDT_SetRefLossThreshold(cardIndex, module, channel, threshold));
else if (sigOrRef == 2)
check_status(naibrd_LVDT_SetThreshold(cardIndex, module, channel, NAIBRD_LVDT_SIG_FAULT_HI_THRESHOLD, threshold));
else if (sigOrRef == 3)
check_status(naibrd_LVDT_SetThreshold(cardIndex, module, channel, NAIBRD_LVDT_REF_FAULT_HI_THRESHOLD, threshold));
else if (sigOrRef == 4)
check_status(naibrd_LVDT_SetOpenThreshold(cardIndex, module, channel, threshold));
else if (sigOrRef == 5)
check_status(naibrd_LVDT_SetShortThreshold(cardIndex, module, channel, threshold));
}
else
{
printf("Invalid Threshold Entered\n");
}
}
else
{
printf("Invalid Threshold Entered\n");
}
}
}
}
}
return NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_FloatingPointMenu(int32_t paramCount, int32_t* p_params)
{
bool_t floatModeEnabled = FALSE;
int32_t chan = 0;
int32_t maxChannel = 0;
float64_t positionAOffset = 0.0, positionBOffset = 0.0, positionAScale = 0.0, positionBScale = 0.0;
float64_t velocityAOffset = 0.0, velocityBOffset = 0.0, velocityAScale = 0.0, velocityBScale = 0.0;
uint32_t attributeTypeToSet = 0u;
bool_t bQuit = FALSE;
bool_t bExit = FALSE;
float64_t valueToSet = 0.0;
char strFloatModeEnabled[10] = "";
char strAttributeType[20] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
uint32_t modId = LVDT_params->modId;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
maxChannel = naibrd_LVDT_GetChannelCount(modId);
while (bQuit == FALSE)
{
printf("====================================================================================================\n");
printf("%4s%12s%12s%12s%12s%12s%12s%12s%12s\n", "Chan", "Position A", "Position A", "Position B", "Position B", "Velocity A", "Velocity A", "Velocity B", "Velocity B");
printf("%4s%9s%13s%11s%13s%11s%13s%11s%13s\n", "", "Scale", "Offset", "Scale", "Offset", "Scale", "Offset", "Scale", "Offset");
printf("----------------------------------------------------------------------------------------------------\n");
for (chan = 1; chan <= maxChannel; chan++)
{
check_status(naibrd_LVDT_GetFloatingPointPositionScale(cardIndex, module, chan, NAIBRD_LVDT_TWO_WIRE_A, &positionAScale));
check_status(naibrd_LVDT_GetFloatingPointPositionOffset(cardIndex, module, chan, NAIBRD_LVDT_TWO_WIRE_A, &positionAOffset));
check_status(naibrd_LVDT_GetFloatingPointPositionScale(cardIndex, module, chan, NAIBRD_LVDT_TWO_WIRE_B, &positionBScale));
check_status(naibrd_LVDT_GetFloatingPointPositionOffset(cardIndex, module, chan, NAIBRD_LVDT_TWO_WIRE_B, &positionBOffset));
check_status(naibrd_LVDT_GetFloatingPointVelocityScale(cardIndex, module, chan, NAIBRD_LVDT_TWO_WIRE_A, &velocityAScale));
check_status(naibrd_LVDT_GetFloatingPointVelocityOffset(cardIndex, module, chan, NAIBRD_LVDT_TWO_WIRE_A, &velocityAOffset));
check_status(naibrd_LVDT_GetFloatingPointVelocityScale(cardIndex, module, chan, NAIBRD_LVDT_TWO_WIRE_B, &velocityBScale));
check_status(naibrd_LVDT_GetFloatingPointVelocityOffset(cardIndex, module, chan, NAIBRD_LVDT_TWO_WIRE_B, &velocityBOffset));
printf("%2d", chan);
printf("%14.4f%12.4f%12.4f%12.4f%12.4f%12.4f%12.4f%12.4f\n", positionAScale, positionAOffset, positionBScale, positionBOffset,
velocityAScale, velocityAOffset, velocityBScale, velocityBOffset);
}
check_status(naibrd_GetFloatingPointModeEnable(cardIndex, module, &floatModeEnabled));
switch (floatModeEnabled)
{
case FALSE:
sprintf(strFloatModeEnabled, "DISABLED");
break;
case TRUE:
sprintf(strFloatModeEnabled, "ENABLED ");
break;
default:
sprintf(strFloatModeEnabled, "UNKNOWN ");
break;
}
printf("Floating-Point Mode: %s\n\n", strFloatModeEnabled);
printf("\nDo you want to enable/disable floating-point mode, set floating-point attributes, or refresh the display? (0 for mode, 1 for attributes, q for quit, anything else to refresh the display): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0) && ((inputBuffer[0] == '0') || (inputBuffer[0] == '1')))
{
if (inputBuffer[0] == '1')
{
printf("\nSet Floating-Point Attributes (0 for Position A Scale, 1 for Position A Offset, 2 for Position B Scale, 3 for Position B Offset, ");
printf("4 for Velocity A Scale, 5 for Velocity A Offset, 6 for Velocity B Scale, 7 for Velocity B Offset, anything else to refresh the display): ");
bExit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bExit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
attributeTypeToSet = 0u;
sprintf(strAttributeType, "Position A Scale");
break;
case '1':
attributeTypeToSet = 1u;
sprintf(strAttributeType, "Position A Offset");
break;
case '2':
attributeTypeToSet = 2u;
sprintf(strAttributeType, "Position B Scale");
break;
case '3':
attributeTypeToSet = 3u;
sprintf(strAttributeType, "Position B Offset");
break;
case '4':
attributeTypeToSet = 4u;
sprintf(strAttributeType, "Velocity A Scale");
break;
case '5':
attributeTypeToSet = 5u;
sprintf(strAttributeType, "Velocity A Offset");
break;
case '6':
attributeTypeToSet = 6u;
sprintf(strAttributeType, "Velocity B Scale");
break;
case '7':
attributeTypeToSet = 7u;
sprintf(strAttributeType, "Velocity B Offset");
break;
default:
bExit = TRUE;
break;
}
if (!bExit)
{
printf("\nEnter %s value to set: ", strAttributeType);
bExit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bExit) && (inputResponseCnt > 0))
{
valueToSet = atof((const char*)inputBuffer);
if (valueToSet == 0.0)
{
if (inputBuffer[0] == '0')
{
switch (attributeTypeToSet)
{
case 0u:
check_status(naibrd_LVDT_SetFloatingPointPositionScale(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_A, valueToSet));
break;
case 1u:
check_status(naibrd_LVDT_SetFloatingPointPositionOffset(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_A, valueToSet));
break;
case 2u:
check_status(naibrd_LVDT_SetFloatingPointPositionScale(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, valueToSet));
break;
case 3u:
check_status(naibrd_LVDT_SetFloatingPointPositionOffset(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, valueToSet));
break;
case 4u:
check_status(naibrd_LVDT_SetFloatingPointVelocityScale(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_A, valueToSet));
break;
case 5u:
check_status(naibrd_LVDT_SetFloatingPointVelocityOffset(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_A, valueToSet));
break;
case 6u:
check_status(naibrd_LVDT_SetFloatingPointVelocityScale(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, valueToSet));
break;
case 7u:
check_status(naibrd_LVDT_SetFloatingPointVelocityOffset(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, valueToSet));
break;
}
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
switch (attributeTypeToSet)
{
case 0u:
check_status(naibrd_LVDT_SetFloatingPointPositionScale(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_A, valueToSet));
break;
case 1u:
check_status(naibrd_LVDT_SetFloatingPointPositionOffset(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_A, valueToSet));
break;
case 2u:
check_status(naibrd_LVDT_SetFloatingPointPositionScale(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, valueToSet));
break;
case 3u:
check_status(naibrd_LVDT_SetFloatingPointPositionOffset(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, valueToSet));
break;
case 4u:
check_status(naibrd_LVDT_SetFloatingPointVelocityScale(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_A, valueToSet));
break;
case 5u:
check_status(naibrd_LVDT_SetFloatingPointVelocityOffset(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_A, valueToSet));
break;
case 6u:
check_status(naibrd_LVDT_SetFloatingPointVelocityScale(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, valueToSet));
break;
case 7u:
check_status(naibrd_LVDT_SetFloatingPointVelocityOffset(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, valueToSet));
break;
}
}
}
}
}
}
else
{
printf("\nEnable or Disable floating-point mode? (0 to disable, 1 to enable, anything else to refresh the display): ");
bExit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bExit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
check_status(naibrd_SetFloatingPointModeEnable(cardIndex, module, FALSE));
break;
case '1':
check_status(naibrd_SetFloatingPointModeEnable(cardIndex, module, TRUE));
break;
}
}
}
}
}
return NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_TestMenu(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
bool_t bCmdFound = FALSE;
int32_t cmd = 0;
float64_t testPosition = 0.0;
uint32_t testPositionRaw = 0u;
bool_t d0TestEnabled = FALSE;
bool_t d3TestEnabled = FALSE;
bool_t pBitComplete = 0u;
uint32_t bitStatusRealtime = 0u;
uint32_t bitStatusLatched = 0u;
float64_t bitErrorLimit = 0.0;
uint32_t bitErrorLimitRaw = 0u;
int32_t channelCount = 0;
char strD0TestEnabled[10] = "";
char strD3TestEnabled[10] = "";
char strPBITComplete[15] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
uint32_t modId = LVDT_params->modId;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
channelCount = naibrd_LVDT_GetChannelCount(modId);
naiapp_utils_LoadParamMenuCommands(LVDT_TESTMENU_CMD_COUNT, LVDT_TestMenuCmds);
do
{
printf("\n\n =============================== \n");
printf(" Chan BIT Status BIT Error\n");
printf(" (R/L) Limit\n");
printf(" -------------------------------\n");
for (channel = 1; channel <= channelCount; channel++)
{
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_BIT_REALTIME, &bitStatusRealtime));
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_STATUS_BIT_LATCHED, &bitStatusLatched));
if (DisplayAsHex)
{
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_BIT_ERROR_LIMIT, &bitErrorLimitRaw));
printf(" %2d (%1d/%1d) 0x%08X\n", channel, bitStatusRealtime, bitStatusLatched, bitErrorLimitRaw);
}
else
{
check_status(naibrd_LVDT_GetBITErrorLimit(cardIndex, module, channel, &bitErrorLimit));
printf(" %2d (%1d/%1d) %12.4f\n", channel, bitStatusRealtime, bitStatusLatched, bitErrorLimit);
}
}
if (DisplayAsHex)
{
check_status(naibrd_LVDT_GetRaw(cardIndex, module, NAI_LVDT_RAW_TEST_POSITION, &testPositionRaw));
}
else
{
check_status(naibrd_LVDT_GetTestPosition(cardIndex, module, &testPosition));
}
check_status(naibrd_LVDT_GetModuleBITEnable(cardIndex, module, NAI_LVDT_TEST_ENABLE_D0, &d0TestEnabled));
switch (d0TestEnabled)
{
case TRUE:
sprintf(strD0TestEnabled, "ENABLED ");
break;
case FALSE:
sprintf(strD0TestEnabled, "DISABLED");
break;
default:
sprintf(strD0TestEnabled, "UNKNOWN ");
break;
}
check_status(naibrd_LVDT_GetModuleBITEnable(cardIndex, module, NAI_LVDT_TEST_ENABLE_D3, &d3TestEnabled));
switch (d3TestEnabled)
{
case TRUE:
sprintf(strD3TestEnabled, "ENABLED ");
break;
case FALSE:
sprintf(strD3TestEnabled, "DISABLED");
break;
default:
sprintf(strD3TestEnabled, "UNKNOWN ");
break;
}
check_status(naibrd_LVDT_CheckPowerOnBITComplete(cardIndex, module, &pBitComplete));
switch (pBitComplete)
{
case TRUE:
sprintf(strPBITComplete, "COMPLETED");
break;
case FALSE:
sprintf(strPBITComplete, "NOT COMPLETED");
break;
default:
sprintf(strPBITComplete, "UNKNOWN");
break;
}
if (DisplayAsHex)
{
printf("\nTest Position Raw Hex Value: 0x%08X\n", testPositionRaw);
}
else
{
printf("\nTest Position: %-16.8f\n", testPosition);
}
printf("D0 Test (UBIT) Enabled/Disabled: %s\n", strD0TestEnabled);
printf("D3 Test (IBIT) Enabled/Disabled: %s\n", strD3TestEnabled);
printf("Power-On BIT Complete: %s\n", strPBITComplete);
naiapp_display_ParamMenuCommands((int8_t*)"LVDT Test Menu");
printf("\n Type command or %c to quit : ", NAI_QUIT_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound)
{
if (cmd == LVDT_TESTMENU_CMD_DISPLAY_CONVERTED)
{
DisplayAsHex = FALSE;
}
else if (cmd == LVDT_TESTMENU_CMD_DISPLAY_HEX)
{
DisplayAsHex = TRUE;
}
else if ((cmd == LVDT_TESTMENU_CMD_CLEAR_BIT_STATUS) || (cmd == LVDT_TESTMENU_CMD_SET_BIT_ERROR_LIMIT))
{
naiapp_query_ChannelNumber(channelCount, 1, &LVDT_params->channel);
LVDT_TestMenuCmds[cmd].func(paramCount, p_params);
}
else
{
LVDT_TestMenuCmds[cmd].func(paramCount, p_params);
}
}
else
{
printf(" Invalid command entered\n");
}
}
} while (!bQuit);
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTBasicMenu_InterruptMenu(int32_t paramCount, int32_t* p_params)
{
int32_t channelCount = 0;
bool_t bCmdFound = FALSE;
bool_t bQuit = FALSE;
int32_t cmd = 0;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
uint32_t modId = LVDT_params->modId;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
channelCount = naibrd_LVDT_GetChannelCount(modId);
naiapp_utils_LoadParamMenuCommands(LVDT_INTERRUPTMENU_CMD_COUNT, LVDT_InterruptMenuCmds);
do
{
LVDTBasicMenu_DisplayInterruptData(cardIndex, module, modId);
naiapp_display_ParamMenuCommands((int8_t*)"LVDT Interrupt Menu");
printf("\n Type command or %c to quit : ", NAI_QUIT_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound)
{
if ((cmd == LVDT_INTERRUPTMENU_CMD_SET_INTERRUPT_ENABLE) || (cmd == LVDT_INTERRUPTMENU_CMD_SET_EDGE_LEVEL_INTERRUPT))
{
naiapp_query_ChannelNumber(channelCount, 1, &LVDT_params->channel);
LVDT_InterruptMenuCmds[cmd].func(paramCount, p_params);
}
else
{
LVDT_InterruptMenuCmds[cmd].func(paramCount, p_params);
}
}
else
{
printf(" Invalid command entered\n");
}
}
} while (!bQuit);
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static void LVDTBasicMenu_DisplayInterruptData(int32_t cardIndex, int32_t module, uint32_t modid)
{
int32_t channelCount = 0;
nai_lvdt_enable_t intEnable = 0u;
nai_lvdt_interrupt_t edgeLevelInt = 0u;
int32_t channel = 0;
uint32_t intVector = 0u;
naibrd_int_steering_t intSteering = 0;
char strIntEnable[10] = "";
char strEdgeLevelInt[8] = "";
char strIntSteering[48] = "";
channelCount = naibrd_LVDT_GetChannelCount(modid);
printf("\n\n ==== ======== BIT ======== ==== Signal Low ===== ==== Signal High ==== ====== Ref Low ====== ===== Ref High ======\n");
printf(" Chan Interrupt Edge/Level Interrupt Edge/Level Interrupt Edge/Level Interrupt Edge/Level Interrupt Edge/Level\n");
printf(" Enable Interrupt Enable Interrupt Enable Interrupt Enable Interrupt Enable Interrupt\n");
printf(" ---- --------------------- --------------------- --------------------- --------------------- ---------------------\n");
for (channel = 1; channel <= channelCount; channel++)
{
printf(" %2d ", channel);
check_status(naibrd_LVDT_GetInterruptEnable(cardIndex, module, channel, NAI_LVDT_STATUS_BIT_LATCHED, &intEnable));
switch (intEnable)
{
case NAI_LVDT_STATE_DISABLED:
sprintf(strIntEnable, "Disabled");
break;
case NAI_LVDT_STATE_ENABLED:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEdgeLevelInterrupt(cardIndex, module, channel, NAI_LVDT_STATUS_BIT_LATCHED, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetInterruptEnable(cardIndex, module, channel, NAI_LVDT_STATUS_SIGNAL_LOW_LATCHED, &intEnable));
switch (intEnable)
{
case NAI_LVDT_STATE_DISABLED:
sprintf(strIntEnable, "Disabled");
break;
case NAI_LVDT_STATE_ENABLED:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEdgeLevelInterrupt(cardIndex, module, channel, NAI_LVDT_STATUS_SIGNAL_LOW_LATCHED, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetInterruptEnable(cardIndex, module, channel, NAI_LVDT_STATUS_SIGNAL_HIGH_LATCHED, &intEnable));
switch (intEnable)
{
case NAI_LVDT_STATE_DISABLED:
sprintf(strIntEnable, "Disabled");
break;
case NAI_LVDT_STATE_ENABLED:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEdgeLevelInterrupt(cardIndex, module, channel, NAI_LVDT_STATUS_SIGNAL_HIGH_LATCHED, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetInterruptEnable(cardIndex, module, channel, NAI_LVDT_STATUS_REF_LOW_LATCHED, &intEnable));
switch (intEnable)
{
case NAI_LVDT_STATE_DISABLED:
sprintf(strIntEnable, "Disabled");
break;
case NAI_LVDT_STATE_ENABLED:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEdgeLevelInterrupt(cardIndex, module, channel, NAI_LVDT_STATUS_REF_LOW_LATCHED, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetInterruptEnable(cardIndex, module, channel, NAI_LVDT_STATUS_REF_HIGH_LATCHED, &intEnable));
switch (intEnable)
{
case NAI_LVDT_STATE_DISABLED:
sprintf(strIntEnable, "Disabled");
break;
case NAI_LVDT_STATE_ENABLED:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEdgeLevelInterrupt(cardIndex, module, channel, NAI_LVDT_STATUS_REF_HIGH_LATCHED, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s\n", strIntEnable, strEdgeLevelInt);
}
check_status(naibrd_LVDT_GetInterruptVector(cardIndex, module, NAI_LVDT_STATUS_BIT_LATCHED, &intVector));
printf("\nBIT Interrupt Vector: 0x%08X, ", intVector);
check_status(naibrd_LVDT_GetInterruptSteering(cardIndex, module, NAI_LVDT_STATUS_BIT_LATCHED, &intSteering));
switch (intSteering)
{
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME:
sprintf(strIntSteering, "VME Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0:
sprintf(strIntSteering, "On Board 0 (Custom Application on ARM)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1:
sprintf(strIntSteering, "On Board 1 (NAI Ethernet Listener Application)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2:
sprintf(strIntSteering, "On Board 2");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP:
sprintf(strIntSteering, "PCIe Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP:
sprintf(strIntSteering, "CPCI Bus");
break;
default:
sprintf(strIntSteering, "Unknown");
break;
}
printf("BIT Interrupt Steering: %s\n", strIntSteering);
check_status(naibrd_LVDT_GetInterruptVector(cardIndex, module, NAI_LVDT_STATUS_SIGNAL_LOW_LATCHED, &intVector));
printf("Signal Low Interrupt Vector: 0x%08X, ", intVector);
check_status(naibrd_LVDT_GetInterruptSteering(cardIndex, module, NAI_LVDT_STATUS_SIGNAL_LOW_LATCHED, &intSteering));
switch (intSteering)
{
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME:
sprintf(strIntSteering, "VME Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0:
sprintf(strIntSteering, "On Board 0 (Custom Application on ARM)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1:
sprintf(strIntSteering, "On Board 1 (NAI Ethernet Listener Application)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2:
sprintf(strIntSteering, "On Board 2");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP:
sprintf(strIntSteering, "PCIe Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP:
sprintf(strIntSteering, "CPCI Bus");
break;
default:
sprintf(strIntSteering, "Unknown");
break;
}
printf("Signal Low Interrupt Steering: %s\n", strIntSteering);
check_status(naibrd_LVDT_GetInterruptVector(cardIndex, module, NAI_LVDT_STATUS_SIGNAL_HIGH_LATCHED, &intVector));
printf("Signal High Interrupt Vector: 0x%08X, ", intVector);
check_status(naibrd_LVDT_GetInterruptSteering(cardIndex, module, NAI_LVDT_STATUS_SIGNAL_HIGH_LATCHED, &intSteering));
switch (intSteering)
{
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME:
sprintf(strIntSteering, "VME Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0:
sprintf(strIntSteering, "On Board 0 (Custom Application on ARM)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1:
sprintf(strIntSteering, "On Board 1 (NAI Ethernet Listener Application)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2:
sprintf(strIntSteering, "On Board 2");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP:
sprintf(strIntSteering, "PCIe Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP:
sprintf(strIntSteering, "CPCI Bus");
break;
default:
sprintf(strIntSteering, "Unknown");
break;
}
printf("Signal High Interrupt Steering: %s\n", strIntSteering);
check_status(naibrd_LVDT_GetInterruptVector(cardIndex, module, NAI_LVDT_STATUS_REF_LOW_LATCHED, &intVector));
printf("Ref Low Interrupt Vector: 0x%08X, ", intVector);
check_status(naibrd_LVDT_GetInterruptSteering(cardIndex, module, NAI_LVDT_STATUS_REF_LOW_LATCHED, &intSteering));
switch (intSteering)
{
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME:
sprintf(strIntSteering, "VME Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0:
sprintf(strIntSteering, "On Board 0 (Custom Application on ARM)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1:
sprintf(strIntSteering, "On Board 1 (NAI Ethernet Listener Application)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2:
sprintf(strIntSteering, "On Board 2");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP:
sprintf(strIntSteering, "PCIe Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP:
sprintf(strIntSteering, "CPCI Bus");
break;
default:
sprintf(strIntSteering, "Unknown");
break;
}
printf("Ref Low Interrupt Steering: %s\n", strIntSteering);
check_status(naibrd_LVDT_GetInterruptVector(cardIndex, module, NAI_LVDT_STATUS_REF_HIGH_LATCHED, &intVector));
printf("Ref High Interrupt Vector: 0x%08X, ", intVector);
check_status(naibrd_LVDT_GetInterruptSteering(cardIndex, module, NAI_LVDT_STATUS_REF_HIGH_LATCHED, &intSteering));
switch (intSteering)
{
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME:
sprintf(strIntSteering, "VME Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0:
sprintf(strIntSteering, "On Board 0 (Custom Application on ARM)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1:
sprintf(strIntSteering, "On Board 1 (NAI Ethernet Listener Application)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2:
sprintf(strIntSteering, "On Board 2");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP:
sprintf(strIntSteering, "PCIe Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP:
sprintf(strIntSteering, "CPCI Bus");
break;
default:
sprintf(strIntSteering, "Unknown");
break;
}
printf("Ref High Interrupt Steering: %s\n", strIntSteering);
printf("\n\n ==== ======= Open ======== ======= Short ======= == Delta Position === ====== Summary ======\n");
printf(" Chan Interrupt Edge/Level Interrupt Edge/Level Interrupt Edge/Level Interrupt Edge/Level\n");
printf(" Enable Interrupt Enable Interrupt Enable Interrupt Enable Interrupt\n");
printf(" ---- --------------------- --------------------- --------------------- ---------------------\n");
for (channel = 1; channel <= channelCount; channel++)
{
printf(" %2d ", channel);
check_status(naibrd_LVDT_GetInterruptEnable(cardIndex, module, channel, NAI_LVDT_STATUS_OPEN_LATCHED, &intEnable));
switch (intEnable)
{
case NAI_LVDT_STATE_DISABLED:
sprintf(strIntEnable, "Disabled");
break;
case NAI_LVDT_STATE_ENABLED:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEdgeLevelInterrupt(cardIndex, module, channel, NAI_LVDT_STATUS_OPEN_LATCHED, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetInterruptEnable(cardIndex, module, channel, NAI_LVDT_STATUS_SHORT_LATCHED, &intEnable));
switch (intEnable)
{
case NAI_LVDT_STATE_DISABLED:
sprintf(strIntEnable, "Disabled");
break;
case NAI_LVDT_STATE_ENABLED:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEdgeLevelInterrupt(cardIndex, module, channel, NAI_LVDT_STATUS_SHORT_LATCHED, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetInterruptEnable(cardIndex, module, channel, NAI_LVDT_STATUS_DELTA_POS_LATCHED, &intEnable));
switch (intEnable)
{
case NAI_LVDT_STATE_DISABLED:
sprintf(strIntEnable, "Disabled");
break;
case NAI_LVDT_STATE_ENABLED:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEdgeLevelInterrupt(cardIndex, module, channel, NAI_LVDT_STATUS_DELTA_POS_LATCHED, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetInterruptEnable(cardIndex, module, channel, NAI_LVDT_STATUS_SUMMARY_LATCHED, &intEnable));
switch (intEnable)
{
case NAI_LVDT_STATE_DISABLED:
sprintf(strIntEnable, "Disabled");
break;
case NAI_LVDT_STATE_ENABLED:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEdgeLevelInterrupt(cardIndex, module, channel, NAI_LVDT_STATUS_SUMMARY_LATCHED, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s\n", strIntEnable, strEdgeLevelInt);
}
check_status(naibrd_LVDT_GetInterruptVector(cardIndex, module, NAI_LVDT_STATUS_OPEN_LATCHED, &intVector));
printf("\nOpen Interrupt Vector: 0x%08X, ", intVector);
check_status(naibrd_LVDT_GetInterruptSteering(cardIndex, module, NAI_LVDT_STATUS_OPEN_LATCHED, &intSteering));
switch (intSteering)
{
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME:
sprintf(strIntSteering, "VME Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0:
sprintf(strIntSteering, "On Board 0 (Custom Application on ARM)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1:
sprintf(strIntSteering, "On Board 1 (NAI Ethernet Listener Application)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2:
sprintf(strIntSteering, "On Board 2");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP:
sprintf(strIntSteering, "PCIe Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP:
sprintf(strIntSteering, "CPCI Bus");
break;
default:
sprintf(strIntSteering, "Unknown");
break;
}
printf("Open Interrupt Steering: %s\n", strIntSteering);
check_status(naibrd_LVDT_GetInterruptVector(cardIndex, module, NAI_LVDT_STATUS_SHORT_LATCHED, &intVector));
printf("Short Interrupt Vector: 0x%08X, ", intVector);
check_status(naibrd_LVDT_GetInterruptSteering(cardIndex, module, NAI_LVDT_STATUS_SHORT_LATCHED, &intSteering));
switch (intSteering)
{
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME:
sprintf(strIntSteering, "VME Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0:
sprintf(strIntSteering, "On Board 0 (Custom Application on ARM)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1:
sprintf(strIntSteering, "On Board 1 (NAI Ethernet Listener Application)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2:
sprintf(strIntSteering, "On Board 2");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP:
sprintf(strIntSteering, "PCIe Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP:
sprintf(strIntSteering, "CPCI Bus");
break;
default:
sprintf(strIntSteering, "Unknown");
break;
}
printf("Short Interrupt Steering: %s\n", strIntSteering);
check_status(naibrd_LVDT_GetInterruptVector(cardIndex, module, NAI_LVDT_STATUS_DELTA_POS_LATCHED, &intVector));
printf("Delta Position Interrupt Vector: 0x%08X, ", intVector);
check_status(naibrd_LVDT_GetInterruptSteering(cardIndex, module, NAI_LVDT_STATUS_DELTA_POS_LATCHED, &intSteering));
switch (intSteering)
{
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME:
sprintf(strIntSteering, "VME Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0:
sprintf(strIntSteering, "On Board 0 (Custom Application on ARM)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1:
sprintf(strIntSteering, "On Board 1 (NAI Ethernet Listener Application)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2:
sprintf(strIntSteering, "On Board 2");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP:
sprintf(strIntSteering, "PCIe Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP:
sprintf(strIntSteering, "CPCI Bus");
break;
default:
sprintf(strIntSteering, "Unknown");
break;
}
printf("Delta Position Interrupt Steering: %s\n", strIntSteering);
check_status(naibrd_LVDT_GetInterruptVector(cardIndex, module, NAI_LVDT_STATUS_SUMMARY_LATCHED, &intVector));
printf("Summary Interrupt Vector: 0x%08X, ", intVector);
check_status(naibrd_LVDT_GetInterruptSteering(cardIndex, module, NAI_LVDT_STATUS_SUMMARY_LATCHED, &intSteering));
switch (intSteering)
{
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME:
sprintf(strIntSteering, "VME Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0:
sprintf(strIntSteering, "On Board 0 (Custom Application on ARM)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1:
sprintf(strIntSteering, "On Board 1 (NAI Ethernet Listener Application)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2:
sprintf(strIntSteering, "On Board 2");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP:
sprintf(strIntSteering, "PCIe Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP:
sprintf(strIntSteering, "CPCI Bus");
break;
default:
sprintf(strIntSteering, "Unknown");
break;
}
printf("Summary Interrupt Steering: %s\n", strIntSteering);
}
static nai_status_t LVDTBasicMenu_FIFOMenu(int32_t paramCount, int32_t* p_params)
{
int32_t channelCount = 0;
bool_t bQuit = FALSE;
bool_t bCmdFound = FALSE;
int32_t cmd = 0;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
uint32_t modId = LVDT_params->modId;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
channelCount = naibrd_LVDT_GetChannelCount(modId);
do
{
naiapp_utils_LoadParamMenuCommands(LVDT_FIFOMENU_CMD_COUNT, LVDT_FIFOMenuCmds);
LVDTBasicMenu_DisplayFIFOData(cardIndex, module, modId);
naiapp_display_ParamMenuCommands((int8_t*)"LVDT FIFO Menu");
printf("\n Type command or %c to quit : ", NAI_QUIT_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound)
{
if (cmd == LVDT_FIFOMENU_CMD_DISPLAY_CONVERTED)
{
DisplayAsHex = FALSE;
}
else if (cmd == LVDT_FIFOMENU_CMD_DISPLAY_HEX)
{
DisplayAsHex = TRUE;
}
else
{
if ((cmd != LVDT_FIFOMENU_CMD_SOFTWARE_TRIGGER) && (cmd != LVDT_FIFOMENU_CMD_FIFO_INTERRUPT_MENU))
{
naiapp_query_ChannelNumber(channelCount, 1, &channel);
}
LVDT_FIFOMenuCmds[cmd].func(paramCount, p_params);
}
}
else
{
printf(" Invalid command entered\n");
}
}
} while (!bQuit);
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static void LVDTBasicMenu_DisplayFIFOData(int32_t cardIndex, int32_t module, uint32_t modid)
{
int32_t channel = 0;
int32_t channelCount = 0;
uint32_t fifoCount = 0u;
uint32_t fifoDataRaw = 0u;
uint32_t almostEmptyThres = 0u;
uint32_t lowThres = 0u;
uint32_t highThres = 0u;
uint32_t almostFullThres = 0u;
uint32_t fifoSize = 0u;
uint32_t sampleRateRaw = 0u;
float64_t sampleRate = 0.0;
uint32_t dataType = 0u;
uint32_t delay = 0u;
uint32_t trigMode = 0u;
uint32_t fifoStatusRealtime = 0u, fifoStatusLatched = 0u;
uint32_t emptyRealtime = 0u, almostEmptyRealtime = 0u, lowRealtime = 0u, highRealtime = 0u, almostFullRealtime = 0u, fullRealtime = 0u, doneRealtime = 0u;
uint32_t emptyLatched = 0u, almostEmptyLatched = 0u, lowLatched = 0u, highLatched = 0u, almostFullLatched = 0u, fullLatched = 0u, doneLatched = 0u;
channelCount = naibrd_LVDT_GetChannelCount(modid);
printf("\n\n ==== ====================== ================== Thresholds =================== ============================================================\n");
printf(" Chan Count Data AlmostEmpty Low High AlmostFull Size SampleRate DataType Delay TriggerMode\n");
printf(" ---- ---------------------- ------------------------------------------------- ------------------------------------------------------------\n");
for (channel = 1; channel <= channelCount; channel++)
{
check_status(naibrd_LVDT_GetFIFOValue(cardIndex, module, channel, &fifoDataRaw));
check_status(naibrd_LVDT_GetFIFOCount(cardIndex, module, channel, &fifoCount));
check_status(naibrd_LVDT_GetFIFOAlmostEmptyThreshold(cardIndex, module, channel, &almostEmptyThres));
check_status(naibrd_LVDT_GetFIFOLoThreshold(cardIndex, module, channel, &lowThres));
check_status(naibrd_LVDT_GetFIFOHiThreshold(cardIndex, module, channel, &highThres));
check_status(naibrd_LVDT_GetFIFOAlmostFullThreshold(cardIndex, module, channel, &almostFullThres));
check_status(naibrd_LVDT_GetFIFOSize(cardIndex, module, channel, &fifoSize));
if (DisplayAsHex)
{
check_status(naibrd_LVDT_GetFIFOSampleRate(cardIndex, module, channel, &sampleRateRaw));
}
else
{
check_status(naibrd_LVDT_GetFIFOSampleRateValue(cardIndex, module, channel, &sampleRate));
}
check_status(naibrd_LVDT_GetFIFODataType(cardIndex, module, channel, &dataType));
check_status(naibrd_LVDT_GetFIFODelay(cardIndex, module, channel, &delay));
check_status(naibrd_LVDT_GetFIFOTrigMode(cardIndex, module, channel, &trigMode));
if (DisplayAsHex)
{
printf(" %2d 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n", channel, fifoCount,
fifoDataRaw, almostEmptyThres, lowThres, highThres, almostFullThres, fifoSize, sampleRateRaw, dataType, delay, trigMode);
}
else
{
printf(" %2d %10u %10u %10u %10u %10u %10u %10u %11.2f %10u %10u %10u\n", channel, fifoCount, fifoDataRaw,
almostEmptyThres, lowThres, highThres, almostFullThres, fifoSize, sampleRate, dataType, delay, trigMode);
}
}
printf("\n\n");
printf(" ==== ========================== Statuses ===========================\n");
printf(" Chan Empty AlmostEmpty Low High AlmostFull Full SampleDone\n");
printf(" (R/L) (R/L) (R/L) (R/L) (R/L) (R/L) (R/L) \n");
printf(" ---- ---------------------------------------------------------------\n");
for (channel = 1; channel <= channelCount; channel++)
{
check_status(naibrd_LVDT_GetFIFORealtimeStatus(cardIndex, module, channel, &fifoStatusRealtime));
check_status(naibrd_LVDT_GetFIFOLatchedStatus(cardIndex, module, channel, &fifoStatusLatched));
/* Empty Status is Bit 0 */
emptyRealtime = fifoStatusRealtime & 0x1u;
emptyLatched = fifoStatusLatched & 0x1u;
/* Almost Empty Status is Bit 1 */
almostEmptyRealtime = (fifoStatusRealtime >> 1) & 0x1u;
almostEmptyLatched = (fifoStatusLatched >> 1) & 0x1u;
/* Low Watermark Status is Bit 2 */
lowRealtime = (fifoStatusRealtime >> 2) & 0x1u;
lowLatched = (fifoStatusLatched >> 2) & 0x1u;
/* High Watermark Status is Bit 3 */
highRealtime = (fifoStatusRealtime >> 3) & 0x1u;
highLatched = (fifoStatusLatched >> 3) & 0x1u;
/* Almost Full Status is Bit 4 */
almostFullRealtime = (fifoStatusRealtime >> 4) & 0x1u;
almostFullLatched = (fifoStatusLatched >> 4) & 0x1u;
/* Full Status is Bit 5 */
fullRealtime = (fifoStatusRealtime >> 5) & 0x1u;
fullLatched = (fifoStatusLatched >> 5) & 0x1u;
/* Sample Done Status is Bit 6 */
doneRealtime = (fifoStatusRealtime >> 6) & 0x1u;
doneLatched = (fifoStatusLatched >> 6) & 0x1u;
printf(" %2d (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d)\n", channel, emptyRealtime,
emptyLatched, almostEmptyRealtime, almostEmptyLatched, lowRealtime, lowLatched, highRealtime, highLatched, almostFullRealtime,
almostFullLatched, fullRealtime, fullLatched, doneRealtime, doneLatched);
}
}
static nai_status_t LVDTBasicMenu_AdvancedOptionsMenu(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
int32_t chan = 0;
bool_t isHex = FALSE;
float64_t detectVa = 0, detectVb = 0;
uint32_t detectVaRaw = 0, detectVbRaw = 0;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
do
{
printf("================================\n");
printf("%7s%12s%12s\n", "Chan", "Va Detect", "Vb Detect");
for (chan = 1; chan <= 4; chan++)
{
if (!isHex)
{
naibrd_LVDT_GetVaSignal(cardIndex, module, chan, NAI_LVDT_SIGNAL_DETECT, &detectVa);
naibrd_LVDT_GetVbSignal(cardIndex, module, chan, NAI_LVDT_SIGNAL_DETECT, &detectVb);
printf("%4d%15.4f%12.4f\n", chan, detectVa, detectVb);
}
else
{
naibrd_LVDT_GetChannelRaw(cardIndex, module, chan, NAI_LVDT_CHAN_RAW_DETECT_VA, &detectVaRaw);
naibrd_LVDT_GetChannelRaw(cardIndex, module, chan, NAI_LVDT_CHAN_RAW_DETECT_VB, &detectVbRaw);
printf("%4d 0x%08X 0x%08X\n", chan, detectVaRaw, detectVbRaw);
}
}
printf("\nDisplay Advanced Values (1 for decimal, 2 for hex, q for quit)?: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
switch(inputBuffer[0])
{
case '1':
isHex = FALSE;
break;
case '2':
isHex = TRUE;
break;
case 'q':
bQuit = TRUE;
break;
}
} while (bQuit == FALSE);
return TRUE;
}
static nai_status_t LVDTTestMenu_ClearBITStatus(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Are you sure you want to clear the Latched BIT status? (Y for Yes or N for No): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0) && (toupper(inputBuffer[0]) == 'Y'))
{
check_status(naibrd_LVDT_ClearStatus(cardIndex, module, channel, NAI_LVDT_STATUS_BIT_LATCHED));
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTTestMenu_SetBITErrorLimit(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
float64_t bitErrorLimit = 0.0;
uint32_t bitErrorLimitRaw = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
if (DisplayAsHex)
{
printf("Type BIT Error Limit Raw Hex value to set: 0x");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
bitErrorLimitRaw = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (bitErrorLimitRaw == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_BIT_ERROR_LIMIT, bitErrorLimitRaw));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetChannelRaw(cardIndex, module, channel, NAI_LVDT_CHAN_RAW_BIT_ERROR_LIMIT, bitErrorLimitRaw));
}
}
}
else
{
printf("Type BIT Error Limit value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
bitErrorLimit = atof((const char*)inputBuffer);
if (bitErrorLimit == 0.0)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetBITErrorLimit(cardIndex, module, channel, bitErrorLimit));
}
else
{
printf("\nInvalid BIT Error Limit entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetBITErrorLimit(cardIndex, module, channel, bitErrorLimit));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTTestMenu_SetTestPosition(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
float64_t testPosition = 0.0;
uint32_t testPositionRaw = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
if (DisplayAsHex)
{
printf("Type Test Position Raw Hex value to set: 0x");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
testPositionRaw = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (testPositionRaw == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetRaw(cardIndex, module, NAI_LVDT_RAW_TEST_POSITION, testPositionRaw));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetRaw(cardIndex, module, NAI_LVDT_RAW_TEST_POSITION, testPositionRaw));
}
}
}
else
{
printf("Type Test Position value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
testPosition = atof((const char*)inputBuffer);
if (testPosition == 0.0)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetTestPosition(cardIndex, module, testPosition));
}
else
{
printf("\nInvalid Test Position entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetTestPosition(cardIndex, module, testPosition));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTTestMenu_SetD0TestEnable(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Enable or Disable D0 Test (0 for disable, 1 for enable): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
check_status(naibrd_LVDT_SetModuleBITEnable(cardIndex, module, NAI_LVDT_TEST_ENABLE_D0, (bool_t)FALSE));
break;
case '1':
check_status(naibrd_LVDT_SetModuleBITEnable(cardIndex, module, NAI_LVDT_TEST_ENABLE_D0, (bool_t)TRUE));
break;
default:
printf("\nInvalid selection entered\n");
break;
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTTestMenu_SetD3TestEnable(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Enable or Disable D3 Test (0 for disable, 1 for enable): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
check_status(naibrd_LVDT_SetModuleBITEnable(cardIndex, module, NAI_LVDT_TEST_ENABLE_D3, (bool_t)FALSE));
break;
case '1':
check_status(naibrd_LVDT_SetModuleBITEnable(cardIndex, module, NAI_LVDT_TEST_ENABLE_D3, (bool_t)TRUE));
break;
default:
printf("\nInvalid selection entered\n");
break;
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTTestMenu_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 LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
uint32_t modId = LVDT_params->modId;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
channelCount = naibrd_LVDT_GetChannelCount(modId);
/* Check to see if PBIT ran for the module. */
printf("Checking if the Power-On BIT test has run...\n");
check_status(naibrd_LVDT_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 (channel = 1; channel <= channelCount; channel++)
{
check_status(naibrd_LVDT_GetStatus(cardIndex, module, channel, NAI_LVDT_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", channel, strBitStatus);
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTInterruptMenu_SetInterruptEnable(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_lvdt_status_type_t statusType = 0u;
char statusTypeStr[18] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Select Status Type to enable/disable interrupts for: (0 for BIT, 1 for Signal Fault Low, 2 for Ref Fault Low, ");
printf("3 for Signal Fault High, 4 for Ref Fault High, 5 for Open, 6 for Short, 7 for Summary, 8 for Delta Position, q for quit): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
statusType = NAI_LVDT_STATUS_BIT_LATCHED;
sprintf(statusTypeStr, "BIT");
break;
case '1':
statusType = NAI_LVDT_STATUS_SIGNAL_LOW_LATCHED;
sprintf(statusTypeStr, "Signal Fault Low");
break;
case '2':
statusType = NAI_LVDT_STATUS_REF_LOW_LATCHED;
sprintf(statusTypeStr, "Ref Fault Low");
break;
case '3':
statusType = NAI_LVDT_STATUS_SIGNAL_HIGH_LATCHED;
sprintf(statusTypeStr, "Signal Fault High");
break;
case '4':
statusType = NAI_LVDT_STATUS_REF_HIGH_LATCHED;
sprintf(statusTypeStr, "Ref Fault High");
break;
case '5':
statusType = NAI_LVDT_STATUS_OPEN_LATCHED;
sprintf(statusTypeStr, "Open");
break;
case '6':
statusType = NAI_LVDT_STATUS_SHORT_LATCHED;
sprintf(statusTypeStr, "Short");
break;
case '7':
statusType = NAI_LVDT_STATUS_SUMMARY_LATCHED;
sprintf(statusTypeStr, "Summary");
break;
case '8':
statusType = NAI_LVDT_STATUS_DELTA_POS_LATCHED;
sprintf(statusTypeStr, "Delta Position");
break;
case 'q':
case 'Q':
bQuit = TRUE;
break;
default:
bQuit = TRUE;
printf("\nInvalid status type entered\n");
break;
}
if (!bQuit)
{
printf("\nDo you want to enable or disable interrupts for the %s status? (1 to enable, 0 to disable): ", statusTypeStr);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
check_status(naibrd_LVDT_SetInterruptEnable(cardIndex, module, channel, statusType, NAI_LVDT_STATE_DISABLED));
break;
case '1':
check_status(naibrd_LVDT_SetInterruptEnable(cardIndex, module, channel, statusType, NAI_LVDT_STATE_ENABLED));
break;
default:
bQuit = TRUE;
printf("\nInvalid selection entered\n");
break;
}
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTInterruptMenu_SetEdgeLevelInterrupt(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_lvdt_status_type_t statusType = 0u;
char statusTypeStr[18] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Select Status Type to set interrupt edge/level trigger type for: (0 for BIT, 1 for Signal Fault Low, 2 for Ref Fault Low, ");
printf("3 for Signal Fault High, 4 for Ref Fault High, 5 for Open, 6 for Short, 7 for Summary, 8 for Delta Position, q for quit): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
statusType = NAI_LVDT_STATUS_BIT_LATCHED;
sprintf(statusTypeStr, "BIT");
break;
case '1':
statusType = NAI_LVDT_STATUS_SIGNAL_LOW_LATCHED;
sprintf(statusTypeStr, "Signal Fault Low");
break;
case '2':
statusType = NAI_LVDT_STATUS_REF_LOW_LATCHED;
sprintf(statusTypeStr, "Ref Fault Low");
break;
case '3':
statusType = NAI_LVDT_STATUS_SIGNAL_HIGH_LATCHED;
sprintf(statusTypeStr, "Signal Fault High");
break;
case '4':
statusType = NAI_LVDT_STATUS_REF_HIGH_LATCHED;
sprintf(statusTypeStr, "Ref Fault High");
break;
case '5':
statusType = NAI_LVDT_STATUS_OPEN_LATCHED;
sprintf(statusTypeStr, "Open");
break;
case '6':
statusType = NAI_LVDT_STATUS_SHORT_LATCHED;
sprintf(statusTypeStr, "Short");
break;
case '7':
statusType = NAI_LVDT_STATUS_SUMMARY_LATCHED;
sprintf(statusTypeStr, "Summary");
break;
case '8':
statusType = NAI_LVDT_STATUS_DELTA_POS_LATCHED;
sprintf(statusTypeStr, "Delta Position");
break;
case 'q':
case 'Q':
bQuit = TRUE;
break;
default:
bQuit = TRUE;
printf("\nInvalid status type entered\n");
break;
}
if (!bQuit)
{
printf("\nSelect interrupt edge/level trigger type to set for the %s status (0 for Edge, 1 for Level): ", statusTypeStr);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
check_status(naibrd_LVDT_SetEdgeLevelInterrupt(cardIndex, module, channel, statusType, NAI_LVDT_EDGE_INTERRUPT));
break;
case '1':
check_status(naibrd_LVDT_SetEdgeLevelInterrupt(cardIndex, module, channel, statusType, NAI_LVDT_LEVEL_INTERRUPT));
break;
default:
bQuit = TRUE;
printf("\nInvalid selection entered\n");
break;
}
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTInterruptMenu_SetInterruptVector(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_lvdt_status_type_t statusType = 0u;
uint32_t vector = 0u;
char statusTypeStr[18] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Select Status Type to set interrupt vector for: (0 for BIT, 1 for Signal Fault Low, 2 for Ref Fault Low, ");
printf("3 for Signal Fault High, 4 for Ref Fault High, 5 for Open, 6 for Short, 7 for Summary, 8 for Delta Position, q for quit): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
statusType = NAI_LVDT_STATUS_BIT_LATCHED;
sprintf(statusTypeStr, "BIT");
break;
case '1':
statusType = NAI_LVDT_STATUS_SIGNAL_LOW_LATCHED;
sprintf(statusTypeStr, "Signal Fault Low");
break;
case '2':
statusType = NAI_LVDT_STATUS_REF_LOW_LATCHED;
sprintf(statusTypeStr, "Ref Fault Low");
break;
case '3':
statusType = NAI_LVDT_STATUS_SIGNAL_HIGH_LATCHED;
sprintf(statusTypeStr, "Signal Fault High");
break;
case '4':
statusType = NAI_LVDT_STATUS_REF_HIGH_LATCHED;
sprintf(statusTypeStr, "Ref Fault High");
break;
case '5':
statusType = NAI_LVDT_STATUS_OPEN_LATCHED;
sprintf(statusTypeStr, "Open");
break;
case '6':
statusType = NAI_LVDT_STATUS_SHORT_LATCHED;
sprintf(statusTypeStr, "Short");
break;
case '7':
statusType = NAI_LVDT_STATUS_SUMMARY_LATCHED;
sprintf(statusTypeStr, "Summary");
break;
case '8':
statusType = NAI_LVDT_STATUS_DELTA_POS_LATCHED;
sprintf(statusTypeStr, "Delta Position");
break;
case 'q':
case 'Q':
bQuit = TRUE;
break;
default:
bQuit = TRUE;
printf("\nInvalid status type entered\n");
break;
}
if (!bQuit)
{
printf("\nType interrupt vector in hex to set for the %s status: 0x", statusTypeStr);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
vector = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (vector == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetInterruptVector(cardIndex, module, statusType, vector));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetInterruptVector(cardIndex, module, statusType, vector));
}
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTInterruptMenu_SetInterruptSteering(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_lvdt_status_type_t statusType = 0u;
char statusTypeStr[18] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Select Status Type to steer interrupts for: (0 for BIT, 1 for Signal Fault Low, 2 for Ref Fault Low, ");
printf("3 for Signal Fault High, 4 for Ref Fault High, 5 for Open, 6 for Short, 7 for Summary, 8 for Delta Position, q for quit): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
statusType = NAI_LVDT_STATUS_BIT_LATCHED;
sprintf(statusTypeStr, "BIT");
break;
case '1':
statusType = NAI_LVDT_STATUS_SIGNAL_LOW_LATCHED;
sprintf(statusTypeStr, "Signal Fault Low");
break;
case '2':
statusType = NAI_LVDT_STATUS_REF_LOW_LATCHED;
sprintf(statusTypeStr, "Ref Fault Low");
break;
case '3':
statusType = NAI_LVDT_STATUS_SIGNAL_HIGH_LATCHED;
sprintf(statusTypeStr, "Signal Fault High");
break;
case '4':
statusType = NAI_LVDT_STATUS_REF_HIGH_LATCHED;
sprintf(statusTypeStr, "Ref Fault High");
break;
case '5':
statusType = NAI_LVDT_STATUS_OPEN_LATCHED;
sprintf(statusTypeStr, "Open");
break;
case '6':
statusType = NAI_LVDT_STATUS_SHORT_LATCHED;
sprintf(statusTypeStr, "Short");
break;
case '7':
statusType = NAI_LVDT_STATUS_SUMMARY_LATCHED;
sprintf(statusTypeStr, "Summary");
break;
case '8':
statusType = NAI_LVDT_STATUS_DELTA_POS_LATCHED;
sprintf(statusTypeStr, "Delta Position");
break;
case 'q':
case 'Q':
bQuit = TRUE;
break;
default:
bQuit = TRUE;
printf("\nInvalid status type entered\n");
break;
}
if (!bQuit)
{
printf("\nSelect direction to steer interrupts for the %s status ", statusTypeStr);
printf("(1 for VME Bus, 2 for On Board 0 (Custom Application on ARM), 3 for On Board 1 (NAI Ethernet Listener Application), ");
printf("4 for On Board 2, 5 for PCIe Bus, 6 for CPCI Bus): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '1':
check_status(naibrd_LVDT_SetInterruptSteering(cardIndex, module, statusType, (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME));
break;
case '2':
check_status(naibrd_LVDT_SetInterruptSteering(cardIndex, module, statusType, (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0));
break;
case '3':
check_status(naibrd_LVDT_SetInterruptSteering(cardIndex, module, statusType, (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1));
break;
case '4':
check_status(naibrd_LVDT_SetInterruptSteering(cardIndex, module, statusType, (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2));
break;
case '5':
check_status(naibrd_LVDT_SetInterruptSteering(cardIndex, module, statusType, (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP));
break;
case '6':
check_status(naibrd_LVDT_SetInterruptSteering(cardIndex, module, statusType, (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP));
break;
default:
bQuit = TRUE;
printf("\nInvalid selection entered\n");
break;
}
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOMenu_SetFIFOThreshold(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
uint32_t threshold = 0u;
uint32_t thresholdTypeToSet = 0u;
char strThresholdTypeToSet[15] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Enter FIFO Threshold type to set (0 for almost empty, 1 for low watermark, 2 for high watermark, 3 for almost full): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
thresholdTypeToSet = 0u;
sprintf(strThresholdTypeToSet, "Almost Empty");
break;
case '1':
thresholdTypeToSet = 1u;
sprintf(strThresholdTypeToSet, "Low Watermark");
break;
case '2':
thresholdTypeToSet = 2u;
sprintf(strThresholdTypeToSet, "High Watermark");
break;
case '3':
thresholdTypeToSet = 3u;
sprintf(strThresholdTypeToSet, "Almost Full");
break;
default:
bQuit = TRUE;
printf("\nInvalid selection entered\n");
break;
}
if (!bQuit)
{
if (DisplayAsHex)
{
printf("Type Raw Hex %s Threshold Value to set: 0x", strThresholdTypeToSet);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
threshold = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (threshold == 0u)
{
if (inputBuffer[0] == '0')
{
switch (thresholdTypeToSet)
{
case 0u:
check_status(naibrd_LVDT_SetFIFOAlmostEmptyThreshold(cardIndex, module, channel, threshold));
break;
case 1u:
check_status(naibrd_LVDT_SetFIFOLoThreshold(cardIndex, module, channel, threshold));
break;
case 2u:
check_status(naibrd_LVDT_SetFIFOHiThreshold(cardIndex, module, channel, threshold));
break;
case 3u:
check_status(naibrd_LVDT_SetFIFOAlmostFullThreshold(cardIndex, module, channel, threshold));
break;
}
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
switch (thresholdTypeToSet)
{
case 0u:
check_status(naibrd_LVDT_SetFIFOAlmostEmptyThreshold(cardIndex, module, channel, threshold));
break;
case 1u:
check_status(naibrd_LVDT_SetFIFOLoThreshold(cardIndex, module, channel, threshold));
break;
case 2u:
check_status(naibrd_LVDT_SetFIFOHiThreshold(cardIndex, module, channel, threshold));
break;
case 3u:
check_status(naibrd_LVDT_SetFIFOAlmostFullThreshold(cardIndex, module, channel, threshold));
break;
}
}
}
}
else
{
printf("Type %s Threshold Value to set: ", strThresholdTypeToSet);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
threshold = (uint32_t)strtoul((const char*)inputBuffer, NULL, 10);
if (threshold == 0u)
{
if (inputBuffer[0] == '0')
{
switch (thresholdTypeToSet)
{
case 0u:
check_status(naibrd_LVDT_SetFIFOAlmostEmptyThreshold(cardIndex, module, channel, threshold));
break;
case 1u:
check_status(naibrd_LVDT_SetFIFOLoThreshold(cardIndex, module, channel, threshold));
break;
case 2u:
check_status(naibrd_LVDT_SetFIFOHiThreshold(cardIndex, module, channel, threshold));
break;
case 3u:
check_status(naibrd_LVDT_SetFIFOAlmostFullThreshold(cardIndex, module, channel, threshold));
break;
}
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
switch (thresholdTypeToSet)
{
case 0u:
check_status(naibrd_LVDT_SetFIFOAlmostEmptyThreshold(cardIndex, module, channel, threshold));
break;
case 1u:
check_status(naibrd_LVDT_SetFIFOLoThreshold(cardIndex, module, channel, threshold));
break;
case 2u:
check_status(naibrd_LVDT_SetFIFOHiThreshold(cardIndex, module, channel, threshold));
break;
case 3u:
check_status(naibrd_LVDT_SetFIFOAlmostFullThreshold(cardIndex, module, channel, threshold));
break;
}
}
}
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOMenu_SetFIFOSize(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
uint32_t fifoSize = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
if (DisplayAsHex)
{
printf("Type Raw Hex FIFO Size setting to set: 0x");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
fifoSize = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (fifoSize == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetFIFOSize(cardIndex, module, channel, fifoSize));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetFIFOSize(cardIndex, module, channel, fifoSize));
}
}
}
else
{
printf("Type FIFO Size setting to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
fifoSize = (uint32_t)strtoul((const char*)inputBuffer, NULL, 10);
if (fifoSize == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetFIFOSize(cardIndex, module, channel, fifoSize));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetFIFOSize(cardIndex, module, channel, fifoSize));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;;
}
static nai_status_t LVDTFIFOMenu_SetFIFODataType(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
uint32_t fifoDataType = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
if (DisplayAsHex)
{
printf("Type Raw Hex FIFO Data Type setting to set: 0x");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
fifoDataType = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (fifoDataType == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetFIFODataType(cardIndex, module, channel, fifoDataType));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetFIFODataType(cardIndex, module, channel, fifoDataType));
}
}
}
else
{
printf("Type FIFO Data Type setting to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
fifoDataType = (uint32_t)strtoul((const char*)inputBuffer, NULL, 10);
if (fifoDataType == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetFIFODataType(cardIndex, module, channel, fifoDataType));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetFIFODataType(cardIndex, module, channel, fifoDataType));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOMenu_SetFIFOSampleRate(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
float64_t sampleRate = 0.0;
uint32_t sampleRateRaw = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
if (DisplayAsHex)
{
printf("Type Raw Hex FIFO Sample Rate Value to set: 0x");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
sampleRateRaw = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (sampleRateRaw == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetFIFOSampleRate(cardIndex, module, channel, sampleRateRaw));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetFIFOSampleRate(cardIndex, module, channel, sampleRateRaw));
}
}
}
else
{
printf("Type FIFO Sample Rate Value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
sampleRate = atof((const char*)inputBuffer);
if (sampleRate == 0.0)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetFIFOSampleRateValue(cardIndex, module, channel, sampleRate));
}
else
{
printf("\nInvalid Sample Rate value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetFIFOSampleRateValue(cardIndex, module, channel, sampleRate));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOMenu_SetFIFODelay(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
uint32_t delay = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
if (DisplayAsHex)
{
printf("Type Raw Hex FIFO Delay setting to set: 0x");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
delay = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (delay == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetFIFODelay(cardIndex, module, channel, delay));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetFIFODelay(cardIndex, module, channel, delay));
}
}
}
else
{
printf("Type FIFO Delay setting to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
delay = (uint32_t)strtoul((const char*)inputBuffer, NULL, 10);
if (delay == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetFIFODelay(cardIndex, module, channel, delay));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetFIFODelay(cardIndex, module, channel, delay));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOMenu_ClearFIFO(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Are you sure you want to clear the FIFO? (Y for Yes, N for No): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0) && (toupper(inputBuffer[0]) == 'Y'))
{
status = check_status(naibrd_LVDT_ClearFIFO(cardIndex, module, channel));
if (status == NAI_SUCCESS)
{
printf("\nFIFO Cleared!\n");
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOMenu_SetFIFOTrigCtrl(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
uint32_t fifoTrigMode = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
if (DisplayAsHex)
{
printf("Type Raw Hex FIFO Trigger Mode setting to set: 0x");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
fifoTrigMode = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (fifoTrigMode == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetFIFOTrigMode(cardIndex, module, channel, fifoTrigMode));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetFIFOTrigMode(cardIndex, module, channel, fifoTrigMode));
}
}
}
else
{
printf("Type FIFO Trigger Mode setting to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
fifoTrigMode = (uint32_t)strtoul((const char*)inputBuffer, NULL, 10);
if (fifoTrigMode == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetFIFOTrigMode(cardIndex, module, channel, fifoTrigMode));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetFIFOTrigMode(cardIndex, module, channel, fifoTrigMode));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOMenu_SoftwareTrigger(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Are you sure you want to trigger the FIFO? (Y for Yes, N for No): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0) && (toupper(inputBuffer[0]) == 'Y'))
{
status = check_status(naibrd_LVDT_SoftwareTrigger(cardIndex, module));
if (status == NAI_SUCCESS)
{
printf("\nFIFO Triggered!\n");
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOMenu_ClearFIFOStatus(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
naibrd_lvdt_event_mapped_status_type_t fifoStatusTypeToClear = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_EMPTY_LATCH;
char strFifoStatusTypeToClear[15] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Select FIFO Latched Status type to clear (0 for empty, 1 for almost empty, 2 for low watermark, 3 for high watermark, ");
printf("4 for almost full, 5 for full, 6 for sample done): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
fifoStatusTypeToClear = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_EMPTY_LATCH;
sprintf(strFifoStatusTypeToClear, "Empty");
break;
case '1':
fifoStatusTypeToClear = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_ALMOST_EMPTY_LATCH;
sprintf(strFifoStatusTypeToClear, "Almost Empty");
break;
case '2':
fifoStatusTypeToClear = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_LOW_THRESHOLD_LATCH;
sprintf(strFifoStatusTypeToClear, "Low Watermark");
break;
case '3':
fifoStatusTypeToClear = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_HIGH_THRESHOLD_LATCH;
sprintf(strFifoStatusTypeToClear, "High Watermark");
break;
case '4':
fifoStatusTypeToClear = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_ALMOST_FULL_LATCH;
sprintf(strFifoStatusTypeToClear, "Almost Full");
break;
case '5':
fifoStatusTypeToClear = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_FULL_LATCH;
sprintf(strFifoStatusTypeToClear, "Full");
break;
case '6':
fifoStatusTypeToClear = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_DONE_LATCH;
sprintf(strFifoStatusTypeToClear, "Sample Done");
break;
default:
bQuit = TRUE;
printf("\nInvalid selection entered\n");
break;
}
if (!bQuit)
{
printf("Are you sure you want to clear the FIFO %s Latched Status? (Y for Yes, N for No): ", strFifoStatusTypeToClear);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0) && (toupper(inputBuffer[0]) == 'Y'))
{
check_status(naibrd_LVDT_ClearEventMappedStatus(cardIndex, module, channel, fifoStatusTypeToClear));
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOMenu_FIFOInterruptMenu(int32_t paramCount, int32_t* p_params)
{
int32_t channelCount = 0;
bool_t bQuit = FALSE;
bool_t bCmdFound = FALSE;
int32_t cmd = 0;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
uint32_t modId = LVDT_params->modId;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
channelCount = naibrd_LVDT_GetChannelCount(modId);
naiapp_utils_LoadParamMenuCommands(LVDT_FIFOINTMENU_CMD_COUNT, LVDT_FIFOInterruptMenuCmds);
do
{
LVDTFIFOMenu_DisplayFIFOInterruptData(cardIndex, module, modId);
naiapp_display_ParamMenuCommands((int8_t*)"LVDT FIFO Interrupt Menu");
printf("\n Type command or %c to quit : ", NAI_QUIT_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound)
{
naiapp_query_ChannelNumber(channelCount, 1, &channel);
LVDT_FIFOInterruptMenuCmds[cmd].func(paramCount, p_params);
}
else
{
printf(" Invalid command entered\n");
}
}
} while (!bQuit);
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static void LVDTFIFOMenu_DisplayFIFOInterruptData(int32_t cardIndex, int32_t module, uint32_t modid)
{
int32_t channel = 0;
int32_t channelCount = 0;
bool_t intEnable = 0u;
nai_lvdt_interrupt_t edgeLevelInt = 0u;
uint32_t intVector = 0u;
naibrd_int_steering_t intSteering = 0;
char strIntEnable[10] = "";
char strEdgeLevelInt[8] = "";
char strIntSteering[48] = "";
channelCount = naibrd_LVDT_GetChannelCount(modid);
printf("\n\n");
printf(" ==== ======= Empty ======= === Almost Empty ==== === Low Watermark === == High Watermark ===\n");
printf(" Chan Interrupt Edge/Level Interrupt Edge/Level Interrupt Edge/Level Interrupt Edge/Level\n");
printf(" Enable Interrupt Enable Interrupt Enable Interrupt Enable Interrupt\n");
printf(" ---- --------------------- --------------------- --------------------- ---------------------\n");
for (channel = 1; channel <= channelCount; channel++)
{
printf(" %2d ", channel);
check_status(naibrd_LVDT_GetEventMappedInterruptEnable(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_EMPTY_LATCH, &intEnable));
switch (intEnable)
{
case (bool_t)FALSE:
sprintf(strIntEnable, "Disabled");
break;
case (bool_t)TRUE:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEventMappedInterruptTriggerType(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_EMPTY_LATCH, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetEventMappedInterruptEnable(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_ALMOST_EMPTY_LATCH, &intEnable));
switch (intEnable)
{
case (bool_t)FALSE:
sprintf(strIntEnable, "Disabled");
break;
case (bool_t)TRUE:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEventMappedInterruptTriggerType(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_ALMOST_EMPTY_LATCH, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetEventMappedInterruptEnable(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_LOW_THRESHOLD_LATCH, &intEnable));
switch (intEnable)
{
case (bool_t)FALSE:
sprintf(strIntEnable, "Disabled");
break;
case (bool_t)TRUE:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEventMappedInterruptTriggerType(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_LOW_THRESHOLD_LATCH, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetEventMappedInterruptEnable(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_HIGH_THRESHOLD_LATCH, &intEnable));
switch (intEnable)
{
case (bool_t)FALSE:
sprintf(strIntEnable, "Disabled");
break;
case (bool_t)TRUE:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEventMappedInterruptTriggerType(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_HIGH_THRESHOLD_LATCH, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s\n", strIntEnable, strEdgeLevelInt);
}
printf("\n\n");
printf(" ==== ==== Almost Full ==== ======= Full ======== ==== Sample Done ====\n");
printf(" Chan Interrupt Edge/Level Interrupt Edge/Level Interrupt Edge/Level\n");
printf(" Enable Interrupt Enable Interrupt Enable Interrupt\n");
printf(" ---- --------------------- --------------------- ---------------------\n");
for (channel = 1; channel <= channelCount; channel++)
{
printf(" %2d ", channel);
check_status(naibrd_LVDT_GetEventMappedInterruptEnable(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_ALMOST_FULL_LATCH, &intEnable));
switch (intEnable)
{
case (bool_t)FALSE:
sprintf(strIntEnable, "Disabled");
break;
case (bool_t)TRUE:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEventMappedInterruptTriggerType(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_ALMOST_FULL_LATCH, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetEventMappedInterruptEnable(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_FULL_LATCH, &intEnable));
switch (intEnable)
{
case (bool_t)FALSE:
sprintf(strIntEnable, "Disabled");
break;
case (bool_t)TRUE:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEventMappedInterruptTriggerType(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_FULL_LATCH, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s ", strIntEnable, strEdgeLevelInt);
check_status(naibrd_LVDT_GetEventMappedInterruptEnable(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_DONE_LATCH, &intEnable));
switch (intEnable)
{
case (bool_t)FALSE:
sprintf(strIntEnable, "Disabled");
break;
case (bool_t)TRUE:
sprintf(strIntEnable, "Enabled ");
break;
default:
sprintf(strIntEnable, "Unknown ");
break;
}
check_status(naibrd_LVDT_GetEventMappedInterruptTriggerType(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_DONE_LATCH, &edgeLevelInt));
switch (edgeLevelInt)
{
case NAI_LVDT_EDGE_INTERRUPT:
sprintf(strEdgeLevelInt, " Edge ");
break;
case NAI_LVDT_LEVEL_INTERRUPT:
sprintf(strEdgeLevelInt, " Level ");
break;
default:
sprintf(strEdgeLevelInt, "Unknown");
break;
}
printf("%8s %7s\n", strIntEnable, strEdgeLevelInt);
}
printf("\n");
for (channel = 1; channel <= channelCount; channel++)
{
check_status(naibrd_LVDT_GetEventMappedInterruptVector(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_CATEGORY_FIFO, &intVector));
printf("FIFO Channel %d Interrupt Vector: 0x%08X, ", channel, intVector);
check_status(naibrd_LVDT_GetEventMappedInterruptSteering(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_CATEGORY_FIFO, &intSteering));
switch (intSteering)
{
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME:
sprintf(strIntSteering, "VME Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0:
sprintf(strIntSteering, "On Board 0 (Custom Application on ARM)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1:
sprintf(strIntSteering, "On Board 1 (NAI Ethernet Listener Application)");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2:
sprintf(strIntSteering, "On Board 2");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP:
sprintf(strIntSteering, "PCIe Bus");
break;
case (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP:
sprintf(strIntSteering, "CPCI Bus");
break;
default:
sprintf(strIntSteering, "Unknown");
break;
}
printf("FIFO Channel %d Interrupt Steering: %s\n", channel, strIntSteering);
}
}
static nai_status_t LVDTFIFOIntMenu_SetFIFOIntEnable(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
naibrd_lvdt_event_mapped_status_type_t statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_EMPTY_LATCH;
char statusTypeStr[15] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Select FIFO Status Type to enable/disable interrupts for (0 for Empty, 1 for Almost Empty, 2 for Low Watermark, ");
printf("3 for High Watermark, 4 for Almost Full, 5 for Full, 6 for Sample Done, q for quit): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_EMPTY_LATCH;
sprintf(statusTypeStr, "Empty");
break;
case '1':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_ALMOST_EMPTY_LATCH;
sprintf(statusTypeStr, "Almost Empty");
break;
case '2':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_LOW_THRESHOLD_LATCH;
sprintf(statusTypeStr, "Low Watermark");
break;
case '3':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_HIGH_THRESHOLD_LATCH;
sprintf(statusTypeStr, "High Watermark");
break;
case '4':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_ALMOST_FULL_LATCH;
sprintf(statusTypeStr, "Almost Full");
break;
case '5':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_FULL_LATCH;
sprintf(statusTypeStr, "Full");
break;
case '6':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_DONE_LATCH;
sprintf(statusTypeStr, "Sample Done");
break;
default:
bQuit = TRUE;
printf("\nInvalid FIFO status type entered\n");
break;
}
if (!bQuit)
{
printf("\nDo you want to enable or disable interrupts for the FIFO %s status? (1 to enable, 0 to disable): ", statusTypeStr);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
check_status(naibrd_LVDT_SetEventMappedInterruptEnable(cardIndex, module, channel, statusType, (bool_t)FALSE));
break;
case '1':
check_status(naibrd_LVDT_SetEventMappedInterruptEnable(cardIndex, module, channel, statusType, (bool_t)TRUE));
break;
default:
bQuit = TRUE;
printf("\nInvalid selection entered\n");
break;
}
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOIntMenu_SetFIFOEdgeLevelInt(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
naibrd_lvdt_event_mapped_status_type_t statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_EMPTY_LATCH;
char statusTypeStr[15] = "";
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("Select FIFO Status Type to set interrupt edge/level trigger type for (0 for Empty, 1 for Almost Empty, 2 for Low Watermark, ");
printf("3 for High Watermark, 4 for Almost Full, 5 for Full, 6 for Sample Done, q for quit): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_EMPTY_LATCH;
sprintf(statusTypeStr, "Empty");
break;
case '1':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_ALMOST_EMPTY_LATCH;
sprintf(statusTypeStr, "Almost Empty");
break;
case '2':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_LOW_THRESHOLD_LATCH;
sprintf(statusTypeStr, "Low Watermark");
break;
case '3':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_HIGH_THRESHOLD_LATCH;
sprintf(statusTypeStr, "High Watermark");
break;
case '4':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_ALMOST_FULL_LATCH;
sprintf(statusTypeStr, "Almost Full");
break;
case '5':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_FULL_LATCH;
sprintf(statusTypeStr, "Full");
break;
case '6':
statusType = NAIBRD_LVDT_EVT_MAP_STATUS_FIFO_DONE_LATCH;
sprintf(statusTypeStr, "Sample Done");
break;
default:
bQuit = TRUE;
printf("\nInvalid FIFO status type entered\n");
break;
}
if (!bQuit)
{
printf("\nSelect interrupt edge/level trigger type to set for the FIFO %s status (0 for Edge, 1 for Level): ", statusTypeStr);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '0':
check_status(naibrd_LVDT_SetEventMappedInterruptTriggerType(cardIndex, module, channel, statusType, NAI_LVDT_EDGE_INTERRUPT));
break;
case '1':
check_status(naibrd_LVDT_SetEventMappedInterruptTriggerType(cardIndex, module, channel, statusType, NAI_LVDT_LEVEL_INTERRUPT));
break;
default:
bQuit = TRUE;
printf("\nInvalid selection entered\n");
break;
}
}
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOIntMenu_SetFIFOIntVector(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
uint32_t vector = 0u;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("\nType interrupt vector in hex to set for the FIFO Channel %d Status: 0x", channel);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
vector = (uint32_t)strtoul((const char*)inputBuffer, NULL, 16);
if (vector == 0u)
{
if (inputBuffer[0] == '0')
{
check_status(naibrd_LVDT_SetEventMappedInterruptVector(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_CATEGORY_FIFO, vector));
}
else
{
printf("\nInvalid value entered\n");
}
}
else
{
check_status(naibrd_LVDT_SetEventMappedInterruptVector(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_CATEGORY_FIFO, vector));
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t LVDTFIFOIntMenu_SetFIFOIntSteering(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = LVDT_params->cardIndex;
int32_t module = LVDT_params->module;
int32_t channel = LVDT_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
printf("\nSelect direction to steer interrupts for the FIFO Channel %d status ", channel);
printf("(1 for VME Bus, 2 for On Board 0 (Custom Application on ARM), 3 for On Board 1 (NAI Ethernet Listener Application), ");
printf("4 for On Board 2, 5 for PCIe Bus, 6 for CPCI Bus): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if ((!bQuit) && (inputResponseCnt > 0))
{
switch (inputBuffer[0])
{
case '1':
check_status(naibrd_LVDT_SetEventMappedInterruptSteering(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_CATEGORY_FIFO, (naibrd_int_steering_t)NAIBRD_INT_STEERING_VME));
break;
case '2':
check_status(naibrd_LVDT_SetEventMappedInterruptSteering(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_CATEGORY_FIFO, (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_0));
break;
case '3':
check_status(naibrd_LVDT_SetEventMappedInterruptSteering(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_CATEGORY_FIFO, (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_1));
break;
case '4':
check_status(naibrd_LVDT_SetEventMappedInterruptSteering(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_CATEGORY_FIFO, (naibrd_int_steering_t)NAIBRD_INT_STEERING_ON_BOARD_2));
break;
case '5':
check_status(naibrd_LVDT_SetEventMappedInterruptSteering(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_CATEGORY_FIFO, (naibrd_int_steering_t)NAIBRD_INT_STEERING_PCIE_APP));
break;
case '6':
check_status(naibrd_LVDT_SetEventMappedInterruptSteering(cardIndex, module, channel, NAIBRD_LVDT_EVT_MAP_CATEGORY_FIFO, (naibrd_int_steering_t)NAIBRD_INT_STEERING_CPCI_APP));
break;
default:
bQuit = TRUE;
printf("\nInvalid selection entered\n");
break;
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}