コード例 #1
0
int CVICALLBACK Thresholding (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	int threshold = 0;
	int histogram[256] = {0};
	HistogramReport *report = NULL;
	
	switch (event)
	{
		case EVENT_COMMIT:
			
			GetCtrlVal (mypanel, MYPANEL_THRESHOLD_SLIDE, &threshold);
			
			imaqThreshold (destimage, sourimage, threshold, 255, TRUE, 255);
			imaqSetWindowTitle (1, "Picture after binaryzation");
			
			imaqMoveWindow (1, imaqMakePoint (150, 260));
			imaqDisplayImage (destimage, 1, TRUE);
			
			report = imaqHistogram (destimage, 256, 0, 255, IMAQ_IMAGE_U8);
			DeleteGraphPlot (mypanel, MYPANEL_MYGRAPH, -1, VAL_IMMEDIATE_DRAW);
			
			PlotY (mypanel, MYPANEL_MYGRAPH, (*report).histogram, 256, VAL_UNSIGNED_INTEGER,
				VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
			break;
	}
	return 0;
}
コード例 #2
0
int CVICALLBACK Load_Picture (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	char picname[512] = {'\0'};
	int ret = 0;
	HistogramReport *report = NULL;
	
	switch (event)
	{
		case EVENT_COMMIT:

			ret = FileSelectPopup ("", "*.*", "", "Load; select an image file",
				VAL_LOAD_BUTTON, 0, 0, 1, 0, picname);
			
			if (ret == 1)
			{
				imaqReadFile (sourimage, picname, NULL, NULL);
				imaqMoveWindow (0, imaqMakePoint (50, 260));
				imaqDisplayImage (sourimage, 0, TRUE);
				
				report = imaqHistogram (sourimage, 256, 0, 255, IMAQ_IMAGE_U8);
				DeleteGraphPlot (mypanel, MYPANEL_MYGRAPH, -1, VAL_IMMEDIATE_DRAW);
				
				PlotY (mypanel, MYPANEL_MYGRAPH, (*report).histogram, 256, 
					VAL_UNSIGNED_INTEGER, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
			}
			
			break;
	}
	return 0;
}
コード例 #3
0
ファイル: gpibrw.c プロジェクト: achauvet/QC-Vision
int display_masks(void)
{   
		
	DeleteGraphPlot (Main_pnl_handle, ERG_panel_mask_display, -1, VAL_IMMEDIATE_DRAW);
	send_masks(drive_level);
	PlotY (Main_pnl_handle, ERG_panel_mask_display, drive_level, Npixel, VAL_INTEGER, VAL_VERTICAL_BAR, VAL_NO_POINT, VAL_SOLID, 1, VAL_RED);
															 
					
	return 0;
}
コード例 #4
0
ファイル: gpibrw.c プロジェクト: cedschmidt/QC-Vision
int CVICALLBACK delete_plot (int panel, int control, int event,
							 void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			DeleteGraphPlot (ERG_panel, ERG_panel_scope, -1, VAL_IMMEDIATE_DRAW);
			break;
	}
	return 0;
}
/* 多个下拉控件-共同调用的函数 */
void drawAnalysisResult(int panel){
	int i = getGraphIndex(panel, 1);
	double tempDataDuplicate1[READ_LENGTH/12], tempDataDuplicate2[READ_LENGTH/12];
	int type_2, type_3, isThroughWindow;
	int pointsNum =  READ_LENGTH/12;
	double spectrum[pointsNum], df;
	for(int j=0; j<(sizeof(tempData[i])/sizeof(double)); j++){
		tempDataDuplicate1[j] = tempData[i][j];
		tempDataDuplicate2[j] = tempData[i][j];
	}
	GetCtrlVal(panel, PopupPanel_RingWindowType, &type_2);
	GetCtrlVal(panel, PopupPanel_RingFFT, &type_3);
	GetCtrlVal(panel, PopupPanel_PopupSwitcher, &isThroughWindow);	
	DeleteGraphPlot(panel, PopupPanel_PopGraph2, -1, VAL_IMMEDIATE_DRAW);
	DeleteGraphPlot(panel, PopupPanel_PopGraph3, -1, VAL_IMMEDIATE_DRAW);
	//获得窗函数类型
	switch(type_2){ //对信号加窗
		case 0://加 汉宁窗
			HanWin(tempDataDuplicate1, pointsNum); break;
		case 1://加 海明窗
			HamWin(tempDataDuplicate1, pointsNum); break;
		case 2://加 布拉克曼窗
			BkmanWin(tempDataDuplicate1, pointsNum); break;
		case 3://加 指数窗
			ExpWin(tempDataDuplicate1, pointsNum, 0.01); break;
		case 4://加 高斯窗
			GaussWin(tempDataDuplicate1, pointsNum, 0.2); break;
		case 5://加 三角窗
			TriWin(tempDataDuplicate1, pointsNum);break;
	}//switch()
	PlotY(panel, PopupPanel_PopGraph2, tempData[i], pointsNum, 
			VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, plotLineColor);
	if(isThroughWindow == 1){
		AutoPowerSpectrum(tempDataDuplicate1, pointsNum, 1/100, spectrum, &df);
	}else{
		AutoPowerSpectrum(tempDataDuplicate2, pointsNum, 1/100, spectrum, &df);
	}
    PlotY(panel, PopupPanel_PopGraph3, spectrum, pointsNum/2,
          VAL_DOUBLE, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, VAL_YELLOW);
}
/* 信号分析窗口-原始信号图表-回调函数 */
int CVICALLBACK PopGraph1Callback (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2) {
	switch (event){
		case EVENT_LEFT_DOUBLE_CLICK:
			int i = getGraphIndex(panel, 1);
			for(int j=0; j<(READ_LENGTH/24); j++)
				tempData[i][j] = resultData[i][j];
			Delay(0.1);
			for(int z=(READ_LENGTH/24),x = 0; z<(READ_LENGTH/12); z++,x++)
				tempData[i][z] = resultData[i][x];
			DeleteGraphPlot(panel, PopGraphs[i], -1, VAL_DELAYED_DRAW);
			PopGPlots[i] = PlotY(PopPanels[i], PopGraphs[i], tempData[i], READ_LENGTH/12, 
							 VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID,1, plotLineColor);
			
			addLog("成功刷新一组数据!", 1, panel);
			break;
	}
	return 0;
}
コード例 #7
0
int CVICALLBACK Aquire_Display (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	double phase = 0.0;
	double datapoints[256];
	
	int i = 0;
	int index = 0;
	
	switch (event)
	{
		case EVENT_COMMIT:
			GetCtrlIndex (MYPANEL, MYPANEL_MYRING, &index);
			switch (index)
			{
			case 0:
			SineWave (256, 1.0, 7.8125e-3, &phase, datapoints);
			break;
			
			case 1:
				SquareWave (256, 1.0, 7.8125e-3, &phase, 50.0, datapoints);
			break;
				
			case 2:
				TriangleWave (256, 1.0, 7.8125e-3, &phase, datapoints);
			break;
					
			case 3:
			for (i = 0; i < 256; i++)
				datapoints[i] = rand() /32767.0;
			break;
			}
			
			DeleteGraphPlot (MYPANEL, MYPANEL_MYGRAPH, -1, VAL_IMMEDIATE_DRAW);
			
			PlotY (MYPANEL, MYPANEL_MYGRAPH, datapoints, 256, VAL_DOUBLE,
			VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
			
			break;
	}
	return 0;
}
コード例 #8
0
ファイル: DataThread.c プロジェクト: caoyuan0923/octlab
int CVICALLBACK DataThread (void *functionData)
{
  char fileNameA[32];
  char fileNameB[32];
  char filePathA[MAX_PATHNAME_LEN]; // for data from channel A
  char filePathB[MAX_PATHNAME_LEN]; // for data from channel B
  U16 *data;
  FILE *outA, *outB;
  unsigned int numberOfElements = 0;
  
  // wait for tread lock
  CmtGetLock (dataThreadLock);
  // release the lock
  CmtReleaseLock (dataThreadLock);
  
  status = 3; // DataThread() is started
  SetCtrlVal (panelHandle, PANEL_STATUS, status);
  SetCtrlVal (panelHandle, PANEL_ERRORMSG,
    "Nice! DataThread() has been started!\n");
  
  // get the total number of elements to write
  numberOfElements = rawBscanSize * rawAlineSize;
  
  // init the values
  dataLoop = 0;
  
  // run until button STOP pressed
  while (stop == 0)
  {
    // wait for event from AlazarAcquire()
    WaitForSingleObject (eventData, INFINITE);
    
    // remove buffer from FIFO buffer and free memory space
    while (FIFOBuff->f_head != FIFOBuff->f_tail)
    {
      data = FIFO_Remove (FIFOBuff); // remove buffer from FIFO queue
      // update counters
      SetCtrlAttribute (panelHandle, PANEL_TIMEVALUE, ATTR_CTRL_VAL,
        timerValue * 1000.0);
      
      // draw plot
      DeleteGraphPlot (panelHandle, PANEL_ALINEGRAPH, -1, VAL_DELAYED_DRAW);
      PlotY (panelHandle, PANEL_ALINEGRAPH,
        data + numberOfElements * channel + rawAlineSize * aLineIndex,
        rawAlineSize, VAL_UNSIGNED_SHORT_INTEGER, VAL_FAT_LINE,
        VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_CYAN);
      
      // record files only if we have directory name in pathName variable
      if ((save == 2) || (dataLoop < alazarLoop))
      {
        // set number of buffers which were saved
        SetCtrlAttribute (panelHandle, PANEL_DATALOOPS, ATTR_CTRL_VAL,
          dataLoop++);
        SetCtrlAttribute (panelHandle, PANEL_ALAZARLOOPS, ATTR_CTRL_VAL,
          alazarLoop);
        // set the name of output files and notify
        sprintf (fileNameA, "%09lli.mzi.raw.dat", dataLoop);
        sprintf (fileNameB, "%09lli.sample.raw.dat", dataLoop);
        MakePathname (pathName, fileNameA, filePathA);
        MakePathname (pathName, fileNameB, filePathB);
        SetCtrlAttribute (panelHandle, PANEL_DIRPATH, ATTR_CTRL_VAL, filePathB);
        // open output files for recording
        outA = fopen (filePathA, "wb");
        outB = fopen (filePathB, "wb");
        // error handling
        if ((outA == NULL) || (outB == NULL))
        {
          SetCtrlVal (panelHandle, PANEL_ERRORMSG,
            "Ooops! We could not open files for recording!\n");
          save = 0;
          SetCtrlVal (panelHandle, PANEL_SAVESWITCH, save);
          break;
        }
        // record buffer from channel A
        if (numberOfElements != fwrite (data, bytesPerSample, numberOfElements,
          outA))
        {
          SetCtrlVal (panelHandle, PANEL_ERRORMSG,
            "Ooops! We could not write the file!\n");
          save = 0;
          SetCtrlVal (panelHandle, PANEL_SAVESWITCH, save);
          fclose (outA);
          break;
        }
        // record buffer from channel B
        if (numberOfElements != fwrite (data + numberOfElements, bytesPerSample,
          numberOfElements, outB))
        {
          SetCtrlVal (panelHandle, PANEL_ERRORMSG,
            "Ooops! We could not write the file!\n");
          save = 0;
          SetCtrlVal (panelHandle, PANEL_SAVESWITCH, save);
          fclose (outB);
          break;
        }
        // close output files
        fclose (outA);
        fclose (outB);
      }  
      
      free (data); // free buffer obtained from FIFO queue
    }
    
  }
  
  SetCtrlVal (panelHandle, PANEL_ERRORMSG,
    "Nice! DataThread() has been stopped!\n");
  
  return 0;
}
コード例 #9
0
ファイル: gpibrw.c プロジェクト: achauvet/QC-Vision
void acquire_scans (void)
{
	int color;
	int Nleft=0;
	char file [ FILENAME_MAX ];

	SetCtrlAttribute (Main_pnl_handle, ERG_panel_acquire, ATTR_DIMMED, 1);
	SetCtrlAttribute (Main_pnl_handle, ERG_panel_abortscan, ATTR_DIMMED, 1);
	if (experiment==1){
		GetCtrlVal (Sequence_pnl_handle, Seq_panel_seq_number, &seq_num);
		Nscans=	seq_num*m;
	}
	else {
		GetCtrlVal (Main_pnl_handle, ERG_panel_nscans, &Nscans);
	}

	DirSelectPopup ("d:\\data\\test", "Select Directory", 1, 1, pathname);

	i=0;
	SetCtrlAttribute (Main_pnl_handle, ERG_panel_pause, ATTR_DIMMED, 0);
	SetCtrlAttribute (Main_pnl_handle, ERG_panel_abortscan, ATTR_DIMMED, 0);
	
// start trigger 
	SRS_flag=2;
	SRS_onoff();
	DeleteGraphPlot (Main_pnl_handle, ERG_panel_mask_display, -1, VAL_IMMEDIATE_DRAW);
	
	if (experiment==1){			 // mode sequence
		for (i=0;i<seq_num;i++) {
			for (h=0;h<m;h++){
				SetCtrlIndex (Sequence_pnl_handle, Seq_panel_mask_list, h);
				for (k=0;k<Npixel;k++){
					drive_level[k]=mask[h].voltages[k];
				}				
				display_masks();
				
				ProcessSystemEvents();
				GetLabelFromIndex (Sequence_pnl_handle, Seq_panel_mask_list, h, &mask_filename);
				strcpy(filename, pathname);
				
				//prepare file to write
				sprintf(file, "\\sequence%d_%s.txt", i, mask_filename);
				strcat(filename, file);
				data_file = OpenFile (filename, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII);
				
				//enable oscillo then wait for trigger and get ERG trace
				color=floor(256/Nscans)*(i*m+h);
				waveform(color, data_file);	
				get_intensity();
				
				//write header file
				headerfile();
				
				//write ERG trace 
				ArrayToFile (filename, data2fit, VAL_DOUBLE, 10000, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_SEP_BY_TAB, 100, VAL_ASCII, VAL_APPEND);
				nmeasure[0]=i*m+h+1;
				displaychannel();
				
				Nleft=Nscans-(i*m+h);
				SetCtrlVal (Main_pnl_handle, ERG_panel_nremain, Nleft);
				ProcessSystemEvents();
				if (pause_flag)
				{
					while (pause_flag)
						ProcessSystemEvents();
				}
			}
		}
	}
	
	else{				  // mode normal
	//prepare file name for acquiring data
		while ( i < Nscans )
		{
			strcpy(filename, pathname);
			sprintf(file, "\\scope_data%d.txt", i);
			strcat(filename, file);
			data_file = OpenFile (filename, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII);
			color=floor(256/Nscans)*i;
			waveform(color, data_file);
			get_intensity();
			
			headerfile();
			ArrayToFile (filename, data2fit, VAL_DOUBLE, 10000, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_SEP_BY_TAB, 100, VAL_ASCII, VAL_APPEND);
			
			i++;
			Nleft=Nscans-i+1;
			SetCtrlVal (Main_pnl_handle, ERG_panel_nremain, Nleft);
			ProcessSystemEvents();
			if (pause_flag)
			{
				while (pause_flag)
					ProcessSystemEvents();
			}
			CloseFile (data_file);
		}
	}
	
	SetCtrlVal (Main_pnl_handle, ERG_panel_nremain, 0);
	SetCtrlAttribute (Main_pnl_handle, ERG_panel_pause, ATTR_DIMMED, 1);
	SetCtrlAttribute (Main_pnl_handle, ERG_panel_abortscan, ATTR_DIMMED, 1);
	SetCtrlAttribute (Main_pnl_handle, ERG_panel_acquire, ATTR_DIMMED, 0);
	
// stop trigger 	
	SRS_flag=0;
	SRS_onoff();
	
	ibsic(device); 
	return;
}