loadsub 'StitchDeclares.scr' ! ! zipScan.scr 5/15/96 mdc added zip dist entry ! 8/8/96 mdc removed X and Y positions. Only Z axis is motorized. ! 3/16/98 mdc changed g_TempDir$ to "" so it would work on both HP and PC ! also cleaned up code ! 07/17/2002 PAL Added code so there is always an error handler ! 09/26/2002 PAL Removed "loadsub" of non-existing file from top of file ! 02/18/2003 PAL Changed all calls to dialog() to use new DO_DIALOG sub-routine. ! Made CENTRAL_ERROR_HANDLER the default error handler. ! Load 'GenStitch.scr' instead of 'StitchSubs.scr' ! ! +-----------------------------------------------------------------------------------------+ ! ! | Sub ZipScan() | ! ! | This provides a way to extend the scan length of a measurement using Zip Stitching. | ! ! | This is a stand alone script which would be called from a MetroScript Button. | ! ! | | ! ! | In Parameters: | ! ! | | ! ! | Out Parameters: | ! ! | | ! ! | Local Variables: | ! ! | g_TempDir$ | ! ! | g_NumZips | ! ! | g_XPos() | ! ! | g_YPos() | ! ! | g_ZPos() | ! ! | l_msg$ | ! ! | ret_Dialog | ! ! | l_sTemp$ | ! ! | l_nTemp | ! ! | g_ZipCoordFile$ | ! ! | @CoorFile_Zip | ! ! | l_FileName$ | ! ! | | ! ! | Procedures Called: | ! ! | | ! ! | Algorithm: | ! ! | 1. Get the nominal zip distance from the user. | ! ! | 2. Take two seperate measurements and save data to file. | ! ! | 3. Zip files together into file called "zip.dat" | ! ! | 4. Remove intermediate data files and coordinate file. | ! ! +-----------------------------------------------------------------------------------------+ ! ZIPSCAN: ! Set the error handler on error goto CENTRAL_ERROR_HANDLER ! Mark that EXIT_ZIP_SCAN routine exists g_ExitZipScanExists = 1 ! Clear the user abort gosub CLEAR_USER_ABORT gosub GET_IDS gosub GET_ZIP_CNTRLS g_TempDir$ = "" g_NumZips = 2 g_OnStitchMeasureError = oeaAbort gosub GET_XY_NO_ERROR g_XPos(1) = tmp_x_pos g_YPos(1) = tmp_y_pos gosub GET_Z g_ZPos(1) = tmp_z_pos ! We now have a position to return to g_ReturnWhenDone = 1 RECPOS: ! To enable this prompt, set bDoZipScanPrompt = 1 if (bDoZipScanPrompt = 1) then g_dlgStyle = DlgNormal_YesNo g_dlgMessage$ = " Done positioning, Yes to begin, No to Exit " gosub DO_DIALOG if (ret_Dialog = DlgNo) then goto EXIT_ZIP_SCAN endif g_ZipDistance = getval(g_idZipDistCntl, "in") ! go down and go up to remove backlash tmp_z_pos = g_ZPos(1) - 0.01 gosub MOVE_Z tmp_z_pos = g_ZPos(1) gosub MOVE_Z gosub GET_Z g_ZPos(1) = tmp_z_pos g_ZipCoordFile$ = g_TempDir$ & "zipcoors.crd" assign @CoorFile_Zip to g_ZipCoordFile$ "w" output @CoorFile_Zip; val$(g_NumZips) TAKEMEAS: for i = 1 to g_NumZips tmp_z_pos = g_ZPos(i) gosub MOVE_Z g_MeasureProcess = 1 acquire g_MeasureProcess = 0 g_XPos(i) = g_XPos(1) g_YPos(i) = g_YPos(1) ! get z val after autofocus gosub GET_Z g_ZPos(i) = tmp_z_pos if (USE_Z_ENCODER% = 0) then g_ZipZPos(i) = tmp_z_pos else gosub GET_Z_ENCODER g_ZipZPos(i) = tmp_ze_pos endif ! want 1 over g_ZPos(i + 1) = g_ZPos(i) + g_ZipDistance l_FileName$ = g_TempDir$ & "zipx" & val$(i) & ".dat" g_FileSaveProcess = 1 savedata(0, l_FileName$) g_FileSaveProcess = 0 ofmtr("%.12lf") output @CoorFile_Zip; l_FileName$ output @CoorFile_Zip; val$(g_XPos(i)) & " " & val$(g_YPos(i)) output @CoorFile_Zip; val$(g_ZipZPos(i)) if ( i = 1 ) then l_FileName$ = g_TempDir$ & "zip.dat" g_FileSaveProcess = 1 savedata(0, l_FileName$) g_FileSaveProcess = 0 endif next i assign @CoorFile_Zip to "" l_sTemp$ = "zip " & g_ZipCoordFile$ l_nTemp = execute(l_sTemp$) if (l_nTemp <> 0) then goto BADCALL VIEWDATA: l_FileName$ = "zip.dat" on error goto NO_ZIP_FILE loaddata( l_FileName$ ) on error goto CENTRAL_ERROR_HANDLER ZipStProcStsCntl = getid("controls/ZipStitch/StoreProcessStats") ZipStProcSts = getval( ZipStProcStsCntl, "" ) if ( ZipStProcSts = 1 ) then storeprocstats goto EXIT_ZIP_SCAN NO_ZIP_FILE: g_dlgMessage$ = " Could not find zip file: " & l_FileName$ g_dlgStyle = DlgError_OK gosub DO_DIALOG goto USER_STITCH_EXIT BADCALL: g_dlgStyle = DlgError_OK if ( l_nTemp = 1000 ) then g_dlgMessage$ = " Maximum zip offset exceeded " else g_dlgMessage$ = " Error in Zip algorithm, program halted. " endif gosub DO_DIALOG EXIT_ZIP_SCAN: ! Check for user abort. Save for later. gosub CHK_USER_ABORT bUserAbort = g_bUserAbort ! Move the stages back to the initial position if ( g_ReturnWhenDone = 1 ) then tmp_x_pos = g_XPos(1) tmp_y_pos = g_YPos(1) gosub MOVE_XY_NO_ERROR tmp_z_pos = g_ZPos(1) gosub MOVE_Z_NO_ERROR endif ! Display an abort message if needed if ( bUserAbort <> 0 ) then g_dlgMessage$ = " Zip-Scan Aborted " g_dlgStyle = DlgError_OK gosub DO_DIALOG endif ! Delete temp files for i = 1 to g_NumZips ok = execute("del /f /q zipx" & val$(i) & ".dat") next i ok = execute("del /f /q " & g_ZipCoordFile$) end loadsub 'GenStitch.scr'