📄 chartdem.c
字号:
/* The example program demonstrates the use of a DAQ Chart control. A DAQ Chart control is a strip chart which can be configured to automatically acquire and display data, log the data in a history buffer, and signal alarm conditions. This program uses the daqchart.fp instrument driver to create the DAQ Chart control.*/ #include <cvirte.h> /* Needed if linking in external compiler; harmless otherwise */#include <utility.h>#include <ansi_c.h>#include <userint.h>#include "daqchart.h"#include "daq_num.h"#include "chartdem.h"int thePanel;int main (int argc, char *argv[]){ if (InitCVIRTE (0, argv, 0) == 0) /* Needed if linking in external compiler; harmless otherwise */ return -1; /* out of memory */ thePanel = LoadPanel (0, "chartdem.uir", PANEL); /* Create the DAQ Chart */ DAQ_Chart_ConvertFromStripChart (thePanel, PANEL_CHART, "Demo Configuration"); /* Create the DAQ numeric knob */ DAQ_Numeric_ConvertFromNumeric (thePanel, PANEL_NUMERICDIAL, "Demo Configuration"); DisplayPanel (thePanel); RunUserInterface (); DiscardPanel (thePanel); return 0;}int CVICALLBACK QuitCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){ switch (event) { case EVENT_COMMIT: QuitUserInterface (0); break; } return 0;} /* This is the callback for the DAQ Chart control. This callback is sent events when alarm conditions are detected. */ int CVICALLBACK DAQChartCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){ char alarmMsg[256]; int logAlarms; switch (event) { case EVENT_DAQ_CHART_DATA_READY: /* This event is sent each time a scan is processed by the chart. (float *)eventData1 is a pointer to the acquired scan. */ /* This demo program does not use this event... */ break; case EVENT_DAQ_CHART_ALARM_ON: case EVENT_DAQ_CHART_ALARM_OFF: GetCtrlVal(panel, PANEL_LOG_ALARMS, &logAlarms); if (logAlarms) { sprintf(alarmMsg,"ALARM '%s' %s. Value = %.2f, Time = %.2f\n", (char *)eventData1, event == EVENT_DAQ_CHART_ALARM_ON ? "ON" : "OFF", *(double *)eventData2, Timer()); SetCtrlVal(panel, PANEL_ALARMLOG, alarmMsg); } break; }Error: return 0;} /* This function is called periodically by a timer control to update the history buffer display */int CVICALLBACK GraphUpdateCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){ int plotHistory; int plotVsTime; int numScansToPlot; switch (event) { case EVENT_TIMER_TICK: GetCtrlVal(panel, PANEL_PLOT, &plotHistory); if (plotHistory) { GetCtrlVal(thePanel, PANEL_PLOT_VS_TIME, &plotVsTime); GetCtrlVal(thePanel, PANEL_NUMSCANSTOPLOT, &numScansToPlot); DAQ_Chart_PlotHistory(thePanel, PANEL_CHART, panel, PANEL_GRAPH, plotVsTime, numScansToPlot, 1, 1, 0, 1); } break; } return 0;} /* This function responds to the user's choice of a new history graph update rate from the GRAPH_RATE ring control */int CVICALLBACK GraphRateCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){ double rate; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, control, &rate); SetCtrlAttribute(thePanel, PANEL_GRAPH_TIMER, ATTR_INTERVAL, 1/rate); break; } return 0;} /* This function displays information about the program when the help button is pressed */int CVICALLBACK HelpCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int helpPanel; switch (event) { case EVENT_COMMIT: helpPanel = LoadPanel(0, "chartdem.uir", HELP_PANEL); InstallPopup(helpPanel); GetUserEvent(1, 0,0); /* wait for OK button (it is the only control on the panel) */ DiscardPanel(helpPanel); break; } return 0;} /* This function set the graph's X-Axis label to match the setting on the binary switch */int CVICALLBACK PlotTypeCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){ int plotVsTime; switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, PANEL_PLOT_VS_TIME, &plotVsTime); if (plotVsTime) SetCtrlAttribute(thePanel, PANEL_GRAPH, ATTR_XNAME, "Time (Seconds)"); else SetCtrlAttribute(thePanel, PANEL_GRAPH, ATTR_XNAME, "Scan"); break; } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -