Example #1
0
int  ManipulateReadingCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    channelPtr chan;
    double reading, min_x, max_x, min_y, max_y;
    int handle, index, scatter, mode, i;

    if (event == EVENT_VAL_CHANGED)
    {
        chan = callbackData;
        GetGraphCursorIndex (chanview.p1, CHANVIEW_GRAPH, 1, &handle, &index);
        GetCtrlVal (panel, control, &reading);
        GetCtrlVal (panel, MANIP_INDEX, &index);
        chan->readings[index] = reading;
        GetCtrlVal (chanview.p1, CHANVIEW_SCATTER, &scatter);
        channel_UpdateViewGraph(chan, scatter);
        GetAxisRange (chanview.p1, CHANVIEW_GRAPH, &mode, &min_x, &max_x,
                      &mode, &min_y, &max_y);
        MaxMin1D (chan->readings + (int)min_x, (int)(max_x - min_x + 1), &max_y,
                  &i, &min_y, &i);
        SetAxisRange (chanview.p1, CHANVIEW_GRAPH, VAL_NO_CHANGE, 0.0, 1.0,
                      VAL_MANUAL, min_y, max_y);
        SetGraphCursor (chanview.p1, CHANVIEW_GRAPH, 1, index, reading);
    }
    return 0;
}
Example #2
0
int  DoDecimateCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    int i, dfact, ave;
    channelPtr chan, newchan;

    if (event == EVENT_COMMIT)
    {
        GetCtrlVal (panel, DECIMATE_CHANNELS, &i);
        GetCtrlVal (panel, DECIMATE_DFACT, &dfact);
        GetCtrlVal (panel, DECIMATE_AVE, &ave);

        chan = channellist_GetItem (i);

        newchan = channel_Create();
        if (newchan && channel_AllocMem (newchan, (int)(chan->pts/dfact)) &&
            (Decimate (chan->readings, chan->pts, dfact, ave, newchan->readings) == NoErr))
        {
            Fmt (newchan->label, "%s (decimated)", chan->label);
            Fmt (newchan->note, "%s\n%s\ndfact = %i\nave = %i\n",
                 chan->note, newchan->label, dfact, ave);
            channellist_AddChannel (newchan);
            return 1;
        }

        MessagePopup ("Decimate Channel Message", "Error decimating channel--function voided");
        if (newchan)
        {
            if (newchan->readings) free (newchan->readings);
            free (newchan);
        }
    }
    return 0;
}
Example #3
0
int  DoClipCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    int i;
    double min, max;
    channelPtr chan, newchan;

    if (event == EVENT_COMMIT)
    {
        GetCtrlVal (panel, CLIP_CHANNELS, &i);
        GetCtrlVal (panel, CLIP_MIN, &min);
        GetCtrlVal (panel, CLIP_MAX, &max);

        chan = channellist_GetItem (i);

        newchan = channel_Create();
        if (newchan && channel_AllocMem (newchan, chan->pts) &&
            (Clip (chan->readings, chan->pts, max, min, newchan->readings) == NoErr))
        {
            Fmt (newchan->label, "%s (clipped)", chan->label);
            Fmt (newchan->note, "%s\n%s\nmin = %f[e2p3]\nmax = %f[e2p3]\n",
                 chan->note, newchan->label, min, max);
            channellist_AddChannel (newchan);
            return 1;
        }

        MessagePopup ("Clip Channel Message", "Error clipping channel--function voided");
        if (newchan)
        {
            if (newchan->readings) free (newchan->readings);
            free (newchan);
        }
    }
    return 0;
}
Example #4
0
int main (int argc, char *argv[])
{
    if (InitCVIRTE (0, argv, 0) == 0)
        return -1;  /* out of memory */      
    if ((pBasicFn = LoadPanel (0, "UIRBasicFnct.uir", P_BASIC_FN)) < 0)
        return -1;
    if ((pSystem = LoadPanel (0, "UIRSystem.uir", P_SYSTEM)) < 0)
        return -1;
    if ((pControlPad = LoadPanel (0, "UIRControlPad.uir", P_CTRL_PAD)) < 0)
        return -1;
    
    GetCtrlVal (pBasicFn, P_BASIC_FN_SWH_FNCT_MODE,         &iFnctMode);
    GetCtrlVal (pBasicFn, P_BASIC_FN_SWH_DISPLAY_MODE,      &iDispMode);
    GetCtrlVal (pBasicFn, P_BASIC_FN_SWH_DISPLAY_LAST_FIVE, &iLastFive);
    GetCtrlVal (pBasicFn, P_BASIC_FN_SWITCH_SENSOR,         &iSwitchSens);
    GetCtrlVal (pBasicFn, P_BASIC_FN_SWITCH_DREH_MODE,      &iDrehMode);
    
    SetCtrlAttribute (pSystem, P_SYSTEM_CMD_DEINIT,             ATTR_DIMMED, 1);
    
    DisplayPanel (pBasicFn);
    RunUserInterface ();
    DiscardPanel (pBasicFn);
    
    return 0;
}
/// HIFN Callback function for changing the spotmask
int CVICALLBACK SpotSize_Callback (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_VAL_CHANGED:
		{
			double sliderpos;
			unsigned int Nx, Ny;
			GetCtrlVal(panel, TABPANEL_3_inputNx, &Nx);
			GetCtrlVal(panel, TABPANEL_3_inputNy, &Ny);
			
			
			// check if we need to update
			if (eventData1 != SLM_NO_UPDATE)
			{
				// update the SLM panel and the simulation Panel (if toggled)
				SLM_update(pnlSLMpixels, SLMpixels_SLMcanvas, pnlSimPanel, SimPanel_CANVAS, 1);
			}
			
			break;
		}
	}
	return 0;
}
/*****************************************************************************
.						
. Función C:			PRE_ActualizarTransmision
. Responsable:			César Armando Cruz Mendoza
. Descripcion: 			Actualiza la informacion de la transmision que se
.						ha editado en el sistema
. Parámetro de entrada:	ninguno
. Parámetro de salida:	cero
. Fecha de creación:	11 de Marzo de 2014
.
*****************************************************************************/
int PRE_ActualizarTransmision()
{
	char cMensajeError[500]={0};	//mensaje de error que se haya detectado
	char cDescripcion[250]={0};		//nombre asignado a la transmision
	int iNumVelocidades=0;			//numero de velocidades asociadas
	double dRelacion=0;				//valor de la relacion de velocidad
	char cVelocidad[5]={0};			//numero de velocidad en cadena
	int iLadoManipulador=0;			//indica el lado del manipulador (0 izq 1 der)
	int iId;						//identificador de la transmision
	double *pdListaRelaciones;		//lista de relaciones configuradas
	
	//se requeren implementar algunas validaciones antes de iniciar
	//el proceso de actualización de la transmision
	
	//obtiene el id de la transmision
	GetCtrlVal(iPanelCatTransmisiones, pCatTransm_lstTransmisiones, &iId);
	
	//verifica la informacion del numero de velocidades asocidadas
	GetCtrlVal (iPanelCatTransmisiones, pCatTransm_numNumeroVelocidades, &iNumVelocidades);
	if (iNumVelocidades == 1)
		strcat(cMensajeError,"- Se ha dejado el valor por defecto de 1 velocidad. \n");
	
	//vefifica los valores de relación para las velocidades capturadas
	pdListaRelaciones = malloc(sizeof(double)*iNumVelocidades);
	for (int i=0; i<iNumVelocidades; i++)
	{
		GetTableCellVal (iPanelCatTransmisiones, pCatTransm_tblRelaciones,
						 MakePoint(1,i+1), &dRelacion);
		pdListaRelaciones[i]=dRelacion;
		
		if (dRelacion == 0)
		{
			strcat(cMensajeError,
				   GRA_Strcat(3,"- Para la velocidad ",GRA_IntStr(i+1)," falta indicar la relación. \n"));
		}
	}
	
	GetCtrlVal (iPanelCatTransmisiones, pCatTransm_chkLadoIzquierdo, &iLadoManipulador);
	
	if (strlen(cMensajeError)>0)
	{
		MessagePopup ("Validación de información.", cMensajeError);
	}
	else
	{
		//inicia el proceso de guardado de la informacion, para lo cual obtiene
		//la lista de relaciones de las velocidades que se han configurado
		BDS_ActualizaTransmision(iId, iNumVelocidades, pdListaRelaciones, iLadoManipulador);
		
		MessagePopup ("Registro actualizado",
					  "Se ha actualizado la información correctamente.");
		
		//regresa la interfaz al modo menu principal
		PRE_CancelarProceso();
	}
	
	free(pdListaRelaciones);
	
	return 0;
}
Example #7
0
void plot_data (int color)
{
	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++;
		}
	}
	
	PlotY (ERG_panel, ERG_panel_scope, buffer, 10000,VAL_DOUBLE , VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, MakeColor(color,color,color));
}
Example #8
0
File: Sr844.c Project: gaorlov/DAAS
int  SR844RefCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    gpibioPtr dev = callbackData;
    double r;
    char cmd[256];

    switch (control) {
        case SR844_REF_FREQ:
            if (event == EVENT_VAL_CHANGED) {
                GetCtrlVal (panel, control, &r);
                Fmt (cmd, "FREQ%f", r);
                gpibio_Out (dev, cmd);
                r = sr844_GetDoubleVal (dev, "FREQ?");
                SetCtrlVal (panel, control, r);
                SetCtrlAttribute (panel, control, ATTR_INCR_VALUE, r/10);
            }
            break;
        case SR844_REF_PHASE:
            if (event == EVENT_VAL_CHANGED) {
                GetCtrlVal (panel, control, &r);
                Fmt (cmd, "PHAS%f", r);
                gpibio_Out (dev, cmd);
                SetCtrlVal (panel, control, sr844_GetDoubleVal(dev, "PHAS?"));
            }
            break;
    }
    return 0;
}
Example #9
0
int  K2400MeasControlCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    acqchanPtr acqchan = callbackData;
    switch (control) {
        case K2400_MEAS_ACQ:
            if (event == EVENT_VAL_CHANGED) {
                GetCtrlVal (panel, control, &acqchan->acquire);
                if (acqchan->acquire) acqchanlist_AddChannel (acqchan);
                    else acqchanlist_RemoveChannel (acqchan);
            }
            break;
        case K2400_MEAS_COEFF:
            if (event == EVENT_COMMIT) {
                GetCtrlVal (panel, control, &acqchan->coeff);
                if (acqchan->p) SetCtrlVal (acqchan->p, ACQDATA_COEFF, acqchan->coeff);
            }
            break;
        case K2400_MEAS_LABEL:
            if (event == EVENT_COMMIT) {
                GetCtrlVal (panel, control, acqchan->channel->label);
                acqchanlist_ReplaceChannel (acqchan);
                if (acqchan->p) SetPanelAttribute (acqchan->p, ATTR_TITLE, acqchan->channel->label);
            }
            break;
        case K2400_MEAS_CLOSE:
            if (event == EVENT_COMMIT) {
                devPanel_Remove(panel);
                
                DiscardPanel (panel);
            }
            break;
    }
    return 0;
}
Example #10
0
static void chanfunc_CalcStatistics (channelPtr chan)
{
    double mean, std_dev, variance, rms, moment, median, mode, min, max;
    int err, order, min_i, max_i, intervals;
    char newnote[256];

    Fmt (chanfunc.note, "");
    err = MaxMin1D (chan->readings, chan->pts, &max, &max_i, &min, &min_i);
    SetInputMode (chanfunc.p, STATISTICS_MIN, !err);
    SetCtrlVal (chanfunc.p, STATISTICS_MIN, min);
    SetInputMode (chanfunc.p, STATISTICS_MAX, !err);
    SetCtrlVal (chanfunc.p, STATISTICS_MAX, max);
    if (err == NoErr)
    {
        Fmt (chanfunc.note, "%s<Min: %f[e2p5]\n", min);
        Fmt (chanfunc.note, "%s[a]<Max: %f[e2p5]\n", max);
    }

    err = Mean (chan->readings, chan->pts, &mean);
    SetInputMode (chanfunc.p, STATISTICS_MEAN, !err);
    SetCtrlVal (chanfunc.p, STATISTICS_MEAN, mean);
    if (err == NoErr) Fmt (chanfunc.note, "%s[a]<Mean: %f[e2p5]\n", mean);

    err = StdDev (chan->readings, chan->pts, &mean, &std_dev);
    SetInputMode (chanfunc.p, STATISTICS_STDDEV, !err);
    SetCtrlVal (chanfunc.p, STATISTICS_STDDEV, std_dev);
    if (err == NoErr) Fmt (chanfunc.note, "%s[a]<StdDev: %f[e2p5]\n", std_dev);

    err = Variance (chan->readings, chan->pts, &mean, &variance);
    SetInputMode (chanfunc.p, STATISTICS_VAR, !err);
    SetCtrlVal (chanfunc.p, STATISTICS_VAR, variance);
    if (err == NoErr) Fmt (chanfunc.note, "%s[a]<Variance: %f[e2p5]\n", variance);

    err = RMS (chan->readings, chan->pts, &rms);
    SetInputMode (chanfunc.p, STATISTICS_RMS, !err);
    SetCtrlVal (chanfunc.p, STATISTICS_RMS, rms);
    if (err == NoErr) Fmt (chanfunc.note, "%s[a]<RMS: %f[e2p5]\n", rms);

    GetCtrlVal (chanfunc.p, STATISTICS_ORDER, &order);
    err = Moment (chan->readings, chan->pts, order, &moment);
    SetInputMode (chanfunc.p, STATISTICS_MOMENT, !err);
    SetInputMode (chanfunc.p, STATISTICS_ORDER, !err);
    SetCtrlVal (chanfunc.p, STATISTICS_MOMENT, moment);
    if (err == NoErr) Fmt (chanfunc.note, "%s[a]<Moment: %f[e2p5] (order: %i)\n", moment, order);

    err = Median (chan->readings, chan->pts, &median);
    SetInputMode (chanfunc.p, STATISTICS_MEDIAN, !err);
    SetCtrlVal (chanfunc.p, STATISTICS_MEDIAN, median);
    if (err == NoErr) Fmt (chanfunc.note, "%s[a]<Median: %f[e2p5]\n", median);

    GetCtrlVal (chanfunc.p, STATISTICS_INTERVAL, &intervals);
    err = Mode (chan->readings, chan->pts, min, max, intervals, &mode);
    SetInputMode (chanfunc.p, STATISTICS_INTERVAL, !err);
    SetInputMode (chanfunc.p, STATISTICS_MODE, !err);
    SetCtrlVal (chanfunc.p, STATISTICS_INTERVAL, intervals);
    SetCtrlVal (chanfunc.p, STATISTICS_MODE, mode);
    if (err == NoErr) Fmt (chanfunc.note, "%s[a]<Mode: %f[e2p5] (intervals: %i)\n", mode, intervals);
}
Example #11
0
int  GenExpControlCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    if (event == EVENT_VAL_CHANGED){
        GetCtrlVal (panel, ACQSETUP_GEN_POINTS, &utilG.acq.nPts);
        GetCtrlVal (panel, ACQSETUP_GEN_DELAY, &expG.delay);
        SetCtrlVal (panel, ACQSETUP_GEN_TIME, (double)utilG.acq.nPts*expG.delay/60);
    }
    return 0;
}
Example #12
0
int das1602_ControlCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    portPtr port = callbackData;
    switch (control)
    {
        case DAS_CTRL_RANGE:
            if(event == EVENT_COMMIT && port)
                GetCtrlVal(panel, control, &port->port.analogueIOport.range);
            break;
        case DAS_CTRL_INPUT:
            if(event == EVENT_COMMIT && port)
            {
                int i;
                MCCdevPtr dev = port->port.analogueIOport.IO.acqchan->dev;
                das1602Ptr das = dev->device;
                GetCtrlVal(panel, control, &i);
                port->control = 0;
                if(i != -1)
                {
                    das->Achannels[i]->control = control;
                    SetCtrlAttribute (panel, control, ATTR_CALLBACK_DATA, das->Achannels[i]);
                    SetCtrlAttribute (panel, DAS_CTRL_RANGE, ATTR_CALLBACK_DATA, das->Achannels[i]);
                    SetCtrlAttribute (panel, DAS_CTRL_ACQ, ATTR_CALLBACK_DATA, das->Achannels[i]);
                    SetCtrlIndex (panel, DAS_CTRL_RANGE, das1602_IndexFromRange(das->Achannels[i]->port.analogueIOport.range));
                    SetCtrlVal (panel, DAS_CTRL_ACQ, das->Achannels[i]->port.analogueIOport.IO.acqchan->acquire);
                }
                SetCtrlAttribute (panel, DAS_CTRL_RANGE, ATTR_DIMMED, (i == -1));
                SetCtrlAttribute (panel, DAS_CTRL_ACQ, ATTR_DIMMED, (i == -1));
                if(i == -1)SetCtrlVal (panel, DAS_CTRL_ACQ, 0);
            }
            break;
        case DAS_CTRL_ACQ:
        if(event == EVENT_COMMIT && port && utilG.acq.status != ACQ_BUSY)
        {
            int i;
            MCCdevPtr dev = port->port.analogueIOport.IO.acqchan->dev;
            das1602Ptr das = dev->device;
            GetCtrlIndex (panel, DAS_CTRL_INPUT, &i);
            if(i)
            {
                GetCtrlVal (panel, control, &port->port.analogueIOport.IO.acqchan->acquire);
                    if (port->port.analogueIOport.IO.acqchan->acquire)
                    acqchanlist_AddChannel(port->port.analogueIOport.IO.acqchan);
                else
                    acqchanlist_RemoveChannel(port->port.analogueIOport.IO.acqchan);
                SetMenuBarAttribute (das->menu, port->menuitem_id, ATTR_CHECKED, port->port.analogueIOport.IO.acqchan->acquire);
            }
        else if(event == EVENT_COMMIT && utilG.acq.status == ACQ_BUSY)
            SetCtrlVal (panel, control, port->port.analogueIOport.IO.acqchan->acquire);
            
        }
        break;
    }
    if(event == EVENT_COMMIT && port)
        das1602_UpdateMeasurePanel (port);
    return 0;
}
Example #13
0
File: Sr844.c Project: gaorlov/DAAS
int  XYMPControlCallback844(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    sr844Ptr lia;
    acqchanPtr acqchan;

    acqchan = callbackData;

    switch (control) {
        case SR844_XYMP_NOTE_1:
        case SR844_XYMP_NOTE_2:
        case SR844_XYMP_NOTE_3:
        case SR844_XYMP_NOTE_4:
            AcqDataNoteCallback (panel, control, event, callbackData, eventData1, eventData2);
            break;
        case SR844_XYMP_XACQ:
        case SR844_XYMP_YACQ:
        case SR844_XYMP_RACQ:
        case SR844_XYMP_PACQ:
            if (event == EVENT_VAL_CHANGED) {
                GetCtrlVal (panel, control, &acqchan->acquire);
                if (acqchan->acquire) acqchanlist_AddChannel (acqchan);
                    else acqchanlist_RemoveChannel (acqchan);
            }
            break;
        case SR844_XYMP_XCOEFF:
        case SR844_XYMP_YCOEFF:
        case SR844_XYMP_RCOEFF:
        case SR844_XYMP_PCOEFF:
            if (event == EVENT_COMMIT) {
                GetCtrlVal (panel, control, &acqchan->coeff);
                if (acqchan->p) SetCtrlVal (acqchan->p, ACQDATA_COEFF, acqchan->coeff);
            }
            break;
        case SR844_XYMP_XLABEL:
        case SR844_XYMP_YLABEL:
        case SR844_XYMP_RLABEL:
        case SR844_XYMP_PLABEL:
            if (event == EVENT_COMMIT) {
                GetCtrlVal (panel, control, acqchan->channel->label);
                acqchanlist_ReplaceChannel (acqchan);
                if (acqchan->p) SetPanelAttribute (acqchan->p, ATTR_TITLE, acqchan->channel->label);
            }
            break;
        case SR844_XYMP_CLOSE:
            if (event == EVENT_COMMIT) {
                lia = callbackData;
                devPanel_Remove(panel);
                DiscardPanel (panel);
            }
            break;
    }
	updateGraphSource();
    return 0;
}
Example #14
0
File: Sr844.c Project: gaorlov/DAAS
int  ADCControlCallback844(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    sr844Ptr lia;
    acqchanPtr acqchan;

    acqchan = callbackData;

    switch (control) {
        case SR844_ADC_NOTE_1:
        case SR844_ADC_NOTE_2:
            AcqDataNoteCallback (panel, control, event, callbackData, eventData1, eventData2);
            break;
        case SR844_ADC_ACQ_1:
        case SR844_ADC_ACQ_2:
            if (event == EVENT_VAL_CHANGED) {
                GetCtrlVal (panel, control, &acqchan->acquire);
                if (acqchan->acquire) acqchanlist_AddChannel (acqchan);
                    else acqchanlist_RemoveChannel (acqchan);
            }
            break;
        case SR844_ADC_CONVERSION_1:
        case SR844_ADC_CONVERSION_2:
            if (event == EVENT_VAL_CHANGED) {
                GetCtrlVal (panel, control, &acqchan->conversion);
                if (acqchan->p) SetCtrlVal (acqchan->p, ACQDATA_CONV, acqchan->conversion);
            }
            break;
        case SR844_ADC_COEFF_1:
        case SR844_ADC_COEFF_2:
            if (event == EVENT_COMMIT) {
                GetCtrlVal (panel, control, &acqchan->coeff);
                if (acqchan->p) SetCtrlVal (acqchan->p, ACQDATA_COEFF, acqchan->coeff);
            }
            break;
        case SR844_ADC_LABEL_1:
        case SR844_ADC_LABEL_2:
            if (event == EVENT_COMMIT) {
                GetCtrlVal (panel, control, acqchan->channel->label);
                acqchanlist_ReplaceChannel (acqchan);
                if (acqchan->p) SetPanelAttribute (acqchan->p, ATTR_TITLE, acqchan->channel->label);
            }
            break;
        case SR844_ADC_CLOSE:
            if (event == EVENT_COMMIT) {
                lia = callbackData;
                devPanel_Remove(panel);
                DiscardPanel (panel);
            }
            break;
    }
    return 0;
}
/// HIFN gets the parameters for the phase grating pattern and sets the SLM
void setPhaseGratingFromParameters()
{
	// read out the parameters from the phase grating tab page
	double a1, a2, b1, b2, angle;	
	GetCtrlVal(TabPage_1_1, TABPANEL_4_Amplitude1, &a1);
	GetCtrlVal(TabPage_1_1, TABPANEL_4_Amplitude2, &a2);
	GetCtrlVal(TabPage_1_1, TABPANEL_4_Period1,    &b1);
	GetCtrlVal(TabPage_1_1, TABPANEL_4_Period2,   &b2);
	GetCtrlVal(TabPage_1_1, TABPANEL_4_Angle,      &angle);
	
	// set the SLM pattern to a phase grating
	SLM_setPhaseGrating(a1, b1, a2, b2, angle);
}
Example #16
0
int CVICALLBACK ManualInput (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			if(control == PANEL_RB_CHECKBOX ){
				int state;
				GetCtrlVal (panel, PANEL_RB_CHECKBOX, &state); 
				if(state)
				{
					SetCtrlAttribute (panel, PANEL_RB_UNLOCKX, ATTR_CTRL_MODE,  VAL_NORMAL);
					SetCtrlAttribute (panel, PANEL_RB_UNLOCKY, ATTR_CTRL_MODE,  VAL_NORMAL);
					SetCtrlAttribute (panel, PANEL_RB_LOCKX, ATTR_CTRL_MODE,  VAL_NORMAL); 
					SetCtrlAttribute (panel, PANEL_RB_LOCKY, ATTR_CTRL_MODE,  VAL_NORMAL);

					SetCtrlAttribute (panel, PANEL_RB_SAV_HI, ATTR_CTRL_MODE,  VAL_NORMAL);
				}
				else
				{
					SetCtrlAttribute (panel, PANEL_RB_UNLOCKX, ATTR_CTRL_MODE,  VAL_INDICATOR);
					SetCtrlAttribute (panel, PANEL_RB_UNLOCKY, ATTR_CTRL_MODE,  VAL_INDICATOR);
					SetCtrlAttribute (panel, PANEL_RB_LOCKX, ATTR_CTRL_MODE,  VAL_INDICATOR); 
					SetCtrlAttribute (panel, PANEL_RB_LOCKY, ATTR_CTRL_MODE,  VAL_INDICATOR);

					SetCtrlAttribute (panel, PANEL_RB_SAV_HI, ATTR_CTRL_MODE,  VAL_INDICATOR);
				}
			}else if(control == PANEL_RB_CHECKBOX_2 ){
				int state;
				GetCtrlVal (panel, PANEL_RB_CHECKBOX_2, &state); 
				if(state)
				{
					SetCtrlAttribute(panel,PANEL_RB_SET_POS, ATTR_DIMMED, 0); 
					SetCtrlAttribute(panel,PANEL_RB_SET_LCK, ATTR_DIMMED, 0);
					SetCtrlAttribute(panel,PANEL_RB_SET_SAV_HI, ATTR_DIMMED, 0);
				}
				else
				{
					SetCtrlAttribute(panel,PANEL_RB_SET_POS, ATTR_DIMMED, 1); 
					SetCtrlAttribute(panel,PANEL_RB_SET_LCK, ATTR_DIMMED, 1);
					SetCtrlAttribute(panel,PANEL_RB_SET_SAV_HI, ATTR_DIMMED, 1);
				}
			}
			
			break;
	}
	return 0;
}
/// HIFN Callback function for toggling the phase grating mode to a pattern Gaussian peaks
int CVICALLBACK GaussianPeaks_Callback (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
		{	
			// check if the button is on or off
			int gptoggle;
			GetCtrlVal(panel, control, &gptoggle);
			
			// toggle the Gaussian peaks setting
			SLM_togglePhaseGratingGaussianPeaks(gptoggle);
			
			// check if we need to update
			if (eventData1 != SLM_NO_UPDATE)
			{
				// update the SLM panel and the simulation Panel (if toggled)
				SLM_update(pnlSLMpixels, SLMpixels_SLMcanvas, pnlSimPanel, SimPanel_CANVAS, 1);
			}
			
			break;
		}
	}
	return 0;
}
Example #18
0
int  CVICALLBACK loaded_mask(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{	
	char dummy[500];
	switch (event)
			
	{
	case EVENT_COMMIT:
		GetCtrlVal (Main_pnl_handle, ERG_panel_loaded_mask_list, &mask_index);
		GetLabelFromIndex (Main_pnl_handle, ERG_panel_loaded_mask_list, mask_index, &mask_filename);
		if (mask_index==0){
			for (i=0;i<Npixel;i++){
					drive_level[i]=0;
				}
		
		}
		else{
			strcpy (dummy, mask_path);
			strcat (dummy, "\\");
			strcat(dummy, mask_filename);
		
			FileToArray (dummy, drive_level, VAL_INTEGER, Npixel, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS, VAL_ASCII);
		}
		
		display_masks();



			  
			break;
	}
	return 0;
}
/* 辅助函数-Log信息台-右键菜单-回调函数 */
void CVICALLBACK logBoxRightClickMenuCallback(int menuBarHandle, int menuItemID, 
			void *callbackData, int panelHandle){
	switch(menuItemID){
		case 3:
			SYSTEMTIME localTime;
			char dirName[MAX_PATHNAME_LEN];
			char filePath[MAX_PATHNAME_LEN]; 
			char fileName[200]; fileName[0]='\0';
			GetProjectDir(dirName);
			strcat(dirName, "\\Logs");
			GetLocalTime(&localTime);
			sprintf(fileName, "Log,%04d-%d-%d,%d_%02d_%02d.txt", 
					localTime.wYear, localTime.wMonth, localTime.wDay,
					localTime.wHour, localTime.wMinute, localTime.wSecond);
			MakePathname(dirName, fileName, filePath);
			FILE *fp = fopen(filePath, "w");
			int len=0;
			GetCtrlAttribute(panelHdl, MainPanel_MainLogBox, ATTR_STRING_TEXT_LENGTH, &len);
			char tempLog[10000];
			GetCtrlVal(panelHdl, MainPanel_MainLogBox, tempLog);
			fwrite(tempLog, sizeof(char), len, fp);
			fclose(fp);
			ResetTextBox(panelHdl, MainPanel_MainLogBox, "Logs have been saved!");
			break;
		case 4:
			ResetTextBox(panelHdl, MainPanel_MainLogBox, "");
			break;
	}
}
Example #20
0
void main()

{
int handle, panel, id;
int var;

id = 0;

 panel = LoadPanel (0, "primcvi.uir", mipanel1);

 DisplayPanel (panel);


while (id != mipanel1_salir) 
	{
	GetUserEvent (0, &handle, &id);
	
    GetCtrlVal (panel, mipanel1_pot1, &var);
	SetCtrlVal (panel, mipanel1_tanque1, var);
	
	}

DiscardPanel (panel);

} /* del main */
Example #21
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;
}
/* 下拉控件-加窗类型-回调函数 */
int CVICALLBACK windowTypeCallback(int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2){
	int i; 
	GetCtrlVal(panel, PopupPanel_RingWindowType, &i);
	switch(event){
		case EVENT_COMMIT:
			drawAnalysisResult(panel);
			char msg[256];msg[0] = '\0';
			sprintf(msg, "添加-");
			switch(i){
				case 0:
					strcat(msg, "海宁窗");
					break;
				case 1:
					strcat(msg, "海明窗");
					break;
				case 2:
					strcat(msg, "布拉克曼窗");
					break;
			  	case 3:
					strcat(msg, "指数窗");
					break;
				case 4:
					strcat(msg, "高斯窗");
					break;
				case 5:
					strcat(msg, "三角窗");
					break;
			}
			strcat(msg, "-函数");
			addLog(msg, 1, panel);
			break;
	}
	return 0;
}
Example #23
0
int CVICALLBACK DataFileSuffixControlCallback (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        char strSuff[MAX_PATHNAME_LEN];
        case EVENT_COMMIT:
            GetCtrlVal(acqG.p.setup, ACQSETUP_FILESUFFIX, strSuff);
            // validate the filename for valid chars
            char invChars[] = {'<', '>', ':', '"', '/', '\\', '|', '?', '*'};  
            int nChars = 9;
            void * chP;
            char ch;
            
            for( int i = 0; i<nChars; i++){
                ch = invChars[i];
                chP = strchr(strSuff, ch);

                if ( chP ) {  
                    MessagePopup("Invalid filename character in the file suffix",
                                      "Do not to use <>:\"/\\\|?* characters");
                    // reverse to previous val
                    SetCtrlVal(acqG.p.setup, ACQSETUP_FILESUFFIX, dataFile.fileSuffix);
                    return 0;
                }
            }
            // store validated suffix
            strcpy(dataFile.fileSuffix, strSuff);

            break;
    }
    return 0;
}
Example #24
0
int waveform (int color, int data_file)
{
	static char write_buffer[100],  read_buffer[10000]  ;
	int numToRead=10000;
	int written_bytes;
	
	////////////////////////////////////////////////
	memset(read_buffer, 0, 10000);
	ibsic(device);

	strcpy (write_buffer, "DATA:STARt 1");
	ibwrt (device, write_buffer, strlen(write_buffer));
	sprintf (write_buffer, "DATA:STOP 10000");
	ibwrt (device, write_buffer, strlen(write_buffer));
	strcpy (write_buffer, "ACQUIRE:MODE SAMPLE");
	ibwrt (device, write_buffer, strlen(write_buffer));

	strcpy (write_buffer, "ACQUIRE:STOPAFTER SEQUENCE");
	ibwrt (device, write_buffer, strlen(write_buffer));
	
	//read pump intensity, mask type and scan ref
	get_intensity();
//	Delay(0.5);
	
	strcpy (write_buffer, "ACQUIRE:STATE ON");
	ibwrt (device, write_buffer, strlen(write_buffer));

	strcpy (write_buffer, "*WAI");
	ibwrt (device, write_buffer, strlen(write_buffer));

	strcpy (write_buffer, "CURVe?");
	ibwrt (device, write_buffer, strlen(write_buffer));
	Delay(0.3); 

	ibrd (device, read_buffer, numToRead);

//Delay(1);	 
	ConvertArrayType (read_buffer, VAL_CHAR, data2fit, VAL_DOUBLE, 10000);
	written_bytes=WriteFile (data_file,read_buffer ,10000 );
	CloseFile (data_file);
	
	
	
	if (written_bytes!=10000)
	{
		printf("Error writing file!!\n");
	}

	plot_data(color);                   
	
	GetCtrlVal (ERG_panel, ERG_panel_fit_live, &j);
//	printf ("%d", j);
	if (j==1)
	{
	fit_data ();
	}
	
	return 1;
}
Example #25
0
int  das1602_MeasureControlCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    acqchanPtr acqchan = callbackData;
    switch (control)
    {
        case MEASURE_RANGE:
            if (event == EVENT_COMMIT)
            {
                portPtr port = acqchan->upLvl;
                GetCtrlVal (panel, control, &port->port.analogueIOport.range);
            }
            break;
        case MEASURE_LABEL:
            if (event == EVENT_COMMIT)
            {
                portPtr port = acqchan->upLvl;
                MCCdevPtr dev = acqchan->dev;
                das1602Ptr das = dev->device;
                GetCtrlVal(panel, control, acqchan->channel->label);
                acqchanlist_ReplaceChannel(acqchan);
                SetPanelAttribute(panel, ATTR_TITLE, acqchan->channel->label);
                SetMenuBarAttribute (das->menu, port->menuitem_id, ATTR_ITEM_NAME,
                                     acqchan->channel->label);
            }
            break;
        case MEASURE_COEFF:
            if (event == EVENT_COMMIT)
                GetCtrlVal(panel, control, &acqchan->coeff);
            break;
        case MEASURE_ACQ:
            if (event == EVENT_COMMIT && utilG.acq.status != ACQ_BUSY)
            {
                portPtr port = acqchan->upLvl;
                MCCdevPtr dev = acqchan->dev;
                das1602Ptr das = dev->device;
                GetCtrlVal(panel, control, &acqchan->acquire);
                if (acqchan->acquire) acqchanlist_AddChannel(acqchan);
                else acqchanlist_RemoveChannel(acqchan);
                SetMenuBarAttribute (das->menu, port->menuitem_id, ATTR_CHECKED, acqchan->acquire);
            }
            else if(event == EVENT_COMMIT && utilG.acq.status == ACQ_BUSY)
                SetCtrlVal (panel, control, acqchan->acquire);
            break;
    }
    return 0;
}
Example #26
0
File: K213.c Project: gaorlov/DAAS
int  K213ControlCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    gpibioPtr dev = callbackData;
    k213Ptr quadsrc = dev->device;
    int port;

    for (port = 0; port < 4; port++)
        if (quadsrc->port[port].panel == panel) {
            switch (control) {
                case K213PORT_DISPLAY:
                    if (event == EVENT_COMMIT) {
                        GetCtrlVal (panel, control, &quadsrc->port[port].src->biaslevel);
                        k213_SetPortLevel (port+1, dev);
						util_Delay(1);
                    }
                    break;
                case K213PORT_AUTORANGE:
                    if (event == EVENT_COMMIT) {
                        GetCtrlVal (panel, control, &quadsrc->port[port].autorange);
                        k213_SetPortLevel (port+1, dev);
                    }
                    break;
                case K213PORT_RANGE:
                    if (event == EVENT_COMMIT) {
                        GetCtrlVal (panel, control, &quadsrc->port[port].range);
                        k213_SetPortLevel (port+1, dev);
                    }
                    break;
                case K213PORT_SETUP:
                    if (event == EVENT_COMMIT) {
                        switch (utilG.exp) {
                            case EXP_SOURCE: source_InitPanel (quadsrc->port[port].src); break;
                            case EXP_FLOAT: gensrc_InitPanel (quadsrc->port[port].src); break;
                        }
                    }
            }
            break;
        }

    if (event == EVENT_COMMIT) {
        k213_GetStatus(dev);
        k213_UpdateControls(panel, dev);
    }
    return 0;
}
Example #27
0
int  K2400SourceCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    sourcePtr src = callbackData;

    if (event == EVENT_COMMIT) {
        GetCtrlVal (panel, control, &src->biaslevel );
        k2400_SetLevel (src);
    }
    return 0;
}
Example #28
0
File: util.c Project: gaorlov/DAAS
int  util_NoteCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    char *note;
    if (event == EVENT_VAL_CHANGED)
    {
        note = callbackData;
        GetCtrlVal (panel, control, note);
    }
    return 0;
}
Example #29
0
int CVICALLBACK BasicFunctions (int panel, int control, int event,
                                void *callbackData, int eventData1, int eventData2)
{
    double dState;
    
    char sTmp [4096];
    
    switch (event)
    {
        case EVENT_COMMIT:
            switch(control)
            {
                case P_BASIC_FN_RNG_SHOW_UI:
                    
                    GetCtrlVal (pBasicFn, P_BASIC_FN_RNG_SHOW_UI, &iCtrlVal);
                    
                    switch(iCtrlVal)
                    {
                        case 0:
                            DisplayPanel (pSystem);
                        break;
                        
                        case 1:
                            DisplayPanel (pControlPad);
                            SetCtrlAttribute (pBasicFn, P_BASIC_FN_TIM_DATA, ATTR_ENABLED, 1);
                        break;
                    }
            }

        break;
        
        case EVENT_TIMER_TICK:
            switch (control)
            {
                case P_BASIC_FN_TIM_DATA:
                
               //     DebugPrintf ("---> [P_BASIC_FN_TIM_DATA]\n");
                
                    PiCardFnct (PI_GET_POS);
                    GetPiCardScrtItem (PI_POS, 1, &dState);
                    sprintf (sTmp, "%f", dState);
                
                    SetCtrlVal (pControlPad, P_CTRL_PAD_LBL_CURRENT_POS_4, sTmp);
                
                    GetPiCardScrtItem (PI_LAST_POS, 1, &dState);
                    sprintf (sTmp, "%f", dState);
                
                    SetCtrlVal (pControlPad, P_CTRL_PAD_LBL_LAST_POS, sTmp);
                
                 break;
            }
    }
    return 0;
}
Example #30
0
int CVICALLBACK BeepCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
	int b;
	switch (event)
	{
		case EVENT_COMMIT:
			GetCtrlVal(panel,control, &b);
			utilG.beep = b;
		break;
	}
	return 0;
}