DS BasicOps
Edit this on GitLab
DS BasicOps Sample Application (SSK 2.x)
Overview
The DS BasicOps sample application demonstrates how to configure and operate digital-to-synchro/resolver (DS) converter modules using the NAI Software Support Kit (SSK 2.x). It covers the core DS operations you will need in your own application: setting output angle, configuring expected VLL and reference voltages, setting threshold voltages, controlling fixed/ratio mode, managing power supply state, running BIT tests, configuring rotation parameters, and setting multi-speed ratios.
This sample supports DS1 through DS5 synchro/resolver output modules. The application provides four operational sub-menus: Angle, BIT Test, Rotation, and Multi-Speed. Each menu command maps directly to one or more naibrd_DS_*() API calls that you can lift into your own code.
For the SSK 1.x version, the closest match is DS MultiSpd (SSK 1.x).
Prerequisites
Before running this sample, make sure you have:
-
An NAI board with a DS module installed (DS1-DS5).
-
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 ds_basic_ops executable from your build output directory. On startup the application looks for a configuration file (default_ds_basic_ops.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 choose between Angle, BIT Test, Rotation, and Multi-Speed sub-menus.
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 DS. |
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_ds_basic_ops.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()so downstream code can adapt to the specific DS variant installed.
#if defined (__VXWORKS__)
int32_t DS_RunAngleProgramSample(void)
#else
int32_t main(void)
#endif
{
bool_t stop = NAI_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) == NAI_TRUE)
{
while (stop != NAI_TRUE)
{
/* Query the user for the card index */
stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
/* Query the user for the module number */
stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
if ((moduleID != 0))
{
DS_RunAngleProgram(cardIndex, module, moduleID, moduleCnt);
}
}
}
naiif_printf("\r\nType Q to quit or Enter key to restart application:\r\n");
stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
}
naiif_printf("\r\nType 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:
-
This sample does not include a VxWorks-specific entry point. Most SSK 2.x samples use
NAIBSP_CONFIG_SOFTWARE_OS_VXWORKSfor VxWorks builds. -
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 VxWorks the entry point is DS_RunAngleProgramSample(); on all other platforms it is main(). The preprocessor guard __VXWORKS__ selects between them. After board connection and module selection, the application calls DS_RunAngleProgram() which presents the top-level function menu.
Command Loop
DS_RunAngleProgram() presents a top-level menu that lets the user select among four functional areas, switch module, or switch channel. Each sub-menu has its own command table and display function.
| Command | Description |
|---|---|
|
Open the Angle sub-menu for setting output angle, voltages, thresholds, and mode. |
|
Open the BIT Test sub-menu for configuring D2/D3 tests and test verify values. |
|
Open the Rotation sub-menu for configuring rotation rate, mode, start/stop angles. |
|
Open the Multi-Speed sub-menu for configuring multi-speed ratios and angle. |
|
Select a different module. |
|
Select a different channel. |
Angle Sub-Menu
The Angle sub-menu allows setting the output angle, expected VLL and reference voltages, voltage thresholds, fixed/ratio mode, channel status enable, and power state. The display shows the current angle, measured voltages, and status for each channel. Before each command prompt, the application calls DS_ShowSetAngleTestResult() to display a one-line status row with all current values.
Angle Sub-Menu Commands
| Command | Description |
|---|---|
|
Set the output angle (0.0 - 359.9954 degrees) |
|
Set the expected line-to-line voltage (0 - 115V) |
|
Set the expected reference voltage (0 - 115V) |
|
Set the VLL threshold voltage (0 - 115V) |
|
Set the VREF threshold voltage (0 - 115V) |
|
Set fixed or ratio output mode (0 = Ratio, 1 = Fixed) |
|
Enable or disable channel status (0 = Disable, 1 = Enable) |
|
Enable or disable module power (0 = Disable, 1 = Enable) |
|
Refresh the display |
|
Return to the top-level menu |
Set Angle
To set the output angle for a channel, call naibrd_DS_SetAngle() with the angle type and the desired value in degrees. The valid range is 0.0 to 359.9954 degrees. The sample validates the input against the limit table before calling the API.
float64_t dValue = 45.0; /* Desired angle in degrees */
/* Set the single-speed output angle */
check_status(naibrd_DS_SetAngle(cardIndex, module, channel,
NAIBRD_DS_ANGLE_SINGLE, dValue));
-
cardIndex— identifies the board. -
module— the slot containing the DS module. -
channel— the channel to configure. -
NAIBRD_DS_ANGLE_SINGLE— angle type for single-speed mode. UseNAIBRD_DS_ANGLE_TWO_SPEEDfor multi-speed mode andNAIBRD_DS_ANGLE_ROTATION_STOPfor the rotation stop angle. -
dValue— angle in degrees (0.0 - 359.9954).
Set Expected VLL and VREF
The expected VLL (line-to-line) and VREF (reference) voltages tell the module what signal levels to expect. These values are used for status monitoring — if the measured voltage falls below the corresponding threshold, a status flag is set.
/* Set expected line-to-line voltage */
check_status(naibrd_DS_SetExpectedVoltage(cardIndex, module, channel,
NAIBRD_DS_EXP_VOLT_SIGNAL, dValue));
/* Set expected reference voltage */
check_status(naibrd_DS_SetExpectedVoltage(cardIndex, module, channel,
NAIBRD_DS_EXP_VOLT_REFERENCE, dValue));
-
NAIBRD_DS_EXP_VOLT_SIGNAL— selects the line-to-line (VLL) expected voltage. -
NAIBRD_DS_EXP_VOLT_REFERENCE— selects the reference (VREF) expected voltage. -
dValue— voltage in volts (0.0 - 115.0).
Set VLL and VREF Threshold
Threshold voltages define the minimum acceptable signal level. When the measured VLL or VREF drops below its threshold, the corresponding status flag indicates signal or reference loss.
/* Set VLL threshold voltage */
check_status(naibrd_DS_SetThresholdVoltage(cardIndex, module, channel,
NAIBRD_DS_THRESHOLD_VOLT_SIGNAL, dValue));
/* Set VREF threshold voltage */
check_status(naibrd_DS_SetThresholdVoltage(cardIndex, module, channel,
NAIBRD_DS_THRESHOLD_VOLT_REFERENCE, dValue));
-
NAIBRD_DS_THRESHOLD_VOLT_SIGNAL— selects the VLL threshold. -
NAIBRD_DS_THRESHOLD_VOLT_REFERENCE— selects the VREF threshold. -
dValue— threshold voltage in volts (0.0 - 115.0).
Set Fixed/Ratio Mode
Fixed mode outputs at the programmed VLL regardless of the reference signal level. Ratio mode scales the output proportionally to the reference signal.
/* Set to ratio mode (output tracks reference) */
check_status(naibrd_DS_SetRatioFixedMode(cardIndex, module, channel,
NAIBRD_DS_OUTPUT_RATIO));
/* Set to fixed mode (output at programmed VLL) */
check_status(naibrd_DS_SetRatioFixedMode(cardIndex, module, channel,
NAIBRD_DS_OUTPUT_FIXED));
-
NAIBRD_DS_OUTPUT_RATIO(0) — ratio mode. -
NAIBRD_DS_OUTPUT_FIXED(1) — fixed mode.
Set Channel Status Enable and Power
Channel status enable (also called "active channel") controls whether the module monitors the channel for signal loss, reference loss, BIT failure, and phase loss. Power enable turns the module’s output stage on or off.
/* Enable channel status monitoring */
check_status(naibrd_DS_SetChanStatusEnable(cardIndex, module, channel, 1));
/* Disable channel status monitoring */
check_status(naibrd_DS_SetChanStatusEnable(cardIndex, module, channel, 0));
/* Enable module power */
check_status(naibrd_DS_SetPowerEnable(cardIndex, module, channel, NAI_TRUE));
/* Disable module power */
check_status(naibrd_DS_SetPowerEnable(cardIndex, module, channel, NAI_FALSE));
Display Current Configuration
The display function reads and prints the current angle, measured angle, expected voltages, measured voltages, threshold voltages, mode, multi-speed ratio, status flags (Signal/Reference/BIT/Phase loss), channel status enable, and power state.
/* Read measured angle */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel,
NAIBRD_DS_MEASURED_ANGLE, &dValue));
/* Read measured VLL */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel,
NAIBRD_DS_MEASURED_SIGNAL_VOLTAGE, &dValue));
/* Read measured VREF */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel,
NAIBRD_DS_MEASURED_REF_VOLTAGE, &dValue));
/* Read measured reference frequency */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel,
NAIBRD_DS_MEASURED_REF_FREQUENCY, &dValue));
/* Read channel-mapped status for signal loss */
check_status(naibrd_DS_GetChanMappedStatus(cardIndex, module, channel,
NAIBRD_DS_CHAN_MAPPED_STATUS_REAL_TIME_SIGNAL_LOST, &unSignalLoss));
BIT Test Sub-Menu
The BIT (Built-In Test) sub-menu allows configuring and running built-in test operations. D2 (online) and D3 (offline) tests can be independently enabled or disabled. The D2 test verify value sets the expected comparison value for the D2 test. The display shows the current test settings, mode, verify value, measured voltages, and status flags.
BIT Test Sub-Menu Commands
| Command | Description |
|---|---|
|
Set the output angle (0.0 - 359.9954 degrees) |
|
Enable or disable the online (D2) test (0 = Disable, 1 = Enable) |
|
Enable or disable the offline (D3) test (0 = Disable, 1 = Enable) |
|
Set the D2 test verify value (0 - 65535) |
|
Set channel status enable (0 = Disable, 1 = Enable) |
|
Enable or disable module power (0 = Disable, 1 = Enable) |
|
Refresh the display |
|
Return to the top-level menu |
Enable/Disable D2 Test (Online)
The D2 test is an online background test that checks the output signal while the module is actively driving. It does not interrupt normal operation.
/* Enable the D2 online test */
check_status(naibrd_DS_SetTestModeEnable(cardIndex, module,
NAIBRD_DS_ON_LINE_TEST, NAI_TRUE));
/* Disable the D2 online test */
check_status(naibrd_DS_SetTestModeEnable(cardIndex, module,
NAIBRD_DS_ON_LINE_TEST, NAI_FALSE));
-
NAIBRD_DS_ON_LINE_TEST— selects the D2 (online) test mode. -
The third parameter —
NAI_TRUEto enable,NAI_FALSEto disable.
Enable/Disable D3 Test (Offline)
The D3 test is an offline background test that requires the module to be taken out of normal operation. It provides a more thorough test of the output circuitry.
/* Enable the D3 offline test */
check_status(naibrd_DS_SetTestModeEnable(cardIndex, module,
NAIBRD_DS_OFF_LINE_TEST, NAI_TRUE));
/* Disable the D3 offline test */
check_status(naibrd_DS_SetTestModeEnable(cardIndex, module,
NAIBRD_DS_OFF_LINE_TEST, NAI_FALSE));
-
NAIBRD_DS_OFF_LINE_TEST— selects the D3 (offline) test mode.
Set Test Verify Value
The test verify value is the expected output value for the D2 test comparison. If the measured value does not match the verify value within tolerance, the BIT status flag is set.
uint32_t unValue = 0x1234u;
/* Set the D2 test verify value */
check_status(naibrd_DS_SetTestVerify(cardIndex, module, unValue));
/* Read the current test verify value */
check_status(naibrd_DS_GetTestVerify(cardIndex, module, &unValue));
-
unValue— the verify value (0 - 65535).
Rotation Sub-Menu
The Rotation sub-menu configures continuous or start-stop rotation for the DS output. Before entering the rotation command loop, the sample automatically configures the channel for rotation by setting fixed mode, enabling the active channel, setting the rotation trigger source to internal (software), and enabling power. You can then set the rotation rate, mode (continuous or start/stop), start and stop angles, and initiate or halt rotation.
Rotation Sub-Menu Commands
| Command | Description |
|---|---|
|
Set the rotation rate in degrees per second (-1000.0 to 1000.0) |
|
Set rotation mode (0 = Continuous, 1 = Start/Stop) |
|
Set the rotation start angle (0.0 - 359.9954 degrees) |
|
Set the rotation stop angle (0.0 - 359.9954 degrees) |
|
Start (initiate) rotation |
|
Stop rotation |
|
Enable or disable module power (0 = Disable, 1 = Enable) |
|
Refresh the display |
|
Return to the top-level menu |
Rotation Initialization
When the rotation sub-menu is entered, the sample performs automatic initialization to ensure the channel is ready for rotation:
/* Set output mode to fixed */
check_status(naibrd_DS_SetRatioFixedMode(cardIndex, module, channel,
NAIBRD_DS_OUTPUT_FIXED));
/* Enable the active channel */
check_status(naibrd_DS_SetActiveChannel(cardIndex, module, channel, NAI_TRUE));
/* Set rotation trigger source to internal (software) */
check_status(naibrd_DS_SetRotationCtrl(cardIndex, module, channel,
NAIBRD_DS_ROTATION_TRIG_SOURCE, (float64_t)NAIBRD_DS_ROT_TRIG_INTERNAL));
/* Enable power */
check_status(naibrd_DS_SetPowerEnable(cardIndex, module, channel, NAI_TRUE));
Set Rotation Rate
The rotation rate specifies how fast the output angle changes, in degrees per second. Positive values rotate in one direction, negative values rotate in the other.
/* Set rotation rate to 100 degrees per second */
check_status(naibrd_DS_SetRotationCtrl(cardIndex, module, channel,
NAIBRD_DS_ROTATION_RATE, 100.0));
-
NAIBRD_DS_ROTATION_RATE— selects the rotation rate parameter. -
Valid range: -1000.0 to 1000.0 degrees per second.
Set Rotation Mode
Continuous mode rotates indefinitely. Start/Stop mode rotates from the start angle to the stop angle and then halts.
/* Set continuous rotation mode */
check_status(naibrd_DS_SetRotationCtrl(cardIndex, module, channel,
NAIBRD_DS_ROTATION_MODE, (float64_t)NAIBRD_DS_ROT_CONTINUOUS_MODE));
/* Set start/stop rotation mode */
check_status(naibrd_DS_SetRotationCtrl(cardIndex, module, channel,
NAIBRD_DS_ROTATION_MODE, (float64_t)NAIBRD_DS_ROT_START_STOP_MODE));
-
NAIBRD_DS_ROT_CONTINUOUS_MODE(0) — continuous rotation. -
NAIBRD_DS_ROT_START_STOP_MODE(1) — rotation between start and stop angles.
Set Start and Stop Angles
In start/stop mode, these angles define the rotation range. The start angle is set using NAIBRD_DS_ANGLE_SINGLE and the stop angle using NAIBRD_DS_ANGLE_ROTATION_STOP.
/* Set rotation start angle */
check_status(naibrd_DS_SetAngle(cardIndex, module, channel,
NAIBRD_DS_ANGLE_SINGLE, 10.0));
/* Set rotation stop angle */
check_status(naibrd_DS_SetAngle(cardIndex, module, channel,
NAIBRD_DS_ANGLE_ROTATION_STOP, 350.0));
Start and Stop Rotation
To initiate or halt rotation, call naibrd_DS_SetRotationEnable(). The display function reads the current rotation state with naibrd_DS_GetRotationStatus() so you can confirm whether rotation is active.
/* Start rotation */
check_status(naibrd_DS_SetRotationEnable(cardIndex, module, channel, NAI_TRUE));
/* Stop rotation */
check_status(naibrd_DS_SetRotationEnable(cardIndex, module, channel, NAI_FALSE));
/* Check rotation state */
check_status(naibrd_DS_GetRotationStatus(cardIndex, module, channel, &unValue));
/* NAIBRD_DS_STATUS_ROT_NOT_DONE = rotating, otherwise stopped */
Multi-Speed Sub-Menu
The Multi-Speed sub-menu allows configuring multi-speed ratios. The multi-speed feature applies a multiplication factor to the output angle, which is useful for synchro/resolver systems that use multiple-speed encoding. In multi-speed mode, channels are used in pairs (e.g., channels 1 and 2), where one channel outputs the coarse angle and the other outputs the fine angle (coarse angle multiplied by the speed ratio). The display shows coarse and fine measured angles along with the voltage and threshold settings.
Multi-Speed Sub-Menu Commands
| Command | Description |
|---|---|
|
Set the multi-speed angle (0.0 - 359.9954 degrees) |
|
Set the expected line-to-line voltage (0 - 115V) |
|
Set the expected reference voltage (0 - 115V) |
|
Set the VLL threshold voltage (0 - 115V) |
|
Set the VREF threshold voltage (0 - 115V) |
|
Set fixed or ratio output mode (0 = Ratio, 1 = Fixed) |
|
Set the multi-speed ratio (1 - 255) |
|
Enable or disable module power (0 = Disable, 1 = Enable) |
|
Refresh the display |
|
Return to the top-level menu |
Set Multi-Speed Ratio
The multi-speed ratio is the multiplication factor applied to the output angle for the fine channel. For example, a ratio of 36 means the fine channel outputs an angle that is 36 times the coarse angle. The ratio applies to a channel pair (e.g., channels 1 and 2).
uint32_t unValue = 36u; /* Multi-speed ratio */
/* Set multi-speed ratio for channel pair 1-2 */
check_status(naibrd_DS_SetMultiSpeedRatio(cardIndex, module,
NAIBRD_DS_MULTI_SPD_CH1_2_PAIR, unValue));
/* Read current multi-speed ratio */
check_status(naibrd_DS_GetMultiSpeedRatio(cardIndex, module,
NAIBRD_DS_MULTI_SPD_CH1_2_PAIR, &unValue));
-
NAIBRD_DS_MULTI_SPD_CH1_2_PAIR— selects the channel 1-2 pair. -
unValue— the multi-speed ratio (1 - 255).
Set Multi-Speed Angle
In multi-speed mode, the angle is set using NAIBRD_DS_ANGLE_TWO_SPEED instead of NAIBRD_DS_ANGLE_SINGLE. This tells the module to compute both the coarse and fine output angles from the single input value.
/* Set the multi-speed angle */
check_status(naibrd_DS_SetAngle(cardIndex, module, channel,
NAIBRD_DS_ANGLE_TWO_SPEED, dValue));
/* Read the multi-speed angle */
check_status(naibrd_DS_GetAngle(cardIndex, module, channel,
NAIBRD_DS_ANGLE_TWO_SPEED, &dValue));
Multi-Speed Display
The multi-speed display reads measured angles for both the coarse channel (channel 1) and the fine channel (channel 2), along with the speed ratio and voltage settings.
uint32_t unCoarseChan = 1;
uint32_t unFineChan = 2;
/* Read coarse measured angle */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, unCoarseChan,
NAIBRD_DS_MEASURED_ANGLE, &dValue));
/* Read fine measured angle */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, unFineChan,
NAIBRD_DS_MEASURED_ANGLE, &dValue));
/* Read multi-speed ratio */
check_status(naibrd_DS_GetMultiSpeedRatio(cardIndex, module,
NAIBRD_DS_MULTI_SPD_CH1_2_PAIR, &unValue));
Troubleshooting Reference
| Error / Symptom | Possible Causes | Suggested Resolution |
|---|---|---|
Module not recognized as DS |
The selected module slot does not contain a DS module. |
Verify the module type in the slot. See the DS1-DS5 Manual. |
Output angle does not change |
Module power supply may be disabled, or the channel status is not enabled. |
Enable power with the |
VLL or reference voltage out of range |
The entered value exceeds the module limits (0-115V). |
Check the input limits displayed in the menu prompt. |
BIT test fails |
A mismatch between the expected and actual output was detected. |
Check external wiring and load impedance. Verify the test verify value setting. |
Rotation does not start |
The rotation mode may not be set, or start/stop angles may be equal. |
Set the rotation mode and ensure the start angle differs from the stop angle for start/stop mode. |
Multi-speed ratio has no effect |
The multi-speed ratio must be >= 1. |
Enter a valid multi-speed ratio between 1 and 255. |
Status shows signal loss |
The module is not detecting the expected reference or output signal. |
Verify external wiring connections and reference signal source. |
Full Source
The complete source for this sample is provided below for reference. The sections above explain each part in detail.
Full Source — ds_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_ds.h"
/* naiif include files */
#include "nai_libs/naiif/include/naiif.h"
#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"
static const int8_t *CONFIG_FILE = (int8_t *)"default_ds_basic_ops.txt";
static const uint8_t DS_RATIO[] = {"RATIO"};
static const uint8_t DS_FIXED[] = {"FIXED"};
static const uint8_t DS_ENABLE[] = {"ENABLE"};
static const uint8_t DS_DISABLE[] = {"DISABLE"};
static const uint8_t DS_ROTATION_CONTINUOUS[] = {"CONT."};
static const uint8_t DS_ROTATION_START_STOP[] = {"STR/STP."};
static const uint8_t DS_ROTATION_SRC_INT[] = {"INT."};
static const uint8_t DS_ROTATION_SRC_EXT[] = {"EXT."};
static const uint8_t DS_NOT_DEFINED[] = {"---"};
static const uint8_t DS_ROTATION_STATUS_ROTATING[] = {"ROTATING"};
static const uint8_t DS_ROTATION_STATUS_NOT_ROTATING[] = {"ROTATION STOP"};
static const uint8_t SYM_SLASH[] = {"/"};
static const uint8_t DS_STATUS_GOOD[] = {"0"};
static const uint8_t DS_STATUS_BAD[] = {"1"};
/* Function prototypes */
static void DS_ShowSetAngleTestResult(int32_t cardIndex, int32_t module, int32_t channel);
static void DS_RunAngleProgram(int32_t cardIndex, int32_t module, uint32_t moduleID, int32_t moduleCount);
static nai_status_t DS_RunAngleFunc(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetNewAngle(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetExpVLL(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetExpVref(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetVllThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetVrefThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetFixedRatioMode(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetPower(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetChannelStatusCtrl(int32_t paramCount, int32_t* p_params);
static void DS_ShowTestMenu(int32_t cardIndex, int32_t module, int32_t channel);
static nai_status_t DS_RunBitTestFunc(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetD2Test(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetD3Test(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetTestVerifyValue(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetRotation(int32_t paramCount, int32_t* p_params);
static void DS_ShowSetRotationTestResult(int32_t cardIndex, int32_t module, int32_t channel);
static nai_status_t DS_SetRotationRate(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetRotationMode(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetRotationStartAngle(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_SetRotationStopAngle(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_StartRotation(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_StopRotation(int32_t paramCount, int32_t* p_params);
static nai_status_t DS_RunMultiSpeedFunc(int32_t paramCount, int32_t* p_params);
static void DS_ShowMultiSpeedMenu(int32_t cardIndex, int32_t module, int32_t channel);
static nai_status_t DS_SetMultiSpd(int32_t paramCount, int32_t* p_params);
static void printInvalidUserInputMessage(uint32_t uTypeIdx, float64_t dUserInput, int32_t menuType);
static void showCurrentModChan(int32_t nModule, int32_t nChannel);
static void getStatus(int32_t cardIndex, int32_t module, int32_t channel, uint8_t *u8Status);
static bool_t checkUserInput(uint32_t uTypeIdx, float64_t dUserInput, int32_t menuType);
/****** Command Table *******/
enum dsfunc_commands
{
DS_FUNC_CMD_SET_ANGLE,
DS_FUNC_CMD_BIT_TEST,
DS_FUNC_CMD_ROTATION,
DS_FUNC_CMD_MULTI_SPEED,
DS_FUNC_CMD_SET_MODULE,
DS_FUNC_CMD_SET_CHANNEL,
DS_FUNC_CMD_COUNT
};
/****** Set Angle Table *******/
enum dsfunc_setAngle
{
DS_ANGLE_MENU_SET_ANGLE,
DS_ANGLE_MENU_SET_EXP_VLL,
DS_ANGLE_MENU_SET_EXP_VREF,
DS_ANGLE_MENU_SET_VLL_THRESHOLD,
DS_ANGLE_MENU_SET_VREF_THRESHOLD,
DS_ANGLE_MENU_FIX_RATIO_MODE,
DS_ANGLE_MENU_CHAN_STATUS_ENABLE,
DS_ANGLE_MENU_POWER,
DS_ANGLE_MENU_REFRESH,
DS_ANGLE_MENU_QUIT,
DS_ANGLE_MENU_INVALID_INPUT,
DS_ANGLE_MENU_COUNT
};
/****** BIT Test Table *******/
enum dsfunc_bitTest
{
DS_BIT_TEST_SET_ANGLE,
DS_BIT_TEST_SET_D2,
DS_BIT_TEST_SET_D3,
DS_BIT_TEST_SET_TEST_VERIFY,
DS_BIT_TEST_ACTIVE_CHAN,
DS_BIT_TEST_POWER,
DS_BIT_TEST_REFRESH,
DS_BIT_TEST_QUIT,
DS_BIT_TEST_INVALID_INPUT,
DS_BIT_TEST_COUNT
};
/****** Rotation Table *******/
enum dsfunc_rotation
{
DS_ROTATION_SET_ROT_RATE,
DS_ROTATION_SET_ROT_MODE,
DS_ROTATION_SET_ROT_START_ANG,
DS_ROTATION_SET_ROT_STOP_ANG,
DS_ROTATION_INITIATE_ROTATION,
DS_ROTATION_STOP_ROTATION,
DS_ROTATION_POWER,
DS_ROTATION_REFRESH,
DS_ROTATION_QUIT,
DS_ROTATION_INVALID_INPUT,
DS_ROTATION_COUNT
};
/****** Multi-Speed Table *******/
enum dsfunc_multiSpeed
{
DS_MULTI_SPEED_SET_ANGLE,
DS_MULTI_SPEED_SET_EXP_VLL,
DS_MULTI_SPEED_SET_EXP_VREF,
DS_MULTI_SPEED_SET_VLL_THRESHOLD,
DS_MULTI_SPEED_SET_VREF_THRESHOLD,
DS_MULTI_SPEED_FIX_RATIO_MODE,
DS_MULTI_SPEED_MULT_SPD,
DS_MULTI_SPEED_POWER,
DS_MULTI_SPEED_REFRESH,
DS_MULTI_SPEED_QUIT,
DS_MULTI_SPEED_INVALID_INPUT,
DS_MULTI_SPEED_COUNT
};
/* assigned cmd #, upper Limit, lower Limit*/
struct dsUserInputLimitTable {
int32_t cmdnum;
int8_t *cmdstr;
float64_t upperLimit;
float64_t lowerLimit;
};
/****** Main Menu Command Table *******/
naiapp_cmdtbl_params_t DS_DemoFuncMenuCmds[] = {
{"ANG", "Run Angle Menu", DS_FUNC_CMD_SET_ANGLE, DS_RunAngleFunc},
{"BIT", "Run BIT Test Menu", DS_FUNC_CMD_BIT_TEST, DS_RunBitTestFunc},
{"ROT", "Run Rotation Menu", DS_FUNC_CMD_ROTATION, DS_SetRotation},
{"SPD", "Run Multi-Speed Menu", DS_FUNC_CMD_MULTI_SPEED, DS_RunMultiSpeedFunc},
{"M ", "Select Module", DS_FUNC_CMD_SET_MODULE, NULL},
{"C ", "Select Channel", DS_FUNC_CMD_SET_CHANNEL, NULL}
};
/****** Set Angle Command Table *******/
naiapp_cmdtbl_params_t DS_DemoSetAngle[] = {
{"ANG ", "Set Angle", DS_ANGLE_MENU_SET_ANGLE, DS_SetNewAngle},
{"VLL ", "Set Exp. VLL", DS_ANGLE_MENU_SET_EXP_VLL, DS_SetExpVLL},
{"VREF ", "Set Exp. Ref Volt", DS_ANGLE_MENU_SET_EXP_VREF, DS_SetExpVref},
{"VLLTH ", "Set VLL Threshold Volt", DS_ANGLE_MENU_SET_VLL_THRESHOLD, DS_SetVllThreshold},
{"REFTH ", "Set VREF Threshold Volt", DS_ANGLE_MENU_SET_VREF_THRESHOLD, DS_SetVrefThreshold},
{"MODE ", "Set Fixed / Ratio Mode", DS_ANGLE_MENU_FIX_RATIO_MODE, DS_SetFixedRatioMode},
{"CSTATUS", "Set Chan Status Enable(Active Chan.)", DS_ANGLE_MENU_CHAN_STATUS_ENABLE, DS_SetChannelStatusCtrl},
{"PWR ", "Set Power", DS_ANGLE_MENU_POWER, DS_SetPower},
{"U", "Update", DS_ANGLE_MENU_REFRESH, NULL},
{"Q ", "Quit", DS_ANGLE_MENU_QUIT, NULL},
{"", "", DS_ANGLE_MENU_INVALID_INPUT, NULL}
};
/****** BIT Test Command Table *******/
naiapp_cmdtbl_params_t DS_DemoBITTest[] = {
{"ANG ", "Set Angle", DS_BIT_TEST_SET_ANGLE, DS_SetNewAngle},
{"D2 ", "Set On-Line(D2) Test", DS_BIT_TEST_SET_D2, DS_SetD2Test},
{"D3 ", "Set On-Line(D3) Test", DS_BIT_TEST_SET_D3, DS_SetD3Test},
{"VERIFY", "Set Test Verify Value", DS_BIT_TEST_SET_TEST_VERIFY, DS_SetTestVerifyValue},
{"ACT ", "Set Active Channel", DS_BIT_TEST_ACTIVE_CHAN, DS_SetChannelStatusCtrl},
{"PWR ", "Set Power", DS_BIT_TEST_POWER, DS_SetPower},
{"UPDATE ", "Update", DS_BIT_TEST_REFRESH, NULL},
{"Q ", "Quit", DS_BIT_TEST_QUIT, NULL},
{"", "", DS_BIT_TEST_INVALID_INPUT, NULL}
};
/****** Rotation Command Table *******/
naiapp_cmdtbl_params_t DS_DemoRotation[] = {
{"RATE", "Set Rotation Rate", DS_ROTATION_SET_ROT_RATE, DS_SetRotationRate},
{"MODE", "Set Rotation Mode", DS_ROTATION_SET_ROT_MODE, DS_SetRotationMode},
{"STRANG", "Set Rotation Start Angle", DS_ROTATION_SET_ROT_START_ANG, DS_SetRotationStartAngle},
{"STPANG", "Set Rotation Stop Angle", DS_ROTATION_SET_ROT_STOP_ANG, DS_SetRotationStopAngle},
{"STRROT", "Start Rotation", DS_ROTATION_INITIATE_ROTATION, DS_StartRotation},
{"STPROT", "Stop Rotation", DS_ROTATION_STOP_ROTATION, DS_StopRotation},
{"PWER", "Set Power", DS_ROTATION_POWER, DS_SetPower},
{"UPDATE", "Update", DS_ROTATION_REFRESH, NULL},
{"Q", "Quit", DS_ROTATION_QUIT, NULL},
{"", "", DS_ROTATION_INVALID_INPUT, NULL}
};
/****** Multi-Speed Command Table *******/
naiapp_cmdtbl_params_t DS_DemoMultiSpeed[] = {
{"ANG ", "Set Multi-speed Angle", DS_MULTI_SPEED_SET_ANGLE, DS_SetNewAngle},
{"VLL ", "Set Exp. VLL", DS_MULTI_SPEED_SET_EXP_VLL, DS_SetExpVLL},
{"VREF ", "Set Exp. Ref Volt", DS_MULTI_SPEED_SET_EXP_VREF, DS_SetExpVref},
{"VLLTH ", "Set VLL Threshold Volt", DS_MULTI_SPEED_SET_VLL_THRESHOLD, DS_SetVllThreshold},
{"REFTH ", "Set VREF Threshold Volt", DS_MULTI_SPEED_SET_VREF_THRESHOLD, DS_SetVrefThreshold},
{"MODE ", "Set Fixed / Ratio Mode", DS_MULTI_SPEED_FIX_RATIO_MODE, DS_SetFixedRatioMode},
{"MULTSPD", "Set Mulit Speed Ratio", DS_MULTI_SPEED_MULT_SPD, DS_SetMultiSpd},
{"PWR ", "Set Power", DS_MULTI_SPEED_POWER, DS_SetPower},
{"UPDATE ", "Update", DS_MULTI_SPEED_REFRESH, NULL},
{"Q ", "Quit", DS_MULTI_SPEED_QUIT, NULL},
{"", "", DS_MULTI_SPEED_INVALID_INPUT, NULL}
};
static struct dsUserInputLimitTable DS_SetAngleMenu_Limits[] = {
{DS_ANGLE_MENU_SET_ANGLE, (int8_t *)"Angle", 359.9954, 0.0},
{DS_ANGLE_MENU_SET_EXP_VLL, (int8_t *)"Exp VLL", 115.0, 0.0},
{DS_ANGLE_MENU_SET_EXP_VREF, (int8_t *)"Exp Vref", 115.0, 0.0},
{DS_ANGLE_MENU_SET_VLL_THRESHOLD, (int8_t *)"VLL Threshold", 115.0, 0.0},
{DS_ANGLE_MENU_SET_VREF_THRESHOLD, (int8_t *)"Vref Threshold", 115.0, 0.0},
{DS_ANGLE_MENU_FIX_RATIO_MODE, (int8_t *)"Ratio/Fixed Mode", 1.0, 0.0},
{DS_ANGLE_MENU_CHAN_STATUS_ENABLE, (int8_t *)"Active Channel", 1.0, 0.0},
{DS_ANGLE_MENU_POWER, (int8_t *)"Set Power", 1.0, 0.0},
{DS_ANGLE_MENU_REFRESH, (int8_t *)"", 0.0, 0.0},
{DS_ANGLE_MENU_QUIT, (int8_t *)"", 0.0, 0.0},
{DS_ANGLE_MENU_INVALID_INPUT, (int8_t *)"", 0.0, 0.0},
{DS_ANGLE_MENU_COUNT, (int8_t *)"", 0.0, 0.0}
};
static struct dsUserInputLimitTable DS_BitTestMenu_Limits[] = {
{DS_BIT_TEST_SET_ANGLE, (int8_t *)"Angle", 359.9954, 0.0},
{DS_BIT_TEST_SET_D2, (int8_t *)"D2 TestDisable/Enable", 1.0, 0.0},
{DS_BIT_TEST_SET_D3, (int8_t *)"D3 TestDisable/Enable", 1.0, 0.0},
{DS_BIT_TEST_SET_TEST_VERIFY, (int8_t *)"D2 Test Verify Value", 65535.0, 0.0},
{DS_BIT_TEST_ACTIVE_CHAN, (int8_t *)"Active Channel", 1.0, 0.0},
{DS_BIT_TEST_POWER, (int8_t *)"Set Power", 1.0, 0.0},
{DS_BIT_TEST_REFRESH, (int8_t *)"", 0.0, 0.0},
{DS_BIT_TEST_QUIT, (int8_t *)"", 0.0, 0.0},
{DS_BIT_TEST_INVALID_INPUT, (int8_t *)"", 0.0, 0.0},
{DS_BIT_TEST_COUNT, (int8_t *)"", 0.0, 0.0}
};
static struct dsUserInputLimitTable DS_RotationMenu_Limits[] = {
{DS_ROTATION_SET_ROT_RATE, (int8_t *)"Rot. Rate", 1000.0, -1000.0 },
{DS_ROTATION_SET_ROT_MODE, (int8_t *)"Rot. Mode", 1.0, 0.0 },
{DS_ROTATION_SET_ROT_START_ANG, (int8_t *)"Rot. Start Angle", 359.9954, 0.0 },
{DS_ROTATION_SET_ROT_STOP_ANG, (int8_t *)"Rot. Stop Angle", 359.9954, 0.0 },
{DS_ROTATION_INITIATE_ROTATION, (int8_t *)"Start Rot", 1.0, 0.0 },
{DS_ROTATION_STOP_ROTATION, (int8_t *)"Stop Rot.", 1.0, 0.0 },
{DS_ROTATION_POWER, (int8_t *)"Set Power", 1.0, 0.0 },
{DS_ROTATION_REFRESH, (int8_t *)"", 0.0, 0.0 },
{DS_ROTATION_QUIT, (int8_t *)"", 0.0, 0.0 },
{DS_ROTATION_INVALID_INPUT, (int8_t *)"", 0.0, 0.0 },
{DS_ROTATION_COUNT, (int8_t *)"", 0.0, 0.0 }
};
static struct dsUserInputLimitTable DS_MultiSpeedMenu_Limits[] = {
{DS_MULTI_SPEED_SET_ANGLE, (int8_t *)"Angle", 359.9954, 0.0 },
{DS_MULTI_SPEED_SET_EXP_VLL, (int8_t *)"Exp VLL", 115.0, 0.0 },
{DS_MULTI_SPEED_SET_EXP_VREF, (int8_t *)"Exp Vref", 115.0, 0.0 },
{DS_MULTI_SPEED_SET_VLL_THRESHOLD, (int8_t *)"VLL Threshold", 115.0, 0.0 },
{DS_MULTI_SPEED_SET_VREF_THRESHOLD, (int8_t *)"Vref Threshold", 115.0, 0.0 },
{DS_MULTI_SPEED_FIX_RATIO_MODE, (int8_t *)"Ratio/Fixed Mode", 1.0, 0.0 },
{DS_MULTI_SPEED_MULT_SPD, (int8_t *)"Multi Speed", 255.0, 1.0 },
{DS_MULTI_SPEED_POWER, (int8_t *)"Set Power", 1.0, 0.0 },
{DS_MULTI_SPEED_REFRESH, (int8_t *)"", 0.0, 0.0 },
{DS_MULTI_SPEED_QUIT, (int8_t *)"", 0.0, 0.0 },
{DS_MULTI_SPEED_INVALID_INPUT, (int8_t *)"", 0.0, 0.0 },
{DS_MULTI_SPEED_COUNT, (int8_t *)"", 0.0, 0.0 }
};
#if defined (__VXWORKS__)
int32_t DS_RunAngleProgramSample(void)
#else
int32_t main(void)
#endif
{
bool_t stop = NAI_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) == NAI_TRUE)
{
while (stop != NAI_TRUE)
{
/* Query the user for the card index */
stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
/* Query the user for the module number */
stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
if (stop != NAI_TRUE)
{
check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
if ((moduleID != 0))
{
DS_RunAngleProgram(cardIndex, module, moduleID, moduleCnt);
}
}
}
naiif_printf("\r\nType Q to quit or Enter key to restart application:\r\n");
stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
}
naiif_printf("\r\nType the Enter key to exit the program: ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
naiapp_access_CloseAllOpenCards();
return 0;
}
/**************************************************************************************************************/
/**
<summary>
DS_RunAngleProgram queries the user for the module and channel to configure for DS output.
</summary>
*/
/**************************************************************************************************************/
static void DS_RunAngleProgram(int32_t cardIndex, int32_t module, uint32_t moduleID, int32_t moduleCount)
{
bool_t bQuit = NAI_FALSE;
bool_t bCmdFound = NAI_FALSE;
int32_t channel = 0;
int32_t MaxChannel = 0;
int32_t cmd;
naiapp_AppParameters_t ds_basicOps_params;
p_naiapp_AppParameters_t p_ds_basicOps_params = &ds_basicOps_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
/* Get the number of D/S channels on the module */
check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
MaxChannel = naibrd_DS_GetChannelCount(moduleID);
p_ds_basicOps_params->cardIndex = cardIndex;
p_ds_basicOps_params->module = module;
p_ds_basicOps_params->channel = 1;
p_ds_basicOps_params->maxChannels = MaxChannel;
p_ds_basicOps_params->modId = moduleID;
p_ds_basicOps_params->displayHex = NAI_FALSE;
/*Show data*/
do
{
naiapp_utils_LoadParamMenuCommands(DS_FUNC_CMD_COUNT, DS_DemoFuncMenuCmds);
naiapp_display_ParamMenuCommands((int8_t*)"DS Basic Ops");
naiif_printf("\r\nType DS 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 ((cmd >= 0) && (cmd < DS_FUNC_CMD_COUNT) && (bCmdFound))
{
switch (cmd)
{
case DS_FUNC_CMD_SET_ANGLE:
if ((p_ds_basicOps_params->module > 0) && (p_ds_basicOps_params->channel > 0))
DS_RunAngleFunc(APP_PARAM_COUNT, (int32_t*)p_ds_basicOps_params);
break;
case DS_FUNC_CMD_BIT_TEST:
if ((p_ds_basicOps_params->module > 0) && (p_ds_basicOps_params->channel > 0))
DS_RunBitTestFunc(APP_PARAM_COUNT, (int32_t*)p_ds_basicOps_params);
break;
case DS_FUNC_CMD_ROTATION:
if ((p_ds_basicOps_params->module > 0) && (p_ds_basicOps_params->channel > 0))
DS_SetRotation(APP_PARAM_COUNT, (int32_t*)p_ds_basicOps_params);
break;
case DS_FUNC_CMD_MULTI_SPEED:
if ((p_ds_basicOps_params->module > 0) && (p_ds_basicOps_params->channel > 0))
DS_RunMultiSpeedFunc(APP_PARAM_COUNT, (int32_t*)p_ds_basicOps_params);
break;
case DS_FUNC_CMD_SET_MODULE:
naiif_printf("\r\nEnter Module Number:\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
module = atoi((const char *)inputBuffer);
if ((module < 1) || (module > moduleCount))
{
naiif_printf("\r\n%s: %d is outside the limits[%d - %d]", "Module #", module, 1, moduleCount);
}
else
{
check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
if (((moduleID & 0xFFFF0000) == NAIBRD_MODULE_ID_DS) || ((moduleID & 0xFFFF0000) == NAIBRD_MODULE_ID_DR))
{
p_ds_basicOps_params->module = module;
}
else
{
naiif_printf("\r\nModule %d is not a DS module!\r\n", module);
}
}
break;
case DS_FUNC_CMD_SET_CHANNEL:
naiif_printf("\r\nEnter Channel Number:\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
channel = atoi((const char *)inputBuffer);
if ((channel < 1) || (channel > MaxChannel))
{
naiif_printf("\r\n%s: %d is outside the limits[%d - %d]", "Channel #", channel, 1, MaxChannel);
}
else
{
p_ds_basicOps_params->channel = channel;
}
break;
default:
break;
}
}
}
} while (bQuit == NAI_FALSE);
}
/*This function puts the specific D/S channel in rotation mode. The
user can set the following set angle attributes:
1. Set Angle.
2. Set Expected VLL.
3. Set Expected VREF.
4. Set VLL Threshold.
5. Set VREF Threshold.
6. Set Fixed/Ratio Mode.
7. Set Active Channel.
8. Set Power.
*/
static nai_status_t DS_RunAngleFunc(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
bool_t bCmdFound = NAI_FALSE;
int32_t cmd;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\n================================================================");
naiif_printf("\r\nThis program allows the user to set the output angle of a ");
naiif_printf("\r\nspecified channel of a D/S module. The user can change the ");
naiif_printf("\r\nfollowing module properties. ");
naiif_printf("\r\n1. Set Angle.");
naiif_printf("\r\n2. Set Expected VLL");
naiif_printf("\r\n3. Set Expected VREF");
naiif_printf("\r\n4. Set VLL Threshold");
naiif_printf("\r\n5. Set VREF Threshold");
naiif_printf("\r\n6. Set Fixed/Ratio Mode");
naiif_printf("\r\n7. Set Active Channel");
naiif_printf("\r\n8. Set Module Power");
naiif_printf("\r\n================================================================\r\n");
do
{
naiapp_utils_LoadParamMenuCommands(DS_ANGLE_MENU_COUNT, DS_DemoSetAngle);
DS_ShowSetAngleTestResult(cardIndex, module, channel);
showCurrentModChan(module, channel);
naiapp_display_ParamMenuCommands((int8_t*)"DS Set Angle Menu");
naiif_printf("\r\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)
{
switch (cmd)
{
case DS_ANGLE_MENU_SET_ANGLE:
case DS_ANGLE_MENU_SET_EXP_VLL:
case DS_ANGLE_MENU_SET_EXP_VREF:
case DS_ANGLE_MENU_SET_VLL_THRESHOLD:
case DS_ANGLE_MENU_SET_VREF_THRESHOLD:
case DS_ANGLE_MENU_FIX_RATIO_MODE:
case DS_ANGLE_MENU_CHAN_STATUS_ENABLE:
case DS_ANGLE_MENU_POWER:
DS_DemoSetAngle[cmd].func(APP_PARAM_COUNT, (int32_t*)p_ds_params);
break;
case DS_ANGLE_MENU_QUIT:
bQuit = NAI_TRUE;
break;
case DS_ANGLE_MENU_REFRESH:
case DS_ANGLE_MENU_INVALID_INPUT:
break;
}
}
}
} while (bQuit == NAI_FALSE);
return NAI_SUCCESS;
}
static void DS_ShowSetAngleTestResult(int32_t cardIndex, int32_t module, int32_t channel)
{
float64_t dValue = 0.0;
uint32_t unValue = 0;
uint8_t u8Status[10];
bool_t bValue = NAI_FALSE;
memset(u8Status, 0, sizeof(u8Status));
naiif_printf("\r\nSet angle Meas angle VLL VRef Mode Meas. VLL Meas. VRef Meas.RFreq VLL.Thres ");
naiif_printf(" VREF.Thres Multi-Spd Status Act.Chan. Power \r\n");
naiif_printf("\r\n ");
naiif_printf(" Ratio S/R/B/P ");
naiif_printf("\r\n---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------");
naiif_printf(" ---------- ---------- ---------- ---------- ---------- \r\n");
/*Set Angle*/
check_status(naibrd_DS_GetAngle(cardIndex, module, channel, NAIBRD_DS_ANGLE_SINGLE, &dValue));
naiif_printf("%-12.4f", dValue);
/*get measured angle*/
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel, NAIBRD_DS_MEASURED_ANGLE, &dValue));
naiif_printf("%-12.4f", dValue); /*wrap angle*/
/*expected VLl */
check_status(naibrd_DS_GetExpectedVoltage(cardIndex, module, channel, NAIBRD_DS_EXP_VOLT_SIGNAL, &dValue));
naiif_printf("%-12.4f", dValue); /*expected Vll*/
/*expected Vref */
check_status(naibrd_DS_GetExpectedVoltage(cardIndex, module, channel, NAIBRD_DS_EXP_VOLT_REFERENCE, &dValue));
naiif_printf("%-12.4f", dValue); /*expected VRef*/
/*fixed/ratio mode */
check_status(naibrd_DS_GetRatioFixedMode(cardIndex, module, channel, &unValue));
if ((naibrd_ds_output_ratio_fixed_mode_t)unValue == NAIBRD_DS_OUTPUT_RATIO)
naiif_printf("%-12s", "Ratio"); /*Ratio*/
else
naiif_printf("%-12s", "Fixed"); /*Fixed*/
/*measured Vll */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel, NAIBRD_DS_MEASURED_SIGNAL_VOLTAGE, &dValue));
naiif_printf("%-12.4f", dValue); /*meas Vll*/
/*measured Vref */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel, NAIBRD_DS_MEASURED_REF_VOLTAGE, &dValue));
naiif_printf("%-12.4f", dValue); /*meas Vref*/
/*measured RefFreq */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel, NAIBRD_DS_MEASURED_REF_FREQUENCY, &dValue));
naiif_printf("%-12.4f", dValue); /*meas RefFreq*/
/*Vll Threshold*/
check_status(naibrd_DS_GetThresholdVoltage(cardIndex, module, channel, NAIBRD_DS_THRESHOLD_VOLT_SIGNAL, &dValue));
naiif_printf("%-12.4f", dValue); /*VLL Threshold*/
/*VREF Threshold*/
check_status(naibrd_DS_GetThresholdVoltage(cardIndex, module, channel, NAIBRD_DS_THRESHOLD_VOLT_REFERENCE, &dValue));
naiif_printf("%-12.4f", dValue); /*VREF Threshold*/
/*Multi-Spd*/
check_status(naibrd_DS_GetMultiSpeedRatio(cardIndex, module, NAIBRD_DS_MULTI_SPD_CH1_2_PAIR, &unValue));
naiif_printf("%-12d", unValue); /*Multi-Spd*/
/*get Status: S=Signal Loss, R=Reference Loss, B=BIT Loss, P=Phase Loss*/
getStatus(cardIndex, module, channel, u8Status);
naiif_printf("%-12s", u8Status); /*status*/
/*get Channel Status Enable (formerly Active Channel))*/
check_status(naibrd_DS_GetChanStatusEnable(cardIndex, module, channel, &unValue));
if (unValue == (uint32_t)NAI_TRUE)
naiif_printf("%-12s", "Enabled");
else
naiif_printf("%-12s", "Disabled");
/*get power State*/
check_status(naibrd_DS_GetPowerEnable(cardIndex, module, channel, &bValue));
if (bValue == NAI_TRUE)
naiif_printf("%-12s", "Enabled");
else
naiif_printf("%-12s", "Disabled");
naiif_printf("\r\n");
}
/*This function puts the D/S module in different test mode. The
user can set the following test modes:
1. Set on line back-ground test mode (D2 Test).
2. Set off line back-ground test mode (D3 Test).
3. Set test verify value.
4. Set Active Channel.
5. Set Power.
*/
static nai_status_t DS_RunBitTestFunc(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
bool_t bCmdFound = NAI_FALSE;
int32_t cmd;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\n================================================================");
naiif_printf("\r\nThis program allows the user to put the D/S module in different ");
naiif_printf("\r\ntest modes. The modes are: 1. On-line back ground test (D2). ");
naiif_printf("\r\n2. Off-line back ground test (D3). ");
naiif_printf("\r\n1. Disable/Enable on-line back ground test (D2).");
naiif_printf("\r\n2. Disable/Enable off-line back ground test (D3).");
naiif_printf("\r\n3. Set test verify value.");
naiif_printf("\r\n4. Set Angle");
naiif_printf("\r\n5. Set Active Channel");
naiif_printf("\r\n6. Set Module Power");
naiif_printf("\r\n================================================================\r\n");
do
{
naiapp_utils_LoadParamMenuCommands(DS_BIT_TEST_COUNT, DS_DemoBITTest);
DS_ShowTestMenu(cardIndex, module, channel);
showCurrentModChan(module, channel);
naiapp_display_ParamMenuCommands((int8_t*)"DS BIT Test Menu");
naiif_printf("\r\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)
{
switch (cmd)
{
case DS_BIT_TEST_SET_ANGLE:
case DS_BIT_TEST_SET_D2:
case DS_BIT_TEST_SET_D3:
case DS_BIT_TEST_SET_TEST_VERIFY:
case DS_BIT_TEST_ACTIVE_CHAN:
case DS_BIT_TEST_POWER:
DS_DemoBITTest[cmd].func(APP_PARAM_COUNT, (int32_t*)p_ds_params);
break;
case DS_BIT_TEST_QUIT:
bQuit = NAI_TRUE;
break;
case DS_BIT_TEST_REFRESH:
case DS_BIT_TEST_INVALID_INPUT:
break;
}
}
}
} while (bQuit == NAI_FALSE);
return NAI_SUCCESS;
}
static void DS_ShowTestMenu(int32_t cardIndex, int32_t module, int32_t channel)
{
float64_t dValue = 0.0;
uint32_t unValue = 0;
uint8_t u8Status[10];
bool_t bValue = NAI_FALSE;
memset(u8Status, 0, sizeof(u8Status));
naiif_printf("\r\nSet angle Meas angle D2 D3 Mode Test Verify Meas. VLL Meas. VRef ");
naiif_printf("Meas.RFreq Status Act.Chan. Power \r\n");
naiif_printf("\r\n Off/On Off/On Ratio/Fixed Value ");
naiif_printf(" S/R/B/P ");
naiif_printf("\r\n---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ");
naiif_printf("---------- ---------- ---------- ----------\r\n");
/*Set Angle*/
check_status(naibrd_DS_GetAngle(cardIndex, module, channel, NAIBRD_DS_ANGLE_SINGLE, &dValue));
naiif_printf("%-12.4f", dValue);
/*get measured angle*/
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel, NAIBRD_DS_MEASURED_ANGLE, &dValue));
naiif_printf("%-12.4f", dValue);
/*Get D2 Test */
check_status(naibrd_DS_GetTestModeEnable(cardIndex, module, NAIBRD_DS_ON_LINE_TEST, &bValue));
if (bValue == NAI_TRUE)
naiif_printf("%-12s", DS_ENABLE);
else
naiif_printf("%-12s", DS_DISABLE);
/*Get D3 Test */
check_status(naibrd_DS_GetTestModeEnable(cardIndex, module, NAIBRD_DS_OFF_LINE_TEST, &bValue));
if (bValue == NAI_TRUE)
naiif_printf("%-12s", DS_ENABLE);
else
naiif_printf("%-12s", DS_DISABLE);
/*fixed/ratio mode */
check_status(naibrd_DS_GetRatioFixedMode(cardIndex, module, channel, &unValue));
if ((naibrd_ds_output_ratio_fixed_mode_t)unValue == NAIBRD_DS_OUTPUT_RATIO)
naiif_printf("%-12s", DS_RATIO); /*Ratio*/
else
naiif_printf("%-12s", DS_FIXED); /*Fixed*/
/*D2 Verify Value*/
check_status(naibrd_DS_GetTestVerify(cardIndex, module, &unValue));
naiif_printf("0x%-10x", unValue);
/*measured Vll */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel, NAIBRD_DS_MEASURED_SIGNAL_VOLTAGE, &dValue));
naiif_printf("%-12.4f", dValue); /*meas Vll*/
/*measured Vref */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel, NAIBRD_DS_MEASURED_REF_VOLTAGE, &dValue));
naiif_printf("%-12.4f", dValue); /*meas Vref*/
/*measured RefFreq */
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel, NAIBRD_DS_MEASURED_REF_FREQUENCY, &dValue));
naiif_printf("%-12.4f", dValue); /*meas RefFreq*/
/*get Status: S=Signal Loss, R=Reference Loss, B=BIT Loss, P=Phase Loss*/
getStatus(cardIndex, module, channel, u8Status);
naiif_printf("%-12s", u8Status); /*status*/
/*get Active Channel*/
check_status(naibrd_DS_GetActiveChannel(cardIndex, module, channel, &bValue));
if (bValue == NAI_TRUE)
naiif_printf("%-12s", DS_ENABLE);
else
naiif_printf("%-12s", DS_DISABLE);
/*get power State*/
check_status(naibrd_DS_GetPowerEnable(cardIndex, module, channel, &bValue));
if (bValue == NAI_TRUE)
naiif_printf("%-12s", DS_ENABLE);
else
naiif_printf("%-12s", DS_DISABLE);
naiif_printf("\r\n");
}
/*This function puts the specific D/S channel in oration mode. The
user can set the following rotation attributes:
1. Rotation Rate.
2. Rotation Mode (Continuous / Start-stop).
3. Rotation Start Angle.
4. Rotation Stop Angle.
5. Initiate Rotation
6. Stop Rotation
This function sets rotation trigger source to internal(software) and
the user can query the current rotation state. */
static nai_status_t DS_SetRotation(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
bool_t bCmdFound = NAI_FALSE;
int32_t cmd;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\n================================================================");
naiif_printf("\r\nThis program puts the specific D/S channel in oration mode.");
naiif_printf("\r\nThe user can set the following rotation attributes:");
naiif_printf("\r\n1. Rotation Rate.");
naiif_printf("\r\n2. Rotation Mode (Continuous / Start-stop).");
naiif_printf("\r\n3. Rotation Start Angle");
naiif_printf("\r\n4. Rotation Stop Angle");
naiif_printf("\r\n5. Initiate Rotation");
naiif_printf("\r\n6. Stop Rotation");
naiif_printf("\r\n7. Set Module Power");
naiif_printf("\r\nThe rotation trigger source is set to internal(software trigger) ");
naiif_printf("\r\nand the user can query the current rotation state.\r\n");
naiif_printf("\r\n================================================================");
/*set up voltage threshold*/
/* check_status( naibrd_DS_SetThresholdVoltage(cardIndex, module, channel, NAI_DS_THRESHOLD_VOLT_REFERENCE,
dDSExpRefVolt * THRESHOLD_VOLT_GAIN ) ); */
/* check_status( naibrd_DS_SetThresholdVoltage(cardIndex, module, channel, NAI_DS_THRESHOLD_VOLT_SIGNAL,
dDSExpSigVolt * THRESHOLD_VOLT_GAIN ) ); */
/*set up expected VLL*/
/* check_status( naibrd_DS_SetExpectedVoltage(cardIndex, module, channel, NAI_DS_EXP_VOLT_REFERENCE, dDSExpRefVolt ) ); */
/* check_status( naibrd_DS_SetExpectedVoltage(cardIndex, module, channel, NAI_DS_EXP_VOLT_SIGNAL, dDSExpSigVolt ) ); */
/*set up ratio/fixed mode*/
check_status(naibrd_DS_SetRatioFixedMode(cardIndex, module, channel, NAIBRD_DS_OUTPUT_FIXED));
/*set up active channel*/
check_status(naibrd_DS_SetActiveChannel(cardIndex, module, channel, NAI_TRUE));
/*set up rotation trigger source to Internal*/
check_status(naibrd_DS_SetRotationCtrl(cardIndex, module, channel, NAIBRD_DS_ROTATION_TRIG_SOURCE,
(float64_t)NAIBRD_DS_ROT_TRIG_INTERNAL));
/*set up power*/
check_status(naibrd_DS_SetPowerEnable(cardIndex, module, channel, NAI_TRUE));
do
{
naiapp_utils_LoadParamMenuCommands(DS_ROTATION_COUNT, DS_DemoRotation);
DS_ShowSetRotationTestResult(cardIndex, module, channel);
showCurrentModChan(module, channel);
naiapp_display_ParamMenuCommands((int8_t*)"DS Rotation Menu");
naiif_printf("\r\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)
{
switch (cmd)
{
case DS_ROTATION_SET_ROT_RATE:
case DS_ROTATION_SET_ROT_MODE:
case DS_ROTATION_SET_ROT_START_ANG:
case DS_ROTATION_SET_ROT_STOP_ANG:
case DS_ROTATION_INITIATE_ROTATION:
case DS_ROTATION_STOP_ROTATION:
case DS_ROTATION_POWER:
DS_DemoRotation[cmd].func(APP_PARAM_COUNT, (int32_t*)p_ds_params);
break;
case DS_ROTATION_QUIT:
bQuit = NAI_TRUE;
break;
case DS_ROTATION_REFRESH:
case DS_ROTATION_INVALID_INPUT:
break;
}
}
}
} while (bQuit == NAI_FALSE);
return NAI_SUCCESS;
}
static void DS_ShowSetRotationTestResult(int32_t cardIndex, int32_t module, int32_t channel)
{
float64_t dValue = 0.0;
uint32_t unValue = 0;
bool_t bValue = NAI_FALSE;
/* 1 1 1 1 1 1 1 1 1 1 1 1 */
/* 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 */
/*naiif_printf("\r\nRot. Rate Rot. Mode Start Angle Stop Angle Rot. Source Rot. State Power "); */
naiif_printf("\r\nRot. Rate Rot. Mode Meas. Ang Start Angle Stop Angle Rot. Source Rot. State Power ");
naiif_printf("\r\n---------- ---------- ---------- ---------- ---------- ---------- ---------- ");
naiif_printf("----------\r\n");
/*get rotation rate*/
check_status(naibrd_DS_GetRotationCtrl(cardIndex, module, channel, NAIBRD_DS_ROTATION_RATE, &dValue));
naiif_printf("%-15.4f", dValue);
/*get rotation Mode*/
check_status(naibrd_DS_GetRotationCtrl(cardIndex, module, channel, NAIBRD_DS_ROTATION_MODE, &dValue));
if ((naibrd_ds_rotation_mode_t)dValue == NAIBRD_DS_ROT_CONTINUOUS_MODE)
naiif_printf("%-15s", DS_ROTATION_CONTINUOUS);
else
naiif_printf("%-15s", DS_ROTATION_START_STOP);
/*get measured angle*/
check_status(naibrd_DS_GetMeasuredValue(cardIndex, module, channel, NAIBRD_DS_MEASURED_ANGLE, &dValue));
naiif_printf("%-15.4f", dValue); /*wrap angle*/
/*get rotation Start Angle*/
check_status(naibrd_DS_GetAngle(cardIndex, module, channel, NAIBRD_DS_ANGLE_SINGLE, &dValue));
naiif_printf("%-15.4f", dValue);
/*get rotation Stop Angle*/
check_status(naibrd_DS_GetAngle(cardIndex, module, channel, NAIBRD_DS_ANGLE_ROTATION_STOP, &dValue));
naiif_printf("%-15.4f", dValue);
/*get rotation Source*/
check_status(naibrd_DS_GetRotationCtrl(cardIndex, module, channel, NAIBRD_DS_ROTATION_TRIG_SOURCE, &dValue));
if ((naibrd_ds_rotation_trigger_source_t)dValue == NAIBRD_DS_ROT_TRIG_INTERNAL)
naiif_printf("%-15s", DS_ROTATION_SRC_INT);
else if ((naibrd_ds_rotation_trigger_source_t)dValue == NAIBRD_DS_ROT_TRIG_EXTERNAL)
naiif_printf("%-15s", DS_ROTATION_SRC_EXT);
else
naiif_printf("%-15s", DS_NOT_DEFINED);
/*get rotation State*/
check_status(naibrd_DS_GetRotationStatus(cardIndex, module, channel, &unValue));
if (unValue == NAIBRD_DS_STATUS_ROT_NOT_DONE)
naiif_printf("%-15s", DS_ROTATION_STATUS_ROTATING);
else
naiif_printf("%-15s", DS_ROTATION_STATUS_NOT_ROTATING);
/*get power State*/
check_status(naibrd_DS_GetPowerEnable(cardIndex, module, channel, &bValue));
if (bValue == NAI_TRUE)
naiif_printf("%-15s", DS_ENABLE);
else
naiif_printf("%-15s", DS_DISABLE);
naiif_printf("\r\n");
}
/*This function puts the specific D/S channel in multi-speed mode.
The user can set the following multi-speed attributes:
1. Set Angle.
2. Set Expected VLL.
3. Set Expected VREF.
4. Set VLL Threshold.
5. Set VREF Threshold.
6. Set Fixed/Ratio Mode.
7. Set Active Channel.
8. Set Power.
*/
static nai_status_t DS_RunMultiSpeedFunc(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = NAI_FALSE;
bool_t bCmdFound = NAI_FALSE;
int32_t cmd;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\n================================================================");
naiif_printf("\r\nThis program allows the user to set the multi-speed ratio in ");
naiif_printf("\r\na D/S module. It also reports back its measured coarse and ");
naiif_printf("\r\nfine angle of the channel. The following D/S properties can ");
naiif_printf("\r\nbe changed by the user: ");
naiif_printf("\r\n1. Set Angle.");
naiif_printf("\r\n2. Set Expected VLL");
naiif_printf("\r\n3. Set Expected VREF");
naiif_printf("\r\n4. Set VLL Threshold");
naiif_printf("\r\n5. Set VREF Threshold");
naiif_printf("\r\n6. Set Fixed/Ratio Mode");
naiif_printf("\r\n7. Set Multi-speed ratio");
naiif_printf("\r\n8. Set Module Power");
naiif_printf("\r\n================================================================\r\n");
do
{
naiapp_utils_LoadParamMenuCommands(DS_MULTI_SPEED_COUNT, DS_DemoMultiSpeed);
DS_ShowMultiSpeedMenu(cardIndex, module, channel);
showCurrentModChan(module, channel);
naiapp_display_ParamMenuCommands((int8_t*)"DS Multi-Speed Menu");
naiif_printf("\r\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)
{
switch (cmd)
{
case DS_MULTI_SPEED_SET_ANGLE:
case DS_MULTI_SPEED_SET_EXP_VLL:
case DS_MULTI_SPEED_SET_EXP_VREF:
case DS_MULTI_SPEED_SET_VLL_THRESHOLD:
case DS_MULTI_SPEED_SET_VREF_THRESHOLD:
case DS_MULTI_SPEED_FIX_RATIO_MODE:
case DS_MULTI_SPEED_MULT_SPD:
case DS_MULTI_SPEED_POWER:
DS_DemoMultiSpeed[cmd].func(APP_PARAM_COUNT, (int32_t*)p_ds_params);
break;
case DS_MULTI_SPEED_QUIT:
bQuit = NAI_TRUE;
break;
case DS_MULTI_SPEED_REFRESH:
case DS_MULTI_SPEED_INVALID_INPUT:
break;
}
}
}
} while (bQuit == NAI_FALSE);
return NAI_SUCCESS;
}
static void DS_ShowMultiSpeedMenu(int32_t cardIndex, int32_t module, int32_t channel)
{
float64_t dValue = 0.0;
uint32_t unValue = 0;
uint8_t u8Status[10];
bool_t bValue = NAI_FALSE;
uint32_t unCoarseChan = 1;
uint32_t unFineChan = 2;
memset(u8Status, 0, sizeof(u8Status));
naiif_printf("\r\nSet angle Meas angle Meas angle Multi Spd VLL VRef Mode Meas. VLL Meas. VRef ");
naiif_printf("Meas.RFreq VLL.Thres VREF.Thres Power \r\n");
naiif_printf("\r\n (coarse) (fine) ratio ");
naiif_printf(" ");
naiif_printf("\r\n---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ");
naiif_printf("---------- ---------- ---------- ---------- \r\n");
/*Set Angle*/
check_status( naibrd_DS_GetAngle(cardIndex, module, unCoarseChan, NAIBRD_DS_ANGLE_TWO_SPEED, &dValue ) );
naiif_printf("%-12.4f",dValue);
/*get measured coarse angle Ch1*/
check_status( naibrd_DS_GetMeasuredValue( cardIndex, module, unCoarseChan, NAIBRD_DS_MEASURED_ANGLE, &dValue) );
naiif_printf("%-12.4f",dValue);
/*get measured fine angle Ch2*/
check_status( naibrd_DS_GetMeasuredValue( cardIndex, module, unFineChan, NAIBRD_DS_MEASURED_ANGLE, &dValue) );
naiif_printf("%-12.4f",dValue);
/*get multi-speed ratio*/
check_status( naibrd_DS_GetMultiSpeedRatio( cardIndex, module, NAIBRD_DS_MULTI_SPD_CH1_2_PAIR, &unValue) );
naiif_printf("%-12d",unValue);
/*expected VLl */
check_status( naibrd_DS_GetExpectedVoltage( cardIndex, module, channel, NAIBRD_DS_EXP_VOLT_SIGNAL, &dValue) );
naiif_printf("%-12.4f",dValue);
/*expected Vref */
check_status( naibrd_DS_GetExpectedVoltage( cardIndex, module, channel, NAIBRD_DS_EXP_VOLT_REFERENCE, &dValue) );
naiif_printf("%-12.4f",dValue);
/*fixed/ratio mode */
check_status( naibrd_DS_GetRatioFixedMode( cardIndex, module, channel, &unValue) );
if ((naibrd_ds_output_ratio_fixed_mode_t)unValue == NAIBRD_DS_OUTPUT_RATIO)
naiif_printf("%-12s",DS_RATIO); /*Ratio*/
else
naiif_printf("%-12s",DS_FIXED); /*Fixed*/
/*measured Vll */
check_status( naibrd_DS_GetMeasuredValue( cardIndex, module, channel, NAIBRD_DS_MEASURED_SIGNAL_VOLTAGE, &dValue) );
naiif_printf("%-12.4f",dValue); /*meas Vll*/
/*measured Vref */
check_status( naibrd_DS_GetMeasuredValue( cardIndex, module, channel, NAIBRD_DS_MEASURED_REF_VOLTAGE, &dValue) );
naiif_printf("%-12.4f",dValue); /*meas Vref*/
/*measured RefFreq */
check_status( naibrd_DS_GetMeasuredValue( cardIndex, module, channel, NAIBRD_DS_MEASURED_REF_FREQUENCY, &dValue) );
naiif_printf("%-12.4f",dValue); /*meas RefFreq*/
/*Vll Threshold*/
check_status( naibrd_DS_GetThresholdVoltage( cardIndex, module, channel, NAIBRD_DS_THRESHOLD_VOLT_SIGNAL, &dValue) );
naiif_printf("%-12.4f",dValue); /*VLL Threshold*/
/*VREF Threshold*/
check_status( naibrd_DS_GetThresholdVoltage( cardIndex, module, channel, NAIBRD_DS_THRESHOLD_VOLT_REFERENCE, &dValue) );
naiif_printf("%-12.4f",dValue); /*VREF Threshold*/
/*get power State*/
check_status( naibrd_DS_GetPowerEnable(cardIndex, module, channel, &bValue ) );
if (bValue == NAI_TRUE)
naiif_printf("%-12s",DS_ENABLE);
else
naiif_printf("%-12s",DS_DISABLE);
naiif_printf("\r\n");
}
static nai_status_t DS_SetNewAngle(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter New Angle\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ANGLE_MENU_SET_ANGLE, dValue, DS_FUNC_CMD_SET_ANGLE);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ANGLE_MENU_SET_ANGLE, dValue, DS_FUNC_CMD_SET_ANGLE);
else
{
/*Set angle*/
check_status(naibrd_DS_SetAngle(cardIndex, module, channel, NAIBRD_DS_ANGLE_SINGLE, dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetExpVLL(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter Expected D/S VLL\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ANGLE_MENU_SET_EXP_VLL, dValue, DS_FUNC_CMD_SET_ANGLE);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ANGLE_MENU_SET_EXP_VLL, dValue, DS_FUNC_CMD_SET_ANGLE);
else
{
/*Set expected VLL*/
check_status(naibrd_DS_SetExpectedVoltage(cardIndex, module, channel, NAIBRD_DS_EXP_VOLT_SIGNAL, dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetExpVref(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter Expected D/S VREF\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ANGLE_MENU_SET_EXP_VREF, dValue, DS_FUNC_CMD_SET_ANGLE);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ANGLE_MENU_SET_EXP_VREF, dValue, DS_FUNC_CMD_SET_ANGLE);
else
{
/*Set expected VREF*/
check_status(naibrd_DS_SetExpectedVoltage(cardIndex, module, channel, NAIBRD_DS_EXP_VOLT_REFERENCE, dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetVllThreshold(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter VLL THRESHOLD\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ANGLE_MENU_SET_VLL_THRESHOLD, dValue, DS_FUNC_CMD_SET_ANGLE);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ANGLE_MENU_SET_VLL_THRESHOLD, dValue, DS_FUNC_CMD_SET_ANGLE);
else
{
/*Set VLL Threshold*/
check_status(naibrd_DS_SetThresholdVoltage(cardIndex, module, channel, NAIBRD_DS_THRESHOLD_VOLT_SIGNAL, dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetVrefThreshold(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter VREF THRESHOLD\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ANGLE_MENU_SET_VREF_THRESHOLD, dValue, DS_FUNC_CMD_SET_ANGLE);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ANGLE_MENU_SET_VREF_THRESHOLD, dValue, DS_FUNC_CMD_SET_ANGLE);
else
{
/*Set VLL Threshold*/
check_status(naibrd_DS_SetThresholdVoltage(cardIndex, module, channel, NAIBRD_DS_THRESHOLD_VOLT_REFERENCE, dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetFixedRatioMode(int32_t paramCount, int32_t* p_params)
{
uint32_t unValue = 0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter Fixed/Ratio Mode [Fixed = 1, Ratio = 0]\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
unValue = atoi((const char *)inputBuffer);
if ((unValue == 0u) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ANGLE_MENU_FIX_RATIO_MODE, unValue, DS_FUNC_CMD_SET_ANGLE);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ANGLE_MENU_FIX_RATIO_MODE, unValue, DS_FUNC_CMD_SET_ANGLE);
else
{
/*Set Fixed/Ratio Mode*/
check_status(naibrd_DS_SetRatioFixedMode(cardIndex, module, channel, unValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetChannelStatusCtrl(int32_t paramCount, int32_t* p_params)
{
uint32_t unValue = 0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nSet Active Channel [Disable = 0, Enable = 1]\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
unValue = atoi((const char *)inputBuffer);
if ((unValue == 0u) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ANGLE_MENU_CHAN_STATUS_ENABLE, unValue, DS_FUNC_CMD_SET_ANGLE);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ANGLE_MENU_CHAN_STATUS_ENABLE, unValue, DS_FUNC_CMD_SET_ANGLE);
else
{
/*Set channel status enable (formerly active channel)*/
check_status(naibrd_DS_SetChanStatusEnable(cardIndex, module, channel, unValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetPower(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nSet Power[DISABLE = 0, ENABLE = 1]\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ANGLE_MENU_POWER, dValue, DS_FUNC_CMD_SET_ANGLE);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ANGLE_MENU_POWER, dValue, DS_FUNC_CMD_SET_ANGLE);
else
{
/*Set Power Enable*/
check_status(naibrd_DS_SetPowerEnable(cardIndex, module, channel, (uint8_t)dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetD2Test(int32_t paramCount, int32_t* p_params)
{
bool_t bValue = NAI_FALSE;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nOn-line Test (D2):[0 = Disable, 1 = Enable]\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
bValue = atoi((const char *)inputBuffer);
if ((bValue == 0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_BIT_TEST_SET_D2, (float64_t)bValue, DS_FUNC_CMD_BIT_TEST);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_BIT_TEST_SET_D2, (float64_t)bValue, DS_FUNC_CMD_BIT_TEST);
else
{
check_status(naibrd_DS_SetTestModeEnable(cardIndex, module, NAIBRD_DS_ON_LINE_TEST, bValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetD3Test(int32_t paramCount, int32_t* p_params)
{
bool_t bValue = NAI_FALSE;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nOff-line Test (D3):[0 = Disable, 1 = Enable]\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
bValue = atoi((const char *)inputBuffer);
if ((bValue == 0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_BIT_TEST_SET_D3, (float64_t)bValue, DS_FUNC_CMD_BIT_TEST);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_BIT_TEST_SET_D3, (float64_t)bValue, DS_FUNC_CMD_BIT_TEST);
else
{
check_status(naibrd_DS_SetTestModeEnable(cardIndex, module, NAIBRD_DS_OFF_LINE_TEST, bValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetTestVerifyValue(int32_t paramCount, int32_t* p_params)
{
uint32_t unValue = 0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter Test Verify Value\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
unValue = atol((const char *)inputBuffer);
if ((unValue == 0u) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_BIT_TEST_SET_TEST_VERIFY, unValue, DS_FUNC_CMD_BIT_TEST);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_BIT_TEST_SET_TEST_VERIFY, unValue, DS_FUNC_CMD_BIT_TEST);
else
{
/*Set Test Verify*/
check_status(naibrd_DS_SetTestVerify(cardIndex, module, unValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetRotationRate(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter Rotation Rate(DPS)\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ROTATION_SET_ROT_RATE, dValue, DS_FUNC_CMD_ROTATION);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ROTATION_SET_ROT_RATE, dValue, DS_FUNC_CMD_ROTATION);
else
{
/*Set rotation rate*/
check_status(naibrd_DS_SetRotationCtrl(cardIndex, module, channel, NAIBRD_DS_ROTATION_RATE, dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetRotationMode(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter Rotation Mode (Continuous = 0 / Start-Stop = 1)\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ROTATION_SET_ROT_MODE, dValue, DS_FUNC_CMD_ROTATION);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ROTATION_SET_ROT_MODE, dValue, DS_FUNC_CMD_ROTATION);
else
{
/*Set rotation mode*/
check_status(naibrd_DS_SetRotationCtrl(cardIndex, module, channel, NAIBRD_DS_ROTATION_MODE, dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetRotationStartAngle(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter Rotation Start Angle [0.0 - 359.9954]\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ROTATION_SET_ROT_START_ANG, dValue, DS_FUNC_CMD_ROTATION);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ROTATION_SET_ROT_START_ANG, dValue, DS_FUNC_CMD_ROTATION);
else
{
/*Set rotation start angle*/
check_status(naibrd_DS_SetAngle(cardIndex, module, channel, NAIBRD_DS_ANGLE_SINGLE, dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetRotationStopAngle(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nEnter Rotation Stop Angle [0.0 - 359.9954]\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ROTATION_SET_ROT_STOP_ANG, dValue, DS_FUNC_CMD_ROTATION);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ROTATION_SET_ROT_STOP_ANG, dValue, DS_FUNC_CMD_ROTATION);
else
{
/*Set rotation stop angle*/
check_status(naibrd_DS_SetAngle(cardIndex, module, channel, NAIBRD_DS_ANGLE_ROTATION_STOP, dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_StartRotation(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nTrigger Start Rotation[STOP = 0, GO = 1]\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ROTATION_INITIATE_ROTATION, dValue, DS_FUNC_CMD_ROTATION);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ROTATION_INITIATE_ROTATION, dValue, DS_FUNC_CMD_ROTATION);
else
{
/*Start Rotation*/
check_status(naibrd_DS_SetRotationEnable(cardIndex, module, channel, (bool_t)dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_StopRotation(int32_t paramCount, int32_t* p_params)
{
float64_t dValue = 0.0;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int32_t channel = p_ds_params->channel;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nTrigger Stop Rotation[STOP = 0, GO = 1]\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
dValue = atof((const char *)inputBuffer);
if ((dValue == 0.0) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_ROTATION_STOP_ROTATION, dValue, DS_FUNC_CMD_ROTATION);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_ROTATION_STOP_ROTATION, dValue, DS_FUNC_CMD_ROTATION);
else
{
/*Stop Rotation*/
check_status(naibrd_DS_SetRotationEnable(cardIndex, module, channel, (bool_t)dValue));
}
}
return NAI_SUCCESS;
}
static nai_status_t DS_SetMultiSpd(int32_t paramCount, int32_t* p_params)
{
uint32_t unValue = 0u;
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t p_ds_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ds_params->cardIndex;
int32_t module = p_ds_params->module;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
naiif_printf("\r\nSet Multi Speed Ratio [1-255]\r\n");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
unValue = atoi((const char *)inputBuffer);
if ((unValue == 0u) && (inputBuffer[0] != '0'))
{
printf("\r\nUser input was invalid!\r\n");
}
else
{
bQuit = checkUserInput(DS_MULTI_SPEED_MULT_SPD, unValue, DS_FUNC_CMD_MULTI_SPEED);
if (bQuit == NAI_TRUE)
printInvalidUserInputMessage(DS_MULTI_SPEED_MULT_SPD, unValue, DS_FUNC_CMD_MULTI_SPEED);
else
{
check_status(naibrd_DS_SetMultiSpeedRatio(cardIndex, module, NAIBRD_DS_MULTI_SPD_CH1_2_PAIR, unValue));
}
}
return NAI_SUCCESS;
}
static bool_t checkUserInput(uint32_t uTypeIdx, float64_t dUserInput, int32_t menuType)
{
bool_t bInvalidInput = NAI_FALSE;
switch (menuType)
{
case DS_FUNC_CMD_BIT_TEST:
if ((dUserInput > DS_BitTestMenu_Limits[uTypeIdx].upperLimit) || (dUserInput < DS_BitTestMenu_Limits[uTypeIdx].lowerLimit))
bInvalidInput = NAI_TRUE;
break;
case DS_FUNC_CMD_ROTATION:
if ((dUserInput > DS_RotationMenu_Limits[uTypeIdx].upperLimit) || (dUserInput < DS_RotationMenu_Limits[uTypeIdx].lowerLimit))
bInvalidInput = NAI_TRUE;
break;
case DS_FUNC_CMD_MULTI_SPEED:
if ((dUserInput > DS_MultiSpeedMenu_Limits[uTypeIdx].upperLimit) || (dUserInput < DS_MultiSpeedMenu_Limits[uTypeIdx].lowerLimit))
bInvalidInput = NAI_TRUE;
break;
case DS_FUNC_CMD_SET_ANGLE:
case DS_FUNC_CMD_SET_MODULE:
case DS_FUNC_CMD_SET_CHANNEL:
case DS_FUNC_CMD_COUNT:
default:
if ((dUserInput > DS_SetAngleMenu_Limits[uTypeIdx].upperLimit) || (dUserInput < DS_SetAngleMenu_Limits[uTypeIdx].lowerLimit))
bInvalidInput = NAI_TRUE;
break;
}
return(bInvalidInput);
}
static void printInvalidUserInputMessage(uint32_t uTypeIdx, float64_t dUserInput, int32_t menuType)
{
switch (menuType)
{
case DS_FUNC_CMD_BIT_TEST:
naiif_printf("\r\n%s: %0.4f is outside the limits[%0.4f - %0.4f]", DS_BitTestMenu_Limits[uTypeIdx].cmdstr,
dUserInput, DS_BitTestMenu_Limits[uTypeIdx].lowerLimit, DS_BitTestMenu_Limits[uTypeIdx].upperLimit);
break;
case DS_FUNC_CMD_ROTATION:
naiif_printf("\r\n%s: %0.4f is outside the limits[%0.4f - %0.4f]", DS_RotationMenu_Limits[uTypeIdx].cmdstr,
dUserInput, DS_RotationMenu_Limits[uTypeIdx].lowerLimit, DS_RotationMenu_Limits[uTypeIdx].upperLimit);
break;
case DS_FUNC_CMD_MULTI_SPEED:
naiif_printf("\r\n%s: %0.4f is outside the limits[%0.4f - %0.4f]", DS_MultiSpeedMenu_Limits[uTypeIdx].cmdstr,
dUserInput, DS_MultiSpeedMenu_Limits[uTypeIdx].lowerLimit, DS_MultiSpeedMenu_Limits[uTypeIdx].upperLimit);
break;
case DS_FUNC_CMD_SET_ANGLE:
case DS_FUNC_CMD_SET_MODULE:
case DS_FUNC_CMD_SET_CHANNEL:
case DS_FUNC_CMD_COUNT:
default:
naiif_printf("\r\n%s: %0.4f is outside the limits[%0.4f - %0.4f]", DS_SetAngleMenu_Limits[uTypeIdx].cmdstr,
dUserInput, DS_SetAngleMenu_Limits[uTypeIdx].lowerLimit, DS_SetAngleMenu_Limits[uTypeIdx].upperLimit);
break;
}
}
static void showCurrentModChan(int32_t nModule, int32_t nChannel)
{
naiif_printf("\r\nModule :%d", nModule);
naiif_printf("\r\nChannel :%d", nChannel);
}
static void getStatus(int32_t cardIndex, int32_t module, int32_t channel, uint8_t *u8Status)
{
naibrd_ds_module_status_t unSignalLoss = 0;
naibrd_ds_module_status_t unRefLoss = 0;
naibrd_ds_module_status_t unBitLoss = 0;
naibrd_ds_module_status_t unPhaseLoss = 0;
check_status(naibrd_DS_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_DS_CHAN_MAPPED_STATUS_REAL_TIME_SIGNAL_LOST,
&unSignalLoss));
check_status(naibrd_DS_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_DS_CHAN_MAPPED_STATUS_REAL_TIME_REFERENCE_LOST,
&unRefLoss));
check_status(naibrd_DS_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_DS_CHAN_MAPPED_STATUS_REAL_TIME_BIT_LOST, &unBitLoss));
check_status(naibrd_DS_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_DS_CHAN_MAPPED_STATUS_REAL_TIME_PHASE_LOST, &unPhaseLoss));
/*SIG*/
if (unSignalLoss == NAIBRD_DS_MODULE_STATUS_GOOD)
*u8Status++ = DS_STATUS_GOOD[0];
else
*u8Status++ = DS_STATUS_BAD[0];
*u8Status++ = SYM_SLASH[0];
/*REF*/
if (unRefLoss == NAIBRD_DS_MODULE_STATUS_GOOD)
*u8Status++ = DS_STATUS_GOOD[0];
else
*u8Status++ = DS_STATUS_BAD[0];
*u8Status++ = SYM_SLASH[0];
/*BIT*/
if (unBitLoss == NAIBRD_DS_MODULE_STATUS_GOOD)
*u8Status++ = DS_STATUS_GOOD[0];
else
*u8Status++ = DS_STATUS_BAD[0];
*u8Status++ = SYM_SLASH[0];
/*PLL*/
if (unPhaseLoss == NAIBRD_DS_MODULE_STATUS_GOOD)
*u8Status++ = DS_STATUS_GOOD[0];
else
*u8Status++ = DS_STATUS_BAD[0];
}