📄 setup.c
字号:
switch (event)
{
case EVENT_TIMER_TICK:
if (bStart)
{
SetBreakOnLibraryErrors (0);
while((status = DAQ_Monitor (iDevice, iChan2Graph, 1, TransformSize,(short *) plot, &index,
&daqStop))==-10802);
NIDAQErrorHandler(status,"DAQ_Monitor", 0);
SetBreakOnLibraryErrors (1);
DeleteGraphPlot (panelHandle, PANEL_FREQGRAPH, -1, VAL_DELAYED_DRAW);
/* DAQ_VScale places the data for your chosen channel into vplot; it first
scales the data to the proper voltage levels. */
DAQ_VScale (iDevice, iChan2Graph, gainVect[iChan2Graph], 1.0, 0.0,
TransformSize, (short *)(plot), vplot);
PlotStripChart (panelHandle, PANEL_TIMECHART, vplot, TransformSize, 0,
0, VAL_DOUBLE);
/* If the user chose a window, then perform scaling */
if (iWindow != 9)
{
ScaledWindow (vplot, TransformSize, iWindow, &WinCons);
}
/* Change to frequency domain, graph, and set the delta X */
AutoPowerSpectrum (vplot, TransformSize, 1/dDesiredRate, power, &deltaF);
PlotY (panelHandle, PANEL_FREQGRAPH, power, Resolution, VAL_DOUBLE,
VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, VAL_GREEN);
}
break;
}
return 0;
}
//******************************************
// ChangeView - When you change the slider,
// the graph corresponding to the chosen
// channel will appear
//******************************************
int CVICALLBACK ChangeView (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int x; // Counting variable
int b = 0; // Boolean variable that indicates whether user has chosen valid channel to view
int old; // Channel user is currently watching but wants to switch from
f64 max;
switch (event)
{
case EVENT_COMMIT:
if (bStart)
{
old = iChan2Graph;
GetCtrlVal (panelHandle, PANEL_CHAN2GRAPH, &iChan2Graph);
/* Go through the channels user has chosen to graph */
for (x=0;x<numChans;x++)
{
if (chanVect[x]==iChan2Graph) // If user chooses to view a graph being acquired
{
b=1; // Then user has chosen valid channel; exit for loop
break;
}
}
if (b == 0) // If user chose an invalid channel
{
iChan2Graph = old; //Go back to channel they were viewing
SetCtrlVal (panelHandle, PANEL_CHAN2GRAPH, chanVect[old]);
}
else
{
iChan2Graph = x; // Otherwise change the channel because everything's okay
switch (gainVect[x]) // Also change the y axis of the strip chart
{
case -20:
max = 42.4;
break;
case -10:
max = 31.6;
break;
case 0:
max = 10;
break;
case 10:
max = 3.16;
break;
case 20:
max = 1;
break;
case 30:
max = .316;
break;
case 40:
max = .1;
break;
case 50:
max = .0316;
break;
case 60:
max = .01;
break;
}
SetAxisScalingMode (panelHandle, PANEL_TIMECHART, VAL_LEFT_YAXIS,
VAL_MANUAL, -max, max);
}
}
break;
}
return 0;
}
//******************************************
// ChangeWindow - When user changes the
// window applied to incoming signal, the
// associated variable should change, too.
//******************************************
int CVICALLBACK ChangeWindow (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal (panelHandle, PANEL_WINDOW, &iWindow);
break;
}
return 0;
}
//******************************************
// StopAcquire - When you push Stop, the
// program should stop acquisition and reset
// the user interface to either quit or
// start again.
//******************************************
int CVICALLBACK StopAcquire (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
bStart = 0;
/* Stop acquisition */
DAQ_Clear (iDevice);
/* When stop acquisition, user can change values and start again */
SetCtrlAttribute (panelHandle, PANEL_START, ATTR_VISIBLE, 1);
SetCtrlAttribute (panelHandle, PANEL_STOP, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_QUIT, ATTR_VISIBLE, 1);
/* Undim controls so that user can change them */
SetCtrlAttribute (panelHandle, PANEL_DEVICE, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_BOARD, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_TRIGGER, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_CHLABEL, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_CH0, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_CH1, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_CH2, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_CH3, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_RANGEDESC, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_RANGE, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_GAINTITLE, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_GAIN0, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_GAIN1, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_GAIN2, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_GAIN3, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPTITLE, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPLING0, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPLING1, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPLING2, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPLING3, ATTR_DIMMED, 0);
SetCtrlAttribute (panelHandle, PANEL_RESOLUTION, ATTR_DIMMED, 0);
break;
}
return 0;
}
//******************************************
// QuitProgram - If you choose Quit, then
// shutdown the program.
//******************************************
int CVICALLBACK QuitProgram (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
int CVICALLBACK Adjust4Board (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
board();
}
return 0;
}
//*********************************************************
// board - Finds the Board type based on the device number
//*********************************************************
void board(void)
{
unsigned long type;
unsigned short choice; // User's board device number
GetCtrlVal (panelHandle, PANEL_DEVICE, &choice);
Get_DAQ_Device_Info (choice, ND_DEVICE_TYPE_CODE, &type);
/* If user is using a 2 channel input board, then remove the options for
the third and fourth channel. */
switch (type) // find the model
{
case 233:
SetCtrlVal (panelHandle, PANEL_BOARD, "PCI-4451");
break;
case 234:
SetCtrlVal (panelHandle, PANEL_BOARD, "PCI-4452");
break;
case 235:
SetCtrlVal (panelHandle, PANEL_BOARD, "NI-4551");
break;
case 236:
SetCtrlVal (panelHandle, PANEL_BOARD, "NI-4552");
break;
default:
SetCtrlVal (panelHandle, PANEL_BOARD, "Not DSA Device");
}
switch (type)
{
case 233:
case 235:
SetCtrlVal (panelHandle, PANEL_CH2, 0);
SetCtrlVal (panelHandle, PANEL_CH3, 0);
SetCtrlAttribute (panelHandle, PANEL_CH2, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_CH3, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_GAIN2, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_GAIN3, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPLING2, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPLING3, ATTR_VISIBLE, 0);
break;
case 234:
case 236:
SetCtrlAttribute (panelHandle, PANEL_CH2, ATTR_VISIBLE, 1);
SetCtrlAttribute (panelHandle, PANEL_CH3, ATTR_VISIBLE, 1);
SetCtrlAttribute (panelHandle, PANEL_GAIN2, ATTR_VISIBLE, 1);
SetCtrlAttribute (panelHandle, PANEL_GAIN3, ATTR_VISIBLE, 1);
SetCtrlAttribute (panelHandle, PANEL_COUPLING2, ATTR_VISIBLE, 1);
SetCtrlAttribute (panelHandle, PANEL_COUPLING3, ATTR_VISIBLE, 1);
break;
default:
SetCtrlVal (panelHandle, PANEL_CH0, 0);
SetCtrlVal (panelHandle, PANEL_CH1, 0);
SetCtrlVal (panelHandle, PANEL_CH2, 0);
SetCtrlVal (panelHandle, PANEL_CH3, 0);
SetCtrlAttribute (panelHandle, PANEL_CH0, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_CH1, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_GAIN0, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_GAIN1, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPLING0, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPLING1, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_CH2, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_CH3, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_GAIN2, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_GAIN3, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPLING2, ATTR_VISIBLE, 0);
SetCtrlAttribute (panelHandle, PANEL_COUPLING3, ATTR_VISIBLE, 0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -