Esempio n. 1
0
int CVICALLBACK GetRruLog (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			  int status; char cmd[100];
			 if (ConfirmPopup ("Get RRUlog","Do you want to Get RRUlog now?")) 
			 {
				memset(cmd,0,100);
				strcpy(cmd,"RemoteAction.exe -d:rrulog");
				DimAction(1); 
				status = ExecutableProcess(cmd,"@action done@");
				if (status)
				{
				  SetLed("Action finished!",1);
				}
				else
				{
				  SetLed("Action failed,please check detail info",0); 
				}
				DimAction(0);
			 }
			break;
	}
	return 0;
}
Esempio n. 2
0
int CVICALLBACK EnablePort (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			 int status; char cmd[100];
			 if (ConfirmPopup ("Enable Port","Do you want to enable SSH and RD port now?")) 
			 {
				memset(cmd,0,100);
				strcpy(cmd,"enableport.exe -e:all");
				DimAction(1); 
				status = ExecutableProcess(cmd,"@action done@");
				if (status)
				{
				  SetLed("Action finished!",1);
				}
				else
				{
				  SetLed("Action failed,please check detail info",0); 
				}
				DimAction(0);
			 }
			break;
	}
	return 0;
}
Esempio n. 3
0
File: util.c Progetto: gaorlov/DAAS
int  BGDoneCallback(int panel, int event, void *callbackData, int eventData1, int eventData2)
{
    if (event == EVENT_CLOSE)
        if (ConfirmPopup ("Exit DAAS?", "Are you so sure you want to exit DAAS?"))
        {
            //utilG.DiscardPanels();
            QuitUserInterface(0);   /* user selected "Exit" from the menu */
            exit(0);
        }
    return 0;
}
Esempio n. 4
0
int CVICALLBACK SearchFile (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			 int status; char cmd[100]; char *info = "";   char *buffer = "";   char *folder = "";   
			
			 info = GetItemInfo(3);
			 buffer=(char*)malloc(1000);
	 		 memset(buffer,0,1000);
			 sprintf(buffer,"Do you want to search files: (%s) now?",info);
			 if (ConfirmPopup ("Search File",buffer)) 
			 {
				 memset(cmd,0,100);
				 strcpy(cmd,"RemoteAction.exe -c:search");
				 DimAction(1); 
				 status = ExecutableProcess(cmd,"@action done@");
				 if (status)
				 {
					SetLed("Search files is finished!",1);
					memset(cmd,0,100);
					strcpy(cmd,"filter.exe -a:search");
					DimAction(1); 
					status = ExecutableProcess(cmd,"@action done@");
					if (status)
					{
						 SetLed("Analyze searched files information finished!",1);
					}
					else
					{
						SetLed("Analyze searched files information failed,please check detail info",0);  
					}
					DimAction(0);
			
				}
				else
				{
 				    memset(buffer,0,1000); 
				    sprintf(buffer,"Search files: (%s) failed,pls check detail info!",info); 	
				    SetLed(buffer,0); 
				}
				DimAction(0);
			 }
			 free(buffer);
			break;
	}
	return 0;
}
Esempio n. 5
0
int		OpenConfigurationFile( char *pszFilePath )
{
	int			iIndex								=	0;

	int			hFileHandle							=	0;
	
	int			iCount								=	0;
	
	int			bForceChanges						=	0;
	
	if ( FileExists( pszFilePath , NULL ))
		if ( strstr( pszFilePath , ".icscnf" ))
		{
			strcpy( szCurrentFilePath , pszFilePath );
			
			hFileHandle = OpenFile (pszFilePath, VAL_READ_ONLY, VAL_TRUNCATE, VAL_BINARY);

			memset( gvtListOfCommands , 0 , sizeof(gvtListOfCommands));

			for ( iIndex = 0 ; iIndex < MAX_LIST_NUMBER; iIndex++ )
			{
				iCount = ReadFile ( hFileHandle , gvtListOfCommands[iIndex].max_size , sizeof(tsSTD_CommandItem) );
			
				if ( iCount != sizeof(tsSTD_CommandItem) )
					break;
				
				if ( gvtListOfCommands[iIndex].ulSignatureID != 0 ) 
					if ( gvtListOfCommands[iIndex].ulSignatureID != DEVICE_ID )
					{
						if ( bForceChanges == 0 )
						{
							if ( ConfirmPopup("Open file error." , "Wrong file format.\nAre you sure you want to adapt format?" ))
								bForceChanges = 1;
							else
								break;
						}
					}
				
			}
		
			giNumberOfItems = iIndex;
		
			giCurrentItemIndex = 0; 
		
			CloseFile (hFileHandle);
		}
	
	return iIndex;
}
Esempio n. 6
0
void		SaveFileAs( int bAskUser , int bAskForSaveChanges )
{
	char		szFilePath[STD_STRING]				=	{0},
				szPath[STD_STRING]					=	{0},
				szFileName[LOW_STRING]				=	{0};

	char		*pTemp								=	NULL;
	
	int			hFileHandle							=	0;
	
	int			iIndex								=	0;
	
	if ( bSaveChanges && (( bAskUser == 0 ) || ( bAskForSaveChanges == 0 ) || ConfirmPopup ("Save Changes", "Do you want to save last changes?")))
	{
		strcpy( szFilePath , szCurrentFilePath );
		strcpy( szPath , szCurrentFilePath );    
	
		pTemp = strrchr( szPath , '\\' );
	
		if ( pTemp )
		{
			*pTemp++ = 0;

			strcpy( szFileName , pTemp );
		}
	
		if (( bAskUser == 0 ) || ( FileSelectPopup (szPath, szFileName , "*.daqcnf", "Save", VAL_SAVE_BUTTON, 0, 1, 1, 1, szFilePath )))
		{
			hFileHandle = OpenFile (szFilePath, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_BINARY);

			for ( iIndex = 0 ; iIndex < giNumberOfItems; iIndex++ )
			{
				gvtListOfCommands[iIndex].ulSignatureID = DEVICE_ID;

				WriteFile ( hFileHandle , gvtListOfCommands[iIndex].max_size , sizeof(tsSTD_Extended_CommandItem) );
			}
	
			CloseFile (hFileHandle);
			
			bSaveChanges = 0;
		}
	}
	
	return;
}
Esempio n. 7
0
int CVICALLBACK RecordUptime (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			 int status; char cmd[100];
			 if (ConfirmPopup ("Record uptime","Do you want to record uptime now?")) 
			 {
				memset(cmd,0,100);
				strcpy(cmd,"RemoteAction.exe -c:uptime");
				DimAction(1); 
				status = ExecutableProcess(cmd,"@action done@");
				if (status)
				{
				    SetLed("Get uptime information finished!",1);
					memset(cmd,0,100);
					strcpy(cmd,"uptimerecord.exe");
					DimAction(1); 
					status = ExecutableProcess(cmd,"@action done@");
					if (status)
					{
						 SetLed("Record uptime information finished!",1);
					}
					else
					{
						SetLed("Record uptime inforamtion failed,please check detail info",0);  
					}
					DimAction(0);
				}
				else
				{
				   SetLed("Get uptime inforamtion failed,please check detail info",0); 
				}
				DimAction(0);
			 }
			break;
	}
	return 0;
}
Esempio n. 8
0
int CVICALLBACK FetchLogs (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			 int status; char cmd[100];  char *buffer=""; char *info = ""; char *folder="";
	 
			 info = GetItemInfo(2); 
			 buffer=(char*)malloc(100);
			 memset(buffer,0,100);
			 sprintf(buffer,"Do you want to fetch filter logs: (%s) now?",info);
			 
			 if (ConfirmPopup ("Fetch Filter Logs",buffer)) 
			 {
				memset(cmd,0,100);
				strcpy(cmd,"RemoteAction.exe -d:filter");
				DimAction(1); 
				status = ExecutableProcess(cmd,"@action done@");
				if (status)
				{   
					memset(buffer,0,100);
					folder= readfoldername();
					sprintf(buffer,"Fetch filter logs: (%s) finished! folder is:%s",info,folder);  
				    SetLed(buffer,1);
				}
				else
				{
				   memset(buffer,0,100); 
				   sprintf(buffer,"Fetch filter logs: (%s) failed,pls check detail info!",info); 	
				   SetLed(buffer,0);
				}
				DimAction(0);
			 }
			 free(buffer);
			break;
	}
	return 0;
}
Esempio n. 9
0
int CVICALLBACK CheckSFP (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			 int status; char cmd[100];  char *buffer=""; char *info = "";
	 
			 info = GetItemInfo(1); 
			 buffer=(char*)malloc(100);
			 memset(buffer,0,100);
			 sprintf(buffer,"Do you want to analyze logs: (%s) now?",info);
			 
			 if (ConfirmPopup ("Analyze Logs",buffer)) 
			 {
				memset(cmd,0,100);
				strcpy(cmd,"filter.exe -a:sysinfo");
				DimAction(1); 
				status = ExecutableProcess(cmd,"@action done@");
				if (status)
				{   
					memset(buffer,0,100);
					sprintf(buffer,"Analyze logs: (%s) finished!",info);  
				    SetLed(buffer,1);
				}
				else
				{
				   memset(buffer,0,100); 
				   sprintf(buffer,"Analyze logs: (%s) failed,pls check detail info!",info); 	
				   SetLed(buffer,0);
				}
				DimAction(0);
			 }
			 free(buffer);
			break;
	}
	return 0;
}
Esempio n. 10
0
int CVICALLBACK UpdateAllPut (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			 int status; char cmd[100];  char *info = "";  char *buffer = "";
			 
			 info = GetItemInfo(1);		// get file item selection
			 buffer=(char*)malloc(100);
	 		 memset(buffer,0,100);
			 sprintf(buffer,"Do you want to Update-Put files: (%s) now?",info);
		
			 if (ConfirmPopup ("Update-Put All Files",buffer)) 
			 {
				memset(cmd,0,100);
				strcpy(cmd,"RemoteAction.exe -u:allupdate");
				DimAction(1); 
				status = ExecutableProcess(cmd,"@action done@");
				if (status)
				{
					memset(buffer,0,100);
					sprintf(buffer,"Update-Put files: (%s) finished!",info);  
				    SetLed(buffer,1);
				}
				else
				{
					memset(buffer,0,100); 
				    sprintf(buffer,"Update-Put files: (%s) failed,pls check detail info!",info); 	
				    SetLed(buffer,0);
				}
				DimAction(0);
			 }
			 free(buffer);
			break;
	}
	return 0;
}
Esempio n. 11
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;
}
Esempio n. 12
0
int CVICALLBACK CheckUptime (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			 char buffer[20000]; char pathName[MAX_PATHNAME_LEN];		char dirName[MAX_PATHNAME_LEN];   FILE    *hFile;	  char *p = ""; int i=0; int lenth=0; char temp[20]; //char value[50];
			 int flag =0;		 int row = 0; int column = 0; int insertcolumn = 0;  int confirmresult = 0;	 
	 
			 typedef struct
				{ 
					int x;
					int y; 
				} Point;

			 confirmresult = ConfirmPopup ("Check uptime","Do you want to check uptime now?");
		 
			 if ((outputHandle = LoadPanel (0, "Remotely.uir", OUTPUTVIEW)) < 0)
				 {
				 SetCtrlVal (panelHandle, PANEL_TEXTBOX,  "Load check uptime panel error,please try again!\r\n"); 
			 	 return -1;
				 }
			 SetPanelAttribute (outputHandle, ATTR_TITLE, "CheckUptimeRecord");
			 SetCtrlAttribute (outputHandle, OUTPUTVIEW_OUTPUTBOX, ATTR_VISIBLE, 0);
			 SetCtrlAttribute (outputHandle, OUTPUTVIEW_TABLE, ATTR_VISIBLE, 1);    
			 GetProjectDir (dirName); 
			 MakePathname (dirName, "uptime.csv", pathName);
			 WriteLog();
		   	 ResetTextBox (panelHandle, PANEL_TEXTBOX, ""); 
		 
			 if (hFile = fopen(pathName, "r"))
			{
		    	while (fgets(buffer, (int)sizeof(buffer), hFile))
		    	{
					row++;
					InsertTableRows (outputHandle, OUTPUTVIEW_TABLE, -1, 1, VAL_CELL_STRING);
			
					column = 0;
					p = buffer;
					flag = 0;
					do
					{
						column++;
						if (insertcolumn == 0)
						{
							InsertTableColumns (outputHandle, OUTPUTVIEW_TABLE, -1, 1, VAL_CELL_STRING);
						}
						lenth = FindPattern (p, 0, -1, ",", 0, 0);   // strip  ","
						if (lenth >=0)
						{
							memset(temp,0,20);
							for (i=0;i<lenth;i++)
							{
								temp[i] = *p;
								p++;
							}
							p++;
							SetTableCellVal (outputHandle, OUTPUTVIEW_TABLE, MakePoint(column, row), temp);
						}
						else
						{

							lenth = FindPattern (p, 0, -1, "\n", 0, 0);	  // strip  "\n"
							if (lenth >=0)								 // if find "\n"  write last string to last column
							{
							    memset(temp,0,20);
								for (i=0;i<lenth;i++)
								{
									temp[i] = *p;
									p++;
								}
								SetTableCellVal (outputHandle, OUTPUTVIEW_TABLE, MakePoint(column, row), temp);
								flag = -1;
								insertcolumn = 1;
							}
							else		// if not find "\n", write all to last column
							{
								SetTableCellVal (outputHandle, OUTPUTVIEW_TABLE, MakePoint(column, row), p);
								flag = -1;
								insertcolumn = 1;
							}
		
						}
				
					}while( flag != -1);
					SetTableColumnAttribute (outputHandle, OUTPUTVIEW_TABLE, -1, ATTR_COLUMN_WIDTH, 80);
					memset(buffer,0,20000);
												 
		    	}
		    	fclose(hFile);
			} 
			if (confirmresult)    // if user select yes to check uptime  install popup
			 {
				InstallPopup(outputHandle);
			 }
			else				 // if user select no, discard panel due to load it at beginning of this function
			{
				if (outputHandle)
				    {
		               DiscardPanel (outputHandle);
			        }
			}
			break;
	}
	return 0;
}
Esempio n. 13
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;
}
Esempio n. 14
0
//---------------------------------------------------------
// работа с ЦАП
//---------------------------------------------------------
int DacPanel(void)
{
	int Pnl;
	int i, j, key, hnd, cnt;
   static int SignalType=0;
	char *UirName="demo.uir";
	char *SignalTypeName[]=
   			{
            	{"Постоянный"},
					{"Синус"},
					{"Меандр"},
					{"Пила"},
					{"Треугольный"}
				};

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

	InitDac(Pnl);

	// покажем название платы в заголовке панели
	ShowNameInTitle(Pnl);

	SetCtrlVal(Pnl, P(BOX), "В данном примере программа по клавише 'СТАРТ ЦАП' \nзапускает ЦАП с заданными параметрами.");
	SetCtrlVal(Pnl, P(DAC_NUMBER), DAC_Number);
	SetCtrlVal(Pnl, P(DAC_RATE), DAC_Rate);
	SetCtrlVal(Pnl, P(SIGNAL_TYPE), SignalType);
	SetCtrlVal(Pnl, P(AMPLITUDE), Amplitude);
	{
		double FREQ=DAC_Rate/(double)DacFifoLength;
		if(Frequency/FREQ < 0.5)
			Frequency=FREQ;
		else
			Frequency=FREQ*(int)((Frequency/FREQ)+0.5);
	}
	SetCtrlVal(Pnl, P(FREQUENCY), Frequency);

	// Отобразим панель на экpане дисплея
	DisplayPanel(Pnl);

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

		GetUserEvent(0, &hnd, &cnt);

  		// Выбpан пункт меню
  		if(hnd==Bar)
		{
			if(cnt!=-1)
			{
				switch(cnt)
				{
					case B(ADC):
					{
						int result=AdcParamPanel();
						if(result == DISK_PANEL)
						{
							UnloadPanel(Pnl);
							return DISK_PANEL;
						}
						else if(result == INPUT_PANEL)
						{
							UnloadPanel(Pnl);
							return INPUT_PANEL;
						}
						break;
					}

					case B(DAC):
						break;

      			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(START):
            {
               char str[200];

				   // запретим работу ЦАП
					if(!ENABLE_DAC_STREAM_PLX(&bi[0], 0))
				   {
						SetCtrlVal(Pnl, P(BOX), " Не выполнена функция ENABLE_DAC_STREAM_PLX()!");
						SetMenuBarAttribute(B(DAC), ATTR_MENU_BAR_ENABLED, DISABLE);
						SetCtrlAttribute(Pnl, P(START), ATTR_CTRL_ENABLED, DISABLE);
						break;
				   }
					// сформируем данные для буфера ЦАП
					MakeDacBuffer(SignalType);
					// положим сформированные данные в память программ DSP в буфер ЦАП
					PUT_PM_ARRAY_PLX(&bi[0], DacFifoBaseAddress, 2*DacFifoLength, Buffer);
					// разрешим работу ЦАП
					if(!ENABLE_DAC_STREAM_PLX(&bi[0], 1))
					{
						SetCtrlVal(Pnl, P(BOX), " Не выполнена функция ENABLE_DAC_STREAM_PLX()!");
						SetMenuBarAttribute(B(DAC), ATTR_MENU_BAR_ENABLED, DISABLE);
						SetCtrlAttribute(Pnl, P(START), ATTR_CTRL_ENABLED, DISABLE);
						break;
					}
					DefaultCtrl(Pnl, P(BOX));
					sprintf(str,  " Осуществлен запуск ЦАП.\n Сейчас ны выходном разъеме должен наблюдаться\n следующий тип сигнала - '%s'.", SignalTypeName[SignalType]);
					SetCtrlVal(Pnl, P(BOX), str);
					break;
				}

				case P(DAC_NUMBER):
				{
					char str[100];

					GetCtrlVal(Pnl, P(DAC_NUMBER), &DAC_Number);
               sprintf(str, " Выбран ЦАП номер %1u.", DAC_Number+1);
					SetCtrlVal(Pnl, P(BOX), str);
					break;
            }

				case P(DAC_RATE):
            {
               char str[100];

					GetCtrlVal(Pnl, P(DAC_RATE), &DAC_Rate);
					SET_DAC_RATE_PLX(&bi[0], &DAC_Rate);
					SetCtrlVal(Pnl, P(DAC_RATE), DAC_Rate);
               sprintf(str, " Частота работы ЦАП установлена %.3f кГц.", DAC_Rate);
					SetCtrlVal(Pnl, P(BOX), str);

               //изменилась и частоты выдаваемого сигнала
					double FREQ=DAC_Rate/(double)DacFifoLength;
	            if(Frequency/FREQ < 0.5)
						Frequency=FREQ;
	            else
						Frequency=FREQ*(int)((Frequency/FREQ)+0.5);
					SetCtrlVal(Pnl, P(FREQUENCY), Frequency);
					break;
            }

				case P(AMPLITUDE):
            {
               char str[100];

					GetCtrlVal(Pnl, P(AMPLITUDE), &Amplitude);
					if(Amplitude > 2047) Amplitude=2047;
					else if(Amplitude < -2047) Amplitude=-2047;
					SetCtrlVal(Pnl, P(AMPLITUDE), Amplitude);
               sprintf(str, " Амплитуда сигнала равна %5i кодов ЦАП.", Amplitude);
					SetCtrlVal(Pnl, P(BOX), str);
					break;
            }

				case P(FREQUENCY):
            {
               char str[100];

					GetCtrlVal(Pnl, P(FREQUENCY), &Frequency);
	            Frequency=fabs(Frequency);
					double FREQ=DAC_Rate/(double)DacFifoLength;
					if(Frequency/FREQ < 0.5) Frequency=FREQ;
					else Frequency=FREQ*(int)((Frequency/FREQ)+0.5);
					SetCtrlVal(Pnl, P(FREQUENCY), Frequency);
               sprintf(str, " Частота выходного сигнала равна %.3f кГц.", Frequency);
					SetCtrlVal(Pnl, P(BOX), str);
					break;
            }

				case P(SIGNAL_TYPE):
            {
               char str[100];

					GetCtrlVal(Pnl, P(SIGNAL_TYPE), &SignalType);
               sprintf(str, " Тип выходного сигнала - '%s'.", SignalTypeName[SignalType]);
					SetCtrlVal(Pnl, P(BOX), str);
					break;
            }
			}
		}
   }

	UnloadPanel(Pnl);
	return EXIT;
}
Esempio n. 15
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;
			}
		}
	}
}