void default1D(struct data *d) { struct file fref; struct data ref; struct datablockhead *dbh; int /*dim1,dim2,*/dim3,nr; int i,j; int wref=FALSE; #ifdef DEBUG char function[20]; strcpy(function,"default1D"); /* Set function name */ #endif /* Open data and phasefile file pointers for writing */ openfpw(d,DATA_FILE); openfpw(d,PHAS_FILE); /* Write data and phasefile file headers */ wdfh(d,DATA_FILE); wdfh(d,PHAS_FILE); /* Set data dimensions */ //dim1=d->np/2; //dim2=1; dim3=d->fh.ntraces; nr=d->nr; /* Set nuber of "volumes" */ d->nvols=d->fh.nblocks/nr; /* Check if there is a water reference */ if (spar(d,"ws","y") && spar(d,"wref","y") && spar(d,"wrefstatus","ws")) wref=TRUE; /* Prepare water reference */ if (wref) { setreffile(&fref,d,"waterref"); /* Set reference file */ getpars(fref.procpar[0],&ref); /* Get pars from reference procpar */ opendata(fref.fid[0],&ref); /* Open reference data file fid */ getvol1D(&ref,0,NDCC); /* Get volume without applying dbh.lvl and dbh.tlt */ weightdata1D(&ref,STD,D1); /* Weight data using standard VnmrJ parameters */ } /* Allocate memory for blocks headers from all receivers */ if ((dbh = malloc(nr*sizeof(d->bh))) == NULL) nomem(); /* For spectra we anticipate there is easily sufficient memory for data from all receiver blocks */ for (d->vol=0;d->vol<d->nvols;d->vol++) { /* loop over "volumes" */ for (i=0;i<nr;i++) { /* loop over receivers */ getdbh(d,nr*d->vol+i); /* Get block header */ copydbh(&d->bh,&dbh[i]); /* Store the block headers for writing */ } getvol1D(d,d->vol,NDCC); /* Get data block without applying dbh.lvl and dbh.tlt */ weightdata1D(d,STD,D1); /* Weight data using standard VnmrJ parameters */ if (wref) refcorr1D(d,&ref); /* Phase correct using the reference */ else combine1D(d); /* Combine data from multiple receivers */ zerofill1D(d,STD,D1); /* Zero fill data using standard VnmrJ parameters */ fft1D(d,D1); /* 1D fft */ shiftdata1D(d,STD,D1); /* Shift data to get spectra */ for (i=0;i<nr;i++) { /* loop over receivers */ copydbh(&dbh[i],&d->bh); /* Copy block header for writing */ for (j=0;j<dim3;j++) { d->bh.index=d->vol*nr*dim3+i*dim3+j; /* Set block index */ wdbh(d,DATA_FILE); /* Write block header */ wdbh(d,PHAS_FILE); /* Write block header */ w1Dtrace(d,i,j,DATA_FILE); /* Write block */ w1Dtrace(d,i,j,PHAS_FILE); /* Write block */ } } clear1Ddata(d); /* Clear data "volume" from memory */ } clear1Dall(d); /* Clear everything from memory */ closefp(d,DATA_FILE); closefp(d,PHAS_FILE); }
/* Paul modify 2013/2/7 */ int initandparserfile(void) { //FILE *fp = NULL; char *pk = NULL; char str_path[PATH_LENGTH] = {0}; char stream[MAX_STREAM] = {0}; char str_key[MAX_KEY] = {0}; char str_type[4] = {0}; int nIndex = 0; uint offset = 0; HASH s_hash; SParser s_parse_tmp; //Andy Chiu, 2015/03/03. retry for cfg_manager restart scoket issue. int res = 0, i; for(i = 0; i < 5; ++i) { res = tcapi_get("LanguageSwitch_Entry", "Type", str_type); if(!res && strlen(str_type) > 0 ) break; tcdbg_printf("[%s, %d]get lang failed!\n", __FUNCTION__, __LINE__); sleep(1); } if (strlen(str_type)) nIndex = atoi(str_type); if(nIndex == 0) { for(i = 0; i < 5; ++i) { memset(str_type, 0, sizeof(str_type)); res = tcapi_get("WebCurSet_Entry", "detected_lang_type", str_type); if(!res && strlen(str_type) > 0 ) break; tcdbg_printf("[%s, %d]get lang failed!\n", __FUNCTION__, __LINE__); sleep(1); } if (strlen(str_type)) nIndex = atoi(str_type); } init_flag = nIndex; closefp();//close file pointer at first if(nIndex == 1) //English sprintf(str_path, STRING_PATH, "EN"); else if(nIndex == 2) //Brazil sprintf(str_path, STRING_PATH, "BR"); else if(nIndex == 3) //Simplified Chinese sprintf(str_path, STRING_PATH, "CN"); else if(nIndex == 4) //Cesky sprintf(str_path, STRING_PATH, "CZ"); else if(nIndex == 5) //Dansk sprintf(str_path, STRING_PATH, "DA"); else if(nIndex == 6) //Deutsch sprintf(str_path, STRING_PATH, "DE"); else if(nIndex == 7) //Espanol sprintf(str_path, STRING_PATH, "ES"); else if(nIndex == 8) //Finsk sprintf(str_path, STRING_PATH, "FI"); else if(nIndex == 9) //Francais sprintf(str_path, STRING_PATH, "FR"); else if(nIndex == 10) //Italiano sprintf(str_path, STRING_PATH, "IT"); else if(nIndex == 11) //Malay sprintf(str_path, STRING_PATH, "MS"); else if(nIndex == 12) //Norsk sprintf(str_path, STRING_PATH, "NO"); else if(nIndex == 13) //Polski sprintf(str_path, STRING_PATH, "PL"); else if(nIndex == 14) //Russian sprintf(str_path, STRING_PATH, "RU"); else if(nIndex == 15) //Svensk sprintf(str_path, STRING_PATH, "SV"); else if(nIndex == 16) //Thai sprintf(str_path, STRING_PATH, "TH"); else if(nIndex == 17) //Turkey sprintf(str_path, STRING_PATH, "TR"); else if(nIndex == 18) //Traditional Chinese sprintf(str_path, STRING_PATH, "TW"); else if(nIndex == 19) //Ukraine sprintf(str_path, STRING_PATH, "UK"); else sprintf(str_path, STRING_PATH, "EN"); fpl=fopen(str_path,"r"); if(fpl == NULL) { tcdbg_printf("\r\n%s:can't open %s\r\n",__FUNCTION__, str_path); return FAILURE; } if (FAILURE == initHashTable(&s_parse_tmp)) { tcdbg_printf("\r\n%s:alloc memory\n", __FUNCTION__); return FAILURE; } ResetHashTable(&s_parse);//free memory at first s_parse = s_parse_tmp; fseek(fpl, 0, SEEK_SET); while(fgets(stream, MAX_STREAM, fpl) != NULL) { int len = strlen(stream); pk = strstr(stream,"="); if ((stream[0] == ';') || (NULL == pk)) { offset += len; continue; } *pk = '\0'; strncpy(str_key, stream, strlen(stream)); s_hash.key = getkey(str_key); s_hash.ioffset = offset; offset += len; strcpy(str_attrname, str_key); insertToHash(&s_parse, s_hash); memset(stream, 0, MAX_STREAM); memset(str_key, 0, MAX_KEY); } //fclose(fp); return SUCCESS; }