⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readseed.c

📁 基于visual c编辑的读取地震波形(行业化标准)原代码,
💻 C
📖 第 1 页 / 共 2 页
字号:
		   SetDlgItemText(hDlg,IDC_CHAN,"???");	
			EnableWindow(GetDlgItem(hDlg,IDC_START),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_END),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_SAVE),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_RESCAN),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_APPLY),FALSE);


		   return TRUE;
			case WM_CLOSE:          
			EndDialog(hDlg,TRUE);  			
			//fclose(outfile);

		return (TRUE);
       case WM_COMMAND: 
		   {     
		   /* message: received a command */
		  
          switch(LOWORD(wParam)) 
			{
			  	case IDC_MYHELP:
				sprintf(helpdir,"%s\\readseed.hlp",DIRNAME);
				WinHelp(hDlg,helpdir,HELP_FINDER,0);
				break;
           
		  case IDC_LDATA:
			EnableWindow(GetDlgItem(hDlg,IDC_START),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_END),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_SAVE),FALSE);
			  break;
          case IDC_RESCAN:
			EnableWindow(GetDlgItem(hDlg,IDC_START),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_END),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_SAVE),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_APPLY),TRUE);

		SetCursor(LoadCursor(hInst,IDC_WAIT));
		strcount=filecount=0;
		GetDlgItemText(hDlg,IDC_BSIZE,tmpstr,80);
		BSIZE=atoi(tmpstr);
		GetDlgItemText(hDlg,IDC_STAN,tmpstr10,80);
		GetDlgItemText(hDlg,IDC_CHAN,tmpstr20,80);
		event=SendDlgItemMessage(hDlg,IDC_CHECK1,BM_GETCHECK,(WPARAM)0,(LPARAM)0);
		onlin=SendDlgItemMessage(hDlg,IDC_ONLINEF,BM_GETCHECK,(WPARAM)0,(LPARAM)0);

		while(SendDlgItemMessage(hDlg,IDC_LDATA,CB_DELETESTRING,(WPARAM)0,(LPARAM)0)!=CB_ERR);
		if((in=fopen(szFile,"rb"))==NULL){
			MessageBox(hDlg,"Cann't Open File","File Error",MB_OK);break;}
		flength=_filelength(_fileno(in))/100;
		


