SG BasicOps
Edit this on GitLab
SG BasicOps Sample Application (SSK 2.x)
Overview
The SG BasicOps sample application demonstrates how to configure and read strain gauge channels using the NAI Software Support Kit (SSK 2.x). It covers excitation voltage setup, bridge configuration, PGA gain, remote sense mode, nominal resistance, gauge factor, Poisson ratio, lead resistance, sample rate, strain thresholds (alarm and alert), imbalance offset, internal bridge completion, standard operations data retrieval, channel status enable/disable, min/max strain reset, and status clearing.
This sample supports the SG1 module type. The application is organized into two sub-menus: Configuration (CFG) and Standard Operations (OPS), each with their own command sets. Both menus support toggling between converted and raw hex display modes. Refer to the SG1 Manual for detailed module specifications.
For the SSK 1.x version, see SG BasicOps (SSK 1.x).
Prerequisites
Before running this sample, make sure you have:
-
An NAI board with an SG1 module installed.
-
SSK 2.x installed on your development host.
-
The sample applications built. Refer to the SSK 2.x Software Development Guide for platform-specific build instructions.
How to Run
Launch the sg_basic_ops executable from your build output directory. On startup the application looks for a configuration file (default_SG_BasicOps.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure a board connection, card index, and module slot. You can save this configuration so that subsequent runs skip the menu and connect automatically. Once connected, a top-level menu lets you select the Configuration or Standard Operations sub-menu.
Board Connection and Module Selection
|
Note
|
This startup sequence is common to all NAI sample applications. The board connection and module selection code shown here is not specific to SG. |
The main() function follows a standard SSK 2.x startup flow:
-
Call
naiapp_RunBoardMenu()to load a saved configuration file (if one exists) or present the interactive board menu. The configuration file (default_SG_BasicOps.txt) is not included with the SSK — it is created when the user saves their connection settings from the board menu. On the first run, the menu will always appear. -
Query the user for a card index with
naiapp_query_CardIndex(). -
Query for a module slot with
naiapp_query_ModuleNumber(). -
Retrieve the module ID with
naibrd_GetModuleName().
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t SG_BasicOps(void)
#else
int32_t main(void)
#endif
{
bool_t bQuit = NAI_FALSE;
int32_t cardIndex = -1;
int32_t module = 0;
int32_t moduleCount = 0;
uint32_t modId = 0u;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(CONFIG_FILE) == NAI_TRUE)
{
while (!bQuit)
{
naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
naibrd_GetModuleCount(cardIndex, &moduleCount);
naiapp_query_ModuleNumber(moduleCount, 1, &module);
naibrd_GetModuleName(cardIndex, module, &modId);
bQuit = SGBasicOps_run(cardIndex, module, modId);
}
naiif_printf("Type the Enter key to exit the program: ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
naiapp_access_CloseAllOpenCards();
return 0;
}
Note the SSK 2.x differences from SSK 1.x in this startup sequence:
-
The VxWorks preprocessor guard uses
NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS(SSK 1.x uses__VXWORKS__). -
The module identifier is retrieved with
naibrd_GetModuleName()(SSK 1.x usesnaibrd_GetModuleID()). -
Boolean constants are
NAI_TRUE/NAI_FALSE(SSK 1.x usesTRUE/FALSE). -
Console output uses
naiif_printf()from the platform abstraction layer (SSK 1.x usesprintf()directly).
|
Important
|
Common connection errors you may encounter at this stage:
|
Program Structure
Entry Point
On standard platforms (Petalinux, DEOS) the entry point is main(). On VxWorks the entry point is SG_BasicOps().
Command Loop
The SGBasicOps_run() function presents the top-level menu with two sub-menus. Each sub-menu loads its own command table and manages its own interaction loop. The back character returns to the parent menu.
| Command | Description |
|---|---|
|
SG Configuration Functions sub-menu |
|
SG Standard Operation Functions sub-menu |
Configuration Sub-Menu
The Configuration sub-menu displays the current channel configuration and provides commands to modify each parameter.
| Command | Description |
|---|---|
|
Retrieve and display current configuration |
|
Set excitation voltage |
|
Set bridge configuration |
|
Set PGA gain |
|
Set remote sense mode |
|
Set nominal resistance |
|
Set gauge factor |
|
Set Poisson ratio |
|
Set lead resistance |
|
Set sample rate |
|
Set strain alarm low threshold |
|
Set strain alert low threshold |
|
Set strain alert high threshold |
|
Set strain alarm high threshold |
|
Set imbalance offset |
|
Enable/disable internal bridge completion |
|
Toggle raw hex display mode |
Key API calls:
-
naibrd_SG_SetExcitation()— sets the excitation voltage. -
naibrd_SG_SetBridgeConfiguration()— sets the Wheatstone bridge configuration. -
naibrd_SG_SetPGAGain()— sets the programmable gain amplifier gain. -
naibrd_SG_SetRemoteDriveSense()— enables or disables remote sense. -
naibrd_SG_SetNominalResistance()— sets the nominal gauge resistance. -
naibrd_SG_SetGaugeFactor()— sets the gauge factor. -
naibrd_SG_SetPoissonRatio()— sets the Poisson ratio. -
naibrd_SG_SetLeadResistance()— sets the lead wire resistance. -
naibrd_SG_SetSampleRate()— sets the measurement sample rate. -
naibrd_SG_SetStrainAlarmLo()/naibrd_SG_SetStrainAlertLo()/naibrd_SG_SetStrainAlertHi()/naibrd_SG_SetStrainAlarmHi()— set strain threshold values. -
naibrd_SG_SetImbalanceOffset()— sets the imbalance offset. -
naibrd_SG_SetBridgeCompletion()— enables/disables internal bridge completion.
Standard Operations Sub-Menu
The Standard Operations sub-menu displays the current operational data including strain readings, min/max strain, and statuses.
| Command | Description |
|---|---|
|
Retrieve and display operational data |
|
Enable or disable channel status reporting |
|
Reset min and max strain values |
|
Clear latched statuses |
|
Toggle raw hex display mode |
Key API calls:
-
naibrd_SG_GetStrain()— reads the current strain measurement. -
naibrd_SG_SetChanStatusEnable()— enables or disables status reporting. -
naibrd_SG_ResetMinMaxStrain()— resets min/max strain tracking. -
naibrd_SG_ClearStatus()— clears latched status bits.
Troubleshooting Reference
| Error / Symptom | Possible Causes | Suggested Resolution |
|---|---|---|
No board found |
Board not powered or not connected |
Verify power and physical connections; check configuration file |
Connection timeout |
Network/bus misconfiguration |
Confirm IP address, subnet, or PCI/PCIe settings |
Invalid card or module index |
Wrong index values entered |
Cards are zero-based, modules are one-based |
Module not present at selected slot |
Slot is empty or contains a different module type |
Use the board menu to verify slot population |
Strain reads zero |
No gauge connected or excitation not configured |
Connect strain gauge; set excitation voltage |
Excitation voltage incorrect |
Wrong value entered |
Check the valid excitation range for your SG1 module |
Imbalance offset too large |
Bridge significantly unbalanced |
Check gauge wiring; adjust imbalance offset |
Strain alarm triggered |
Measured strain exceeds threshold |
Check load conditions; adjust threshold if appropriate |
Bridge completion has no effect |
External bridge completion resistors present |
Remove external completion resistors when using internal completion |
PGA gain causing saturation |
Gain too high for signal level |
Reduce PGA gain to avoid saturating the ADC |
Full Source
The complete source for this sample is provided below for reference. The sections above explain each part in detail.
Full Source — sg_basic_ops.c (SSK 2.x)
/* nailib include files */
#include "nai_libs/nailib/include/naitypes.h"
#include "nai_libs/nailib/include/nailib.h"
#include "nai_libs/nailib/include/nailib_utils.h"
/* naibrd include files */
#include "nai_libs/naibrd/include/naibrd.h"
#include "nai_libs/naibrd/include/functions/naibrd_sg.h"
/* naiif include files */
#include "nai_libs/naiif/include/naiif_stdio.h"
/* Common Sample Program include files */
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_menu.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_query.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_access.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_display.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_utils.h"
/* SG Sample App include files */
#include "nai_sample_apps/naiapp_src/board_modules/sg/sg_common_utils/sg_common_utils.h"
static const int8_t *SAMPLE_PGM_NAME = (const int8_t *)"SG Module Basic Operation Program";
static const int8_t *CONFIG_FILE = (const int8_t *)"default_SG_BasicOps.txt";
/* Function prototypes */
static bool_t SGBasicOps_run(int32_t cardIndex, int32_t module, uint32_t modId);
static nai_status_t SGBasicOps_handleConfiguration(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_handleStandardOperation(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_toggleNumDisplay(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_toggleHexModeOps(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_toggleHexModeConfig(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_displayChannelCfg(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setExcitation(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setRemoteDriveSense(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setBridgeConfig(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setNominalRes(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setGaugeFactor(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setPoissonRatio(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setLeadRes(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setSampleRate(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setStrainAlarmLo(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setStrainAlertLo(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setStrainAlertHi(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setStrainAlarmHi(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setImbalanceOffset(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setBridgeComp(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setPGAGain(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_displayStandardOpsData(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_setChanStatusEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_resetMinMaxStrain(int32_t paramCount, int32_t* p_params);
static nai_status_t SGBasicOps_clearStatus(int32_t paramCount, int32_t* p_params);
static const int32_t DEF_SG_CARD_INDEX = 0;
static const int32_t DEF_SG_MODULE = 1;
static const int32_t DEF_SG_CHANNEL = 1;
/****** Command Table *******/
/* Invariant: enumeration of cmd table starts from 0 and increments by 1 */
enum sg_basicOps_commands
{
SG_BASICOP_CMD_CONFIG,
SG_BASICOP_CMD_STANDARDOPS,
SG_BASICOP_CMD_COUNT
};
enum sg_config_commands
{
SG_GEN5_CONFIG_CMD_READ,
SG_GEN5_CONFIG_CMD_EXCITATION,
SG_GEN5_CONFIG_CMD_BRIDGE_CONFIG,
SG_GEN5_CONFIG_CMD_PGA_GAIN,
SG_GEN5_CONFIG_CMD_REMOTE_SENSE,
SG_GEN5_CONFIG_CMD_NOMINAL_RES,
SG_GEN5_CONFIG_CMD_GAUGE_FACTOR,
SG_GEN5_CONFIG_CMD_POISSON_RATIO,
SG_GEN5_CONFIG_CMD_LEAD_RES,
SG_GEN5_CONFIG_CMD_SAMPLE_RATE,
SG_GEN5_CONFIG_CMD_STRAIN_ALARM_LO,
SG_GEN5_CONFIG_CMD_STRAIN_ALERT_LO,
SG_GEN5_CONFIG_CMD_STRAIN_ALERT_HI,
SG_GEN5_CONFIG_CMD_STRAIN_ALARM_HI,
SG_GEN5_CONFIG_CMD_IMBALANCE_OFFSET,
SG_GEN5_CONFIG_CMD_INTERNAL_BRIDGE_COMPLETION,
SG_GEN5_CONFIG_CMD_TOGGLE_HEX_MODE,
SG_GEN5_CONFIG_CMD_COUNT
};
enum sg_gen5_standard_operations_commands
{
SG_GEN5_STANDARD_OPERATIONS_CMD_READ_DATA,
SG_GEN5_STANDARD_OPERATIONS_CMD_CHAN_STATUS_ENABLE,
SG_GEN5_STANDARD_OPERATIONS_CMD_RESET_MIN_MAX_STRAIN,
SG_GEN5_STANDARD_OPERATIONS_CMD_CLEAR_STATUS,
SG_GEN5_STANDARD_OPERATIONS_CMD_TOGGLE_HEX_MODE,
SG_GEN5_STANDARD_OPERATIONS_CMD_COUNT
};
/****** Command Tables *******/
naiapp_cmdtbl_params_t SG_BasicOpMenuCmds[] =
{
{"CFG", "SG Configuration Functions", SG_BASICOP_CMD_CONFIG, SGBasicOps_handleConfiguration},
{"OPS", "SG Standard Operation Functions", SG_BASICOP_CMD_STANDARDOPS, SGBasicOps_handleStandardOperation},
};
naiapp_cmdtbl_params_t SG_ConfigMenuCmds[] = {
{"READ ", "Retrieve Configuration", SG_GEN5_CONFIG_CMD_READ, SGBasicOps_displayChannelCfg},
{"EXCITATION ", "Set Excitation Voltage", SG_GEN5_CONFIG_CMD_EXCITATION, SGBasicOps_setExcitation},
{"DCONFIG ", "Set Bridge Configuration", SG_GEN5_CONFIG_CMD_BRIDGE_CONFIG, SGBasicOps_setBridgeConfig},
{"GAIN ", "Set PGA Gain", SG_GEN5_CONFIG_CMD_PGA_GAIN, SGBasicOps_setPGAGain},
{"SENSE ", "Set Remote Sense Mode", SG_GEN5_CONFIG_CMD_REMOTE_SENSE, SGBasicOps_setRemoteDriveSense},
{"NOMINAL RES", "Set Nominal Resistance", SG_GEN5_CONFIG_CMD_NOMINAL_RES, SGBasicOps_setNominalRes},
{"FACTOR ", "Set Gauge Factor", SG_GEN5_CONFIG_CMD_GAUGE_FACTOR, SGBasicOps_setGaugeFactor},
{"POISSON ", "Set Poisson Ratio", SG_GEN5_CONFIG_CMD_POISSON_RATIO, SGBasicOps_setPoissonRatio},
{"LEAD RES ", "Set Lead Resistance", SG_GEN5_CONFIG_CMD_LEAD_RES, SGBasicOps_setLeadRes},
{"RATE ", "Set Sample Rate", SG_GEN5_CONFIG_CMD_SAMPLE_RATE, SGBasicOps_setSampleRate},
{"MIN THRESH ", "Set Strain Alarm Lo Threshold", SG_GEN5_CONFIG_CMD_STRAIN_ALARM_LO, SGBasicOps_setStrainAlarmLo},
{"LOW THRESH ", "Set Strain Alert Lo Threshold", SG_GEN5_CONFIG_CMD_STRAIN_ALERT_LO, SGBasicOps_setStrainAlertLo},
{"HIGH THRESH", "Set Strain Alert Hi Threshold", SG_GEN5_CONFIG_CMD_STRAIN_ALERT_HI, SGBasicOps_setStrainAlertHi},
{"MAX THRESH ", "Set Strain Alarm Hi Threshold", SG_GEN5_CONFIG_CMD_STRAIN_ALARM_HI, SGBasicOps_setStrainAlarmHi},
{"IMBALANCE ", "Set Imbalance Offset", SG_GEN5_CONFIG_CMD_IMBALANCE_OFFSET, SGBasicOps_setImbalanceOffset},
{"COMPLETION ", "Enable/Disable Internal Bridge Completion", SG_GEN5_CONFIG_CMD_INTERNAL_BRIDGE_COMPLETION, SGBasicOps_setBridgeComp},
{"TOGGLE HEX ", "Enable/Disable Raw Hex Mode", SG_GEN5_CONFIG_CMD_TOGGLE_HEX_MODE, SGBasicOps_toggleHexModeConfig}
};
naiapp_cmdtbl_params_t SG_StandardOperationMenuCmds[] = {
{"GET ", "Retrieve Data", SG_GEN5_STANDARD_OPERATIONS_CMD_READ_DATA, SGBasicOps_displayStandardOpsData},
{"ENABLE", "Enable/Disable Channel Status Reporting", SG_GEN5_STANDARD_OPERATIONS_CMD_CHAN_STATUS_ENABLE, SGBasicOps_setChanStatusEnable},
{"RESET ", "Reset Min and Max Strain", SG_GEN5_STANDARD_OPERATIONS_CMD_RESET_MIN_MAX_STRAIN, SGBasicOps_resetMinMaxStrain},
{"CLEAR ", "Clear Statuses", SG_GEN5_STANDARD_OPERATIONS_CMD_CLEAR_STATUS, SGBasicOps_clearStatus},
{"HEX ", "Enable/Disable Raw Hex Mode", SG_GEN5_STANDARD_OPERATIONS_CMD_TOGGLE_HEX_MODE, SGBasicOps_toggleHexModeOps}
};
/*****************************************************************************/
/**
* <summary>
* The purpose of the SG_BasicOps is to illustrate the methods to call in the
* naibrd library to perform basic operations with the SG modules for
* configuration setup and reading the channels.
* </summary>
*/
/*****************************************************************************/
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t SG_BasicOps(void)
#else
int32_t main(void)
#endif
{
bool_t bQuit = NAI_FALSE;
int32_t cardIndex = -1;
int32_t module = 0;
int32_t moduleCount = 0;
uint32_t modId = 0u;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(CONFIG_FILE) == NAI_TRUE)
{
while (!bQuit)
{
naiapp_query_CardIndex(naiapp_GetBoardCnt(),0,&cardIndex);
naibrd_GetModuleCount(cardIndex, &moduleCount);
naiapp_query_ModuleNumber(moduleCount,1,&module);
naibrd_GetModuleName(cardIndex, module, &modId);
bQuit = SGBasicOps_run(cardIndex, module, modId);
}
naiif_printf("Type the Enter key to exit the program: ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
naiapp_access_CloseAllOpenCards();
return 0;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_run illustrates the channel configuration and prepares the menu
* which will handle user command requests. Returns NAI_TRUE if the user enters
* the Quit Command at any point within its scope.
* </summary>
*/
/*****************************************************************************/
static bool_t SGBasicOps_run(int32_t cardIndex, int32_t module, uint32_t modId)
{
bool_t bQuit = NAI_FALSE;
bool_t bCmdFound = NAI_FALSE;
int32_t cmd;
naiapp_AppParameters_t sg_basicops_params;
p_naiapp_AppParameters_t sg_basicOps_params = &sg_basicops_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
sg_basicOps_params->cardIndex = cardIndex;
sg_basicOps_params->module = module;
sg_basicOps_params->channel = DEF_SG_CHANNEL;
sg_basicOps_params->maxChannels = naibrd_SG_GetChannelCount(modId);
sg_basicOps_params->modId = modId;
sg_basicOps_params->displayHex = NAI_FALSE;
do
{
naiapp_utils_LoadParamMenuCommands(SG_BASICOP_CMD_COUNT, SG_BasicOpMenuCmds);
naiapp_display_ParamMenuCommands((int8_t*)SAMPLE_PGM_NAME);
naiif_printf("\r\n\r\nPlease enter a command or 'q' to quit:");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound)
{
SG_BasicOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)sg_basicOps_params);
}
else
{
naiif_printf("Invalid command entered\r\n");
}
}
}
} while (!bQuit);
return bQuit;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_handleConfiguration is called if the user chooses to
* configure the SG module or to read the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_handleConfiguration(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
bool_t bContinue = NAI_TRUE;
bool_t bCmdFound = NAI_FALSE;
int32_t cmd;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
while (bContinue)
{
naiapp_utils_LoadParamMenuCommands(SG_GEN5_CONFIG_CMD_COUNT, SG_ConfigMenuCmds);
naiapp_display_ParamMenuCommands((int8_t *)"SG Configuration Menu");
naiif_printf("\r\nType SG command or %c to go back : cfg >", BACK_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), BACK_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound)
{
switch (cmd)
{
case SG_GEN5_CONFIG_CMD_READ:
case SG_GEN5_CONFIG_CMD_EXCITATION:
case SG_GEN5_CONFIG_CMD_BRIDGE_CONFIG:
case SG_GEN5_CONFIG_CMD_PGA_GAIN:
case SG_GEN5_CONFIG_CMD_REMOTE_SENSE:
case SG_GEN5_CONFIG_CMD_NOMINAL_RES:
case SG_GEN5_CONFIG_CMD_GAUGE_FACTOR:
case SG_GEN5_CONFIG_CMD_POISSON_RATIO:
case SG_GEN5_CONFIG_CMD_LEAD_RES:
case SG_GEN5_CONFIG_CMD_SAMPLE_RATE:
case SG_GEN5_CONFIG_CMD_STRAIN_ALARM_LO:
case SG_GEN5_CONFIG_CMD_STRAIN_ALERT_LO:
case SG_GEN5_CONFIG_CMD_STRAIN_ALERT_HI:
case SG_GEN5_CONFIG_CMD_STRAIN_ALARM_HI:
case SG_GEN5_CONFIG_CMD_IMBALANCE_OFFSET:
case SG_GEN5_CONFIG_CMD_INTERNAL_BRIDGE_COMPLETION:
case SG_GEN5_CONFIG_CMD_TOGGLE_HEX_MODE:
SG_ConfigMenuCmds[cmd].func(paramCount, p_params);
break;
default:
naiif_printf("Invalid command entered\r\n");
break;
}
}
else
{
naiif_printf("Invalid command entered\r\n");
}
}
}
else
{
bContinue = NAI_FALSE;
}
}
return NAI_SUCCESS;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_handleStandardOperation is called if the user chooses to
* perform SG standard operations checks to retrieve the
* SG standard operations data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_handleStandardOperation(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
bool_t bContinue = NAI_TRUE;
bool_t bCmdFound = NAI_FALSE;
int32_t cmd = 0;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayStandardOpsDataRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayStandardOpsData(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
while (bContinue)
{
naiapp_utils_LoadParamMenuCommands(SG_GEN5_STANDARD_OPERATIONS_CMD_COUNT, SG_StandardOperationMenuCmds);
naiapp_display_ParamMenuCommands((int8_t*)"SG Standard Operations Menu");
naiif_printf("\r\nType SG command or %c to go back : ops >", BACK_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), BACK_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound)
{
switch (cmd)
{
case SG_GEN5_STANDARD_OPERATIONS_CMD_READ_DATA:
case SG_GEN5_STANDARD_OPERATIONS_CMD_CHAN_STATUS_ENABLE:
case SG_GEN5_STANDARD_OPERATIONS_CMD_RESET_MIN_MAX_STRAIN:
case SG_GEN5_STANDARD_OPERATIONS_CMD_CLEAR_STATUS:
case SG_GEN5_STANDARD_OPERATIONS_CMD_TOGGLE_HEX_MODE:
SG_StandardOperationMenuCmds[cmd].func(paramCount, p_params);
break;
default:
naiif_printf("Invalid command entered\r\n");
break;
}
}
else
{
naiif_printf("Invalid command entered\r\n");
}
}
}
else
{
bContinue = NAI_FALSE;
}
}
return NAI_SUCCESS;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_toggleNumDisplay toggles the display raw hex mode.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_toggleNumDisplay(int32_t paramCount, int32_t* p_params)
{
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
if (NAI_FALSE == p_sgParams->displayHex)
{
p_sgParams->displayHex = NAI_TRUE;
}
else
{
p_sgParams->displayHex = NAI_FALSE;
}
status = NAI_SUCCESS;
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_toggleHexModeOps toggles the display raw hex mode
* and then displays all of the standard operations data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_toggleHexModeOps(int32_t paramCount, int32_t* p_params)
{
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
nai_status_t status = SGBasicOps_toggleNumDisplay(paramCount, p_params);
if (status == NAI_SUCCESS)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayStandardOpsDataRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayStandardOpsData(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_toggleHexModeConfig toggles the display raw hex mode
* and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_toggleHexModeConfig(int32_t paramCount, int32_t* p_params)
{
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
nai_status_t status = SGBasicOps_toggleNumDisplay(paramCount, p_params);
if (status == NAI_SUCCESS)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_displayChannelCfg displays the configuration data for the
* SG module (excitation voltage, bridge configuration, PGA gain,
* remote/local sense mode, nominal resistance, gauge factor,
* poisson ratio, lead resistance, sample rate, strain alarm low threshold,
* strain alert low threshold, strain alert high threshold,
* strain alarm high threshold, imbalance offset, and
* internal bridge completion enable value).
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_displayChannelCfg(int32_t paramCount, int32_t* p_params)
{
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
if (APP_PARAM_COUNT == paramCount)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
status = NAI_SUCCESS;
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setExcitation sets the excitation voltage to the value
* specified by the user and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setExcitation(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
uint32_t excitationVoltRaw = 0u;
float64_t excitationVolt = 0.0;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
if (p_sgParams->displayHex == NAI_FALSE)
{
naiif_printf("Type Excitation Voltage value to set (V): ");
}
else
{
naiif_printf("Type raw hex Excitation Voltage register value to set: ");
}
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
excitationVoltRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
status = check_status(naibrd_SG_SetChannelRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_RAW_CHAN_EXCITATION_VOLT, excitationVoltRaw));
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
excitationVolt = atof((const char *)inputBuffer);
status = check_status(naibrd_SG_SetExcitationSignal(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
excitationVolt));
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setRemoteDriveSense sets the remote drive sense to the value
* specified by the user and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setRemoteDriveSense(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
naibrd_sg_remote_sense_t remoteDriveSense = 0u;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
naiif_printf("Type Remote Drive Sense Selection (6 for remote sense, 4 for local): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
remoteDriveSense = (naibrd_sg_remote_sense_t)atoi((const char *)inputBuffer);
if ((remoteDriveSense == NAIBRD_SG_GEN5_REMOTE_SENSE) || (remoteDriveSense == NAIBRD_SG_GEN5_LOCAL_SENSE))
{
status = check_status(naibrd_SG_SetRemoteDriveSense(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
remoteDriveSense));
}
else
{
naiif_printf("\r\nInvalid value entered!\r\n");
}
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setBridgeConfig sets the bridge configuration to the value
* specified by the user and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setBridgeConfig(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
naibrd_sg_bridge_config_type_t bridgeConfig = NAIBRD_SG_BRIDGE_CONFIG_QUARTER_BRIDGE_1;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
naiif_printf("Type Bridge Configuration Selection (0 for quarter bridge 1, 1 for quarter bridge 2, 2 for half bridge 1, ");
naiif_printf("3 for half bridge 2, 4 for full bridge 1, 5 for full bridge 2, 6 for full bridge 3): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
bridgeConfig = (naibrd_sg_bridge_config_type_t)atoi((const char *)inputBuffer);
if ((bridgeConfig >= 0) && (bridgeConfig < NAIBRD_SG_BRIDGE_CONFIG_TYPE_ENUM_COUNT))
{
status = check_status(naibrd_SG_SetBridgeConfiguration(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
bridgeConfig));
}
else
{
naiif_printf("\r\nInvalid value entered!\r\n");
}
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setNominalRes sets the nominal resistance to the value
* specified by the user and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setNominalRes(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
uint32_t nominalResRaw = 0u;
float64_t nominalRes = 0.0;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
naiif_printf("Type raw hex Nominal Resistance register value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
nominalResRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
status = check_status(naibrd_SG_SetChannelRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_RAW_CHAN_NOMINAL_RESISTANCE, nominalResRaw));
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
else
{
naiif_printf("Type Nominal Resistance value to set (Ohms): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
nominalRes = atof((const char *)inputBuffer);
status = check_status(naibrd_SG_SetNominalResistance(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
nominalRes));
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setGaugeFactor sets the gauge factor to the value
* specified by the user and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setGaugeFactor(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
uint32_t gaugeFactorRaw = 0u;
float64_t gaugeFactor = 0.0;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
naiif_printf("Type raw hex Gauge Factor register value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
gaugeFactorRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
status = check_status(naibrd_SG_SetChannelRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_RAW_CHAN_GAUGE_FACTOR, gaugeFactorRaw));
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
else
{
naiif_printf("Type Gauge Factor value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
gaugeFactor = atof((const char *)inputBuffer);
status = check_status(naibrd_SG_SetGaugeFactor(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
gaugeFactor));
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setPoissonRatio sets the poisson ratio to the value
* specified by the user and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setPoissonRatio(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
uint32_t poissonRatioRaw = 0u;
float64_t poissonRatio = 0.0;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
naiif_printf("Type raw hex Poisson Ratio register value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
poissonRatioRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
status = check_status(naibrd_SG_SetChannelRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_RAW_CHAN_POISSON_RATIO, poissonRatioRaw));
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
else
{
naiif_printf("Type Poisson Ratio value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
poissonRatio = atof((const char *)inputBuffer);
status = check_status(naibrd_SG_SetPoissonRatio(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
poissonRatio));
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setLeadRes sets the lead resistance to the value
* specified by the user and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setLeadRes(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
uint32_t leadResRaw = 0u;
float64_t leadRes = 0.0;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
naiif_printf("Type raw hex Lead Resistance register value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
leadResRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
status = check_status(naibrd_SG_SetChannelRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_RAW_CHAN_LEAD_RESISTANCE, leadResRaw));
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
else
{
naiif_printf("Type Lead Resistance value to set (Ohms): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
leadRes = atof((const char *)inputBuffer);
status = check_status(naibrd_SG_SetLeadResistance(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
leadRes));
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setSampleRate sets the sample rate to the value
* specified by the user and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setSampleRate(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
naibrd_sg_sample_rate_type_t sampleRate = NAIBRD_SG_SAMPLE_RATE_2P5_SPS;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
naiif_printf("Type Sample Rate Selection (All values are in Hz: 0 for 2.5, 1 for 5, 2 for 10, 3 for 16.6666, 4 for 20, ");
naiif_printf("5 for 50, 6 for 60, 7 for 100, 8 for 400, 9 for 1200, 10 for 2400, 11 for 4800, 12 for 7200, 13 for 14400, 14 for 19200,");
naiif_printf(" 15 for 38400): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
sampleRate = (naibrd_sg_sample_rate_type_t)atoi((const char *)inputBuffer);
if ((sampleRate >= 0) && (sampleRate < NAIBRD_SG_SAMPLE_RATE_TYPE_ENUM_COUNT))
{
status = check_status(naibrd_SG_SetSampleRate(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
sampleRate));
}
else
{
naiif_printf("\r\nInvalid value entered!\r\n");
}
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setStrainAlarmLo sets the strain alarm low threshold to the
* value specified by the user and then displays all of the
* configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setStrainAlarmLo(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
uint32_t strainAlarmLoRaw = 0u;
float64_t strainAlarmLo = 0.0;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
naiif_printf("Type raw hex Strain Alarm Low Threshold register value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
strainAlarmLoRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
status = check_status(naibrd_SG_SetChannelRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_RAW_CHAN_STRAIN_ALARM_LO_THRESHOLD, strainAlarmLoRaw));
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
else
{
naiif_printf("Type Strain Alarm Low Threshold value to set (microstrain): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
strainAlarmLo = atof((const char *)inputBuffer);
status = check_status(naibrd_SG_SetStrainAlertValue(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_LOW_STRAIN_ALERT_2_VALUE, strainAlarmLo));
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setStrainAlertLo sets the strain alert low threshold to the
* value specified by the user and then displays all of the
* configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setStrainAlertLo(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
uint32_t strainAlertLoRaw = 0u;
float64_t strainAlertLo = 0.0;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
naiif_printf("Type raw hex Strain Alert Low Threshold register value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
strainAlertLoRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
status = check_status(naibrd_SG_SetChannelRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_RAW_CHAN_STRAIN_ALERT_LO_THRESHOLD, strainAlertLoRaw));
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
else
{
naiif_printf("Type Strain Alert Low Threshold value to set (microstrain): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
strainAlertLo = atof((const char *)inputBuffer);
status = check_status(naibrd_SG_SetStrainAlertValue(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_LOW_STRAIN_ALERT_1_VALUE, strainAlertLo));
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setStrainAlertHi sets the strain alert high threshold to the
* value specified by the user and then displays all of the
* configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setStrainAlertHi(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
uint32_t strainAlertHiRaw = 0u;
float64_t strainAlertHi = 0.0;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
naiif_printf("Type raw hex Strain Alert High Threshold register value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
strainAlertHiRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
status = check_status(naibrd_SG_SetChannelRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_RAW_CHAN_STRAIN_ALERT_HI_THRESHOLD, strainAlertHiRaw));
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
else
{
naiif_printf("Type Strain Alert High Threshold value to set (microstrain): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
strainAlertHi = atof((const char *)inputBuffer);
status = check_status(naibrd_SG_SetStrainAlertValue(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_HIGH_STRAIN_ALERT_1_VALUE, strainAlertHi));
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setStrainAlarmHi sets the strain alarm high threshold to the
* value specified by the user and then displays all of the
* configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setStrainAlarmHi(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
uint32_t strainAlarmHiRaw = 0u;
float64_t strainAlarmHi = 0.0;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
naiif_printf("Type raw hex Strain Alarm High Threshold register value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
strainAlarmHiRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
status = check_status(naibrd_SG_SetChannelRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_RAW_CHAN_STRAIN_ALARM_HI_THRESHOLD, strainAlarmHiRaw));
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
else
{
naiif_printf("Type Strain Alarm High Threshold value to set (microstrain): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
strainAlarmHi = atof((const char *)inputBuffer);
status = check_status(naibrd_SG_SetStrainAlertValue(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_HIGH_STRAIN_ALERT_2_VALUE, strainAlarmHi));
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setImbalanceOffset sets the imbalance offset value to the
* value specified by the user and then displays all of the
* configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setImbalanceOffset(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
uint32_t imbalanceOffsetRaw = 0u;
float64_t imbalanceOffset = 0.0;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
naiif_printf("Type raw hex Imbalance Offset register value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
imbalanceOffsetRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
status = check_status(naibrd_SG_SetChannelRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
NAIBRD_SG_RAW_CHAN_IMBALANCE_OFFSET, imbalanceOffsetRaw));
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
else
{
naiif_printf("Type Imbalance Offset value to set: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
imbalanceOffset = atof((const char *)inputBuffer);
status = check_status(naibrd_SG_SetImbalanceOffsetValue(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
imbalanceOffset));
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setBridgeComp sets the internal bridge completion
* enabled/disabled setting to the value specified by the user
* and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setBridgeComp(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
bool_t useBridgeComp = NAI_FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
naiif_printf("Type Internal Bridge Completion Enable/Disable setting to set (0 for disable, 1 for enable): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
useBridgeComp = (bool_t)atoi((const char *)inputBuffer);
if ((useBridgeComp == NAI_TRUE) || (useBridgeComp == NAI_FALSE))
{
status = check_status(naibrd_SG_SetUseInternalBridgeCompletion(p_sgParams->cardIndex, p_sgParams->module,
p_sgParams->channel, useBridgeComp));
}
else
{
naiif_printf("\r\nInvalid value entered!\r\n");
}
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setPGAGain sets the PGA Gain setting to the value
* specified by the user and then displays all of the configuration data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setPGAGain(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
naibrd_sg_pga_gain_type_t pgaGain = NAIBRD_SG_PGA_GAIN_1;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
naiif_printf("Type PGA Gain setting to set (0 for 1, 1 for 2, 2 for 4, 3 for 8, 4 for 16, 5 for 32): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
pgaGain = (naibrd_sg_pga_gain_type_t)atoi((const char *)inputBuffer);
if ((pgaGain >= 0) && (pgaGain < NAIBRD_SG_PGA_GAIN_TYPE_ENUM_COUNT))
{
status = check_status(naibrd_SG_SetPGAGain(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel, pgaGain));
}
else
{
naiif_printf("\r\nInvalid value entered!\r\n");
}
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayCfgRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayCfg(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_displayStandardOpsData calls SGUtils_DisplayStandardOpsData
* to display the SG Standard Operations Table for Gen 5 SG modules.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_displayStandardOpsData(int32_t paramCount, int32_t* p_params)
{
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
if (APP_PARAM_COUNT == paramCount)
{
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayStandardOpsDataRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayStandardOpsData(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
status = NAI_SUCCESS;
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_setChanStatusEnable sets the channel status reporting
* enabled/disabled setting to the value specified by the user
* and then displays all of the standard operations data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_setChanStatusEnable(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
bool_t enable = NAI_FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
naiif_printf("Type Channel Status Reporting Enable/Disable setting to set (0 for disable, 1 for enable): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
enable = (bool_t)atoi((const char *)inputBuffer);
if ((enable == NAI_TRUE) || (enable == NAI_FALSE))
{
status = check_status(naibrd_SG_SetChanStatusEnable(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
enable));
}
else
{
naiif_printf("\r\nInvalid value entered!\r\n");
}
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayStandardOpsDataRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayStandardOpsData(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_resetMinMaxStrain resets the min and max strain values stored
* in the module (if the user chooses to) and then displays all of the
* standard operations data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_resetMinMaxStrain(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
naiif_printf("Are you sure you want to reset min and max strain? (Y = Yes, N = No): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
if (toupper(inputBuffer[0]) == 'Y')
{
status = naibrd_SG_ResetMinimumAndMaximumStrain(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel);
if (status == NAI_SUCCESS)
{
naiif_printf("\r\nReset Min and Max Strain Successful\r\n");
}
else
{
naiif_printf("\r\nReset Min and Max Strain Failed!\r\n");
}
}
else if (toupper(inputBuffer[0]) == 'N')
{
naiif_printf("\r\nMin and Max Strain will not be reset\r\n");
}
else
{
naiif_printf("\r\nInvalid value entered!\r\n");
}
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayStandardOpsDataRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayStandardOpsData(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}
/*****************************************************************************/
/**
* <summary>
* SGBasicOps_clearStatus clears the status corresponding to the
* status type specified by the user (if the user chooses to) and then
* displays all of the standard operations data.
* </summary>
*/
/*****************************************************************************/
static nai_status_t SGBasicOps_clearStatus(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
naibrd_sg_chan_mapped_status_type_t statusType = NAIBRD_SG_CHAN_MAPPED_STATUS_BIT_LATCHED;
int32_t responseNum = 0;
p_naiapp_AppParameters_t p_sgParams = (p_naiapp_AppParameters_t)p_params;
char statusTypeStr[20] = "";
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(p_sgParams->maxChannels, DEF_SG_CHANNEL, &(p_sgParams->channel));
if (!bQuit)
{
naiif_printf("Type status type to clear (0 for BIT, 1 for Open, 2 for High Strain Alert, ");
naiif_printf("3 for High Strain Alarm, 4 for Low Strain Alert, 5 for Low Strain Alarm): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
responseNum = atoi((const char *)inputBuffer);
switch (responseNum)
{
case 0:
statusType = NAIBRD_SG_CHAN_MAPPED_STATUS_BIT_LATCHED;
naiif_snprintf(statusTypeStr, 4, "BIT");
break;
case 1:
statusType = NAIBRD_SG_CHAN_MAPPED_STATUS_OPEN_LATCHED;
naiif_snprintf(statusTypeStr, 5, "Open");
break;
case 2:
statusType = NAIBRD_SG_CHAN_MAPPED_STATUS_HIGH_STRAIN_ALERT_1_LATCHED;
naiif_snprintf(statusTypeStr, 18, "High Strain Alert");
break;
case 3:
statusType = NAIBRD_SG_CHAN_MAPPED_STATUS_HIGH_STRAIN_ALERT_2_LATCHED;
naiif_snprintf(statusTypeStr, 18, "High Strain Alarm");
break;
case 4:
statusType = NAIBRD_SG_CHAN_MAPPED_STATUS_LOW_STRAIN_ALERT_1_LATCHED;
naiif_snprintf(statusTypeStr, 17, "Low Strain Alert");
break;
case 5:
statusType = NAIBRD_SG_CHAN_MAPPED_STATUS_LOW_STRAIN_ALERT_2_LATCHED;
naiif_snprintf(statusTypeStr, 17, "Low Strain Alarm");
break;
default:
naiif_printf("\r\nInvalid value entered!\r\n");
status = NAI_ERROR_INVALID_VALUE;
break;
}
if (status != NAI_ERROR_INVALID_VALUE)
{
naiif_printf("Are you sure you want to clear the %s status? (Y = Yes, N = No): ", statusTypeStr);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
if (toupper(inputBuffer[0]) == 'Y')
{
status = naibrd_SG_ClearChanMappedStatus(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->channel,
statusType);
if (status == NAI_SUCCESS)
{
naiif_printf("\r\nSuccessfully cleared %s status\r\n", statusTypeStr);
}
else
{
naiif_printf("\r\nFailed to clear %s status!\r\n", statusTypeStr);
}
}
else if (toupper(inputBuffer[0]) == 'N')
{
naiif_printf("\r\n%s status will not be cleared\r\n", statusTypeStr);
}
else
{
naiif_printf("\r\nInvalid value entered!\r\n");
}
}
}
}
if (p_sgParams->displayHex == NAI_TRUE)
{
SGUtils_DisplayStandardOpsDataRaw(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
else
{
SGUtils_DisplayStandardOpsData(p_sgParams->cardIndex, p_sgParams->module, p_sgParams->maxChannels);
}
}
}
}
}
return status;
}