Exemplo n.º 1
0
int main (int argc, char *argv[])
{
	if (InitCVIRTE (0, argv, 0) == 0)
		return -1;	/* out of memory */
	if ((panelHandle = LoadPanel (0, "Remotely.uir", PANEL)) < 0)
		return -1;
	if ((configHandle = LoadPanel (0, "Remotely.uir", CONFIG)) < 0)
		return -1;
	if ((itemHandle = LoadPanel (0, "Remotely.uir", FILE_ITEM)) < 0)
		return -1;
	menubarHandle = GetPanelMenuBar (panelHandle); 
	GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, 0, &bbucommonHandle);
	GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, 1, &rrucommonHandle); 
	GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, 2, &customizingHandle); 
	SetActiveTabPage (panelHandle, PANEL_TAB, 0);
	if(Initial(0, 0)<0 || Initial(1, 0)<0 || Initial(2, 0)<0 || Initial(3, 0)<0)
	{
		SetLed("Read file type information from config.ini to UI error,please try again!",0); 
	}
	WriteLog();
	DisplayPanel (panelHandle);
	RunUserInterface ();
																	 
	return 0;
}
/* 辅助函数-将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;
}
Exemplo n.º 3
0
int		UpdateCurrentItem( int panelHandle )
{
	int			iIndex								=	giCurrentItemIndex;
	
	char		szStringValue[LOW_STRING]			=	{0};
	
	int			iPortIndex							=	0,
				iCurrentTabIndex					=	0;
	
	int			tabPanelHandle						=	0;
	
	GetActiveTabPage (panelHandle , PANEL_TAB , &iCurrentTabIndex );
	
	GetPanelHandleFromTabPage ( panelHandle , PANEL_TAB , iCurrentTabIndex, &tabPanelHandle );
	
	SetCtrlVal( panelHandle , PANEL_COMMAND_NAME_STRING , gvtListOfCommands[iIndex].szCommandName );
	
	if (( gvtListOfCommands[iIndex].iConfigType == 1 ) || ( gvtListOfCommands[iIndex].iConfigType == 2 ))
		SetTabPageAttribute ( panelHandle , PANEL_TAB , 2 , ATTR_VISIBLE, 1 );
	else
		SetTabPageAttribute ( panelHandle , PANEL_TAB , 2 , ATTR_VISIBLE, 0 );
	
	if ( gvtListOfCommands[iIndex].iConfigType == 4 ) 
		SetTabPageAttribute ( panelHandle , PANEL_TAB , 1 , ATTR_VISIBLE, 1 );
	else
		SetTabPageAttribute ( panelHandle , PANEL_TAB , 1 , ATTR_VISIBLE, 0 );
	
	switch(iCurrentTabIndex)
	{
		case 0:
				if ( gvtListOfCommands[iIndex].pBaudRateArray[0] )
					sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].pBaudRateArray[0] ); 							     
				else
					strcpy( szStringValue , "-" ); 							     
				
				SetCtrlVal( tabPanelHandle , DEFAULT_BOUD_RATE , szStringValue );
				
				sprintf( szStringValue , "0x%02llX" , gvtListOfCommands[iIndex].BitDirectionMask ); 												  
				SetCtrlVal( tabPanelHandle , DEFAULT_BIT_DIR_MASK , szStringValue ); 
				
				sprintf( szStringValue , "%lf" , gvtListOfCommands[iIndex].lfSetTimeout ); 											
				SetCtrlVal( tabPanelHandle , DEFAULT_SET_TIMEOUT , szStringValue );     											  
				
				sprintf( szStringValue , "%lf" , gvtListOfCommands[iIndex].lfSetDelay ); 
				SetCtrlVal( tabPanelHandle , DEFAULT_SET_DELAY , szStringValue );												  	  
				
				sprintf( szStringValue , "%lf" , gvtListOfCommands[iIndex].dPowerUpLevel ); 													  
				SetCtrlVal( tabPanelHandle , DEFAULT_POWER_UP_LEVEL , szStringValue );  	
													
				if ( gvtListOfCommands[iIndex].lfMaxValue == 0.0 )
					gvtListOfCommands[iIndex].lfMaxValue = 5.0;
				
				sprintf( szStringValue , "%lf" , gvtListOfCommands[iIndex].lfMaxValue ); 													  
				SetCtrlVal( tabPanelHandle , DEFAULT_MAX_VALUE , szStringValue ); 
				
				sprintf( szStringValue , "%lf" , gvtListOfCommands[iIndex].lfMinValue ); 													  
				SetCtrlVal( tabPanelHandle , DEFAULT_MIN_VALUE , szStringValue ); 
																				
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].valueCount ); 														  
				SetCtrlVal( tabPanelHandle , DEFAULT_VALUE_COUNT , szStringValue ); 
				
				sprintf( szStringValue , "0x%02llX" , gvtListOfCommands[iIndex].DefValue ); 													  
				SetCtrlVal( tabPanelHandle , DEFAULT_DEFAULT_VALUE , szStringValue );  
				
				sprintf( szStringValue , "0x%02llX" , gvtListOfCommands[iIndex].UseBitsMap ); 															  
				SetCtrlVal( tabPanelHandle , DEFAULT_USE_BITS_MAP , szStringValue );												  
						
				if ( gvtListOfCommands[iIndex].iPortsQuantity == 0)
					gvtListOfCommands[iIndex].iPortsQuantity = 1;
				
				memset( szStringValue , 0 , LOW_STRING );
				
				for ( iPortIndex = 0; iPortIndex < gvtListOfCommands[iIndex].iPortsQuantity; iPortIndex++ )
				{
					if ( iPortIndex > 0 )
						strcat( szStringValue , "," );
					
					sprintf( szStringValue + strlen(szStringValue) , "%d" , gvtListOfCommands[iIndex].pPortNumbersArray[iPortIndex] ); 															  
				}
				
				SetCtrlVal( tabPanelHandle , DEFAULT_PORTS , szStringValue );
				
				SetCtrlVal( tabPanelHandle , DEFAULT_PULLING_TYPE , gvtListOfCommands[iIndex].bPullingState );
				
				SetCtrlVal( tabPanelHandle , DEFAULT_DEVICE_NAME , gvtListOfCommands[iIndex].szDeviceName );
				
				SetCtrlVal( tabPanelHandle , DEFAULT_VALUE_TYPE , gvtListOfCommands[iIndex].valueType );
				
				SetCtrlVal( tabPanelHandle , DEFAULT_PILLING_STATE , gvtListOfCommands[iIndex].bPowerUpState );
	
				if ( gvtListOfCommands[iIndex].iConfigType )
					SetCtrlVal( tabPanelHandle , DEFAULT_CONFIG_TYPE , gvtListOfCommands[iIndex].iConfigType );
				else
					SetCtrlIndex( tabPanelHandle , DEFAULT_CONFIG_TYPE , 0 );
					
				if ( gvtListOfCommands[iIndex].iMeasureType )
					SetCtrlVal( tabPanelHandle , DEFAULT_MEASURE_TYPE , gvtListOfCommands[iIndex].iMeasureType );
				else
					SetCtrlIndex( tabPanelHandle , DEFAULT_MEASURE_TYPE , 0 );
				
				break; 
				
		case 1:
				break;
				
		case 2:
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].iAlalogMeasureNumberOfPoints  ); 
				SetCtrlVal( tabPanelHandle , MEAS_CONF_NUMBER_OF_POINTS , szStringValue );
				
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].iAlalogMeasureSimpleRate ); 
				SetCtrlVal( tabPanelHandle , MEAS_CONF_SIMPLE_RATE , szStringValue );
				
				SetCtrlVal( tabPanelHandle , MEAS_CONF_MEASURE_FUNCTION , gvtListOfCommands[iIndex].iAlalogMeasureFunction );
				
				break;
		
		default: 
				break;
	}
	
	return 0;
}
Exemplo n.º 4
0
int		UpdateCurrentItem( int panelHandle )
{
	int			iIndex								=	giCurrentItemIndex;
	
	char		szStringValue[LOW_STRING]			=	{0};
	
	int			iCurrentTabIndex					=	0;
	
	int			tabPanelHandle						=	0;
	
	GetActiveTabPage (panelHandle , PANEL_TAB , &iCurrentTabIndex );
	
	GetPanelHandleFromTabPage ( panelHandle , PANEL_TAB , iCurrentTabIndex, &tabPanelHandle );
	
	SetCtrlVal( panelHandle , PANEL_COMMAND_NAME_STRING , gvtListOfCommands[iIndex].szCommandName );
	
	if ( gvtListOfCommands[iIndex].iInterfaceType == 1 ) 
		SetTabPageAttribute ( panelHandle , PANEL_TAB , 1 , ATTR_VISIBLE, 1 );
	else
		SetTabPageAttribute ( panelHandle , PANEL_TAB , 1 , ATTR_VISIBLE, 0 );
	
	if ( gvtListOfCommands[iIndex].valueMode == VALUE_MODE_ON_OFF ) // On Off 
	{
		SetCtrlAttribute( tabPanelHandle , DEFAULT_STATE_ON_VAL , ATTR_DIMMED , 0 );
		SetCtrlAttribute( tabPanelHandle , DEFAULT_STATE_OFF_VAL , ATTR_DIMMED , 0 );
	}
	else
	{
		SetCtrlAttribute( tabPanelHandle , DEFAULT_STATE_ON_VAL , ATTR_DIMMED , 1 );
		SetCtrlAttribute( tabPanelHandle , DEFAULT_STATE_OFF_VAL , ATTR_DIMMED , 1 );
	}
	
	switch(iCurrentTabIndex)
	{
		case 0:
				sprintf( szStringValue , "0x%02llX" , gvtListOfCommands[iIndex].BitDirectionMask ); 												  
				SetCtrlVal( tabPanelHandle , DEFAULT_BIT_DIR_MASK , szStringValue ); 
				
				//sprintf( szStringValue , "%lf" , gvtListOfCommands[iIndex].lfSetTimeout ); 											
				//SetCtrlVal( tabPanelHandle , DEFAULT_SET_TIMEOUT , szStringValue );     											  
				
				sprintf( szStringValue , "%lf" , gvtListOfCommands[iIndex].lfSetDelay ); 
				SetCtrlVal( tabPanelHandle , DEFAULT_SET_DELAY , szStringValue );												  	  
				
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].valueCount ); 														  
				SetCtrlVal( tabPanelHandle , DEFAULT_VALUE_COUNT , szStringValue ); 
				
				sprintf( szStringValue , "0x%02llX" , gvtListOfCommands[iIndex].DefValue ); 													  
				SetCtrlVal( tabPanelHandle , DEFAULT_DEFAULT_VALUE , szStringValue );  
				
				sprintf( szStringValue , "0x%02llX" , gvtListOfCommands[iIndex].UseBitsMap ); 															  
				SetCtrlVal( tabPanelHandle , DEFAULT_USE_BITS_MAP , szStringValue );												  
						
				if ( gvtListOfCommands[iIndex].iPortsQuantity == 0)
					gvtListOfCommands[iIndex].iPortsQuantity = 1;
				
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].pPortNumbersArray[0] ); 															  
				SetCtrlVal( tabPanelHandle , DEFAULT_PORTS , szStringValue );
				
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].pFeedbackPortNumbersArray[0] ); 															  
				SetCtrlVal( tabPanelHandle , DEFAULT_PORTS_FEEDBACK , szStringValue );
				
				sprintf( szStringValue , "0x%02llX" , gvtListOfCommands[iIndex].FeedbackBitsMap ); 															  
				SetCtrlVal( tabPanelHandle , DEFAULT_BITS_MAP_FEEDBACK , szStringValue );		   
				
				SetCtrlVal( tabPanelHandle , DEFAULT_VALUE_TYPE , gvtListOfCommands[iIndex].valueType );
				
				SetCtrlVal( tabPanelHandle , DEFAULT_VALUE_MODE , gvtListOfCommands[iIndex].valueMode ); 
				
				SetCtrlVal( tabPanelHandle , DEFAULT_FEEDBACK_MODE , gvtListOfCommands[iIndex].feedbackMode ); 
				
				SetCtrlVal( tabPanelHandle , DEFAULT_FEEDBACK_SWAP , gvtListOfCommands[iIndex].bFeedbackSwaped );   
				
				SetCtrlVal( tabPanelHandle , DEFAULT_DATA_SWAP , gvtListOfCommands[iIndex].bDataSwaped ); 
				
				if ( gvtListOfCommands[iIndex].valueMode == VALUE_MODE_ON_OFF ) 
				{
					sprintf( szStringValue , "0x%02llX" , gvtListOfCommands[iIndex].StateOnValue ); 
					SetCtrlVal( tabPanelHandle , DEFAULT_STATE_ON_VAL , szStringValue );
					
					sprintf( szStringValue , "0x%02llX" , gvtListOfCommands[iIndex].StateOffValue );  
					SetCtrlVal( tabPanelHandle , DEFAULT_STATE_OFF_VAL , szStringValue ); 
				}
				
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].SetValueShiftIndex ); 															  
				SetCtrlVal( tabPanelHandle , DEFAULT_SET_VAL_OFFSET , szStringValue );
				
				break; 
				
		case 1:
				SetCtrlVal( tabPanelHandle , SPI_READ_BIT_PORT , gvtListOfCommands[iIndex].iSPI_ReadBitPort );                               
				SetCtrlVal( tabPanelHandle , SPI_ENABLE_BIT_POLARITY , gvtListOfCommands[iIndex].iSPI_EnableBitPolarity ); 								           
				SetCtrlVal( tabPanelHandle , SPI_READ_BIT_INDEX , gvtListOfCommands[iIndex].iSPI_ReadBitIndex );      								           
				SetCtrlVal( tabPanelHandle , SPI_CLOCK_BIT_POLARITY , gvtListOfCommands[iIndex].iSPI_ClockBitPolarity );  								           
				SetCtrlVal( tabPanelHandle , SPI_ENABLE_BIT_INDEX , gvtListOfCommands[iIndex].iSPI_EnableBitIndex );    								           
				SetCtrlVal( tabPanelHandle , SPI_DATA_BIT_INDEX , gvtListOfCommands[iIndex].iSPI_DataBitIndex );      								           
				SetCtrlVal( tabPanelHandle , SPI_CLOCK_BIT_INDEX , gvtListOfCommands[iIndex].iSPI_ClockBitIndex );  
				SetCtrlVal( tabPanelHandle , SPI_CLOCK_BIT_PHASE , gvtListOfCommands[iIndex].iSPI_ClockBitPhase );  
					
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].iSPI_WriteBitsCount ); 															  
				SetCtrlVal( tabPanelHandle , SPI_WRITE_BITS_COUNT , szStringValue );
				
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].iSPI_ReadBitsCount ); 															  
				SetCtrlVal( tabPanelHandle , SPI_READ_BITS_COUNT , szStringValue );
				
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].iSetDataShiftIndex ); 
				SetCtrlVal( tabPanelHandle , SPI_SET_DATA_SHIFT , szStringValue );
				
				sprintf( szStringValue , "%d" , gvtListOfCommands[iIndex].iGetDataShiftIndex ); 
				SetCtrlVal( tabPanelHandle , SPI_GET_DATA_SHIFT , szStringValue );
				
				break;
		
		default: 
				break;
	}
	
	return 0;
}
/* 菜单栏-Switch View Mode-切换视图 */
void CVICALLBACK switchViewMode(int menuBar, int menuItem, void *callbackData,
		int panel){
	if(CPanels[0] <=0 && TPanels[0]<=0) return;
	int tempReceiveFlag = receiveFlag;
	pauseDataAcq();
	if(tabFlag == 0){ //Child-Panel => Tab-Pages
		//创建Tab
		if(tabCtrl <=0){
			tabWidth = pWidth-extraRight-averSpaceH;
			tabHeight = pHeight - averSpaceV*2 + 12;
			tabCtrl = NewCtrl(panelHdl, CTRL_TABS, "", mHeight + 5, averSpaceH);
	        SetCtrlAttribute(panelHdl, tabCtrl, ATTR_WIDTH, tabWidth);
	        SetCtrlAttribute(panelHdl, tabCtrl, ATTR_HEIGHT, tabHeight);
		}
		for(int i=0; i<validMonNum; i++){
			InsertPanelAsTabPage(panelHdl, tabCtrl, -1, CPanels[i]);
		}
		for(int i=0; i<validMonNum; i++){
			GetPanelHandleFromTabPage(panelHdl, tabCtrl, i, &TPanels[i]);
			SetCtrlAttribute(TPanels[i], PGraphs[i], ATTR_WIDTH, tabWidth-3);
			SetCtrlAttribute(TPanels[i], PGraphs[i], ATTR_HEIGHT, tabHeight-15);
			SetAxisScalingMode(TPanels[i], PGraphs[i], VAL_LEFT_YAXIS, graphScaleMode, yAxisRange[0], yAxisRange[1]);
			SetCtrlAttribute(TPanels[i], PGraphs[i], ATTR_YFORMAT,VAL_FLOATING_PT_FORMAT);
			SetCtrlAttribute (TPanels[i], PGraphs[i], ATTR_POINTS_PER_SCREEN, 40);
		}
		tabFlag = 1;
		for(int i=0; i<validMonNum; i++){
			DiscardPanel(CPanels[i]);
			CPanels[i] = 0;
		}
	}else{ //Tab-Pages => Child-Panel
		for(int i=0; i<validMonNum; i++){
			CPanels[i] = ConvertTabPageToChildPanel(panelHdl, tabCtrl, i);
			SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_WIDTH, cWidth);
			SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_HEIGHT, cHeight);
		}
		for(int i=0; i<validMonNum; i++){
			if(PGraphs[i]>0){
				SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_WIDTH, cWidth);
				SetCtrlAttribute(CPanels[i], PGraphs[i], ATTR_WIDTH, cWidth);
				SetCtrlAttribute (CPanels[i], PGraphs[i], ATTR_POINTS_PER_SCREEN, 24);
			}
		}
		tabFlag = 0;
		for(int i=0; i<validMonNum; i++){
			DisplayPanel(CPanels[i]);
			TPanels[i] = 0;
		}
		DiscardCtrl(panelHdl, tabCtrl);
		tabCtrl = 0;
	}//else
	receiveFlag = tempReceiveFlag;
	if(receiveFlag == 0){
		if(tabFlag == 0){
			for(int i=0; i<validMonNum; i++)
				PlotStripChart(CPanels[i], PGraphs[i], resultData[i], READ_LENGTH/24, 0, 0, VAL_DOUBLE);
		}else{
			PlotStripChart(TPanels[0], PGraphs[0], resultData[0], READ_LENGTH/24, 0, 0, VAL_DOUBLE);
		}
	}else{
		startDataAcq();
	}
}