if(onlin)
{fread(&aaa.info[0],15,1,in);
if(aaa.info[0]!='A'||aaa.info[1]!='S'||aaa.info[2]!='L')
{MessageBox(hDlg,"It is Not Online Buffer","File Error",MB_OK);
			fclose(in);break;}

BSIZE=aaa.inin[2];
filecount=aaa.inin[0]+5;
filecount%=aaa.inin[1];
if(fseek(in,filecount*BSIZE+15,SEEK_SET)!=0){
fseek(in,15,SEEK_SET);filecount=0;}
}
			while(1)
			{
				rrr=fread(&Data[0],BSIZE,1,in);
				if(!rrr&&!onlin)break;
		    if(onlin){	
				if(!rrr)filecount=0;
			filecount%=aaa.inin[1];
			if(filecount==0)fseek(in,15,SEEK_SET);
			if(filecount==aaa.inin[0])break;}
			//	if(strcount>20)break;
		if(dec_h((SEED_data_record*)(Data),NT,ST,CH,&d1,&d2,tmpstr20,tmpstr10,event,&Rate)<0){filecount++;continue;}
		persent=ftell(in)/flength;
		if(persent!=persent1){sprintf(tmpstr,"Creating Data Base %ld%c",persent,0x25);
		SetWindowText(hDlg,tmpstr);}
		persent1=persent;
		sprintf(tmpstr,"%s%s %s %s %06d",ST,CH,cdatostr(d1,ssdata,1),cdatostr(d2,sedata,1),filecount);
		//SetWindowText(hDlg,tmpstr);

		if(strcount==0){SendDlgItemMessage(hDlg,IDC_LDATA,CB_ADDSTRING,(WPARAM)0,(LPARAM)tmpstr);
	//	fprintf(outfile,"%s\n",tmpstr);
		strcount++;filecount++;continue;}
			for(i=0;i<strcount;i++)
			{
			SendDlgItemMessage(hDlg,IDC_LDATA,CB_GETLBTEXT,(WPARAM)i,(LPARAM)tmpstr);
			Getlist(tmpstr,STLIST,CHLIST,&StartList,&EndList,&filelist);
			if(strcmp(ST,STLIST)==0&&strcmp(CH,CHLIST)==0)
			{cdatostr(d1,tmpstr1,1);
			 cdatostr(EndList,tmpstr2,1);
			 raz=fabs(raznd(d1,EndList));
			if((raz>=0. &&raz<=Rate)||(raz<0.&&raz>-Rate))break;
			}
			}
	if(i!=strcount)
	{sprintf(tmpstr,"%s%s %s %s %06d",ST,CH,cdatostr(StartList,ssdata,1),cdatostr(d2,sedata,1),filelist);
	SendDlgItemMessage(hDlg,IDC_LDATA,CB_DELETESTRING,(WPARAM)i,(LPARAM)0);
	SendDlgItemMessage(hDlg,IDC_LDATA,CB_ADDSTRING,(WPARAM)0,(LPARAM)tmpstr);
	}
	else {
	sprintf(tmpstr,"%s%s %s %s %06d",ST,CH,cdatostr(d1,ssdata,1),cdatostr(d2,sedata,1),filecount);
	SendDlgItemMessage(hDlg,IDC_LDATA,CB_ADDSTRING,(WPARAM)0,(LPARAM)tmpstr);
	strcount ++;
	}
	
	filecount++;	

				}

			fclose(in);
			SendDlgItemMessage(hDlg,IDC_LDATA,CB_SETCURSEL,(WPARAM)0,(LPARAM)0);	  

			  break;
		  case IDC_APPLY:
			EnableWindow(GetDlgItem(hDlg,IDC_START),TRUE);
			EnableWindow(GetDlgItem(hDlg,IDC_END),TRUE);
			EnableWindow(GetDlgItem(hDlg,IDC_SAVE),TRUE);
		  i=SendDlgItemMessage(hDlg,IDC_LDATA,CB_GETCURSEL,(WPARAM)0,(LPARAM)0);	  
		  SendDlgItemMessage(hDlg,IDC_LDATA,CB_GETLBTEXT,(WPARAM)i,(LPARAM)tmpstr);
		 //sscanf(tmpstr,"%s %s %s %s %s %d",STATION,CHANNEL,Time1,Time2,&SeekPoz);
		  for(i=0;i<5;i++)STATION[i]=tmpstr[i];STATION[5]=0;
		  for(i=0;i<3;i++)CHANNEL[i]=tmpstr[i+5];CHANNEL[3]=0;
		  sscanf(tmpstr+32+24,"%d",&SeekPoz);
		  strcpy(Time1,tmpstr+8);
		  strcpy(Time2,tmpstr+32);
			Time1[24]=0;
			Time2[24]=0;
			DC1=confromstr(Time1);
			DC2=confromstr(Time2);
		  SetDlgItemText(hDlg,IDC_START,Time1);
		  SetDlgItemText(hDlg,IDC_END,Time2);

			break;
		  case IDC_BUTTON1:
			strcpy(szFilter1,"(*.*)|*.*|");
			for (i=0; szFilter1[i]; i++)
			if (szFilter1[i] =='|') szFilter1[i] = '\0';
			memset(&ofn1, 0, sizeof(OPENFILENAME));
			ofn1.lStructSize = sizeof(OPENFILENAME);
			ofn1.hwndOwner = hWnd;
			ofn1.lpstrFilter = szFilter1;
			ofn1.nFilterIndex = 1;
			ofn1.lpstrFile = szFile1;
			ofn1.nMaxFile =128;
			ofn1.lpstrFileTitle = szFileTitle1;
			ofn1.nMaxFileTitle = 128;
			ofn1.lpstrInitialDir =NULL;
			ofn1.Flags=(long)NULL ;
			if(!GetSaveFileName(&ofn1))break;
			if((outlog=fopen(szFile1,"w"))==NULL)break;
			i=0;
			fprintf(outlog,"%s\n",szFile);
			while(SendDlgItemMessage(hDlg,IDC_LDATA,CB_GETLBTEXT,(WPARAM)i,(LPARAM)tmpstr)!=CB_ERR)
			{fprintf(outlog,"%s\n",tmpstr);i++;}
			 fclose(outlog);
			  
			  break;

			case IDC_BUTTON2:
			strcpy(szFilter1,"(*.*)|*.*|");
			for (i=0; szFilter1[i]; i++)
			if (szFilter1[i] =='|') szFilter1[i] = '\0';
			memset(&ofn1, 0, sizeof(OPENFILENAME));
			ofn1.lStructSize = sizeof(OPENFILENAME);
			ofn1.hwndOwner = hWnd;
			ofn1.lpstrFilter = szFilter1;
			ofn1.nFilterIndex = 1;
			ofn1.lpstrFile = szFile1;
			ofn1.nMaxFile =128;
			ofn1.lpstrFileTitle = szFileTitle1;
			ofn1.nMaxFileTitle = 128;
			ofn1.lpstrInitialDir =NULL;
			ofn1.Flags=(long)NULL ;
			if(!GetOpenFileName(&ofn1))break;
			if((inlog=fopen(szFile1,"r"))==NULL)break;
			while(SendDlgItemMessage(hDlg,IDC_LDATA,CB_DELETESTRING,(WPARAM)0,(LPARAM)0)!=CB_ERR);
			fscanf(inlog,"%s\n",szFile);
			while(fgets(tmpstr,80,inlog))
			{
			tmpstr[strlen(tmpstr)-1]=0;
			SendDlgItemMessage(hDlg,IDC_LDATA,CB_ADDSTRING,(WPARAM)0,(LPARAM)tmpstr);
			}
			EnableWindow(GetDlgItem(hDlg,IDC_APPLY),TRUE);
			fclose(inlog);
			break;

		  
		  case IDC_OPEN:
			EnableWindow(GetDlgItem(hDlg,IDC_START),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_END),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_SAVE),FALSE);
			EnableWindow(GetDlgItem(hDlg,IDC_APPLY),FALSE);
			
			strcpy(szFilter,"Online Buffers(*.*)|*.*|");
			for (i=0; szFilter[i]; i++)
			if (szFilter[i] =='|') szFilter[i] = '\0';

			memset(&ofn, 0, sizeof(OPENFILENAME));
			ofn.lStructSize = sizeof(OPENFILENAME);
			ofn.hwndOwner = hWnd;
			ofn.lpstrFilter = szFilter;
			ofn.nFilterIndex = 1;
			ofn.lpstrFile = szFile;
			ofn.nMaxFile =128;
			ofn.lpstrFileTitle = szFileTitle;
			ofn.nMaxFileTitle = 128;
			ofn.lpstrInitialDir =NULL;
			ofn.Flags=(long)NULL ;
			if(!GetOpenFileName(&ofn))break;
		    EnableWindow(GetDlgItem(hDlg,IDC_RESCAN),TRUE);
			
			break;
		  case IDC_SAVE:
			strcpy(szFilter1,"(*.*)|*.*|");
			for (i=0; szFilter1[i]; i++)
			if (szFilter1[i] =='|') szFilter1[i] = '\0';
			memset(&ofn1, 0, sizeof(OPENFILENAME));
			ofn1.lStructSize = sizeof(OPENFILENAME);
			ofn1.hwndOwner = hWnd;
			ofn1.lpstrFilter = szFilter1;
			ofn1.nFilterIndex = 1;
			ofn1.lpstrFile = szFile1;
			ofn1.nMaxFile =128;
			ofn1.lpstrFileTitle = szFileTitle1;
			ofn1.nMaxFileTitle = 128;
			ofn1.lpstrInitialDir =NULL;
			ofn1.Flags=(long)NULL ;
			if(!GetSaveFileName(&ofn1))break;
			if((in=fopen(szFile,"rb"))==NULL)
			{MessageBox(hDlg,"Cann't Open input File","File Open Error",MB_OK);break;}
			if((out=fopen(szFile1,"wb"))==NULL)
			{MessageBox(hDlg,"Cann't Open input File","File Open Error",MB_OK);break;}
			fseek(in,SeekPoz*BSIZE,SEEK_SET);
			if(onlin)fseek(in,15,SEEK_CUR);
			CurrPoz=SeekPoz;
			GetDlgItemText(hDlg,IDC_START,tmpstr,80);
			DT1=confromstr(tmpstr);
			GetDlgItemText(hDlg,IDC_END,tmpstr,80);
			DT2=confromstr(tmpstr);
			Dframes=(BSIZE-64)/64;
			NSAMP=0;
			if(raznd(DC1,DT1)>0||raznd(DC2,DT2)<0)
			{
MessageBox(hDlg,"Selected Time Interval Must Be Inside Status Time","Time Error",MB_OK);
fclose(in);fclose(out);break;
			}


			while(1)
			{
				if(onlin){
					if(CurrPoz==0)fseek(in,15,SEEK_SET);
					CurrPoz++;
					CurrPoz%=aaa.inin[1];
				}

				rrr=fread(&Data[0],BSIZE,1,in);
				if(!rrr)break;
				
			
			if(dec_h((SEED_data_record*)(Data),NT,ST,CH,&d1,&d2,CHANNEL,STATION,event,&Rate)<0)continue;
			if(NSAMP==0)
			{   RTT=Rate;
				strcpy(NTYPE,NT);
				nsamp=(int)(raznd(DT2,DT1)/Rate)+10;
				DATAARRAY=(long *)malloc(nsamp*4);
				if(!DATAARRAY){
MessageBox(hDlg,"Not Enought Memory To allocate Data","Memory Error",MB_OK);
fclose(in);fclose(out);return(TRUE);}
			}
			//if(raznd(DT1,d1)<0)continue;
			if(raznd(DT1,d2)>0)continue;
			if(raznd(DT2,d1)<0)break;
			numb=sreadseed(Level,Dframes,(SEED_data_record *)Data,Udata);
			if(numb<=0)continue;
			for(i=0;i<numb;i++)
			{currd=daatadsec(d1,Rate*i);
			

			if(raznd(currd,DT1)>=0.)
			{if(NSAMP==0){DATASTART.day=currd.day;DATASTART.msec=currd.msec;}
				DATAARRAY[NSAMP]=Udata[i];NSAMP++;}
			if(raznd(currd,DT2)>0.)break;
			}

			}
			if(SendDlgItemMessage(hDlg,IDC_WGSE,BM_GETCHECK,(WPARAM)0,(LPARAM)0)==1)
			save_wgse();
			else if(SendDlgItemMessage(hDlg,IDC_SGR,BM_GETCHECK,(WPARAM)0,(LPARAM)0)==1)
			save_sac(out,DATASTART,DATAARRAY,NSAMP,STATION,CHANNEL,NTYPE,RTT);
				else if(save_wgsn_new(out,DATASTART,DATAARRAY,NSAMP,STATION,CHANNEL,NTYPE,RTT)!=0)
				{MessageBox(hDlg,"Cann't fill Information from response.ini and station.ini","Error Message",MB_OK|MB_ICONSTOP);}
			free(DATAARRAY);
			fclose(in);fclose(out);
			break;

		  case IDC_SAVE_ALL:
			  EnableWindow(GetDlgItem(hDlg,IDC_APPLY),TRUE);
			strcpy(szFilter1,"(*.*)|*.*|");
			for (i=0; szFilter1[i]; i++)
			if (szFilter1[i] =='|') szFilter1[i] = '\0';
			memset(&ofn1, 0, sizeof(OPENFILENAME));
			ofn1.lStructSize = sizeof(OPENFILENAME);
			ofn1.hwndOwner = hWnd;
			ofn1.lpstrFilter = szFilter1;
			ofn1.nFilterIndex = 1;
			ofn1.lpstrFile = szFile1;
			ofn1.nMaxFile =128;
			ofn1.lpstrFileTitle = szFileTitle1;
			ofn1.nMaxFileTitle = 128;
			ofn1.lpstrInitialDir =NULL;
			ofn1.Flags=(long)NULL ;
			if(!GetSaveFileName(&ofn1))break;
			if((in=fopen(szFile,"rb"))==NULL)
			{MessageBox(hDlg,"Cann't Open input File","File Open Error",MB_OK);break;}
			if((out=fopen(szFile1,"wb"))==NULL)
			{MessageBox(hDlg,"Cann't Open input File","File Open Error",MB_OK);break;}
			iii=0;
			while(SendDlgItemMessage(hDlg,IDC_LDATA,CB_GETLBTEXT,(WPARAM)iii,(LPARAM)tmpstr)!=CB_ERR)
			{
			//SendMessage(hDlg,WM_COMMAND,(WPARAM)IDC_APPLY,(LPARAM)0);
		  for(i=0;i<5;i++)STATION[i]=tmpstr[i];STATION[5]=0;
		  for(i=0;i<3;i++)CHANNEL[i]=tmpstr[i+5];CHANNEL[3]=0;
		  sscanf(tmpstr+32+24,"%d",&SeekPoz);
		  strcpy(Time1,tmpstr+8);
		  strcpy(Time2,tmpstr+32);
			Time1[24]=0;
			Time2[24]=0;
			DC1=confromstr(Time1);
			DC2=confromstr(Time2);
			DT1=confromstr(Time1);
			DT2=confromstr(Time2);
			fseek(in,SeekPoz*BSIZE,SEEK_SET);
			if(onlin)fseek(in,15,SEEK_CUR);
			CurrPoz=SeekPoz;
			Dframes=(BSIZE-64)/64;
			NSAMP=0;
			if(raznd(DC1,DT1)>0||raznd(DC2,DT2)<0)
			{
MessageBox(hDlg,"Selected Time Interval Must Be Inside Status Time","Time Error",MB_OK);
fclose(in);fclose(out);break;
			}


			while(1)
			{
				if(onlin){
					if(CurrPoz==0)fseek(in,15,SEEK_SET);
					CurrPoz++;
					CurrPoz%=aaa.inin[1];
				}

				rrr=fread(&Data[0],BSIZE,1,in);
				if(!rrr)break;
				
			
			if(dec_h((SEED_data_record*)(Data),NT,ST,CH,&d1,&d2,CHANNEL,STATION,event,&Rate)<0)continue;
			if(NSAMP==0)
			{   RTT=Rate;
				strcpy(NTYPE,NT);
				nsamp=(int)(raznd(DT2,DT1)/Rate)+10;
				DATAARRAY=(long *)malloc(nsamp*4);
				if(!DATAARRAY){
MessageBox(hDlg,"Not Enought Memory To allocate Data","Memory Error",MB_OK);
fclose(in);fclose(out);return(TRUE);}
			}
			//if(raznd(DT1,d1)<0)continue;
			if(raznd(DT1,d2)>0)continue;
			if(raznd(DT2,d1)<0)break;
			numb=sreadseed(Level,Dframes,(SEED_data_record *)Data,Udata);
			if(numb<=0)continue;
			for(i=0;i<numb;i++)
			{currd=daatadsec(d1,Rate*i);
			

			if(raznd(currd,DT1)>=0.)
			{if(NSAMP==0){DATASTART.day=currd.day;DATASTART.msec=currd.msec;}
				DATAARRAY[NSAMP]=Udata[i];NSAMP++;}
			if(raznd(currd,DT2)>0.)break;
			}

			}
			if(SendDlgItemMessage(hDlg,IDC_WGSE,BM_GETCHECK,(WPARAM)0,(LPARAM)0)==1)
save_wgse();
				//save_wgse(out,DATASTART,DATAARRAY,NSAMP,STATION,CHANNEL,NTYPE,RTT);
			else if(SendDlgItemMessage(hDlg,IDC_SGR,BM_GETCHECK,(WPARAM)0,(LPARAM)0)==1)
			save_sac(out,DATASTART,DATAARRAY,NSAMP,STATION,CHANNEL,NTYPE,RTT);
				else if(save_wgsn_new(out,DATASTART,DATAARRAY,NSAMP,STATION,CHANNEL,NTYPE,RTT)!=0)
				{MessageBox(hDlg,"Cann't fill Information from response.ini and station.ini","Error Message",MB_OK|MB_ICONSTOP);}
			free(DATAARRAY);
			iii++;			
			}
	fclose(in);fclose(out);
			break;


			default:
            return FALSE;
           }
        return (TRUE);
			}
    } 

    return (FALSE);                           /* Didn't process a message    */
        
}




LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);



int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
                    LPSTR lpszCmdParam, int nCmdShow)
{
	
	MSG         msg ;
	WNDCLASS    wndclass ; 
	
	char *szAppName="MiniSeed";

	
	if (!hPrevInstance)
	{
		wndclass.style			= CS_HREDRAW | CS_VREDRAW ;
		wndclass.lpfnWndProc	= WndProc ;
		wndclass.cbClsExtra    	= 0 ;
		wndclass.cbWndExtra    	= 0 ;
		wndclass.hInstance     	= hInstance ;
		wndclass.hIcon         	= NULL ;
		wndclass.hCursor       	= LoadCursor (NULL, IDC_ARROW) ;
		wndclass.hbrBackground 	= NULL;
		wndclass.lpszMenuName  	= NULL;
		wndclass.lpszClassName 	= szAppName ;

   	RegisterClass (&wndclass) ;
	}
	hInst=hInstance;
	hWnd = CreateWindow (
				szAppName,       		// window class name
				"SCANSCSI",     		// window caption
				WS_OVERLAPPEDWINDOW,    // window style
				CW_USEDEFAULT,          // initial x position
				CW_USEDEFAULT,          // initial y position
				CW_USEDEFAULT,          // initial x size
				CW_USEDEFAULT,          // initial y size
				NULL,                   // parent window handle
				NULL,                   // window menu handle
				hInstance,              // program instance handle
				NULL) ;		     		// creation parameters
	

GetCurrentDirectory(100,DIRNAME);

	while (GetMessage( &msg, NULL, 0, 0 ))
   {
         TranslateMessage( &msg ) ;
         DispatchMessage( &msg ) ;
   }
   return (msg.wParam);           /* Returns the value from PostQuitMessage */
	
}




	LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)

{

		switch (message)
	          
		{	case WM_CREATE:
		
		 DialogBox(hInst,"IDD_GETSTAT",hWnd,GetStatus);
		 PostQuitMessage(0);
			break;
		
		default:

	return DefWindowProc (hWnd, message, wParam, lParam) ;
		}

}
	



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -