Ignore:
Timestamp:
Mar 29, 2007 5:07:06 PM (16 years ago)
Author:
srkline
Message:

many changes to PatchFiles?.ipf to get the reads and writes separated
and put into NCNR_DataReadWrite.ipf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/PatchFiles.ipf

    r59 r71  
    417417        //change the sample label ? 
    418418        if(change[0]) 
    419                 Open/A/T="????TEXT" refnum as fname      //Open for writing! Move to EOF before closing! 
    420                 textstr = textVal[0] 
    421                 FSetPos refnum,98 
    422                 FBinWrite/F=0 refnum, textstr      //native object format (character) 
    423                 //move to the end of the file before closing 
    424                 FStatus refnum 
    425                 FSetPos refnum,V_logEOF 
    426                 //Print "Wrote end of header to " + num2str(V_filePOS) 
    427          
    428                 Close refnum 
     419                RewriteTextToHeader(fname,textVal[0],98) 
    429420        Endif 
    430421         
    431422        //total count time is an integer, handle separately 
    432423        if(change[6]) 
    433                 Open/A/T="????TEXT" refnum as fname      //Open for writing! Move to EOF before closing! 
    434424                num =str2num(textVal[6]) 
    435                 FSetPos refnum,31 
    436                 FBinWrite/B=3/F=3 refnum, num      //write a 4-byte integer 
    437                 //move to the end of the file before closing 
    438                 FStatus refnum 
    439                 FSetPos refnum,V_logEOF 
    440                 //Print "Wrote end of header to " + num2str(V_filePOS) 
    441          
    442                 Close refnum 
     425                RewriteIntegerToHeader(fname,num,31) 
    443426        Endif 
    444427         
     
    689672End 
    690673 
    691  
    692674//This function will read only the selected values editable in the patch panel 
    693675//The values read are passed to the panel through the global variables 
     
    701683        //just reset the global variables that are on the patch panel 
    702684         
    703         Variable refNum,integer,realval 
    704         String textstr="" 
    705         Variable countTime 
    706          
    707         //full filename with path is passed in 
    708         //actually open the file 
    709         Open/R refNum as fname 
    710          
    711         // read the sample.label text field 
    712         FSetPos refNum,98          //will start reading at byte 99 
    713         FReadLine/N=60 refNum,textstr 
    714         FSetPos refNum,31 
    715         FBinRead/B=3/F=3 refnum,countTime 
    716          
    717         Close refNum 
    718          
    719         //Print "countTime = ",countTime 
    720          
    721         //now get all of the reals 
    722         // 
    723         //Do all the GBLoadWaves at the end 
    724         // 
    725         //FBinRead Cannot handle 32 bit VAX floating point 
    726         //GBLoadWave, however, can properly read it 
    727         String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 
    728         String strToExecute 
    729         //append "/S=offset/U=numofreals" to control the read 
    730         // then append fname to give the full file path 
    731         // then execute 
    732          
    733         // NEW reads 
    734         Variable moncnt,savmon,detcnt,atten,trans,thick,temp,field 
    735         Variable dis,ang,bstop,ap1,ap2,ap12dis,lmda,dlmda,beamx,beamy,trnscnt 
    736          
    737         strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + fname + "\"" 
    738         Execute strToExecute 
    739         Wave w=$"tempGBWave0" 
    740         moncnt = w[0] 
    741         savmon = w[1] 
    742         detcnt = w[2] 
    743         atten = w[3] 
    744         //printf "moncnt = %g,savmon = %g,detcnt = %g,atten = %g\r",moncnt,savmon,detcnt,atten 
    745          
    746         strToExecute = GBLoadStr + "/S=158/U=2" + "\"" + fname + "\"" 
    747         Execute strToExecute 
    748         trans = w[0] 
    749         thick = w[1] 
    750         //printf "trans = %g, thick = %g\r",trans,thick 
    751          
    752         strToExecute = GBLoadStr + "/S=186/U=2" + "\"" + fname + "\"" 
    753         Execute strToExecute 
    754         temp = w[0] 
    755         field = w[1] 
    756         //printf "temp = %g, field = %g\r",temp,field 
    757          
    758         strToExecute = GBLoadStr + "/S=252/U=12" + "\"" + fname + "\"" 
    759         Execute strToExecute 
    760         beamx = w[0] 
    761         beamy = w[1] 
    762         dis = w[2] 
    763         ang = w[3] 
    764         // w[4] det size 
    765         bstop = w[5] 
    766         // w[6] blank 
    767         ap1 = w[7] 
    768         ap2 = w[8] 
    769         ap12dis = w[9] 
    770         lmda = w[10] 
    771         dlmda = w[11] 
    772         //printf "beamx = %g, beamy = %g\r",beamx,beamy 
    773         //printf "dis = %g,ang = %g, bstop = %g,ap1= %g,ap2 = %g\r",dis,ang,bstop,ap1,ap2 
    774         //printf "ap12dis = %g, lmda = %g, dlmda = %g\r",ap12dis,lmda,dlmda 
    775          
    776         strToExecute = GBLoadStr + "/S=388/U=1" + "\"" + fname + "\"" 
    777         Execute strToExecute 
    778         trnscnt = w[0] 
    779         //printf "trnscnt = %g\r",trnscnt 
     685//      Variable refNum,integer,realval 
     686//      String textstr="" 
     687//      Variable countTime 
     688//       
     689//      //full filename with path is passed in 
     690//      //actually open the file 
     691//      Open/R refNum as fname 
     692//       
     693//      // read the sample.label text field 
     694//      FSetPos refNum,98          //will start reading at byte 99 
     695//      FReadLine/N=60 refNum,textstr 
     696//      FSetPos refNum,31 
     697//      FBinRead/B=3/F=3 refnum,countTime 
     698//       
     699//      Close refNum 
     700//       
     701//      //Print "countTime = ",countTime 
     702//       
     703//      //now get all of the reals 
     704//      // 
     705//      //Do all the GBLoadWaves at the end 
     706//      // 
     707//      //FBinRead Cannot handle 32 bit VAX floating point 
     708//      //GBLoadWave, however, can properly read it 
     709//      String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" 
     710//      String strToExecute 
     711//      //append "/S=offset/U=numofreals" to control the read 
     712//      // then append fname to give the full file path 
     713//      // then execute 
     714//       
     715//      // NEW reads 
     716//      Variable moncnt,savmon,detcnt,atten,trans,thick,temp,field 
     717//      Variable dis,ang,bstop,ap1,ap2,ap12dis,lmda,dlmda,beamx,beamy,trnscnt 
     718//       
     719//      strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + fname + "\"" 
     720//      Execute strToExecute 
     721//      Wave w=$"tempGBWave0" 
     722//      moncnt = w[0] 
     723//      savmon = w[1] 
     724//      detcnt = w[2] 
     725//      atten = w[3] 
     726//      //printf "moncnt = %g,savmon = %g,detcnt = %g,atten = %g\r",moncnt,savmon,detcnt,atten 
     727//       
     728//      strToExecute = GBLoadStr + "/S=158/U=2" + "\"" + fname + "\"" 
     729//      Execute strToExecute 
     730//      trans = w[0] 
     731//      thick = w[1] 
     732//      //printf "trans = %g, thick = %g\r",trans,thick 
     733//       
     734//      strToExecute = GBLoadStr + "/S=186/U=2" + "\"" + fname + "\"" 
     735//      Execute strToExecute 
     736//      temp = w[0] 
     737//      field = w[1] 
     738//      //printf "temp = %g, field = %g\r",temp,field 
     739//       
     740//      strToExecute = GBLoadStr + "/S=252/U=12" + "\"" + fname + "\"" 
     741//      Execute strToExecute 
     742//      beamx = w[0] 
     743//      beamy = w[1] 
     744//      dis = w[2] 
     745//      ang = w[3] 
     746//      // w[4] det size 
     747//      bstop = w[5] 
     748//      // w[6] blank 
     749//      ap1 = w[7] 
     750//      ap2 = w[8] 
     751//      ap12dis = w[9] 
     752//      lmda = w[10] 
     753//      dlmda = w[11] 
     754//      //printf "beamx = %g, beamy = %g\r",beamx,beamy 
     755//      //printf "dis = %g,ang = %g, bstop = %g,ap1= %g,ap2 = %g\r",dis,ang,bstop,ap1,ap2 
     756//      //printf "ap12dis = %g, lmda = %g, dlmda = %g\r",ap12dis,lmda,dlmda 
     757//       
     758//      strToExecute = GBLoadStr + "/S=388/U=1" + "\"" + fname + "\"" 
     759//      Execute strToExecute 
     760//      trnscnt = w[0] 
     761//      //printf "trnscnt = %g\r",trnscnt 
     762//       
     763//      //assign to the globals for display in the panel 
     764//      String/G root:myGlobals:Patch:gPS1= textstr 
     765//      Variable/G root:myGlobals:Patch:gPV1 = trans 
     766//      Variable/G root:myGlobals:Patch:gPV2 = thick 
     767//      Variable/G root:myGlobals:Patch:gPV3 = beamx 
     768//      Variable/G root:myGlobals:Patch:gPV4 = beamy 
     769//      Variable/G root:myGlobals:Patch:gPV5 = atten 
     770//      Variable/G root:myGlobals:Patch:gPV6 = countTime 
     771//      Variable/G root:myGlobals:Patch:gPV7 = moncnt 
     772//      Variable/G root:myGlobals:Patch:gPV8 = detcnt 
     773//      Variable/G root:myGlobals:Patch:gPV9 = trnscnt 
     774//      Variable/G root:myGlobals:Patch:gPV10 = lmda 
     775//      Variable/G root:myGlobals:Patch:gPV11 = dlmda 
     776//      Variable/G root:myGlobals:Patch:gPV12 = temp 
     777//      Variable/G root:myGlobals:Patch:gPV13 = field 
     778//      Variable/G root:myGlobals:Patch:gPV14 = ap1 
     779//      Variable/G root:myGlobals:Patch:gPV15 = ap2 
     780//      Variable/G root:myGlobals:Patch:gPV16 = ap12dis 
     781//      Variable/G root:myGlobals:Patch:gPV17 = ang 
     782//      Variable/G root:myGlobals:Patch:gPV18 = bstop 
     783//      Variable/G root:myGlobals:Patch:gPV19 = dis 
     784//       
     785//      //clean up - get rid of w = $"tempGBWave0" 
     786//      KillWaves/Z w 
     787         
     788        // each "get" is an individual call to GBLoadWave... 
     789        // test for acceptable speed over a network... 
    780790         
    781791        //assign to the globals for display in the panel 
    782         String/G root:myGlobals:Patch:gPS1= textstr 
    783         Variable/G root:myGlobals:Patch:gPV1 = trans 
    784         Variable/G root:myGlobals:Patch:gPV2 = thick 
    785         Variable/G root:myGlobals:Patch:gPV3 = beamx 
    786         Variable/G root:myGlobals:Patch:gPV4 = beamy 
    787         Variable/G root:myGlobals:Patch:gPV5 = atten 
    788         Variable/G root:myGlobals:Patch:gPV6 = countTime 
    789         Variable/G root:myGlobals:Patch:gPV7 = moncnt 
    790         Variable/G root:myGlobals:Patch:gPV8 = detcnt 
    791         Variable/G root:myGlobals:Patch:gPV9 = trnscnt 
    792         Variable/G root:myGlobals:Patch:gPV10 = lmda 
    793         Variable/G root:myGlobals:Patch:gPV11 = dlmda 
    794         Variable/G root:myGlobals:Patch:gPV12 = temp 
    795         Variable/G root:myGlobals:Patch:gPV13 = field 
    796         Variable/G root:myGlobals:Patch:gPV14 = ap1 
    797         Variable/G root:myGlobals:Patch:gPV15 = ap2 
    798         Variable/G root:myGlobals:Patch:gPV16 = ap12dis 
    799         Variable/G root:myGlobals:Patch:gPV17 = ang 
    800         Variable/G root:myGlobals:Patch:gPV18 = bstop 
    801         Variable/G root:myGlobals:Patch:gPV19 = dis 
    802          
    803         //clean up - get rid of w = $"tempGBWave0" 
    804         KillWaves/Z w 
     792        String/G root:myGlobals:Patch:gPS1= getSampleLabel(fname) 
     793        Variable/G root:myGlobals:Patch:gPV1 = getSampleTrans(fname) 
     794        Variable/G root:myGlobals:Patch:gPV2 = getSampleThickness(fname) 
     795        Variable/G root:myGlobals:Patch:gPV3 = getBSXPos(fname) 
     796        Variable/G root:myGlobals:Patch:gPV4 = getBSYPos(fname) 
     797        Variable/G root:myGlobals:Patch:gPV5 = getAttenNumber(fname) 
     798        Variable/G root:myGlobals:Patch:gPV6 = getCountTime(fname) 
     799        Variable/G root:myGlobals:Patch:gPV7 = getMonitorCount(fname) 
     800        Variable/G root:myGlobals:Patch:gPV8 = getDetCount(fname) 
     801        Variable/G root:myGlobals:Patch:gPV9 = getTransDetectorCounts(fname) 
     802        Variable/G root:myGlobals:Patch:gPV10 = getWavelength(fname) 
     803        Variable/G root:myGlobals:Patch:gPV11 = getWavelengthSpread(fname) 
     804        Variable/G root:myGlobals:Patch:gPV12 = getTemperature(fname) 
     805        Variable/G root:myGlobals:Patch:gPV13 = getFieldStrength(fname) 
     806        Variable/G root:myGlobals:Patch:gPV14 = getSourceApertureDiam(fname) 
     807        Variable/G root:myGlobals:Patch:gPV15 = getSampleApertureDiam(fname) 
     808        Variable/G root:myGlobals:Patch:gPV16 = getSourceToSampleDist(fname) 
     809        Variable/G root:myGlobals:Patch:gPV17 = getDetectorOffset(fname) 
     810        Variable/G root:myGlobals:Patch:gPV18 = getBSDiameter(fname) 
     811        Variable/G root:myGlobals:Patch:gPV19 = getSDD(fname) 
    805812         
    806813        Return 0 
Note: See TracChangeset for help on using the changeset viewer.