Ejemplo n.º 1
0
void setRobotCommand(ROBOT* rb,RTANK_ID rid, COMMAND_TYPE type)
{
	if(testBit(sys->hsAuto,RB)>0) 
	{
		MessagePopup("Robot is auto","Robot is auto!");
		return;
	}
	
	if(testBit(rb->hsBusyStatus,RB) > 0)
	{
		MessagePopup("Robot is busy","Robot is busy!");
		return;
	}
	if(testBit(rb->hsHomeStatus,RB) == 0 && type != HOME_COMMAND)
	{
		MessagePopup("Robot is not home","Robot is not home!");
		return;
	}
	
	if(ListNumItems(rb->cmdList))
	{
		MessagePopup("Robot is busy","Robot is busy!");
		return;
	}
	
	ROBOT_COMMAND cmd;
	cmd.type = type;
	cmd.tid = sys->rtk[rid].tid;
	cmd.rid = rid;
	cmd.status = MANUAL_STATUS;
	
	ListInsertItem(rb->cmdList,&cmd, END_OF_LIST);

}
Ejemplo n.º 2
0
int  DataFileSaveAsCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    char path[300], path1[300], path2[300], name[300];
    int i, filestatus;  char *date, mon[10], day[10], yr[10];
	
    if (event == EVENT_COMMIT) {
        Fmt (name, "%s<%s.%i", dataFile.name, dataFile.ext);
        filestatus = FileSelectPopup (dataFile.dir, name, "",
                                      "Save As [file extension must be a #!]:",
                                      VAL_OK_BUTTON, 0, 0, 1, 1, path);
        switch (filestatus) {
            case VAL_EXISTING_FILE_SELECTED:
                MessagePopup ("Save As Message", "Cannot select duplicate file paths");
                break;
            case VAL_NEW_FILE_SELECTED:
                Fmt (path1, path);
                while (Scan(path1, "%s>%s[xdt92]%s", path2) == 2)
                    Fmt (path1, path2);
                Scan (path2, "%s>%s[t46]", dataFile.name);
                i = Scan (path2, "%s>%s[xdt46]%i[b2]", &dataFile.ext);
                if (i != 2)
                    MessagePopup ("File name error",
                              "File extension must be a number..."
                              "extension ignored");
                Fmt (path1, path);
                i = FindPattern (path1, 0, StringLength (path1), path2, 0, 0);
                CopyString (dataFile.dir, 0, path1, 0, i-1);  
                acquire_UpdateDataFileInfo();
                break;
        }
    }
    return 0;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
