/* 辅助函数-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;
	}
}
示例#2
0
int PRE_ResaltarOpcion(int iPanel, int iControl, int iFondo, int iCantidad, ...)
{
	int iTop = 0;
	int iLeft = 0;
	int *iLista;
	va_list pa;
	int iExiste = 0;
	
	va_start(pa, iCantidad);
	
	//Crea la lista en la cual colocará cada una de las referencias de los controles
	//y verifica que el parámetro iControl es diferente a lo que hay en iLista
	iLista = malloc(sizeof(int)*iCantidad);
	
	for (int i=0;i<iCantidad;i++)
	{
		iLista[i] = va_arg(pa, int);
		if (iControl == iLista[i])
		{
			iExiste=1;
			break;
		}
	}
	
	
	if (iExiste == 0)
	{
		GetCtrlAttribute(iPanel, iControl, ATTR_TOP, &iTop);
		GetCtrlAttribute(iPanel, iControl, ATTR_LEFT, &iLeft);
	
	
		SetCtrlAttribute(iPanel, iFondo, ATTR_TOP, iTop);
		SetCtrlAttribute(iPanel, iFondo, ATTR_LEFT, iLeft);
	}
	
	//Llama al proceso que pinta el mensaje de ayuda en pantalla
	PRI_MensajeControl(iPanel, iControl);

	return 0;
}
示例#3
0
void acquire_UpdatePanelExp (void)
{
    int bTop, cTop, height, bottom;

/* Floating experiment */

    SetCtrlAttribute (acqG.p.setup, ACQSETUP_GEN_POINTS, ATTR_VISIBLE, utilG.exp == EXP_FLOAT);
    SetCtrlAttribute (acqG.p.setup, ACQSETUP_GEN_DELAY, ATTR_VISIBLE, utilG.exp == EXP_FLOAT);
    SetCtrlAttribute (acqG.p.setup, ACQSETUP_GEN_TIME, ATTR_VISIBLE, utilG.exp == EXP_FLOAT);
    SetMenuBarAttribute (acquire_GetMenuBar(), ACQMENUS_EXP_GENERAL, ATTR_CHECKED, utilG.exp == EXP_FLOAT);

