Ignore:
Timestamp:
Sep 10, 2010 5:50:17 PM (13 years ago)
Author:
srkline
Message:

some changes to the XML and the DataSetHandling? to get closer to a functional batch conversion panel. Functionality is mmostly there with these changes. Still to be done is to verify that all of the proper information is being re-written to the converted files.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Common/DataSetHandling.ipf

    r728 r732  
    363363        Make/O/T/N=1 filewave="" 
    364364        Make/O/N=1 selWave=0 
    365         Variable/G ind=0 
     365        Variable/G ind=0,gRadioVal=1 
    366366        SetDataFolder root: 
    367367End 
     
    370370        PauseUpdate; Silent 1           // building window... 
    371371        NewPanel /W=(658,347,1018,737)/N=NCNRBatchConvertPanel/K=2 as "Batch Convert 1D Data" 
     372//      NewPanel /W=(658,347,1018,737)/N=NCNRBatchConvertPanel as "Batch Convert 1D Data" 
    372373        ModifyPanel cbRGB=(40000,50000,32896) 
    373374        ModifyPanel fixedSize=1 
     
    383384         
    384385        GroupBox filterGroup,pos={13,200},size={206,60},title="Filter list by input file type" 
     386        CheckBox filterCheck_1,pos={24,220},size={36,14},title="XML",value= 1,mode=1, proc=BC_filterCheckProc 
     387        CheckBox filterCheck_2,pos={24,239},size={69,14},title="ABS or AVE",value= 0,mode=1, proc=BC_filterCheckProc 
     388        CheckBox filterCheck_3,pos={100,220},size={69,14},title="none",value= 0,mode=1, proc=BC_filterCheckProc 
    385389         
    386390        Button button8,pos={238,76},size={100,20},proc=NCNRBatchConvertHelpProc,title="Help" 
     
    389393 
    390394        GroupBox outputGroup,pos={13,270},size={206,60},title="Output File Type" 
    391  
     395        CheckBox outputCheck_1,pos={24,289},size={36,14},title="XML",value= 0,mode=1, proc=BC_outputCheckProc 
     396        CheckBox outputCheck_2,pos={24,309},size={69,14},title="ABS or AVE",value= 1,mode=1, proc=BC_outputCheckProc 
    392397         
    393398        Button button6,pos={13,350},size={206,20},proc=NCNRBatchConvertFiles,title="Convert File(s)" 
     
    398403End 
    399404 
     405Function BC_filterCheckProc(ctrlName,checked) : CheckBoxControl 
     406        String ctrlName 
     407        Variable checked 
     408 
     409        NVAR gRadioVal= root:Packages:NIST:BatchConvert:gRadioVal 
     410         
     411        strswitch (ctrlName) 
     412                case "filterCheck_1": 
     413                        gRadioVal= 1 
     414                        break 
     415                case "filterCheck_2": 
     416                        gRadioVal= 2 
     417                        break 
     418                case "filterCheck_3": 
     419                        gRadioVal= 3 
     420                        break 
     421        endswitch 
     422        CheckBox filterCheck_1,value= gRadioVal==1 
     423        CheckBox filterCheck_2,value= gRadioVal==2 
     424        CheckBox filterCheck_3,value= gRadioVal==3 
     425         
     426        NCNRBatchConvertGetList() 
     427          
     428        return(0) 
     429End 
     430 
     431Function BC_outputCheckProc(ctrlName,checked) : CheckBoxControl 
     432        String ctrlName 
     433        Variable checked 
     434 
     435        if(cmpstr("outputCheck_1",ctrlName)==0) 
     436                CheckBox outputCheck_1,value=checked 
     437                CheckBox outputCheck_2,value=!checked 
     438        else 
     439                CheckBox outputCheck_1,value=!checked 
     440                CheckBox outputCheck_2,value=checked 
     441        endif 
     442         
     443        return(0) 
     444End 
    400445 
    401446Function NCNRBatchConvertFiles(ba) : ButtonControl 
    402447                STRUCT WMButtonAction &ba 
    403448                 
     449                 
    404450                switch (ba.eventCode) 
    405451                        case 2: 
     452                         
     453                                //check the input/output as best I can (none may be the input filter) 
     454                                Variable inputType,outputType=1 
     455                                NVAR gRadioVal= root:Packages:NIST:BatchConvert:gRadioVal 
     456                                inputType = gRadioVal 
     457                                ControlInfo outputCheck_1 
     458                                if(V_value==1) 
     459                                        outputType = 1          //xml 
     460                                else 
     461                                        outputType = 2          //6-col 
     462                                endif 
     463                                 
     464                                if(inputType==outputType) 
     465                                        DoAlert 0,"Input and output types are the same. Nothing will be converted" 
     466                                        return(0) 
     467                                endif 
     468                         
     469                         
     470                                        // input and output are different, proceed 
     471 
    406472                                Wave/T fileWave=$"root:Packages:NIST:BatchConvert:fileWave" 
    407                                 Wave sel=$"root:BatchConvert:NIST:BatchConvert:selWave" 
     473                                Wave sel=$"root:Packages:NIST:BatchConvert:selWave" 
     474                                 
     475                                String fname="",pathStr="",newFileName="" 
     476                                Variable ii,num 
     477                                PathInfo catPathName                    //this is where the files are 
     478                                pathStr=S_path 
     479                                                         
     480                                // process the selected items 
     481                                num=numpnts(sel) 
     482                                ii=0 
     483                                do 
     484                                        if(sel[ii] == 1) 
     485                                                fname=pathStr + fileWave[ii] 
     486                                                 
     487                                                if(outputType == 1) 
     488                                                        convertNISTtoNISTXML(fname) 
     489                                                endif 
     490                                                 
     491                                                if(outputType == 2) 
     492                                                        convertNISTXMLtoNIST6Col(fname) 
     493                                                endif 
     494                                        endif 
     495                                        ii+=1 
     496                                while(ii<num) 
    408497                                 
    409498                                break 
     
    426515End 
    427516 
     517 
     518// filter is a bit harsh - will need to soften this by presenting an option to enter the suffix 
     519// 
    428520Function NCNRBatchConvertGetList() 
    429521 
     
    434526        Endif 
    435527         
    436         String newList = A_ReducedDataFileList("") 
     528        String newList = A_ReducedDataFileList(""),tmpList="" 
    437529        Variable num 
     530         
     531        NVAR gRadioVal= root:Packages:NIST:BatchConvert:gRadioVal 
     532        ControlInfo filterCheck_1 
     533        if(gRadioVal == 1) 
     534                //keep XML data 
     535                tmpList = ListMatch(newList, "*.ABSx" ,";") 
     536                tmpList += ListMatch(newList, "*.AVEx" ,";") 
     537                tmpList += ListMatch(newList, "*.xml" ,";") 
     538        else 
     539                if(gRadioVal ==2) 
     540                        //keep ave, abs data 
     541                        tmpList = ListMatch(newList, "*.ABS" ,";") 
     542                        tmpList += ListMatch(newList, "*.AVE" ,";") 
     543                else 
     544                        //return everything 
     545                        tmpList = newList 
     546                endif 
     547        endif 
     548        newList = tmpList 
    438549         
    439550        num=ItemsInList(newlist,";") 
     
    444555        fileWave = StringFromList(p,newlist,";") 
    445556        Sort filewave,filewave 
     557         
     558        return 0 
    446559End 
    447560 
     
    15511664 
    15521665 
     1666 
     1667// still need to get the header information, and possibly the SASprocessnote from the XML load into the 6-column header 
     1668// 
     1669// start by looking in:  
     1670//      String xmlReaderFolder = "root:Packages:CS_XMLreader:" 
     1671// for Title and Title_folder strings -> then the metadata (but the processnote is still not there 
     1672// 
     1673// may need to get it directly using the filename 
     1674Function  convertNISTXMLtoNIST6Col(fname) 
     1675        String fname 
     1676 
     1677        String list, item,path 
     1678        Variable num,ii 
     1679         
     1680        //load the XML 
     1681         
     1682        LoadNISTXMLData(fname,"",0,0)           //no plot, no force overwrite 
     1683//      Execute "A_LoadOneDDataWithName(\""+fname+"\",0)"               //won't plot 
     1684 
     1685        // then rewrite what is in the data folder that was just loaded 
     1686        String basestr = ParseFilePath(0, fname, ":", 1, 0) 
     1687        baseStr = CleanupName(baseStr,0) 
     1688        print fname 
     1689        print basestr 
     1690 
     1691        fReWrite1DData_noPrompt(baseStr,"tab","CR") 
     1692 
     1693        return(0) 
     1694End 
     1695 
     1696 
    15531697///////// SRK - VERY SIMPLE batch converter 
    15541698// no header information is preserved 
  • sans/Dev/trunk/NCNR_User_Procedures/Common/NIST_XML_v40.ipf

    r710 r732  
    565565end 
    566566 
     567// 
     568// !!! nf.Sample_ID is not set correctly here, since it's not read in from the NIST 6-col data file 
     569// and SASprocessnote does not get set either! 
     570// 
    567571Function convertNISTtoNISTXML(fileStr) 
    568572        String fileStr 
     
    639643                         
    640644                endif 
    641                  
    642                 //Tidy up 
    643                 Variable i = 0 
    644                 do 
    645                         WAVE/Z wv= $(StringFromList(i,S_waveNames,";")) 
    646                         if( WaveExists(wv) == 0 ) 
    647                                 break 
    648                         endif 
    649                         KillWaves wv 
    650                         i += 1 
    651                 while (1)       // exit is via break statement 
    652  
    653645         
    654646        endif   //6-col data 
     
    666658 
    667659        writeNISTXML(outfileName, nf) 
     660 
     661        //Tidy up AFTER we're all done, since STRUCT points to wave0,wave1, etc. 
     662        Variable i = 0 
     663        do 
     664                WAVE/Z wv= $(StringFromList(i,S_waveNames,";")) 
     665                if( WaveExists(wv) == 0 ) 
     666                        break 
     667                endif 
     668                KillWaves wv 
     669                i += 1 
     670        while (1)       // exit is via break statement 
    668671 
    669672end 
     
    695698                if (stringmatch(buffer,"*FIRST File LABEL:*") == 1) 
    696699                        NISTfile.title = TrimWS(StringFromList(1,buffer, ":")) 
    697                 elseif(stringmatch(buffer,"*LABEL:*") == 1) 
     700                endif 
     701                if(stringmatch(buffer,"*LABEL:*") == 1) 
    698702                        NISTfile.title = TrimWS(StringFromList(1,buffer, ":")) 
     703                endif 
     704                if(stringmatch(buffer,"NSORT*") == 1) 
     705                        NISTfile.title = buffer 
    699706                endif 
    700707                 
Note: See TracChangeset for help on using the changeset viewer.