Archivo: K213.c Proyecto: gaorlov/DAAS
static void k213_GetErrorStatus (gpibioPtr dev)
{
    int error, s;
    char e_msg[256], *s_msg, rsp[256];

    gpibio_Out (dev, "E?");
    gpibio_In (dev, rsp);

    Scan (rsp, "%s>E%i", &error);
    switch (error) {
        case 1: MessagePopup ("Keithley 213 Message", "ERROR: Unrecognized command"); break;
        case 2: MessagePopup ("Keithley 213 Message", "ERROR: Invalid command parameter"); break;
        case 3: MessagePopup ("Keithley 213 Message", "ERROR: Command conflict"); break;
        case 4: MessagePopup ("Keithley 213 Message", "ERROR: Calibration switch not closed"); break;
        case 5:
            gpibio_Out (dev, "S?");
            gpibio_In (dev, rsp);
            Scan (rsp, "%s>S%i", &s);
            Fmt (e_msg, "ERROR: Non-volatile RAM error, system defaults or calibration may be lost.");
            if (s) s_msg = "User programmed defaults are still valid";
                else s_msg = "Factory defaults are in use, user programmed defaults were lost";
            Fmt (e_msg, "%s[a]<\n%s", s_msg);
            MessagePopup ("Keithley 213 Message", e_msg);
            break;
    }
}
Ejemplo n.º 5
0
int CVIFUNC mouth_Error (const char message[], dnaByte abortQ,
						 dnaByte forceErrorQ)
{
	int status,err;
	long count;
	char mouthMessage[80]={0};
#if VERBOSE > 0
	if (forceErrorQ) {
		FmtOut ("%s\n", message);
		Beep();
		Breakpoint();
		ScanIn ("%s", mouthMessage);		// Wait for enter to be pressed
		if (abortQ) abort();
		return -1;
	}		
	status = ThreadIbsta ();
	if (status & ERR) {						// ERR is defined in gpib.h
		err=ThreadIberr();
		count = ThreadIbcntl();
		FmtOut ("%s\n", message);
		FmtOut ("status %d  error %d count %d\n", status,err,count);
		FmtOut ("Library error so Abort always requested.\n");
		FmtOut ("Reminder: Did you turn on the SRS? to GPIB ID #19?\n");
		Beep();
		Breakpoint();
		ScanIn ("%s", mouthMessage);		// Wait for enter to be pressed
		if (abortQ) abort();
		return -1;
	}		
#else
	if (forceErrorQ) {
		Beep();
		MessagePopup ("Mouth Error", message);
		Breakpoint();
		if (abortQ) abort();
		return -1;
	}
	status = ThreadIbsta ();
	if (status & ERR) {
		err=ThreadIberr();
		count = ThreadIbcntl();
		Fmt (mouthMessage, "%s<%s\n", message);
		Fmt (mouthMessage, "%s[a]<status %d  error %d count %d\n", status,err,count);
		if (abortQ)
			Fmt (mouthMessage, "%s[a]<Software Error and Abort has been requested.\n");
		Fmt (mouthMessage, "%s[a]<Reminder: Did you turn on the SRS? to GPIB ID #19?\n");
		Beep();
		MessagePopup ("Mouth Error", mouthMessage);
		Breakpoint();
//		if (abortQ) abort();
		return -1;
	}		

#endif

	return 0;    
}
Ejemplo n.º 6
0
Archivo: K213.c Proyecto: gaorlov/DAAS
static void k213_CheckforProblems (gpibioPtr dev)
{
    char msg[256];
    short statusbyte;
    k213Ptr quadsrc = dev->device;

    gpibio_GetStatusByte (dev, &statusbyte);

    if (statusbyte & K213_SRE_TRIGOVERRUN)
        MessagePopup ("K213 Message", "Trigger overrun");
    if (statusbyte & K213_SRE_ERROR) k213_GetErrorStatus (dev);
    if (statusbyte & K213_SRE_EXTTRANS)
        MessagePopup ("K213 Message", "External input transition detected");
}
Ejemplo n.º 7
0
void acquire_Init (void)
{
    if (utilG.acq.status != ACQ_NONE) {
        util_ChangeInitMessage ("Acquisition Utilities...");
        util_WriteLog("acquire_Init()\nStarting...\n");
        acqG.p.setup = LoadPanel (utilG.p, "acquireu.uir", ACQSETUP);
        
        //SetPanelPos (acqG.p.setup, VAL_AUTO_CENTER, VAL_AUTO_CENTER);
        // Set default data dir and suffix
        int dirNameLen;
        if(FileExists(DFLT_DATA_DIR, &dirNameLen) ) {
            strcpy(dataFile.dataDir, DFLT_DATA_DIR);
        } else {
            char msg[MAX_PATHNAME_LEN*2];
            sprintf(msg, "Default Data Does not exist:\n%s\nUsing application dir.", DFLT_DATA_DIR);
            MessagePopup ("Acquisition Setup", msg );

            GetProjectDir (dataFile.dataDir);
        }
        SetCtrlVal (acqG.p.setup, ACQSETUP_DATADIR, dataFile.dataDir);
        strcpy(dataFile.fileSuffix, DFLT_FILE_SUFFIX);
        SetCtrlVal(acqG.p.setup, ACQSETUP_FILESUFFIX, dataFile.fileSuffix); 

        // This control is a button on startup panel, "control. acquisition, and analysis"
        InstallCtrlCallback (utilG.p, BG_ACQSETUP, AcqSetupCallback, 0);

    } else SetCtrlAttribute (utilG.p, BG_ACQSETUP, ATTR_VISIBLE, FALSE);
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
int exp_Begin (void)
{
    int size;

/*    if (GetFileInfo (dataFile.path, &size)) {
        MessagePopup ("Begin Experiment Message",
                      "Cannot save data to file w/ duplicate name");
        return FALSE;
    }//*/

    if (acqchanG.channels.nItems < 1)
    {
        MessagePopup ("Begin Experiment Message",
                      "Must select at least one channel for acquisition");
        return FALSE;
    }

    //updateGraphSource();
	if (!acqchanlist_AllocMemory()) return FALSE;

    utilG.acq.status = ACQ_BUSY;

    utilG.acq.pt = 0;
    expG.InitExp();
    acqchanlist_InitDataFile(dataFile.path);

    return TRUE;
}
Ejemplo n.º 11
0
void InverseCallback(int menubar, int menuItem, void *callbackData, int panel)
{
    channelPtr chan, newchan;
    int pt, err;

    chan = channellist_GetSelection();

    err = FALSE;
    newchan = channel_Create();
    if (newchan && channel_AllocMem (newchan, chan->pts))
    {
        for (pt = 0; pt < chan->pts; pt++)
        {
            if (chan->readings[pt] != 0.0)
                newchan->readings[pt] = 1/chan->readings[pt];
            else {err = TRUE; break;}
        }
        if (!err)
        {
            Fmt (newchan->label, "%s<1 / (%s)", chan->label);
            Fmt (newchan->note, "%s\n%s\n", chan->note, newchan->label);
            channellist_AddChannel (newchan);
        }
        else {free (newchan->readings); free (newchan); newchan = NULL;}
    }
    else err = TRUE;
    if (err)
    {
        MessagePopup ("Inverse Function Message", "Channel readings include 0.0 - function voided");
        if (newchan) free (newchan);
    }
}
Ejemplo n.º 12
0
void DisplayActiveXErrorMessageOnFailure (HRESULT error)
{
    if (FAILED (error))
    {
        char errBuf [ERR_MSG_SIZE];
        CVIXMLGetErrorString (error, errBuf, sizeof (errBuf));
        MessagePopup (ERR_MSG_TITLE, errBuf);
    }

}
int CVICALLBACK OK_Btn_Callback (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2) {
	switch (event) {
		case EVENT_COMMIT:
			char title[30] = "I'm the title!";
			char msg[100] = "Hello World !";
			MessagePopup(title, msg);
			break;
	}
	return 0;
}
/* -------------------------------------------------------------------------- */
int main ()
{
    ViSession   tkafg3k;
    ViStatus    error = VI_SUCCESS;
    ViString    popUpMsg = "The function generator is outputting the waveform "  
                           "that you configured.\n\nPress <Enter> to continue";

    /* Initialize */
    checkErr( tkafg3k_InitWithOptions ("GPIB::11::INSTR", VI_TRUE, VI_TRUE,
                                        TKAFG3K_EXAMPLE_INIT_OPTION,
                                        &tkafg3k));

    /* Set trigger */
    checkErr( tkafg3k_ConfigureTriggerSource (tkafg3k, "1", TKAFG3K_VAL_INTERNAL_TRIGGER));
    checkErr( tkafg3k_ConfigureInternalTriggerRate (tkafg3k, 1000.0));

    /* Configure burst settings */
    checkErr( tkafg3k_ConfigureBurstCount (tkafg3k, "1", 5));
    checkErr( tkafg3k_ConfigureBurstMode (tkafg3k, "1", TKAFG3K_VAL_BURST_TRIGGER));
    checkErr( tkafg3k_ConfigureBurstEnabled (tkafg3k, "1", VI_TRUE));

    /* Enables the output */
    checkErr( tkafg3k_ConfigureOutputEnabled (tkafg3k, "1", VI_TRUE));


    MessagePopup ("Message", popUpMsg);
                                        
Error:
    if (error != VI_SUCCESS)
        {
            ViChar   errStr[2048];

            tkafg3k_GetError (tkafg3k, &error, 2048, errStr);
            MessagePopup ("Error!", errStr);
        }

    if (tkafg3k)
        tkafg3k_close (tkafg3k);
}
/* -------------------------------------------------------------------------- */
int main ()
{
    ViSession   tkafg1k;
    ViStatus    error = VI_SUCCESS;
    ViString    popUpMsg = "The function generator is outputting the waveform "  
                           "that you configured.\n\nPress <Enter> to continue";

    /* Initialize */
    checkErr( tkafg1k_InitWithOptions ("USB0::0x0699::0x0353::1525004::INSTR", VI_TRUE, VI_TRUE,
                                        TKAFG1K_EXAMPLE_INIT_OPTION,
                                        &tkafg1k));
	/* Configure waveform */
	checkErr( tkafg1k_ConfigureOperationMode (tkafg1k, "1", TKAFG1K_VAL_OPERATE_CONTINUOUS));
    checkErr( tkafg1k_ConfigureOutputMode (tkafg1k, TKAFG1K_VAL_OUTPUT_FUNC)); 
    checkErr( tkafg1k_ConfigureStandardWaveform (tkafg1k, "1",
                                                 TKAFG1K_VAL_WFM_SINE, 1.0, 0.0,
                                                 1000000.0, 0.0));
    /* Configure sweep settings */
    checkErr( tkafg1k_ConfigureSweep (tkafg1k, "1", 100000, 1000000));
    checkErr( tkafg1k_ConfigureSweepEnabled (tkafg1k, "1", VI_TRUE));

    /* Enables the output */
    checkErr( tkafg1k_ConfigureOutputEnabled (tkafg1k, "1", VI_TRUE));


    MessagePopup ("Message", popUpMsg);
                                        
Error:
    if (error != VI_SUCCESS)
        {
            ViChar   errStr[2048];

            tkafg1k_GetError (tkafg1k, &error, 2048, errStr);
            MessagePopup ("Error!", errStr);
        }

    if (tkafg1k)
        tkafg1k_close (tkafg1k);
}
Ejemplo n.º 16
0
// Called from the menu experiment->begin
int exp_Begin (void)
{
    int size;

    if (acqchanG.channels.nItems < 1)
    {
        MessagePopup ("Begin Experiment Failed:",
                      "Please select at least one channel for acquisition");
        return FALSE;
    }
    // Check datafile dir exists (in case it was removed after it was set
    int dirNameLen;
    if( ! FileExists(dataFile.dataDir, &dirNameLen) ) {
        MessagePopup ("Begin Experiment Failed:",
                      "Data dir does not exist! ");
        return FALSE;
    }
    if (!acqchanlist_AllocMemory()) return FALSE;
        
    // set filepath from the data dir, timestamp, suffix and extension
    double dt;
    GetCurrentDateTime(&dt); // sec from 1900, local time
    char fname[MAX_PATHNAME_LEN];
    FormatDateTimeString(dt, "%Y-%m-%d_%H%M%S", fname, MAX_PATHNAME_LEN-1);
    sprintf(dataFile.filePath,"%s\\%s_%s.daas", dataFile.dataDir, fname, dataFile.fileSuffix);
    util_printfLog("Starting Experiment...\n");
    util_printfLog("Data file path: %s\n", dataFile.filePath);
    SetCtrlVal (acqG.p.setup, ACQSETUP_FILEPATH, dataFile.filePath);                      
    //updateGraphSource();

    utilG.acq.pt = 0;
    expG.InitExp();
    acqchanlist_InitDataFile(dataFile.filePath);
    exp_StartDaq();

    return TRUE;
}
Ejemplo n.º 17
0
void InitSubsetCallback(int menubar, int menuItem, void *callbackData, int panel)
{
    channelPtr chan;
    channel_InitViewPanel();
    chan = channellist_GetSelection();
    channel_UpdateViewPanel(chan);
    SetCtrlAttribute (chanview.p1, CHANVIEW_CHANNELS, ATTR_CTRL_MODE,
                      VAL_INDICATOR);
    InstallCtrlCallback (chanview.p1, CHANVIEW_DONE, SubsetDoneCallback,
                         chan);
    InstallPopup (chanview.p1);
    MessagePopup ("Subset Channel Message",
                  "Place window over desired readings"
                  " and press DONE to create subset");
}
Ejemplo n.º 18
0
void NegativeCallback(int menubar, int menuItem, void *callbackData, int panel)
{
    channelPtr chan, newchan;
    chan = channellist_GetSelection();

    newchan = channel_Create();
    if (newchan && channel_AllocMem (newchan, chan->pts) &&
        (Neg1D (chan->readings, chan->pts, newchan->readings) == NoErr))
    {
        Fmt (newchan->label, "%s<- (%s)", chan->label);
        Fmt (newchan->note, "%s\n%s\n", chan->note, newchan->label);
        channellist_AddChannel (newchan);
    }
    else MessagePopup ("Negative Function Message", "Random error...try again");
}
Ejemplo n.º 19
0
main ()

{
    ViSession   tkafg3k;
    ViStatus    error = VI_SUCCESS;
    ViString    popUpMsg = "The function generator is outputting the waveform "  
                           "that you configured.\n\nPress <Enter> to continue";

        /* 
            If you want to run this sample program and the instrument is not
            present, set the Simulate flag to 1.  (Example:  "Simulate = 1")
        */
    checkErr( tkafg3k_InitWithOptions ("GPIB::11::INSTR", VI_TRUE, VI_TRUE,
                                        "Simulate=0,RangeCheck=1,QueryInstrStatus=1,Cache=1",
                                        &tkafg3k));

    checkErr( tkafg3k_ConfigureOperationMode (tkafg3k, "1", TKAFG3K_VAL_OPERATE_CONTINUOUS));
    checkErr( tkafg3k_ConfigureOutputMode (tkafg3k, TKAFG3K_VAL_OUTPUT_FUNC)); 
    checkErr( tkafg3k_ConfigureStandardWaveform (tkafg3k, "1",
                                                 TKAFG3K_VAL_WFM_SINE, 1.0, 0.0,
                                                 1000000.0, 0.0));
    checkErr( tkafg3k_ConfigureOutputEnabled (tkafg3k, "1", VI_TRUE));                                               
    MessagePopup ("Message", popUpMsg);
                                        
Error:
    if (error != VI_SUCCESS)
        {
            ViChar   errStr[2048];

            tkafg3k_GetError (tkafg3k, &error, 2048, errStr);
            MessagePopup ("Error!", errStr);
        }

    if (tkafg3k)
        tkafg3k_close (tkafg3k);
}
Ejemplo n.º 20
0
void InitManipulateCallback(int menubar, int menuItem, void *callbackData, int panel)
{
    int i, height1, height2;
    channelPtr chan;

    channel_InitViewPanel();
    InstallCtrlCallback (chanview.p1, CHANVIEW_CHANNELS,
                         ManipulateSelectionCallback, 0);
    ClearListCtrl (chanview.p1, CHANVIEW_CHANNELS);
    for (i = 0; i < channelG.channels.nItems; i++)
    {
        chan = channellist_GetItem (i);
        if (!chan->curves.nItems)
            InsertListItem (chanview.p1, CHANVIEW_CHANNELS, -1, chan->label, i);
    }

    SetCtrlIndex (chanview.p1, CHANVIEW_CHANNELS, 0);
    GetCtrlVal (chanview.p1, CHANVIEW_CHANNELS, &i);
    chan = channellist_GetItem (i);
    InstallCtrlCallback (chanview.p1, CHANVIEW_GRAPH,
                         ManipulateGraphCallback, chan);

    channel_UpdateViewPanel(chan);

    SetCtrlAttribute (chanview.p1, CHANVIEW_GRAPH, ATTR_CTRL_MODE,
                      VAL_HOT);
    SetCtrlAttribute (chanview.p1, CHANVIEW_GRAPH, ATTR_NUM_CURSORS, 1);
    SetCursorAttribute (chanview.p1, CHANVIEW_GRAPH, 1, ATTR_CURSOR_MODE,
                        VAL_SNAP_TO_POINT);
    SetCursorAttribute (chanview.p1, CHANVIEW_GRAPH, 1,
                        ATTR_CROSS_HAIR_STYLE, VAL_SHORT_CROSS);
    SetCursorAttribute (chanview.p1, CHANVIEW_GRAPH, 1, ATTR_CURSOR_COLOR,
                        VAL_YELLOW);
    GetPanelAttribute (chanview.p1, ATTR_HEIGHT, &height1);

    chanview.p2 = LoadPanel (chanview.p1, "chanfncu.uir", MANIP);
    
    GetPanelAttribute (chanview.p2, ATTR_HEIGHT, &height2);
    SetPanelAttribute (chanview.p1, ATTR_HEIGHT, height1+height2+6);
    SetPanelPos (chanview.p2, height1, 6);

    InstallCtrlCallback (chanview.p2, MANIP_READING,
                         ManipulateReadingCallback, chan);

    DisplayPanel (chanview.p2);
    InstallPopup (chanview.p1);
    MessagePopup ("Manipulate Channel Message", "Only channels not connected to a curve may be edited");
}
Ejemplo n.º 21
0
static void chanfunc_AddtoList (char *label, channelPtr chan)
{
    char info[256];

    if (chanfunc.NoErr)
    {
        Fmt (chan->label, label);
        channellist_AddChannel (chan);
    }
    else
    {
        Fmt (info, "Error during %s function", label);
        MessagePopup ("Generate Channel Message", info);
        if (chan)
        {
            if (chan->readings) free(chan->readings);
            free (chan);
        }
    }
}
Ejemplo n.º 22
0
int CVICALLBACK OpenProjectConfirm (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			int i, checked;
/*			for (i = 0; i < projectlist.number; i++)
			{
				IsListItemChecked(panel_open,OPPANEL_TREE_ProjectList,i,&checked);
				if (checked)
				{
					MessagePopup("Number of Projects","checked");
					operatingproject = projectlist.projects[i];
					break;
				}
			}*/
			GetTreeItem(panel_open,OPPANEL_TREE_ProjectList,VAL_ALL,0,0,VAL_NEXT_PLUS_SELF,VAL_SELECTED,&i);
			if (i == -1)
			{
				MessagePopup("打开时出错!","请选中某项后再点击打开按钮");
				return -1;
			}
			if (state_open == 1)
			{
				operatingproject = projectlist.projects[i];
				getDetails(&operatingproject);
				openproject();
			}
			else
			{
				operatinggroupnum = i+1;
				openmeasuregroup();
			}
			HidePanel (panel_open);
			state_open = 0;
			DisplayPanel (panel_main);
			break;
	}
	return 0;
}
Ejemplo n.º 23
0
Archivo: K213.c Proyecto: gaorlov/DAAS
void K213LoadCallback(int menubar, int menuItem, void *callbackData, int panel)
{
    int fileselect, id;
    char path[256], info[256];
    gpibioPtr dev = callbackData;
    k213Ptr quadsrc = dev->device;

    fileselect = FileSelectPopup ("", "*.dev", "*.dev", "Load Keithley 213 Quad Voltage Source Setup",
                                  VAL_LOAD_BUTTON, 0, 1, 1, 0, path);
    if (fileselect == VAL_EXISTING_FILE_SELECTED) {
        fileHandle.analysis = util_OpenFile (path, FILE_READ, FALSE);
        ScanFile (fileHandle.analysis, "%s>#INSTRSETUP %i", &id);
        if (quadsrc->id == id) {
            k213_Load (dev);
            ReadLine (fileHandle.analysis, info, 255);
            k213_UpdateControls(panel, dev);
        }
        else MessagePopup ("Keithley Load Message", "Different instrument types--process aborted");
        util_CloseFile();
    }
}
Ejemplo n.º 24
0
int  DoExponentCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    int i, err, pt;
    double expon;
    channelPtr chan, newchan = NULL;

    if (event == EVENT_COMMIT)
    {
        GetCtrlVal (panel, EXPONENT_CHANNELS, &i);
        chan = channellist_GetItem (i);
        GetCtrlVal (panel, EXPONENT_EXPON, &expon);
        newchan = channel_Create();
        err = FALSE;
        if (newchan && channel_AllocMem (newchan, chan->pts))
        {
            for (pt = 0; pt < chan->pts; pt++) {
                if (chan->readings[pt] != 0.0)
                    newchan->readings[pt] = exp(expon/2*log(chan->readings[pt]*chan->readings[pt]));
                else {
                    err = TRUE;
                    break;
                }
            }
            if (!err) {
                Fmt (newchan->label, "Power[%s]", chan->label);
                Fmt (newchan->note, "%s\nPower [%s]\n"
                                "y = x^a\n"
                                "a: %f[e2p5]\n",
                                chan->note, chan->label, expon);
                channellist_AddChannel (newchan);
            }
        } else err = TRUE;
        if (err)
        {
            MessagePopup ("Exponent Function Message", "Channel readings include 0.0 or < 0.0 - function voided");
            if (newchan) {if (newchan->readings) free (newchan->readings); free (newchan);}
        }
    }
    return 0;
}
Ejemplo n.º 25
0
/*****************************************************************************
.						
. Función C:			PRE_EliminarTransmision
. Responsable:			César Armando Cruz Mendoza
. Descripcion: 			Procesa la selección de eliminar la transmision
.						que el usuario ha seleccionado en la lista de la
.						pantalla.
. Parámetro de entrada:	ninguno
. Parámetro de salida:	cero
. Fecha de creación:	12 de Marzo de 2014
.
*****************************************************************************/
int PRE_EliminarTransmision()
{
	char cDescripcion[250]={0};
	int iNumVelocidades=0;
	int iId=0;
	//se debe tomar el id de la transmisión para hacer una investigación
	//sobre la información que se encuentra vinculada a esta transmision
	//se propone mostrar en pantalla un informe con el total de datos
	//que se encuentran relacionados, a fin de que el usuario pueda
	//tomar la mejor decision sobre eliminar o no el elemento
	
	//primero, informar el número de elementos de velocidades que se
	//estarán eliminando
	GetCtrlVal (iPanelCatTransmisiones, pCatTransm_lstTransmisiones, &iId);
	GetCtrlVal (iPanelCatTransmisiones, pCatTransm_txtNombreTransmision, cDescripcion);
	GetCtrlVal (iPanelCatTransmisiones, pCatTransm_numNumeroVelocidades, &iNumVelocidades);
	
	if (ConfirmPopup ("Eliminar transmisión.", 
					  BDS_InformeParaEliminar(iId, cDescripcion, iNumVelocidades))==1)
	{
		BDS_EliminarTransmision(iId);
		
		//limpia la información de los controles
		SetCtrlVal (iPanelCatTransmisiones, pCatTransm_txtNombreTransmision, "");
		SetCtrlVal (iPanelCatTransmisiones, pCatTransm_numNumeroVelocidades, 1);
		SetCtrlVal (iPanelCatTransmisiones, pCatTransm_chkLadoIzquierdo, 1);
		SetCtrlVal (iPanelCatTransmisiones, pCatTransm_chkLadoDerecho, 0);
		DeleteTableRows (iPanelCatTransmisiones, pCatTransm_tblRelaciones, 1,
						 -1);
		
		MessagePopup ("Transmision eliminada",
					  "Se ha eliminado la información correctamente.");
		
		//regresa la interfaz al modo menu principal
		PRE_CancelarProceso();
	}
	return 0;
}
Ejemplo n.º 26
0
int DoChannelDivisionCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    channelPtr chan1, chan2, newchan;
    int i, err, pts;

    if (event == EVENT_COMMIT)
    {
        GetCtrlVal (panel, CHANOPS_2_CHAN_1, &i);
        chan1 = channellist_GetItem (i);
        GetCtrlVal (panel, CHANOPS_2_CHAN_2, &i);
        chan2 = channellist_GetItem (i);
        if (chan1->pts < chan2->pts) pts = chan1->pts;
        else pts = chan2->pts;

        newchan = channel_Create();
        if (newchan && channel_AllocMem (newchan, pts) &&
            (Div1D (chan1->readings, chan2->readings, pts, newchan->readings) == NoErr))
        {
            Fmt (newchan->label, "Division Result");
            Fmt (newchan->note, "%s /\n%s\n", chan1->label, chan2->label);
            channellist_AddChannel (newchan);
        }
        else
        {
            MessagePopup ("Channel Division Message",
                          "Error during Division calculation");
            if (newchan)
            {
                if (newchan->readings) free (newchan->readings);
                free (newchan);
            }
        }

        
        DiscardPanel (chanops.p);
    }
    return 0;
}
/* 系统初始化 */
void initVars(void){
	/*-- After load Panel, you can init args' value right here ---*/
	//Panel relative Vals
	GetPanelAttribute(panelHdl, ATTR_WIDTH, &pWidth);
	GetPanelAttribute(panelHdl, ATTR_HEIGHT, &pHeight);
	GetPanelAttribute(panelHdl, ATTR_MENU_HEIGHT, &mHeight);
	validMonNum = 6;
	averSpaceH = 8; averSpaceV = 20; extraRight = 150;
	pHeight = pHeight - mHeight;
	cWidth = (pWidth - extraRight - averSpaceH*3)/3;
	cHeight = (pHeight - averSpaceV*2)/2;
	plotBakgColor = MakeColor(200, 200, 200); //Set background color of graphs
	plotGridColor = MakeColor(10, 10, 10);
	plotLineColor = MakeColor(136, 0, 25);
	graphScaleMode = VAL_MANUAL; //or VAL_MANUAL VAL_AUTOSCALE
	//x,y坐标的标值范围
	xAxisRange[0] = 0.0, xAxisRange[1] = 9.0; //temp
	yAxisRange[0] =0.00, yAxisRange[1] = 3.00;
	
	popPanelIsPloting = 0;
	//Create a ThreadPool
	if(setupThreadPool()<0){
		MessagePopup("s", "Create thread pool error.");
	}
	//ChildPanel,TabPage、and Popup panel's Vals
	tabWidth = pWidth-extraRight-averSpaceH*3;
	tabHeight = pHeight - averSpaceV*3;
	
	dataSrc = 0;
	for(int i=0; i<validMonNum; i++)
		signalShowingStat[i] = 1;
	//init the necessary Directory this system needs
	initDirectorySets();
	refreshDimmedStat();
	isDataAcqRunning = 0;
}
Ejemplo n.º 28
0
//---------------------------------------------------------------------------
//  панель ввода получаемых данных на диск и последующего просмотра на экране
//---------------------------------------------------------------------------
int DiskPanel(void)
{
	unsigned long j;
	int i, Key;
	int Pnl, hnd, cnt;
	int N_Blocks=100;
	static int DrawMode=0;
	static int Channel=0;
	unsigned int irq_address;
	char tip[400];
	char *UirName="demo.uir";

	// Загрузим панель
	Pnl=LoadPanel(UirName, DISK);

	ConfigureAxes(Pnl, P(GRAPH), -1, 0.0, 0.0, 0, -Diapason[Gain]/1000., Diapason[Gain]/1000.);
	SetGraphAttribute(Pnl, P(GRAPH), ATTR_GRAPH_Y_AXIS_PRECISION, 3);
	SetCtrlAttribute(Pnl, P(COUNT), ATTR_CTRL_ENABLED, DISABLE);
	SetCtrlVal(Pnl, P(DRAWMODE), DrawMode);
	SetCtrlVal(Pnl, P(CHANNEL), Channel);
	SetCtrlVal(Pnl, P(IRQ_NUMBER), bi[0].InterruptNumber);

	sprintf(tip, "В данном примере программа по клавише 'ПУСК ЗАПИСИ' запускает ввод %7lu \nточек с указанного канала АЦП в файл TEST.DAT. По нажатию на клавишу \n'ПРОСМОТР ЗАПИСИ' выводится содержимое файла TEST.DAT в виде графика.", (unsigned long)((double)BufferLenght*(double)N_Blocks));
	SetCtrlVal(Pnl, P(BOX1),tip);

	// Отобразим панель
	DisplayPanel(Pnl);

	KeyFlag=0;
	for( ; ; )
	{
		if(KeyFlag)
		{
			KeyFlag=0;
			if(KeyCode == 0x1B)
			{
				*KeybPtr1 = *KeybPtr2;
				if(ConfirmPopup("Вы желаете выйти?"))
				{
					UnloadPanel(Pnl);
					return EXIT;
				}
				KeyFlag=0;
			}
		}

		GetUserEvent(0, &hnd, &cnt);
again:
		// Выбpан пункт меню
		if(hnd==Bar)
		{
			if(cnt!=-1)
			{
				switch(cnt)
				{
					case  B(ADC):
						if(AdcParamPanel() == INPUT_PANEL)
						{
							UnloadPanel(Pnl);
							return INPUT_PANEL;
						}
						ConfigureAxes(Pnl, P(GRAPH), -1, 0.0, 0.0, 0, -Diapason[Gain]/1000., Diapason[Gain]/1000.);
						break;

					case  B(DAC):
						UnloadPanel(Pnl);
						return DAC_PANEL;

					case  B(TTL):
						UnloadPanel(Pnl);
						return TTL_PANEL;

					case  B(QUIT):
						if(ConfirmPopup("Вы желаете выйти?"))
						{
							UnloadPanel(Pnl);
							return EXIT;
						}
				}
			}
		}

		// Выбpана опция на панели
		if(hnd == Pnl)
		{
			switch(cnt)
			{
				case P(CHANNEL):
					GetCtrlVal(Pnl, P(CHANNEL), &Channel);
					DefaultCtrl(Pnl, P(BOX1));
					SetCtrlVal(Pnl, P(BOX1),tip);
					break;

				case P(DRAW):
				{
					GetCtrlVal(Pnl, P(DRAWMODE), &DrawMode);
					DeletePlots(Pnl, P(GRAPH));
					SetGraphAttribute (Pnl, P(GRAPH), ATTR_STRIP_SCROLL_MODE,
							(DrawMode) ? SCROLL_MODE_CONTINUOUS : SCROLL_MODE_BLOCK);
					DefaultCtrl(Pnl, P(BOX1));
					SetCtrlVal(Pnl, P(BOX1), "Воспроизводим данные, записанные в файле TEST.DAT");

					fp=fopen("test.dat", "rb");
					if(fp == NULL)
					{
							MessagePopup("Не могу найти файл test.dat! Нечего показывать-то!!!");
							break;
					}

					KeyFlag=0;
					while(!feof(fp) && !KeyFlag)
					{
						fread(StripData, 2, 64, fp);
						for(i=0; i < 64; i++)
							SData[i]=StripData[i]*Diapason[Gain]/(MaxAdcCode*1000.);
						PlotStripChart (Pnl, P(GRAPH), SData, 64, 0, 0, 4);
						GetUserEvent(0, &hnd, &cnt);
						if(cnt != -1) goto again;
					}
					KeyFlag=0;
					fclose(fp);
					DefaultCtrl(Pnl, P(BOX1));
					SetCtrlVal(Pnl, P(BOX1),tip);
					break;
				}

				// стаот сбоpа данных с АЦП по пpеpываниям
				case P(START):
					SetCtrlAttribute(Pnl, P(COUNT), ATTR_CTRL_ENABLED, ENABLE);
					Control_Table[0] = Channel & 0x1F;
					Control_Table[0] |= (Gain << 6);
					Control_Table[0] |= (DifOrCom << 5);
					LOAD_CONTROL_TABLE_PLX(&bi[0], 1, Control_Table);

					fp=fopen("test.dat", "wb");
					if(fp == NULL)
					{
						MessagePopup("Не могу открыть файл для записи данных!");
						break;
					}

					IrqBuffer= new int[BufferLenght];
					if(IrqBuffer == NULL)
					{
						MessagePopup("Не могу выделить память под буфер!");
						break;
					}

					DefaultCtrl(Pnl, P(BOX1));
					SetCtrlVal(Pnl, P(BOX1), "Идет ввод данных...");
					SetCtrlVal(Pnl, P(BOX1), "Для завершения ввода данных нажмите любую клавишу.");
					SetCtrlAttribute(Pnl, P(DRAW), ATTR_CTRL_ENABLED, DISABLE);

					IrqN=Half1=Half2=KeyFlag=0;
					// инициализация пpеpываний
					INIT_INTERRUPT_PLX(&bi[0], IRQ_Handler);
					// запуск pаботы АЦП
					ENABLE_IRQ_PLX(&bi[0], 1, IrqStep=1024);

					// цикл записи собpанных данных на диск
					for(i=0; i < N_Blocks; i++)
					{
						SetCtrlVal(Pnl, P(COUNT), N_Blocks-i);

						while(!Half1 && !kbhit());
						if(KeyFlag) break;
						Half1=0;
						fwrite(IrqBuffer, 2, BufferLenght/2, fp);

						while(!Half2 && !kbhit());
						if(KeyFlag) break;
						Half2=0;
						fwrite(IrqBuffer+BufferLenght/2, 2, BufferLenght/2, fp);
					}

					// останов pаботы АЦП
					ENABLE_IRQ_PLX(&bi[0], 0, 0);
					// восстановление пpеpываний
					STOP_INTERRUPT_PLX(&bi[0]);

					delete[] IrqBuffer;
					SetCtrlAttribute(Pnl, P(DRAW), ATTR_CTRL_ENABLED, ENABLE);

					DefaultCtrl(Pnl, P(BOX1));
					if(KeyFlag)
					{
						KeyFlag=0;
						SetCtrlVal(Pnl, P(BOX1), "Ввод данных злобно прерван!");
					}
					else
						SetCtrlVal(Pnl, P(BOX1), "Ввод данных удачно закончен!");
					fclose(fp);
					Control_Table[0] = 0x0;
					Control_Table[0] |= (Gain << 6);
					Control_Table[0] |= (DifOrCom << 5);
					LOAD_CONTROL_TABLE_PLX(&bi[0], CHANNEL_QUANTITY, Control_Table);
					SetCtrlAttribute(Pnl, P(COUNT), ATTR_CTRL_ENABLED, DISABLE);
					break;
			}
		}
	}
}
Ejemplo n.º 29
0
int CVICALLBACK UpdateVendor (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	char *name = "";	int ret=0;
	switch (event)
	{
		case EVENT_COMMIT:
			 int status; char cmd[100];
			 
			 name=(char*)malloc(100); 
			 memset(name,0,100);
			 GetCtrlVal (customizingHandle, CUSTOM_UPDATENAME, name); 
			 ret = strlen(name);
						 
			 if ((NULL != (strstr (name, ".xml")))&&(ret != 4))
			 {
				 if (ConfirmPopup ("Update Vendor","Do you want to update vendor now?")) 
				 {
					memset(cmd,0,100);
					strcpy(cmd,"RemoteAction.exe -d:vendor");
					DimAction(1); 
					status = ExecutableProcess(cmd,"@action done@");
					if (status)
					{
						  SetLed("Get vendor finished!",1);
						  if(Initial(0, 1)<0)    //  write local vendor name to config.ini 
						  {
						    SetLed("Write local vendor name to config.ini error,please try again!",0);   
						  }
						  else
						  {
							  if(ConfirmPopup ("Confirm carrying on...","Make sure upgrading finished then continue updating process?"))
							  {
								    memset(cmd,0,100);
									strcpy(cmd,"RemoteAction.exe -u:update");
									status = ExecutableProcess(cmd,"@action done@");
									if (status)
									{
										DimAction(0); 
									    SetLed("Update vendor finished!",1); 
									}
							  }
							  else
							  {
							   DimAction(0); 
							   SetLed("U canceled the update process...",0);   
							  }
						  }
					}
					else
					{
					  SetLed("Action failed,please check detail info",0); 
					}
					DimAction(0);
				 }
			 }
			 else
			 {
				 MessagePopup ("Error", "Please confirm you have input vendor name(.xml) before updating!");
			 }
			 
			 free(name);
			 
			break;
	}
	return 0;
}
Ejemplo n.º 30
0
int DoChannelAdditionCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    channelPtr chan, newchan;
    int i, n, checked, err, pts;

    if (event == EVENT_COMMIT)
    {
        GetNumCheckedItems (chanops.p, CHANOPS_1_CHANNELS, &n);
        if (n < 2)
        {
            MessagePopup ("Channel Addition Message",
                          "Cannot perform addition w/ less than 2 channels");
            return 0;
        }

        err = FALSE;
        newchan = NULL;
        for (i = 0; i < channelG.channels.nItems; i++)
        {
            IsListItemChecked (panel, CHANOPS_1_CHANNELS, 0, &checked);
            DeleteListItem (panel, CHANOPS_1_CHANNELS, 0, 1);
            if (checked)
            {
                chan = channellist_GetItem (i);
                if (newchan)
                {
                    if (newchan->pts < chan->pts) pts = newchan->pts;
                    else pts = chan->pts;
                    err = Add1D (newchan->readings, chan->readings, pts,
                                 newchan->readings);
                    if (!err)
                        Fmt (newchan->note, "%s[a]<+\n%s", chan->label);
                    else
                    {
                        MessagePopup ("Channel Addition Message",
                                      "Error during calculation -- operation cancelled");
                        break;
                    }
                }
                else
                {
                    newchan = channel_Create();
                    if (newchan && channel_AllocMem (newchan, chan->pts))
                    {
                        Copy1D (chan->readings, chan->pts, newchan->readings);
                        Fmt (newchan->label, "Addition Result");
                        Fmt (newchan->note, "%s", chan->label);
                    }
                    else
                    {
                        util_OutofMemory ("Channel Addition Message");
                        err = TRUE;
                        break;
                    }
                }
            }
            GetNumCheckedItems (panel, CHANOPS_1_CHANNELS, &n);
            if (n == 0) break;
        }
        if (!err)
        {
            Fmt (newchan->note, "%s[a]<\n");
            channellist_AddChannel (newchan);
        }
        else if (newchan)
        {
            if (newchan->readings) free (newchan->readings);
            free (newchan);
        }

        
        DiscardPanel (chanops.p);
    }
    return 0;
}