/* Source experiment */

    SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_LIST, ATTR_VISIBLE, utilG.exp == EXP_SOURCE);
    SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_MOVEUP, ATTR_VISIBLE, utilG.exp == EXP_SOURCE);
    SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_MOVEDOWN, ATTR_VISIBLE, utilG.exp == EXP_SOURCE);
    SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_REMOVE, ATTR_VISIBLE, utilG.exp == EXP_SOURCE);
    SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_POINTS, ATTR_VISIBLE, utilG.exp == EXP_SOURCE);
    SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_TIME, ATTR_VISIBLE, utilG.exp == EXP_SOURCE);
    SetMenuBarAttribute (acquire_GetMenuBar(), ACQMENUS_EXP_SOURCE, ATTR_CHECKED, utilG.exp == EXP_SOURCE);


    switch (utilG.exp) {
        case EXP_FLOAT:
            GetCtrlAttribute (acqG.p.setup, ACQSETUP_GEN_DELAY, ATTR_TOP, &cTop);
            GetCtrlAttribute (acqG.p.setup, ACQSETUP_GEN_DELAY, ATTR_HEIGHT, &height);
            SetCtrlVal (acqG.p.setup, ACQSETUP_EXPTITLE, "Floating Experiment");
            break;
        case EXP_SOURCE:
            GetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_POINTS, ATTR_TOP, &cTop);
            GetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_POINTS, ATTR_HEIGHT, &height);
            SetCtrlVal (acqG.p.setup, ACQSETUP_EXPTITLE, "source control experiment");
            break;
    }

    GetCtrlAttribute (acqG.p.setup, ACQSETUP_BOX_1, ATTR_TOP, &bTop);
    SetCtrlAttribute (acqG.p.setup, ACQSETUP_BOX_1, ATTR_HEIGHT, cTop+height+10-bTop);
    SetPanelAttribute (acqG.p.setup, ATTR_HEIGHT, cTop+height+36);
}
示例#4
0
文件: util.c 项目: gaorlov/DAAS
void utilG_Init (void (*DiscardPanels)(void))
{
    int p, control, top, height, width;
	int grw, chw, asw, acw;
    

    utilG.acq.pt = 0;
    utilG.acq.nPts = 0;
    utilG.acq.status = ACQ_NONE;

    utilG.p = LoadPanel (0, "utilu.uir", BG);
    
    utilG.DiscardPanels = DiscardPanels;

	SetPanelAttribute (utilG.p, ATTR_WINDOW_ZOOM, VAL_MAXIMIZE);
    DisplayPanel (utilG.p);
	
	GetCtrlAttribute(utilG.p, BG_GRAPHS, ATTR_WIDTH, &grw);
	GetCtrlAttribute(utilG.p, BG_CHANNELS, ATTR_WIDTH, &chw);
	GetCtrlAttribute(utilG.p, BG_ACQSETUP, ATTR_WIDTH, &asw);
	GetCtrlAttribute(utilG.p, BG_ACQCHANNELS, ATTR_WIDTH, &acw);
	GetPanelAttribute(utilG.p, ATTR_WIDTH, &width);
	
	SetCtrlAttribute(utilG.p, BG_GRAPHS, ATTR_LEFT,			(3*width/20) - grw);
	SetCtrlAttribute(utilG.p, BG_CHANNELS, ATTR_LEFT, 		(7*width/20) - chw);
	SetCtrlAttribute(utilG.p, BG_ACQSETUP, ATTR_LEFT, 		(9*width/15) - asw);
	SetCtrlAttribute(utilG.p, BG_ACQCHANNELS, ATTR_LEFT, 	(9*width/10) - acw);
	
	initP = LoadPanel (utilG.p, "utilu.uir", INIT);
    
    SetPanelPos (initP, VAL_AUTO_CENTER, VAL_AUTO_CENTER);

    SetCtrlAttribute (initP, INIT_TEXT, ATTR_VISIBLE, FALSE);
    DisplayPanel (initP);

    GetUserEvent (1, &p, &control);
    switch (control) {
        case INIT_CONTROL: utilG.acq.status = ACQ_DONE; break;
        case INIT_ANALYSIS: utilG.acq.status = ACQ_NONE; break;
        case INIT_EXIT:
            utilG_Exit();
            QuitUserInterface(0);
            exit (EXIT_SUCCESS);
            break;
    }
    SetMouseCursor (VAL_HOUR_GLASS_CURSOR);

    SetCtrlAttribute (initP, INIT_TEXT, ATTR_VISIBLE, TRUE);
    SetCtrlAttribute (initP, INIT_TEXT_10, ATTR_VISIBLE, FALSE);
    SetCtrlAttribute (initP, INIT_CONTROL, ATTR_VISIBLE, FALSE);
    SetCtrlAttribute (initP, INIT_ANALYSIS, ATTR_VISIBLE, FALSE);
    SetCtrlAttribute (initP, INIT_EXIT, ATTR_VISIBLE, FALSE);

    GetCtrlAttribute (initP, INIT_TEXT, ATTR_TOP, &top);
    GetCtrlAttribute (initP, INIT_TEXT, ATTR_HEIGHT, &height);
    SetPanelAttribute (initP, ATTR_HEIGHT, top+height+6);
    util_ChangeInitMessage ("DAAS Utilities...");
}
示例#5
0
文件: util.c 项目: gaorlov/DAAS
int util_OpenFile(char *path, int action, int ascii)
{
    int handle;
    unsigned int  nBytes, pos, width;
    long size;
    char info[256];

    if (action == FILE_WRITE) {
        handle = OpenFile (path, FILE_WRITE, 0, ascii);
        if (!ascii) FmtFile (handle, "BINARY\n");
    }
    else {
        handle = OpenFile (path, action, 0, 0);
        nBytes = ReadLine (handle, info, 255);
        if (CompareBytes (info, 0, "BINARY", 0, 6, 0) != 0) {
            CloseFile (handle);
            handle = OpenFile (path, action, 0, 1);
            ascii = TRUE;
        }
    }
	if(handle)
    {
		fileP = LoadPanel (0, "utilu.uir", FILESTAT);

    	

    	if (action == FILE_WRITE) {
        	Fmt (info, "Saving file: %s", path);
        	if (ascii) Fmt (info, "%s[a]< (ASCII file...go for coffee!)");
    	} else {
        	GetFileSize (path, &size);
        	Fmt (info, "Loading file: %s (%i kB)", path, size/1000);
        	if (ascii) Fmt (info, "%s[a]< (ASCII file...take a nap!)");
    	}

    	SetCtrlVal (fileP, FILESTAT_TEXT, info);
    	GetCtrlAttribute (fileP, FILESTAT_TEXT, ATTR_WIDTH, &width);
    	SetPanelAttribute (fileP, ATTR_WIDTH, width+12);
    	SetCtrlAttribute (fileP, FILESTAT_TEXT, ATTR_LEFT, 6);

    	SetPanelPos (fileP, VAL_AUTO_CENTER, VAL_AUTO_CENTER);
    	InstallPopup (fileP);
	}
	else
		handle = 0;
	return handle;
}
/* 辅助函数-将TabPage还原回ChildPanel */
int ConvertTabPageToChildPanel(int panel, int tab, int tabIndex){
    int     childPanel, tabPanel, ctrl;
    char    title[256];
	//Get the tab-page label and handle
    GetTabPageAttribute(panel, tab, tabIndex, ATTR_LABEL_TEXT, title);
    GetPanelHandleFromTabPage(panel, tab, tabIndex, &tabPanel);
    //Create new child panel and set its attributes
    childPanel = createChildPanel(title, tabIndex);
    //Get the first control in the tab-page to convert.
	GetPanelAttribute(tabPanel, ATTR_PANEL_FIRST_CTRL, &ctrl);
	while(ctrl != 0){
		//Duplicate the control to the child panel
        DuplicateCtrl(tabPanel, ctrl, childPanel, 0, 
			VAL_KEEP_SAME_POSITION, VAL_KEEP_SAME_POSITION);
        //Get the next control to duplicate
        GetCtrlAttribute(tabPanel, ctrl, ATTR_NEXT_CTRL, &ctrl);
	}
    return childPanel;
}
示例#7
0
int CVICALLBACK clbMeasureConfigValueChanged (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
	int			iIndex								=	giCurrentItemIndex;
	
	char		szStringValue[LOW_STRING]			=	{0};
	
	long		lValue								=	0;

	int			iStyle								=	0;
	
	int			iTabIndex							=	0;
	
	switch (event)
	{
		case EVENT_COMMIT:

			bSaveChanges = 1;
			
			GetCtrlAttribute ( panel , control , ATTR_CTRL_STYLE, &iStyle );
			
			switch(iStyle)
			{
				case CTRL_STRING_LS:
				case CTRL_STRING:	
					
						GetCtrlVal( panel , control , szStringValue );  
			
						if ( strchr( szStringValue , 'x' ) || strchr( szStringValue , 'X' ))
							sscanf( szStringValue , "%x" , &lValue );
						else
							sscanf( szStringValue , "%d" , &lValue );
			
						break;
						
				default:
					
						GetCtrlVal( panel , control , &lValue ); 
						break;
						
			}
			
			switch (control)
			{
				case MEAS_CONF_NUMBER_OF_POINTS:
				
					gvtListOfCommands[iIndex].iAlalogMeasureNumberOfPoints = lValue; 
					break;
				
				case MEAS_CONF_SIMPLE_RATE:
				
					gvtListOfCommands[iIndex].iAlalogMeasureSimpleRate = lValue; 
					break;
				
				case MEAS_CONF_MEASURE_FUNCTION:
				
					gvtListOfCommands[iIndex].iAlalogMeasureFunction = lValue; 
					break;
				
				default:
					break;
			}
	}
	
	return 0;
}
示例#8
0
int CVICALLBACK clbValueChanged (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
	int			iIndex								=	giCurrentItemIndex;
	
	char		szStringValue[LOW_STRING]			=	{0};
	
	long		lValue								=	0;

	int			iStyle								=	0;
	
	int			iTabIndex							=	0;
	
	switch (event)
	{
		case EVENT_COMMIT:

			bSaveChanges = 1;
			
			GetCtrlAttribute ( panel , control , ATTR_CTRL_STYLE, &iStyle );
			
			switch(iStyle)
			{
				case CTRL_STRING_LS:
				case CTRL_STRING:	
					
						GetCtrlVal( panel , control , szStringValue );  
			
						if ( strchr( szStringValue , 'x' ) || strchr( szStringValue , 'X' ))
							sscanf( szStringValue , "%x" , &lValue );
						else
							sscanf( szStringValue , "%d" , &lValue );
			
						break;
						
				default:
					
						GetCtrlVal( panel , control , &lValue ); 
						break;
						
			}
			
			switch (control)
			{
				case DEFAULT_BIT_DIR_MASK:
				
					gvtListOfCommands[iIndex].BitDirectionMask = lValue; 												  
					break;
			
				//case DEFAULT_SET_TIMEOUT:
				//	   
				//	gvtListOfCommands[iIndex].lfSetTimeout = atof(szStringValue); 											
				//	break;
			
				case DEFAULT_SET_DELAY:
				
					gvtListOfCommands[iIndex].lfSetDelay = atof(szStringValue); 											
					break;
			
				case DEFAULT_VALUE_COUNT:
				
					gvtListOfCommands[iIndex].valueCount = lValue; 														  
					break;
				
				case DEFAULT_DEFAULT_VALUE:
							
					gvtListOfCommands[iIndex].DefValue = lValue; 													  
					break;
			
				case DEFAULT_USE_BITS_MAP:
				
					gvtListOfCommands[iIndex].UseBitsMap = lValue;  															  
					break;
			
				case DEFAULT_PORTS:
								 
					gvtListOfCommands[iIndex].pPortNumbersArray[0] = lValue;   
					gvtListOfCommands[iIndex].iPortsQuantity = 1;
				
					break;
			
				case DEFAULT_PORTS_FEEDBACK:
								 
					gvtListOfCommands[iIndex].pFeedbackPortNumbersArray[0] = lValue;   
					gvtListOfCommands[iIndex].iFeedbackPortsQuantity = 1;
				
					break;	
					
				case DEFAULT_BITS_MAP_FEEDBACK:
				
					gvtListOfCommands[iIndex].FeedbackBitsMap = lValue;  															  
					break;	
				
				case DEFAULT_VALUE_TYPE:
										  
					gvtListOfCommands[iIndex].valueType = lValue; 
					break;
			
				case DEFAULT_INTERFACE_TYPE:
				
					gvtListOfCommands[iIndex].iInterfaceType = lValue; 
					break;
					
				case DEFAULT_VALUE_MODE:
				
					gvtListOfCommands[iIndex].valueMode = lValue; 
					break;	
					
				case DEFAULT_FEEDBACK_MODE:
				
					gvtListOfCommands[iIndex].feedbackMode = lValue; 
					break;
					
				case DEFAULT_FEEDBACK_SWAP:
				
					gvtListOfCommands[iIndex].bFeedbackSwaped = lValue; 
					break;	
					
				case DEFAULT_DATA_SWAP:
				
					gvtListOfCommands[iIndex].bDataSwaped = lValue; 
					break;	
					
				case DEFAULT_STATE_ON_VAL:
					
					gvtListOfCommands[iIndex].StateOnValue = lValue; 
					break;
					
				case DEFAULT_STATE_OFF_VAL:
					
					gvtListOfCommands[iIndex].StateOffValue = lValue; 
					break;	
					
				case DEFAULT_SET_VAL_OFFSET:
					
					gvtListOfCommands[iIndex].SetValueShiftIndex = lValue; 
					break;		
			}
	}
	
	return 0;
}
示例#9
0
int CVICALLBACK clbSpiConfigValueChanged (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
	int			iIndex								=	giCurrentItemIndex;
	
	char		szStringValue[LOW_STRING]			=	{0};
	
	long		lValue								=	0;

	int			iStyle								=	0;
	
	int			iTabIndex							=	0;
	
	switch (event)
	{
		case EVENT_VAL_CHANGED:

			bSaveChanges = 1;
			
			GetCtrlAttribute ( panel , control , ATTR_CTRL_STYLE, &iStyle );
			
			switch(iStyle)
			{
				case CTRL_STRING_LS:
				case CTRL_STRING:	
					
						GetCtrlVal( panel , control , szStringValue );  
			
						if ( strchr( szStringValue , 'x' ) || strchr( szStringValue , 'X' ))
							sscanf( szStringValue , "%x" , &lValue );
						else
							sscanf( szStringValue , "%d" , &lValue );
			
						break;
						
				default:
					
						GetCtrlVal( panel , control , &lValue ); 
						break;
						
			}
			
			switch (control)
			{  
				case SPI_READ_BIT_PORT:
					gvtListOfCommands[iIndex].iSPI_ReadBitPort = lValue;  
					break;
				case SPI_ENABLE_BIT_POLARITY:
					gvtListOfCommands[iIndex].iSPI_EnableBitPolarity = lValue; 
					break;
				case SPI_READ_BIT_INDEX:
					gvtListOfCommands[iIndex].iSPI_ReadBitIndex = lValue; 
					break;
				case SPI_CLOCK_BIT_POLARITY:
					gvtListOfCommands[iIndex].iSPI_ClockBitPolarity = lValue; 
					break;
				case SPI_ENABLE_BIT_INDEX:
					gvtListOfCommands[iIndex].iSPI_EnableBitIndex = lValue;   
					break;
				case SPI_DATA_BIT_INDEX:
					gvtListOfCommands[iIndex].iSPI_DataBitIndex = lValue;
					break;
				case SPI_CLOCK_BIT_INDEX:
					gvtListOfCommands[iIndex].iSPI_ClockBitIndex = lValue;  
					break;
				case SPI_WRITE_BITS_COUNT:
					gvtListOfCommands[iIndex].iSPI_WriteBitsCount = lValue; 
					break;
				case SPI_READ_BITS_COUNT:
					gvtListOfCommands[iIndex].iSPI_ReadBitsCount = lValue; 									          
					break;
				case SPI_CLOCK_BIT_PHASE:
					gvtListOfCommands[iIndex].iSPI_ClockBitPhase = lValue; 									          
					break;
				case SPI_SET_DATA_SHIFT:
					gvtListOfCommands[iIndex].iSetDataShiftIndex = lValue; 
					break;
				case SPI_GET_DATA_SHIFT:
					gvtListOfCommands[iIndex].iGetDataShiftIndex = lValue; 
					break;
			}
				
	}
	
	return 0;
}
示例#10
0
/// HIFN Callback for the SLM pixels panel 
int CVICALLBACK SLMpixels_Callback (int panel, int event, void *callbackData,
		int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_PANEL_SIZE:
		{	
			// get the new panel size
			int xsize, ysize;
			GetPanelAttribute(panel, ATTR_WIDTH,  &xsize);
			GetPanelAttribute(panel, ATTR_HEIGHT, &ysize);
			
			// check if we are not dealing with an event fired after a programmatical resize
			if ((xsize != SLM_getXres()) || (ysize != SLM_getYres()))
			{
			
				// manually check for a maximize event, which sets the y size of the panel to 1061
				// so we use that value to detect a maximization (NOTE: This code is highly specific to 
				// the UCP lab computer and/or the Windows version running on that)
				if (ysize == 1061)
				{
					// yes, apparently we tried to maximize the panel
				
					// however, 1061 is not what we want, so we
					// set the size manually again to the desired SLM resolution
					SetPanelSize (panel, 1080, 1920);
				
					// set the upper left corner to the upper left corner of the screen,
					// and hope we have banned the titlebar
					SetPanelPos(panel, 0, 1920);
				}
			
				// adjust the canvas size accordingly
				SetCtrlAttribute(panel, SLMpixels_SLMcanvas, ATTR_WIDTH,  xsize);
				SetCtrlAttribute(panel, SLMpixels_SLMcanvas, ATTR_HEIGHT, ysize);
			
				// get the size of the simulation canvas
				int SimX, SimY;
				GetCtrlAttribute(pnlSimPanel, SimPanel_CANVAS, ATTR_WIDTH,  &SimX);
				GetCtrlAttribute(pnlSimPanel, SimPanel_CANVAS, ATTR_HEIGHT, &SimY);
				
				// get the subsampling factor
				int subsample;
				GetCtrlVal(TabPage_0, TABPANEL_SubSample, &subsample);

				// all data structures of the SLM need to be resized to acommodate the new 
				// number of pixels, so we just reintialise the SLM in its entirety			
				SLM_initialise(xsize, ysize, SimX, SimY, subsample);
			
				// update the SLM panel and the simulation Panel (if toggled)
				SLM_update(pnlSLMpixels, SLMpixels_SLMcanvas, pnlSimPanel, SimPanel_CANVAS, 1);
			
				// update the displayed information about the SLM 
				UpdateSLMinfo();
			}
				
			break;
		}
	}
	return 0;
}
示例#11
0
文件: ctrl.c 项目: warroommm/xvos2
//callback associated with the controls on a panel that is loaded at run-time
int CVICALLBACK RuntimeCtrlCB (int panelHandle, int control, int event, void *callbackdata, int eventData1, int eventData2)
{
	char childWindowMenu[MAX_STRING_SIZE];
	int isChildPanel;
	int numCtrls;
	int menuBarHandle;
	int menuID;
	int ctrlType;
	char ctrlString[MAX_STRING_SIZE];
	char menuString[MAX_STRING_SIZE];
	CTRLSTRUCT* ctrlArray = callbackdata;
	int releaseID =0;

	switch(event)
	{
		case EVENT_RIGHT_CLICK:
			if(ctrlArray == NULL)
				return 0;

			menuBarHandle = NewMenuBar (0);
			menuID = NewMenu(menuBarHandle,"",-1);

			GetCtrlAttribute(panelHandle,control,ATTR_CTRL_STYLE,&ctrlType);

			GetStyleNameForCtrl(ctrlType, ctrlString);
			sprintf(menuString,"Control Type: %s",ctrlString);

			NewMenuItem(menuBarHandle,menuID,menuString,-1,0,NULL,NULL);

			GetPanelAttribute(panelHandle,ATTR_NUM_CTRLS,&numCtrls);

			strcpy(ctrlString, FindCtrlCBName(ctrlArray,control,numCtrls));

			sprintf(menuString,"Ctrl Callback: %s",strlen(ctrlString)==0?"<null>":ctrlString);

			NewMenuItem(menuBarHandle,menuID,menuString,-1,0,NULL,NULL);

			InsertSeparator(menuBarHandle, menuID, -1);
			GetPanelAttribute (panelHandle, ATTR_PANEL_PARENT, &isChildPanel);

			if(!isChildPanel)
			   sprintf(childWindowMenu,"Confine Window");
			else
			   sprintf(childWindowMenu,"Release Window");

			releaseID = NewMenuItem (menuBarHandle, menuID, childWindowMenu, -1, 0, 0, 0);

			if(releaseID == RunPopupMenu(menuBarHandle,menuID,panelHandle,eventData1,eventData2,0,0,0,0))
			{
			   SetPanelParenthood(panelHandle,isChildPanel);
			}

			DiscardMenu(menuBarHandle,menuID);
			DiscardMenuBar(menuBarHandle);

			//indicate to the panel that this is a control callback
			gbCtrlCB = 1;
 		break;
	}

	return 0;
}
/// HIFN add a control to the list of controls to be operated in Client Mode
void addClientModeControl(int panel, int control, char pattern_recalc, char units[])
{
    // first, we add the control to the list of Client Mode Controls

    // make room for an extra control
    gNumClientControls++;
    gClientControl_Panel    = (int*) realloc(gClientControl_Panel,    gNumClientControls * sizeof(int));
    gClientControl_Control  = (int*) realloc(gClientControl_Control,  gNumClientControls * sizeof(int));
    gClientControl_DataType = (int*) realloc(gClientControl_DataType, gNumClientControls * sizeof(int));
    gClientControl_Values = (void**) realloc(gClientControl_Values,   gNumClientControls * sizeof(void*));
    gClientControl_Updated = (char*) realloc(gClientControl_Updated,  gNumClientControls * sizeof(char));
    gClientControl_RequiresPatternCalculation = (char*) realloc(gClientControl_RequiresPatternCalculation, gNumClientControls * sizeof(char));

    // obtain the control data type
    int datatype;
    GetCtrlAttribute(panel, control, ATTR_DATA_TYPE, &datatype);

    // fill out the data fields
    int index = gNumClientControls - 1;
    gClientControl_Panel   [index] = panel;
    gClientControl_Control [index] = control;
    gClientControl_DataType[index] = datatype;
    gClientControl_Updated [index] = 0;
    gClientControl_RequiresPatternCalculation[index] = pattern_recalc;

    // allocate memory for holding the variable value
    int datasize;
    switch (datatype)
    {
    case VAL_INTEGER:
        datasize = sizeof(int);
        break;

    case VAL_DOUBLE:
    default:
        datasize = sizeof(double);
        break;
    }
    gClientControl_Values[index] = (void*) malloc(1 * datasize);

    // structure for storing the variable information
    ScanController_Struct_VarInfo varinfo= {0};

    // get the control value and range as doubles
    switch (datatype)
    {
    case VAL_INTEGER:
    {
        // get the value, min and max as integers
        int val, min, max;
        GetCtrlVal(panel, control, &val);
        GetCtrlAttribute(panel, control, ATTR_MIN_VALUE, &min);
        GetCtrlAttribute(panel, control, ATTR_MAX_VALUE, &max);

        // store them in the varinfor structure as doubles
        varinfo.initvalue = (double) val;
        varinfo.initmin   = (double) min;
        varinfo.initmax   = (double) max;

        break;
    }
    case VAL_DOUBLE:
    {
        // read out the value, min, and max directly into the varinfo struct
        GetCtrlVal(panel, control, &(varinfo.initvalue));
        GetCtrlAttribute(panel, control, ATTR_MIN_VALUE, &(varinfo.initmin));
        GetCtrlAttribute(panel, control, ATTR_MAX_VALUE, &(varinfo.initmax));

        break;
    }
    }

    // fill the remaining fields of the varinfo struct
    GetCtrlAttribute(panel, control, ATTR_LABEL_TEXT, (varinfo.name));

    for (int k = 0; k < strlen(varinfo.name); k++)
        if (varinfo.name[k] == ' ')
            varinfo.name[k] = '_';

    varinfo.vartype = datatype;
    strcpy(varinfo.unit, units);

    // add the variable to the ScanController
    ScanController_Client_AddVar(varinfo, gClientControl_Values[index], datasize, &gClientControl_Updated[index]);

    // dim the control such that it is no longer editable through the GUI
    SetCtrlAttribute(panel, control, ATTR_DIMMED, 1);
}
示例#13
0
double acqTimerGetInterval(){
    double delay;
    int err = GetCtrlAttribute (acqG.p.setup, ACQSETUP_ACQ_TIMER, ATTR_INTERVAL, &delay);
    return delay;
}
示例#14
0
int CVICALLBACK clbValueChanged (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
	int			iIndex								=	giCurrentItemIndex;
	
	char		szStringValue[LOW_STRING]			=	{0};
	
	long		lValue								=	0;

	int			iStyle								=	0;
	
	int			iTabIndex							=	0,
				iPortIndex							=	0;
	
	char		*pTemp								=	NULL,
				*pNext								=	NULL,
				*pCurrent							=	NULL;
				
	switch (event)
	{
		case EVENT_COMMIT:

			bSaveChanges = 1;
			
			GetCtrlAttribute ( panel , control , ATTR_CTRL_STYLE, &iStyle );
			
			switch(iStyle)
			{
				case CTRL_STRING_LS:
				case CTRL_STRING:	
					
						GetCtrlVal( panel , control , szStringValue );  
			
						if ( strchr( szStringValue , 'x' ) || strchr( szStringValue , 'X' ))
							sscanf( szStringValue , "%x" , &lValue );
						else
							sscanf( szStringValue , "%d" , &lValue );
			
						break;
						
				default:
					
						GetCtrlVal( panel , control , &lValue ); 
						break;
						
			}
			
			switch (control)
			{
				case DEFAULT_BOUD_RATE:
					
					gvtListOfCommands[iIndex].pBaudRateArray[0] = lValue;				     
					break;
			
				case DEFAULT_BIT_DIR_MASK:
				
					gvtListOfCommands[iIndex].BitDirectionMask = lValue; 												  
					break;
			
				case DEFAULT_SET_TIMEOUT:
					   
					gvtListOfCommands[iIndex].lfSetTimeout = atof(szStringValue); 											
					break;
			
				case DEFAULT_SET_DELAY:
				
					gvtListOfCommands[iIndex].lfSetDelay = atof(szStringValue); 											
					break;
			
				case DEFAULT_POWER_UP_LEVEL:
				
					gvtListOfCommands[iIndex].dPowerUpLevel = atof(szStringValue); 											
					break;
			
				case DEFAULT_MIN_VALUE:
					
					gvtListOfCommands[iIndex].lfMinValue = atof(szStringValue); 											
					break;

				case DEFAULT_MAX_VALUE:
					
					gvtListOfCommands[iIndex].lfMaxValue = atof(szStringValue); 											
					break;
					
				case DEFAULT_VALUE_COUNT:
				
					gvtListOfCommands[iIndex].valueCount = lValue; 														  
					break;
				
				case DEFAULT_DEFAULT_VALUE:
							
					gvtListOfCommands[iIndex].DefValue = lValue; 													  
					break;
			
				case DEFAULT_USE_BITS_MAP:
				
					gvtListOfCommands[iIndex].UseBitsMap = lValue;  															  
					break;
			
				case DEFAULT_PORTS:
								 
					if ( strchr( szStringValue , ',' ) == NULL )
					{
						gvtListOfCommands[iIndex].pPortNumbersArray[0] = lValue;   
						gvtListOfCommands[iIndex].iPortsQuantity = 1;
					}
					else
					{
						pNext = szStringValue;
						iPortIndex = 0;
						
						do
						{
							pTemp = strchr( pNext , ',' );
							
							pCurrent = pNext;
							
							if ( pTemp )
							{
								*pTemp = 0;
								pNext = pTemp + 1; 
							}
							else
							{
								pNext = NULL;
							}
							
							gvtListOfCommands[iIndex].pPortNumbersArray[iPortIndex++] = atoi(pCurrent);   
							
						}while( pNext != NULL );
						
						gvtListOfCommands[iIndex].iPortsQuantity = iPortIndex; 
					}
				
					break;
			
				case DEFAULT_PULLING_TYPE:
						   
					gvtListOfCommands[iIndex].bPullingState = lValue; 
					break;
			
				case DEFAULT_DEVICE_NAME:
				
					strcpy( gvtListOfCommands[iIndex].szDeviceName , szStringValue );
					break;
			
				case DEFAULT_VALUE_TYPE:
										  
					gvtListOfCommands[iIndex].valueType = lValue; 
					break;
			
				case DEFAULT_PILLING_STATE:
										
					gvtListOfCommands[iIndex].bPowerUpState = lValue; 							
					break;
				
				case DEFAULT_CONFIG_TYPE:
				
					gvtListOfCommands[iIndex].iConfigType = lValue; 
					break;
				
				case DEFAULT_MEASURE_TYPE:
				
					gvtListOfCommands[iIndex].iMeasureType = lValue; 
					break;
			}
	}
	
	return 0;
}
/// HIFN draws lines marking the spot pattern
void drawSpotLines(int Panel, int Canvas)
{
	// if the current SLM pattern is a spot pattern, we plot a grid
	// indicating the spot positions
	if (SLM_getCurrentPattern() == SLM_BEAMSPLIT_IFTA)
	{
		// get the canvas dimensions
		int CanvasX, CanvasY;
		GetCtrlAttribute(Panel, Canvas, ATTR_WIDTH,  &CanvasX);
		GetCtrlAttribute(Panel, Canvas, ATTR_HEIGHT, &CanvasY);
		
		// retrieve the current settings from the control panel
		int Nx, Ny, sigxoffset, sigyoffset, spotxoffset, spotyoffset, spotxspacing, spotyspacing;
		GetCtrlVal(TabPage_1_2, TABPANEL_5_NumXSpots,    &Nx);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_NumYSpots,    &Ny);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SpotXOffset,  &spotxoffset);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SpotYOffset,  &spotyoffset);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SigXOffset,   &sigxoffset);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SigYOffset,   &sigyoffset);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SpotXSpacing, &spotxspacing);
		GetCtrlVal(TabPage_1_2, TABPANEL_5_SpotYSpacing, &spotyspacing);
		
		// convenience variables for the lattice periods
		double periodx = spotxspacing + 1.0;
		double periody = spotyspacing + 1.0;
		
		// compute the upper left spot coordinates in camera space
		int ulxpos = gOx + gCamMPx * (spotxoffset + sigxoffset + 1);
		int ulypos = gOy + gCamMPy * (spotyoffset + sigyoffset + 1);
		
		// compute the lower right spot coordinates
		int lrxpos = gOx + gCamMPx * ((spotxoffset + sigxoffset + 1) + (Nx - 1) * (periodx));
		int lrypos = gOy + gCamMPy * ((spotyoffset + sigyoffset + 1) + (Ny - 1) * (periody));
		
		// set the pen color
		SetCtrlAttribute(Panel, Canvas, ATTR_PEN_COLOR, 0x00AAAAAA);
		
		// draw a cross at the origin
		int xo = TransformBitmapToCamCanvasX(gOx);
		int yo = TransformBitmapToCamCanvasY(gOy);
		CanvasDrawLine(Panel, Canvas, MakePoint(xo, 0), MakePoint(xo, CanvasY));
		CanvasDrawLine(Panel, Canvas, MakePoint(0, yo), MakePoint(CanvasX, yo));
		
		// draw vertical lines indicating the grid
		for (int k = 0; k <= Nx; k++)
		{
			// get the coordinates of the endpoints of the gridline
			int xc = TransformBitmapToCamCanvasX((int) (ulxpos + gCamMx * SLM_getFocalUnitX() * (-periodx / 2.0 + k * periodx) / (gCamPixelSize * 1e6)));
			int y1 = TransformBitmapToCamCanvasY((int) (ulypos - gCamMy * SLM_getFocalUnitY() * periody * 0.5 / (gCamPixelSize * 1e6)));
			int y2 = TransformBitmapToCamCanvasY((int) (lrypos + gCamMy * SLM_getFocalUnitY() * periody * 0.5 / (gCamPixelSize * 1e6)));

			// draw the line
			CanvasDrawLine(Panel, Canvas, MakePoint(xc, y1), MakePoint(xc, y2));
		}

		// draw horizontal lines indicating the grid
		for (int l = 0; l <= Ny; l++)
		{
			// get the coordinates of the endpoints of the gridline
			int yc = TransformBitmapToCamCanvasY((int) (ulypos + gCamMy * SLM_getFocalUnitY() * (-periody / 2.0 + l * periody) / (gCamPixelSize * 1e6)));
			int x1 = TransformBitmapToCamCanvasX((int) (ulxpos - gCamMx * SLM_getFocalUnitX() * periodx * 0.5 / (gCamPixelSize * 1e6)));
			int x2 = TransformBitmapToCamCanvasX((int) (lrxpos + gCamMx * SLM_getFocalUnitX() * periodx * 0.5 / (gCamPixelSize * 1e6)));

			// draw the line
			CanvasDrawLine(Panel, Canvas, MakePoint(x1, yc), MakePoint(x2, yc));
		}
	}	
}
示例#16
0
/*****************************************************************************
.
. Función C:			PRE_UbicarPanel
. Responsable:			César Armando Cruz Mendoza
. Descripcion: 			Despliega un panel en pantalla considerando las
.						condiciones de la misma como lo es la posicion del
.						panel anterior y si existe el menu desplegado
. Parámetro de entrada:	Ninguno
. Parámetro de salida:	Referencia a la cadena de caracteres con el mensaje
. Fecha de creación:	31 de Marzo de 2014
.
*****************************************************************************/
int PRE_UbicarPanel(int iPanel)
{
	int iBarra=0;
	int iAlto=0;
	int iAncho=0;
	int iExistePanel=0;
	int iLeftPanelExiste=0;
	static int iPanelAnterior=0;
	

	if (iPanel!=0)
	{
		if (iPanelAnterior != 0)
			GetPanelAttribute (iPanelAnterior, ATTR_LEFT, &iLeftPanelExiste);
	
	
		if ((iPanelAnterior != 0) && (iPanelAnterior != iPanel))
		{
			//implementa la animación de salida
			int i=0;
		
			while (i<60)
			{
				SetPanelAttribute(iPanelAnterior, ATTR_LEFT, iLeftPanelExiste-i);
				DelayWithEventProcessing (.001);
				i+=20;
			}
		
			SetPanelAttribute (iPanelAnterior, ATTR_VSCROLL_OFFSET, 0);
			SetPanelAttribute (iPanelAnterior, ATTR_HSCROLL_OFFSET, 0);
		
			HidePanel(iPanelAnterior);
		}
	
	
		GetPanelAttribute(iPanelMenuPrincipal, ATTR_VISIBLE, &iExistePanel);
		if (iExistePanel==1)
			iLeftPanelExiste = ANCHO_MENU;
	
		GetPanelAttribute (iPanelPrincipal, ATTR_HEIGHT, &iAlto);
		GetPanelAttribute (iPanelPrincipal, ATTR_WIDTH, &iAncho);
	
		GetCtrlAttribute(iPanelPrincipal, pPrincipal_SPLITTER, ATTR_TOP, &iBarra);
	
		SetPanelAttribute(iPanel, ATTR_TOP, iBarra+8);
		SetPanelAttribute(iPanel, ATTR_LEFT, iLeftPanelExiste);
		SetPanelAttribute (iPanel, ATTR_TITLEBAR_VISIBLE, 0);
		SetPanelAttribute (iPanel, ATTR_FRAME_STYLE, VAL_HIDDEN_FRAME);
	
		SetPanelAttribute (iPanel, ATTR_HEIGHT, iAlto-120);
		SetPanelAttribute (iPanel, ATTR_WIDTH, iAncho-iLeftPanelExiste);
	
		GetPanelAttribute(iPanel, ATTR_VISIBLE, &iExistePanel);

		if (iExistePanel==0)
		{
			DisplayPanel(iPanel);
			iPanelVisible = iPanel;
		}
	
		iPanelAnterior = iPanel;
	}
	
	return 0;
}
示例#17
0
STD_ERROR	DLLEXPORT	GRAPH_AddLabel( void *Data , double X_Position , double Y_Position , char *szLabelText  , int color , int label_type )
{
	STD_ERROR				StdError						=	{0};

	int					iStart_Y  				=	0,
						iStart_X  				=	0,
						iStop_Y   				=	0,
						iStop_X   				=	0,
						iPointLeft				=	0,
						iPointTop				=	0; 
	
	tsLabelItem			*pCurrentLabel			=	NULL,
						*pReferenceLabel		=	NULL; 
	
	int					derection				=	0,
						temp					=	0;
	
	int					min_digits				=	0,
						min_digits_counts		=	0,
						max_digits				=	0, 
						max_digits_counts		=	0,
						x_offset				=	0;
	
	double				xPosition				=	0.0,
						yPosition				=	0.0;
	
	tsPlotGraphData		*pData					=	NULL;
	
	SetBreakOnLibraryErrors (0);
	
	IF ( (Data == NULL) , "Pointer passed NULL");
	
	pData = (tsPlotGraphData*)Data;
	
	IF (( pData->panel == 0 ) , "No Graph Data Created.");  
	IF (( szLabelText == 0 ) , "Label Text is NULL pointer."); 
	
	xPosition = X_Position;
	yPosition = Y_Position;
	
	pCurrentLabel = &pData->Labels;
		
	if ( pCurrentLabel->controlID )
		do
		{
			if ( pCurrentLabel->pNextLabel == NULL )
			{
				CALLOC_ERR( pCurrentLabel->pNextLabel , 1 , sizeof(tsLabelItem));
				
				pCurrentLabel = pCurrentLabel->pNextLabel;
				break;
			}
			else
			{
				pCurrentLabel = pCurrentLabel->pNextLabel;	
			}
			
		} while(pCurrentLabel);
	
	switch(label_type)
	{
		case 1:
			
			pCurrentLabel->controlID = DuplicateCtrl ( pData->panel , GRAPH_BUIL_RIGHT_LABEL , pData->panel , szLabelText , 0 , 0 );
			
			break;
			
		default:
			
			pCurrentLabel->controlID = DuplicateCtrl ( pData->panel , GRAPH_BUIL_UP_LABEL , pData->panel , szLabelText , 0 , 0 );

			break;
	}
	
	GetCtrlAttribute ( pData->panel , GRAPH_BUIL_UP_LABEL , ATTR_TOP , &iStop_Y );
	GetCtrlAttribute ( pData->panel , GRAPH_BUIL_UP_LABEL , ATTR_LEFT , &iStart_X );
	GetCtrlAttribute ( pData->panel , GRAPH_BUIL_RIGHT_LABEL , ATTR_TOP , &iStart_Y );
	GetCtrlAttribute ( pData->panel , GRAPH_BUIL_RIGHT_LABEL , ATTR_LEFT , &iStop_X );
	
	GetCtrlAttribute ( pData->panel , pData->control , ATTR_POINTS_PER_SCREEN, &temp );
		
	X_Position = ( X_Position - pData->start_x ) / ( pData->stop_x - pData->start_x );
	Y_Position = ( Y_Position - pData->y_axis_min ) / ( pData->y_axis_max - pData->y_axis_min ); 
	
	Y_Position = 1.0 - Y_Position;
	
	min_digits = pData->y_axis_min; 
	min_digits_counts = 0;
	max_digits = pData->y_axis_max; 
	max_digits_counts = 0;
	
	do
	{
		min_digits /= 10;
		min_digits_counts++;
	}while(min_digits);
	do
	{
		max_digits /= 10;
		max_digits_counts++;
	}while(max_digits);

	if (( max_digits_counts > min_digits_counts ) || ( pData->y_axis_min >= 0.0 ))
	{
		max_digits_counts--;
		
		x_offset = max_digits_counts * 6; // 6 digit points
	}
	else
	{
		min_digits_counts--;
		
		x_offset = min_digits_counts * 6; // 6 digit points
		x_offset += 3; // - points
	}
	
	iPointLeft = (( iStop_X - iStart_X ) * X_Position ) + iStart_X + x_offset;
	iPointTop = (( iStop_Y - iStart_Y ) * Y_Position ) + iStart_Y; 
	
	SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_TOP , iPointTop );
	SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LEFT , iPointLeft );
	
	if ( color )
	{
		SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_OFF_COLOR , color );
		SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_BGCOLOR , color );
	}
	
	GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_LEFT , &pCurrentLabel->left );  
	GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_TOP , &pCurrentLabel->top );
	GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_HEIGHT , &pCurrentLabel->bottom );  
	GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_WIDTH , &pCurrentLabel->right );
	
	pCurrentLabel->bottom += pCurrentLabel->top;
	pCurrentLabel->right += pCurrentLabel->left;
	
	pCurrentLabel->X_Position = xPosition; 
	pCurrentLabel->Y_Position = yPosition;
	
	if (szLabelText)
		strcpy(pCurrentLabel->szLabelText , szLabelText);
	
	pCurrentLabel->label_type = label_type;
	
	pReferenceLabel = &pData->Labels;
		
	if ( pReferenceLabel->controlID )
		do
		{
			if ( pCurrentLabel != pReferenceLabel )
			{
				if ( marge_protection( &derection , pCurrentLabel , pReferenceLabel , iStop_X ))
				{
					SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_LEFT , pCurrentLabel->left );  
					SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_TOP , pCurrentLabel->top );
	
					// chack again
					pReferenceLabel = &pData->Labels;
				}
			}
			
			pReferenceLabel = pReferenceLabel->pNextLabel;	
			
		} while(pReferenceLabel);
	
	
	SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_VISIBLE , 1 ); 
	
	ProcessDrawEvents();
	
Error:											   
	
	SetBreakOnLibraryErrors (1);
	
	return StdError;									   
}