예제 #1
0
////////////////////////////
// Set element Y data
STDMETHODIMP CGraphElement::PlotY(double Y)
{
    int X;
    X = m_PointList.GetSize();

    return PlotXY(X, Y);
}
예제 #2
0
void fit_data (void)
{
	int Npoints, num;
	double slope, intercept, residue, coef[4], value;
	GetCtrlVal (ERG_panel, ERG_panel_start_val, &start);
	GetCtrlVal (ERG_panel, ERG_panel_points_num, &Npoints);
	double fit[Npoints];
	int maximumIndex, minimumIndex;
	CNVData data=0;
	CNVWriter writer = 0;
	
	for (int k = 0; k < Npoints; k++)
    fit[k] = 0;
	///////////////////////////////////////////////////////////////
	//////////////mto do : create specific function for background subtraction
	int pix_num,bckgrd_satus;
	double bckgrd_val;
	GetCtrlVal (ERG_panel, ERG_panel_bckgrd_sub, &bckgrd_satus); 
	if (bckgrd_satus==1)
	{
		GetCtrlVal (ERG_panel, ERG_panel_bckgrd, &pix_num);
		Mean (&data2fit[pix_num-50], 100, &bckgrd_val);
		j=0;
		while (j<10000)
		{
			buffer[j] = data2fit[j]-bckgrd_val;
			j++;
		}
	}
	else
	{
		  j=0;
		while (j<10000)
		{
			buffer[j] = data2fit[j];
			j++;
		}
	}
	//////////////////////////////////////////////////////////////
	
	
	
	generate_xarray ();   
	PlotXY (ERG_panel, ERG_panel_scope, &xarray[start], &buffer[start], Npoints, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_SOLID_SQUARE, VAL_SOLID, 1, VAL_GREEN); 
 	
	GetCtrlVal (ERG_panel, ERG_panel_fit_function, &j);
	if (j==0)
	{
		MaxMin1D(&buffer[start], Npoints, &maximumValue, &maximumIndex, &minimumValue, &minimumIndex);
		Npoints=  minimumIndex;
		LinearFitEx (&xarray[start], &buffer[start], NULL, Npoints, LEAST_SQUARE, 0.0001, fit, &slope, &intercept, &residue);
	
		////////////to do: create separated function for uploading network variable/////////////
		//write optimization value (slope) as a network variable
		CNVCreateWriter ("\\\\localhost\\ERG\\optimisation_value", 0, 0, 10000, 0, &writer);
		CNVCreateScalarDataValue (&data, CNVDouble, slope);
//		Delay(0.5);     
		CNVWrite (writer, data, 5000);
		CNVDisposeData (data);
		Delay(0.5);
//		printf("Slope=%f\n", slope); 
	}
							  
	if (j==1)
	{
		Mean (&buffer[start-100], 100, &baseline);
		MaxMin1D(&buffer[start], Npoints, &maximumValue, &maximumIndex, &minimumValue, &minimumIndex);
		Npoints=  minimumIndex;
		Mean (&buffer[start+minimumIndex-5], 10, &minimumValue);
		coef[0]= start+minimumIndex;
		coef[1]= minimumIndex/2;
	//	printf("base=%f, min=%f\n",baseline, minimumValue);      
		NonLinearFitWithMaxIters (&xarray[start], &buffer[start], fit, Npoints, 100, ModelFunct, coef, 2, &residue);
	//	printf("coef1=%f, coef2=%f\n",coef[0], coef[1]);
		
		//write optimization value (rise time; coef[1]) as a network variable
//		coef[1]=coef[1]/10;
		CNVCreateWriter ("\\\\localhost\\ERG\\optimisation_value", 0, 0, 10000, 0, &writer);
		CNVCreateScalarDataValue (&data, CNVDouble, coef[1]/10000);
		CNVWrite (writer, data, 5000);
		CNVDisposeData (data);
		Delay(0.5);
	}
	
	if (j==2)
	{
		MaxMin1D(&buffer[start], Npoints, &maximumValue, &maximumIndex, &minimumValue, &minimumIndex);
		value= maximumValue - minimumValue;
		
		if (minimumIndex < maximumIndex)
		{
			Npoints=maximumIndex-minimumIndex;
			Copy1D (&buffer[minimumIndex+start], Npoints, fit);
			start= minimumIndex+start;
			value= maximumValue - minimumValue;
		}
		else
		{
			value= 0;
		}
		
		CNVCreateWriter ("\\\\localhost\\ERG\\optimisation_value", 0, 0, 10000, 0, &writer);
		CNVCreateScalarDataValue (&data, CNVDouble, value);
		CNVWrite (writer, data, 5000);
		CNVDisposeData (data);
		Delay(0.5);
	}
	
	PlotXY (ERG_panel, ERG_panel_scope, &xarray[start], fit, Npoints, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED);
}
예제 #3
0
파일: gpibrw.c 프로젝트: achauvet/QC-Vision
void displaychannel(void)
{
	PlotXY (Main_pnl_handle, ERG_panel_signal_display, nmeasure, channel_data, 1, VAL_INTEGER, VAL_DOUBLE, VAL_DOT, VAL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED);
}