loadsub 'reStitchDeclares.scr' !reGenStitch.scr ! 03/11/08 emf Added joyoff command to BEG_STITCH and joyon to CEH_BEGIN and ! BEG_STITCH_NEXT_STEP. These changes are to accommodate ! closed loop stages on NewView 7000 with MPX Motion ! 01/09/97 mdc Combined all the stitches into one file. ! Added a new control to choose which stitch to use. ! 06/16/97 mdc Major Mods, ! 08/16/97 mdc Added Annulus Stitch type, only works for version 7.1.16 or later, ! but wont hurt. ! 08/25/97 mdc Added auto tilt and cleaned up code ! 11/25/97 mdc We now record the z position for use by zipping ! 09/21/98 mdc Modified to add Manual Stage Stitch. Also do not do XY backlash ! removal on single measurement also changed output from stitch. ! It now uses stdout. Invoke stitch by calling shell, ! executing stitch and redirect output. ! 10/21/98 mdc modified g_TempDir$ to be absolute, not relative. Now ! handle error of not being able to write to disk. ! 07/17/2002 PAL Added code so there is always an error handler ! 02/18/2003 PAL Centralized the error handler. ! Added DO_DIALOG routine. ! Ignore error when moving stages in EXIT_STITCH ! Removed unused routines. ! +-----------------------------------------------------------------------------------------+ ! ! | Sub STARTSEQ() | ! ! | Starting point for any type of stitching. | ! ! | | ! ! | In Parameters: | ! ! | g_bUNIX | ! ! | g_idAutoFocusCntl | ! ! | g_idAutoTiltCntl | ! ! | | ! ! | Out Parameters: | ! ! | g_TempDir$ | ! ! | g_bStageRetry | ! ! | g_StitchType | ! ! | | ! ! | Local Variables: | ! ! | | ! ! | Procedures Called: | ! ! | GET_OS | ! ! | CREATE_TMP_DIR | ! ! | MAN_STCH | ! ! | COL_STCH | ! ! | XY_STCH | ! ! | SE_STCH | ! ! | RUN_SEQ_STCH | ! ! | RUN_SEQ_3D_STCH | ! ! | ALIGN_STG_STCH | ! ! | ANNULUS_STCH | ! ! | MAN_STAGE_STCH | ! ! | STCH_INIT | ! ! | | ! ! | Algorithm: | ! ! | 1. Create temp directory. | ! ! | 2. Perform specific stitches. | ! ! | 3. reset Auto Focus and Auto Tilt controls. | ! ! +-----------------------------------------------------------------------------------------+ ! STARTSEQ: ! Set the error handler on error goto CENTRAL_ERROR_HANDLER ! Mark that EXIT_STITCH routine exists g_ExitStitchExists = 1 ! Clear the user abort gosub CLEAR_USER_ABORT gosub GET_OS g_TempDir$ = getwrkdir$ & g_PathSep$ & "stch_tmp" ! place to put temp files gosub STCH_INIT gosub CREATE_TMP_DIR g_bStageRetry = 0 !STAGE_ERROR = 0 g_idStchTypeCntl = getid("controls/stitch/Type") g_StitchType = getval(g_idStchTypeCntl, "") g_idSeqFileIsCRD = getid("controls/custom/boolean1") g_SeqFileIsCRD = getval(g_idSeqFileIsCRD, "") ! **** START OF SPECIFIC TYPES **** if (g_StitchType = ManualStitch) then ! replace the default manual stitch routine with a custom ! version to enable guided scans of top and bottom surfaces ! of a transparent film. ! gosub MAN_STCH gosub MAN_STCH_2 endif if (g_StitchType = ColumnStitch) then gosub COL_STCH endif if (g_StitchType = XYStitch) then gosub XY_STCH endif if (g_StitchType = StartEndStitch) then gosub SE_STCH endif if (g_StitchType = RunSequenceStitch) then if (g_SeqFileIsCRD = 0) then gosub RUN_SEQ_STCH else gosub RUN_SEQ_3D_STCH endif endif if (g_StitchType = AlignStageStitch) then gosub ALIGN_STG_STCH endif if (g_StitchType = AnnulusStitch) then gosub ANNULUS_STCH endif if (g_StitchType = ManualStageStitch) then gosub MAN_STAGE_STCH endif ! reset Auto Focus and Tilt back to the original values setnum(g_idAutoFocusCntl, tmpFocus, "") setnum(g_idAutoTiltCntl, tmpTilt, "") STARTSEQ_EXIT: gosub CHK_USER_ABORT if (g_bUserAbort = 1) then g_dlgMessage$ = " Stitching Aborted " g_dlgStyle = DlgError_OK gosub DO_DIALOG endif end ! end of the top level routine ! +-----------------------------------------------------------------------------------------+ ! ! | Sub MAN_STCH() | ! ! | Manual Stitching. The user sets the locations for measurements. | ! ! | | ! ! | In Parameters: | ! ! | | ! ! | Out Parameters: | ! ! | g_NumMeas | ! ! | | ! ! | Local Variables: | ! ! | X | ! ! | Y | ! ! | Z | ! ! | l_msg$ | ! ! | ret_Dialog | ! ! | l_NumPos | ! ! | | ! ! | Procedures Called: | ! ! | GET_XY | ! ! | GET_Z | ! ! | SAVE_SEQ | ! ! | BEG_STITCH | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! MAN_STCH: MAN_STCH_LOOP: ! RECORD POSITIONS g_dlgMessage$ = " Press Yes to Save Position " & val$(l_NumPos) & " " g_dlgMessage$ = g_dlgMessage$ & "\n Press No to Begin Stitch " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG if (ret_Dialog <> DlgNo) then gosub GET_XY g_XPos(l_NumPos) = tmp_x_pos g_YPos(l_NumPos) = tmp_y_pos gosub GET_Z g_ZPos(l_NumPos) = tmp_z_pos g_XMeasPos(l_NumPos) = g_XPos(l_NumPos) g_YMeasPos(l_NumPos) = g_YPos(l_NumPos) g_ZMeasPos(l_NumPos) = g_ZPos(l_NumPos) l_NumPos = l_NumPos + 1 goto MAN_STCH_LOOP else g_NumMeas = l_NumPos - 1 !to remove extra endif gosub SAVE_SEQ gosub BEG_STITCH MAN_STCH_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub COL_STCH() | ! ! | Column Stitching. The locations for measurements are calculated based on the | ! ! | number of rows and columns and the percent overlap. | ! ! | | ! ! | In Parameters: | ! ! | g_ColCount | ! ! | g_RowCount | ! ! | g_XIncrement | ! ! | g_YIncrement | ! ! | g_XCameraSize | ! ! | g_YCameraSize | ! ! | | ! ! | Out Parameters: | ! ! | g_XSize | ! ! | g_YSize | ! ! | g_NumMeas | ! ! | | ! ! | Local Variables: | ! ! | ret_ChkDims | ! ! | ret_ChkDiskSize | ! ! | | ! ! | Procedures Called: | ! ! | GET_STCH_SIZE | ! ! | CHK_DIMENS | ! ! | EXIT_STITCH (on error) | ! ! | SET_STCH_LOCS | ! ! | CHK_DISK_SIZE | ! ! | SAVE_SEQ | ! ! | BEG_STITCH | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! COL_STCH: gosub GET_STCH_SIZE g_XSize = ((g_ColCount * g_XIncrement) + (g_XCameraSize - g_XIncrement)) g_YSize = ((g_RowCount * g_YIncrement) + (g_YCameraSize - g_YIncrement)) gosub CHK_DIMENS !chk if max dimensions are exceeded if (ret_ChkDims = 1) then gosub EXIT_STITCH goto COL_STCH_EXIT endif gosub SET_STCH_LOCS gosub CHK_DISK_SIZE !chk if max dimensions are exceeded if (ret_ChkDiskSize = 1) then gosub EXIT_STITCH goto COL_STCH_EXIT endif g_NumMeas = g_ColCount * g_RowCount gosub SAVE_SEQ gosub BEG_STITCH COL_STCH_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub XY_STCH() | ! ! | X & Y Stitching. The user specifies the size of the area to be stitched and the | ! ! | minimum amout of overlap. | ! ! | | ! ! | In Parameters: | ! ! | g_ColCount | ! ! | g_RowCount | ! ! | | ! ! | Out Parameters: | ! ! | g_XSize | ! ! | g_YSize | ! ! | g_NumMeas | ! ! | | ! ! | Local Variables: | ! ! | ret_ChkDims | ! ! | ret_ChkDiskSize | ! ! | | ! ! | Procedures Called: | ! ! | GET_STCH_SIZE | ! ! | CHK_DIMENS | ! ! | EXIT_STITCH (on error) | ! ! | SETROWCOL | ! ! | SET_STCH_LOCS | ! ! | CHK_DISK_SIZE | ! ! | SAVE_SEQ | ! ! | BEG_STITCH | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! XY_STCH: gosub GET_STCH_SIZE if (g_DoingZip = 0) then g_XSize = getval(g_idStchXSizeCntl, "in") g_YSize = getval(g_idStchYSizeCntl, "in") endif gosub CHK_DIMENS !chk if max dimensions are exceeded if (ret_ChkDims = 1) then gosub EXIT_STITCH goto XY_STCH_EXIT endif gosub SETROWCOL ! set the number of g_RowCount and columns gosub SET_STCH_LOCS gosub CHK_DISK_SIZE !chk if max dimensions are exceeded if (ret_ChkDiskSize = 1) then gosub EXIT_STITCH goto XY_STCH_EXIT endif g_NumMeas = g_ColCount * g_RowCount if (g_DoingZip = 0) then gosub SAVE_SEQ endif gosub BEG_STITCH XY_STCH_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub SE_STCH() | ! ! | Start end Stitching. The user specifies the upper right and lower left corners of | ! ! | of the area to be stitched and the locations for measurements are calculated. | ! ! | | ! ! | In Parameters: | ! ! | g_XCameraSize | ! ! | g_YCameraSize | ! ! | g_ColCount | ! ! | g_RowCount | ! ! | | ! ! | Out Parameters: | ! ! | g_XStart | ! ! | g_YStart | ! ! | g_XEnd | ! ! | g_YEnd | ! ! | g_XSize | ! ! | g_YSize | ! ! | g_NumMeas | ! ! | | ! ! | Local Variables: | ! ! | X | ! ! | Y | ! ! | l_msg$ | ! ! | ret_Dialog | ! ! | l_nTemp | ! ! | ret_ChkDims | ! ! | ret_ChkDiskSize | ! ! | | ! ! | Procedures Called: | ! ! | GET_XY | ! ! | GET_STCH_SIZE | ! ! | CHK_DIMENS | ! ! | EXIT_STITCH (on error) | ! ! | SETROWCOL | ! ! | SET_STCH_LOCS | ! ! | CHK_DISK_SIZE | ! ! | SAVE_SEQ | ! ! | BEG_STITCH | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! SE_STCH: g_dlgMessage$ = " Position at Upper Right of Area " g_dlgStyle = DlgNormal_OK gosub DO_DIALOG gosub GET_XY g_XStart = tmp_x_pos g_YStart = tmp_y_pos g_dlgMessage$ = " Position at Lower Left of Area " g_dlgStyle = DlgNormal_OK gosub DO_DIALOG gosub GET_STCH_SIZE gosub GET_XY g_XEnd = tmp_x_pos g_YEnd = tmp_y_pos l_nTemp = abs(g_XStart - g_XEnd) if ((abs(l_nTemp) < 0.002) and (l_nTemp <> 0)) then g_dlgMessage$ = " X delta is minimal, ignore ? " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG if (ret_Dialog = DlgOK_Yes) then l_nTemp = 0 endif g_XSize = g_XCameraSize + l_nTemp l_nTemp = abs(g_YStart - g_YEnd) if ((abs(l_nTemp) < 0.002) and (l_nTemp <> 0)) then g_dlgMessage$ = " Y delta is minimal, ignore ? " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG if (ret_Dialog = DlgOK_Yes) then l_nTemp = 0 endif g_YSize = g_YCameraSize + l_nTemp gosub CHK_DIMENS !chk if max dimensions are exceeded if (ret_ChkDims = 1) then gosub EXIT_STITCH goto SE_STCH_EXIT endif gosub SETROWCOL ! set the number of g_RowCount and columns gosub SET_STCH_LOCS gosub CHK_DISK_SIZE !chk if max dimensions are exceeded if (ret_ChkDiskSize = 1) then gosub EXIT_STITCH goto SE_STCH_EXIT endif g_NumMeas = g_ColCount * g_RowCount gosub SAVE_SEQ gosub BEG_STITCH SE_STCH_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub MAN_STCH_2() | ! ! | Start end Stitching for 2-surface scans of transparent films, modeled after | ! ! | SE_STCH, but with manual positioning and 2 scans per frame. | ! ! | | ! ! | In Parameters: | ! ! | g_XCameraSize | ! ! | g_YCameraSize | ! ! | g_ColCount | ! ! | g_RowCount | ! ! | | ! ! | Out Parameters: | ! ! | g_XStart | ! ! | g_YStart | ! ! | g_XEnd | ! ! | g_YEnd | ! ! | g_XSize | ! ! | g_YSize | ! ! | g_NumMeas | ! ! | | ! ! | Local Variables: | ! ! | X | ! ! | Y | ! ! | l_msg$ | ! ! | ret_Dialog | ! ! | l_nTemp | ! ! | ret_ChkDims | ! ! | ret_ChkDiskSize | ! ! | | ! ! | Procedures Called: | ! ! | GET_XY | ! ! | GET_STCH_SIZE | ! ! | CHK_DIMENS | ! ! | EXIT_STITCH (on error) | ! ! | SETROWCOL | ! ! | SET_STCH_LOCS | ! ! | CHK_DISK_SIZE | ! ! | SAVE_SEQ | ! ! | BEG_STITCH_2 | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! MAN_STCH_2: g_dlgMessage$ = " Position at Upper Right of Area " g_dlgStyle = DlgNormal_OK gosub DO_DIALOG gosub GET_XY g_XStart = tmp_x_pos g_YStart = tmp_y_pos g_dlgMessage$ = " Position at Lower Left of Area " g_dlgStyle = DlgNormal_OK gosub DO_DIALOG gosub GET_STCH_SIZE gosub GET_XY g_XEnd = tmp_x_pos g_YEnd = tmp_y_pos l_nTemp = abs(g_XStart - g_XEnd) if ((abs(l_nTemp) < 0.002) and (l_nTemp <> 0)) then g_dlgMessage$ = " X delta is minimal, ignore ? " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG if (ret_Dialog = DlgOK_Yes) then l_nTemp = 0 endif g_XSize = g_XCameraSize + l_nTemp l_nTemp = abs(g_YStart - g_YEnd) if ((abs(l_nTemp) < 0.002) and (l_nTemp <> 0)) then g_dlgMessage$ = " Y delta is minimal, ignore ? " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG if (ret_Dialog = DlgOK_Yes) then l_nTemp = 0 endif g_YSize = g_YCameraSize + l_nTemp gosub CHK_DIMENS !chk if max dimensions are exceeded if (ret_ChkDims = 1) then gosub EXIT_STITCH goto MAN_STCH_2_EXIT endif gosub SETROWCOL ! set the number of g_RowCount and columns gosub SET_STCH_LOCS gosub CHK_DISK_SIZE !chk if max dimensions are exceeded if (ret_ChkDiskSize = 1) then gosub EXIT_STITCH goto MAN_STCH_2_EXIT endif g_NumMeas = g_ColCount * g_RowCount gosub SAVE_SEQ gosub BEG_STITCH_2 MAN_STCH_2_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub RUN_SEQ_STCH() | ! ! | Run Sequence Stitch. Locations for measurements are read from a file. | ! ! | | ! ! | In Parameters: | ! ! | | ! ! | Out Parameters: | ! ! | | ! ! | Local Variables: | ! ! | | ! ! | Procedures Called: | ! ! | READ_SEQ | ! ! | BEG_STITCH | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! RUN_SEQ_STCH: gosub READ_SEQ gosub BEG_STITCH RUN_SEQ_STCH_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub RUN_SEQ_3D_STCH() | ! ! | Run a 3D Sequence Stitch. Locations for measurements are read from a file. | ! ! | | ! ! | In Parameters: | ! ! | | ! ! | Out Parameters: | ! ! | | ! ! | Local Variables: | ! ! | | ! ! | Procedures Called: | ! ! | READ_COORDF | ! ! | BEG_STITCH_3D | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! RUN_SEQ_3D_STCH: gosub READ_COORDF gosub BEG_STITCH_3D RUN_SEQ_3D_STCH_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub ALIGN_STG_STCH() | ! ! | Stage Alignment Stitching. This type of stitching is used to verify that the stage | ! ! | is aligned properly to give an accurate composite of the images. | ! ! | | ! ! | In Parameters: | ! ! | g_idStchMvmntCntl | ! ! | g_XIncrement | ! ! | g_YIncrement | ! ! | g_XCameraSize | ! ! | g_YCameraSize | ! ! | | ! ! | Out Parameters: | ! ! | g_ColCount | ! ! | g_RowCount | ! ! | g_Overlap | ! ! | g_XSize | ! ! | g_YSize | ! ! | g_NumMeas | ! ! | | ! ! | Local Variables: | ! ! | ret_ChkDims | ! ! | ret_ChkDiskSize | ! ! | | ! ! | Procedures Called: | ! ! | GET_STCH_SIZE | ! ! | CHK_DIMENS | ! ! | EXIT_STITCH (on error) | ! ! | SET_STCH_LOCS | ! ! | CHK_DISK_SIZE | ! ! | SAVE_SEQ | ! ! | BEG_STITCH | ! ! | | ! ! | Algorithm: | ! ! | Taken from OMP-375, Stage Alignment Procedures: | ! ! | 6. In the Stitch Controls window, set the Type control to Align Stage, then | ! ! | click the Stitch button. The software takes two measurements and then | ! ! | displays the composite image. Examine the area along the intersection of | ! ! | the two measurements. if pixels are offset and there is a noticeable shift | ! ! | greater than ±1 pixel, align the stage as described in step 7. | ! ! +-----------------------------------------------------------------------------------------+ ! ALIGN_STG_STCH: ! for stage alignment, force rast movement and turn off avg setnum(g_idStchMvmntCntl, 1, "") !AvgOvrlap = 0 gosub GET_STCH_SIZE g_ColCount = 2 g_RowCount = 1 g_Overlap = 10 g_XSize = ((g_ColCount * g_XIncrement) + (g_XCameraSize - g_XIncrement)) g_YSize = ((g_RowCount * g_YIncrement) + (g_YCameraSize - g_YIncrement)) gosub CHK_DIMENS !chk if max dimensions are exceeded if (ret_ChkDims = 1) then gosub EXIT_STITCH goto ALIGN_STG_STCH_EXIT endif gosub SET_STCH_LOCS gosub CHK_DISK_SIZE !chk if max dimensions are exceeded if (ret_ChkDiskSize = 1) then gosub EXIT_STITCH goto ALIGN_STG_STCH_EXIT endif gosub SAVE_SEQ ! save all locs .. why? g_NumMeas = g_ColCount * g_RowCount gosub BEG_STITCH ALIGN_STG_STCH_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub ANNULUS_STCH() | ! ! | Annulus Stitching. The user specifies the Inner and Outer Radii of the part to be | ! ! | stitched and also gives the location of the top of the part. | ! ! | | ! ! | In Parameters: | ! ! | g_InnerRadius | ! ! | g_OuterRadius | ! ! | g_ColCount | ! ! | g_RowCount | ! ! | | ! ! | Out Parameters: | ! ! | g_NumMeas | ! ! | | ! ! | Local Variables: | ! ! | ret_ChkDims | ! ! | ret_ChkDiskSize | ! ! | | ! ! | Procedures Called: | ! ! | GET_STCH_SIZE | ! ! | GET_RADII | ! ! | EXIT_STITCH (on error) | ! ! | CHK_DIMENS | ! ! | SETROWCOL | ! ! | SET_STCH_LOCS | ! ! | CHK_DISK_SIZE | ! ! | UPDATE_LOCS | ! ! | SAVE_SEQ | ! ! | BEG_STITCH | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! ANNULUS_STCH: gosub GET_STCH_SIZE gosub GET_RADII ! this sets g_XSize and g_YSize if ((g_InnerRadius >= g_OuterRadius)) then g_dlgMessage$ = " Inner and Outer Radii match, abort " g_dlgStyle = DlgWarning_OK gosub DO_DIALOG gosub EXIT_STITCH goto ANNULUS_STCH_EXIT endif gosub CHK_DIMENS !chk if max dimensions are exceeded if (ret_ChkDims = 1) then gosub EXIT_STITCH goto ANNULUS_STCH_EXIT endif gosub SETROWCOL ! set the number of g_RowCount and columns gosub SET_STCH_LOCS gosub CHK_DISK_SIZE !chk if max dimensions are exceeded if (ret_ChkDiskSize = 1) then gosub EXIT_STITCH goto ANNULUS_STCH_EXIT endif g_NumMeas = g_ColCount * g_RowCount gosub UPDATE_LOCS ! updates the windows used, and sets g_NumMeas gosub SAVE_SEQ gosub BEG_STITCH ANNULUS_STCH_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub MAN_STAGE_STCH() | ! ! | Manual Stage Stitching. This is manual stitching without a motorized stage. | ! ! | | ! ! | In Parameters: | ! ! | g_TempDir$ | ! ! | g_idSavePrDataID | ! ! | ret_PromptXY_x | ! ! | ret_PromptXY_y | ! ! | | ! ! | Out Parameters: | ! ! | g_NumMeas | ! ! | g_XMeasPos() | ! ! | g_YMeasPos() | ! ! | g_ZMeasPos() | ! ! | | ! ! | Local Variables: | ! ! | l_FileName$ | ! ! | l_NumPos | ! ! | l_msg$ | ! ! | ret_Dialog | ! ! | | ! ! | Procedures Called: | ! ! | PROMPT_FOR_XY | ! ! | DOSTITCH | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! MAN_STAGE_STCH: g_NumMeas = 1 MAN_STAGE_STCH_LOOP: gosub PROMPT_FOR_XY measure g_HaveData = 1 l_FileName$ = g_TempDir$ & g_PathSep$ & "stch" & val$(g_NumMeas) & ".dat" if (g_bSaveProcessedData = 0) then savedata(0, l_FileName$) else savedata(g_idSavePrDataID, l_FileName$) endif g_XMeasPos(g_NumMeas) = ret_PromptXY_x g_YMeasPos(g_NumMeas) = ret_PromptXY_y g_ZMeasPos(g_NumMeas) = 0 g_NumMeas = g_NumMeas + 1 l_NumPos = l_NumPos + 1 ! RECORD POSITIONS g_dlgMessage$ = " Press Yes to measure Location " & val$(l_NumPos) & " " g_dlgMessage$ = g_dlgMessage$ & "\n Press No to Begin Stitch " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG if (ret_Dialog <> DlgNo) then goto MAN_STAGE_STCH_LOOP else g_NumMeas = l_NumPos - 1 !to remove extra endif gosub DOSTITCH MAN_STAGE_STCH_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub PROMPT_FOR_XY() | ! ! | | ! ! | In Parameters: | ! ! | | ! ! | Out Parameters: | ! ! | ret_PromptXY_x | ! ! | ret_PromptXY_y | ! ! | | ! ! | Local Variables: | ! ! | l_sTemp$ | ! ! | | ! ! | Procedures Called: | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! PROMPT_FOR_XY: l_sTemp$ = promptstr$(" Move part into place, then enter the X coordinate in inches ", " 0 ", 9) ret_PromptXY_x = val(l_sTemp$) l_sTemp$ = promptstr$(" enter the Y coordinate in inches ", " 0 ", 9) ret_PromptXY_y = val(l_sTemp$) PROMPT_FOR_XY_EXIT: return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub BEG_STITCH() | ! ! | Begin Stitch acquires the data and saves the file and measurement information. | ! ! | | ! ! | In Parameters: | ! ! | g_NumMeas | ! ! | g_idStchMvmntCntl | ! ! | g_XPos() | ! ! | g_YPos() | ! ! | g_XStart | ! ! | g_bShowMesaurement | ! ! | g_RetryCount | ! ! | g_TempDir$ | ! ! | g_bSaveProcessedData | ! ! | g_idSavePrDataID | ! ! | g_ErrorReturn | ! ! | | ! ! | Out Parameters: | ! ! | g_StageMovement | ! ! | g_MesaureMessage$ | ! ! | g_XMeasPos | ! ! | g_YMeasPos | ! ! | g_ZMeasPos | ! ! | g_HaveData | ! ! | | ! ! | Local Variables: | ! ! | X | ! ! | Y | ! ! | Z | ! ! | l_CurrentPosition | ! ! | l_NumPos | ! ! | l_MeasIndex | ! ! | l_FileName$ | ! ! | | ! ! | Procedures Called: | ! ! | MOVE_XY | ! ! | UPDATE_CNTRLS | ! ! | SET_FOCUS_TILT | ! ! | GET_Z | ! ! | DOSTITCH | ! ! | GENERAL_ERROR (on error) | ! ! | MEAS_ERROR (on error) | ! ! | FILE_SAVE_ERROR (on error) | ! ! | EXIT_STITCH (on error) | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! BEG_STITCH: joyoff g_CollectingData = 1 !resetmasks l_CurrentPosition = 1 l_NumPos = g_NumMeas g_StageMovement = getval(g_idStchMvmntCntl, "") ! 1 is Rast, 2 is Serp l_MeasIndex = 1 if ((g_StageMovement = RasterMove) and (l_NumPos > 1)) then tmp_x_pos = g_XPos(l_CurrentPosition) - 0.01 tmp_y_pos = g_YPos(l_CurrentPosition) - 0.01 gosub MOVE_XY ! remove backlash endif STITCH_LOOP_CONT: if (l_CurrentPosition > l_NumPos) then goto BEG_STITCH_NEXT_STEP g_MesaureMessage$ = val$(l_MeasIndex) & " of " & val$(g_NumMeas) gosub UPDATE_CNTRLS ! we need to update these, when data loaded these are cleared if ( g_CollectingData = 0 ) then goto BEG_STITCH_EXIT ! remove backlash in x ONLY if ((g_StageMovement = RasterMove) and (g_XPos(l_CurrentPosition) = g_XStart) and (l_NumPos > 1)) then tmp_x_pos = g_XStart - 0.01 tmp_y_pos = g_YPos(l_CurrentPosition) gosub MOVE_XY ! remove backlash x only if ( g_CollectingData = 0 ) then goto BEG_STITCH_EXIT endif tmp_x_pos = g_XPos(l_CurrentPosition) tmp_y_pos = g_YPos(l_CurrentPosition) gosub MOVE_XY if ( g_CollectingData = 0 ) then goto BEG_STITCH_EXIT ! set auto focus and tilt gosub SET_FOCUS_TILT if ( g_CollectingData = 0 ) then goto BEG_STITCH_EXIT g_MeasureProcess = 1 if (g_bShowMesaurement = 0) then acquire else measure endif g_MeasureProcess = 0 g_HaveData = 1 g_RetryCount = 0 g_FileSaveProcess = 1 l_FileName$ = g_TempDir$ & g_PathSep$ & "stch" & val$(l_MeasIndex) & ".dat" if (g_bSaveProcessedData = 0) then savedata(0, l_FileName$) else savedata(g_idSavePrDataID, l_FileName$) endif g_FileSaveProcess = 0 g_XMeasPos(l_MeasIndex) = g_XPos(l_CurrentPosition) ! record the position of the good measurement g_YMeasPos(l_MeasIndex) = g_YPos(l_CurrentPosition) gosub GET_Z if ( g_CollectingData = 0 ) then goto BEG_STITCH_EXIT g_ZMeasPos(l_MeasIndex) = tmp_z_pos l_CurrentPosition = l_CurrentPosition + 1 l_MeasIndex = l_MeasIndex + 1 goto STITCH_LOOP_CONT BEG_STITCH_NEXT_STEP: g_CollectingData = 0 joyon gosub DOSTITCH BEG_STITCH_EXIT: g_CollectingData = 0 return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub BEG_STITCH_2() | ! ! | Begin Stitch 2 acquires scan data and saves the file and measurement information. | ! ! | It is modeled on BEG_STITCH, but it takes 2 scans per stitch position, and allows | ! ! | the user to refine the head position before each scan. | ! ! | | ! ! | In Parameters: | ! ! | g_NumMeas | ! ! | g_idStchMvmntCntl | ! ! | g_XPos() | ! ! | g_YPos() | ! ! | g_ZPos() | ! ! | g_XStart | ! ! | g_bShowMesaurement | ! ! | g_RetryCount | ! ! | g_TempDir$ | ! ! | g_bSaveProcessedData | ! ! | g_idSavePrDataID | ! ! | g_ErrorReturn | ! ! | | ! ! | Out Parameters: | ! ! | g_StageMovement | ! ! | g_MesaureMessage$ | ! ! | g_XMeasPos | ! ! | g_YMeasPos | ! ! | g_ZMeasPos | ! ! | g_ZMeasUpper | ! ! | g_ZMeasLower | ! ! | g_HaveData | ! ! | | ! ! | Local Variables: | ! ! | X | ! ! | Y | ! ! | Z | ! ! | l_CurrentPosition | ! ! | l_NumPos | ! ! | l_MeasIndex | ! ! | l_FileName$ | ! ! | | ! ! | Procedures Called: | ! ! | MOVE_XY | ! ! | UPDATE_CNTRLS | ! ! | SET_FOCUS_TILT | ! ! | GET_Z | ! ! | DOSTITCH_2 | ! ! | GENERAL_ERROR (on error) | ! ! | MEAS_ERROR (on error) | ! ! | FILE_SAVE_ERROR (on error) | ! ! | EXIT_STITCH (on error) | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! BEG_STITCH_2: joyoff g_CollectingData = 1 !resetmasks l_CurrentPosition = 1 l_NumPos = g_NumMeas g_StageMovement = getval(g_idStchMvmntCntl, "") ! 1 is Rast, 2 is Serp l_MeasIndex = 1 if ((g_StageMovement = RasterMove) and (l_NumPos > 1)) then tmp_x_pos = g_XPos(l_CurrentPosition) - 0.01 tmp_y_pos = g_YPos(l_CurrentPosition) - 0.01 gosub MOVE_XY ! remove backlash endif STITCH_2_LOOP_CONT: if (l_CurrentPosition > l_NumPos) then goto BEG_STITCH_2_NEXT_STEP g_MeasureMessage$ = val$(l_MeasIndex) & " of " & val$(g_NumMeas) gosub UPDATE_CNTRLS ! we need to update these, when data loaded these are cleared if ( g_CollectingData = 0 ) then goto BEG_STITCH_2_EXIT ! remove backlash in x ONLY if ((g_StageMovement = RasterMove) and (g_XPos(l_CurrentPosition) = g_XStart) and (l_NumPos > 1)) then tmp_x_pos = g_XStart - 0.01 tmp_y_pos = g_YPos(l_CurrentPosition) gosub MOVE_XY ! remove backlash x only if ( g_CollectingData = 0 ) then goto BEG_STITCH_2_EXIT endif tmp_x_pos = g_XPos(l_CurrentPosition) tmp_y_pos = g_YPos(l_CurrentPosition) gosub MOVE_XY if (l_CurrentPosition > 1) then tmp_z_pos = g_ZMeasLower(l_CurrentPosition - 1) -0.1 ! backlash correction gosub MOVE_Z tmp_z_pos = g_ZMeasLower(l_CurrentPosition - 1) gosub MOVE_Z endif if ( g_CollectingData = 0 ) then goto BEG_STITCH_2_EXIT joyon g_dlgMessage$ = " Adjust Z to center bottom surface fringes in the image." g_dlgMessage$ = g_dlgMessage$ & "\n Continue? " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG joyoff if (ret_Dialog = DlgNo) then goto BEG_STITCH_2_EXIT if ( g_CollectingData = 0 ) then goto BEG_STITCH_2_EXIT ! set auto focus and tilt gosub SET_FOCUS_TILT if ( g_CollectingData = 0 ) then goto BEG_STITCH_2_EXIT ! make the first scan with the preset values g_MeasureProcess = 1 if (g_bShowMesaurement = 0) then acquire else measure endif g_MeasureProcess = 0 g_HaveData = 1 g_RetryCount = 0 g_FileSaveProcess = 1 l_FileName$ = g_TempDir$ & g_PathSep$ & "stch_lower" & val$(l_MeasIndex) & ".dat" if (g_bSaveProcessedData = 0) then savedata(0, l_FileName$) else savedata(g_idSavePrDataID, l_FileName$) endif g_FileSaveProcess = 0 gosub GET_Z g_ZMeasLower(l_MeasIndex) = tmp_z_pos ! make the second scan with adjusted values for the brighter surface ! 1) 5% lower light level ! 2) scan length 100 microns ! 3) minimum modulation at 0.5% l_idLightLev = getid("controls/acquisition/light level pct") l_lightlev = getval(l_idLightLev,"") setnum(l_idLightLev,l_lightlev-5,"") l_idMinMod = getid("controls/acquisition/min mod (%)") l_minmod = getval(l_idMinMod,"") setnum(l_idMinMod,0.5,"") l_idScanLen = getid("controls/acquisition/scan length") l_scanlen = getval(l_idScanLen,"") ! setnum(l_idScanLen,8,"") if (l_CurrentPosition > 1) then tmp_z_pos = g_ZMeasUpper(l_CurrentPosition - 1) -0.1 ! backlash correction gosub MOVE_Z tmp_z_pos = g_ZMeasUpper(l_CurrentPosition - 1) gosub MOVE_Z endif if ( g_CollectingData = 0 ) then goto BEG_STITCH_2_EXIT joyon g_dlgMessage$ = " Adjust Z to center upper surface fringes in the image." g_dlgMessage$ = g_dlgMessage$ & "\n Continue? " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG joyoff if (ret_Dialog = DlgNo) then goto BEG_STITCH_2_EXIT if ( g_CollectingData = 0 ) then goto BEG_STITCH_2_EXIT ! set auto focus and tilt gosub SET_FOCUS_TILT if ( g_CollectingData = 0 ) then goto BEG_STITCH_2_EXIT ! make the second scan with the adjusted values g_MeasureProcess = 1 if (g_bShowMesaurement = 0) then acquire else measure endif g_MeasureProcess = 0 setnum(l_idMinMod,l_minmod,"") setnum(l_idScanLen,l_scanlen,"") setnum(l_idLightLev,l_lightlev,"") g_HaveData = 1 g_RetryCount = 0 g_FileSaveProcess = 1 l_FileName$ = g_TempDir$ & g_PathSep$ & "stch_upper" & val$(l_MeasIndex) & ".dat" if (g_bSaveProcessedData = 0) then savedata(0, l_FileName$) else savedata(g_idSavePrDataID, l_FileName$) endif g_FileSaveProcess = 0 g_XMeasPos(l_MeasIndex) = g_XPos(l_CurrentPosition) ! record the position of the good measurement g_YMeasPos(l_MeasIndex) = g_YPos(l_CurrentPosition) gosub GET_Z if ( g_CollectingData = 0 ) then goto BEG_STITCH_2_EXIT g_ZMeasUpper(l_MeasIndex) = tmp_z_pos l_CurrentPosition = l_CurrentPosition + 1 l_MeasIndex = l_MeasIndex + 1 goto STITCH_2_LOOP_CONT BEG_STITCH_2_NEXT_STEP: g_CollectingData = 0 joyon gosub DOSTITCH_2 BEG_STITCH_2_EXIT: g_CollectingData = 0 return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub BEG_STITCH_3D() | ! ! | Begin Stitch 3D acquires the data and saves the file and measurement information. | ! ! | It is modeled on BEG_STITCH, but it moves on a 3D grid contained in input arrays | ! ! | g_Xpos(), g_Ypos(), and g_Zpos(), instead of just the first two. | ! ! | | ! ! | In Parameters: | ! ! | g_NumMeas | ! ! | g_idStchMvmntCntl | ! ! | g_XPos() | ! ! | g_YPos() | ! ! | g_ZPos() | ! ! | g_XStart | ! ! | g_bShowMesaurement | ! ! | g_RetryCount | ! ! | g_TempDir$ | ! ! | g_bSaveProcessedData | ! ! | g_idSavePrDataID | ! ! | g_ErrorReturn | ! ! | | ! ! | Out Parameters: | ! ! | g_StageMovement | ! ! | g_MesaureMessage$ | ! ! | g_XMeasPos | ! ! | g_YMeasPos | ! ! | g_ZMeasPos | ! ! | g_HaveData | ! ! | | ! ! | Local Variables: | ! ! | X | ! ! | Y | ! ! | Z | ! ! | l_CurrentPosition | ! ! | l_NumPos | ! ! | l_MeasIndex | ! ! | l_FileName$ | ! ! | | ! ! | Procedures Called: | ! ! | MOVE_XY | ! ! | UPDATE_CNTRLS | ! ! | SET_FOCUS_TILT | ! ! | GET_Z | ! ! | DOSTITCH | ! ! | GENERAL_ERROR (on error) | ! ! | MEAS_ERROR (on error) | ! ! | FILE_SAVE_ERROR (on error) | ! ! | EXIT_STITCH (on error) | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! BEG_STITCH_3D: joyoff g_CollectingData = 1 !resetmasks l_CurrentPosition = 1 l_NumPos = g_NumMeas g_StageMovement = getval(g_idStchMvmntCntl, "") ! 1 is Rast, 2 is Serp l_MeasIndex = 1 if ((g_StageMovement = RasterMove) and (l_NumPos > 1)) then tmp_x_pos = g_XPos(l_CurrentPosition) - 0.01 tmp_y_pos = g_YPos(l_CurrentPosition) - 0.01 gosub MOVE_XY ! remove backlash endif STITCH_3D_LOOP_CONT: if (l_CurrentPosition > l_NumPos) then goto BEG_STITCH_3D_NEXT_STEP g_MeasureMessage$ = val$(l_MeasIndex) & " of " & val$(g_NumMeas) gosub UPDATE_CNTRLS ! we need to update these, when data loaded these are cleared if ( g_CollectingData = 0 ) then goto BEG_STITCH_3D_EXIT ! remove backlash in x ONLY if ((g_StageMovement = RasterMove) and (g_XPos(l_CurrentPosition) = g_XStart) and (l_NumPos > 1)) then tmp_x_pos = g_XStart - 0.01 tmp_y_pos = g_YPos(l_CurrentPosition) gosub MOVE_XY ! remove backlash x only if ( g_CollectingData = 0 ) then goto BEG_STITCH_3D_EXIT endif tmp_x_pos = g_XPos(l_CurrentPosition) tmp_y_pos = g_YPos(l_CurrentPosition) gosub MOVE_XY if ( g_CollectingData = 0 ) then goto BEG_STITCH_3D_EXIT tmp_z_pos = g_ZPos(l_CurrentPosition) gosub MOVE_Z joyon g_dlgMessage$ = " Adjust Z to center fringes in the image." g_dlgMessage$ = g_dlgMessage$ & "\n Continue? " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG joyoff if (ret_Dialog = DlgNo) then goto BEG_STITCH_3D_EXIT if ( g_CollectingData = 0 ) then goto BEG_STITCH_3D_EXIT ! set auto focus and tilt gosub SET_FOCUS_TILT if ( g_CollectingData = 0 ) then goto BEG_STITCH_3D_EXIT g_MeasureProcess = 1 if (g_bShowMesaurement = 0) then acquire else measure endif g_MeasureProcess = 0 g_HaveData = 1 g_RetryCount = 0 g_FileSaveProcess = 1 l_FileName$ = g_TempDir$ & g_PathSep$ & "stch" & val$(l_MeasIndex) & ".dat" if (g_bSaveProcessedData = 0) then savedata(0, l_FileName$) else savedata(g_idSavePrDataID, l_FileName$) endif g_FileSaveProcess = 0 g_XMeasPos(l_MeasIndex) = g_XPos(l_CurrentPosition) ! record the position of the good measurement g_YMeasPos(l_MeasIndex) = g_YPos(l_CurrentPosition) gosub GET_Z if ( g_CollectingData = 0 ) then goto BEG_STITCH_3D_EXIT g_ZMeasPos(l_MeasIndex) = tmp_z_pos l_CurrentPosition = l_CurrentPosition + 1 l_MeasIndex = l_MeasIndex + 1 goto STITCH_3D_LOOP_CONT BEG_STITCH_3D_NEXT_STEP: g_CollectingData = 0 joyon gosub DOSTITCH BEG_STITCH_3D_EXIT: g_CollectingData = 0 return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub DOSTITCH() | ! ! | Do stitch runs stitch.exe to combine all the data files. | ! ! | | ! ! | In Parameters: | ! ! | g_NumMeas | ! ! | g_bUNIX | ! ! | g_MPBinDir$ | ! ! | g_CoordFile$ | ! ! | | ! ! | Out Parameters: | ! ! | | ! ! | Local Variables: | ! ! | l_msg$ | ! ! | ret_Dialog | ! ! | l_FileName$ | ! ! | l_nTemp | ! ! | | ! ! | Procedures Called: | ! ! | CREATE_COORDF | ! ! | SAVE_SEQ | ! ! | UPDATE_CNTRLS | ! ! | STCH_ERROR | ! ! | GENERAL_ERROR (on error) | ! ! | EXIT_STITCH | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! DOSTITCH: ! flag to say that we tried stitching the data g_DoStitch = 1 if (g_NumMeas = 0) then g_dlgMessage$ = " No Valid measurements, Stitching Aborted " g_dlgStyle = DlgError_OK gosub DO_DIALOG goto DOSTITCH_EXIT endif l_FileName$ = "stitch.dat" if (g_bUNIX = 1) then l_nTemp = execute("rm -f " & l_FileName$) else l_nTemp = execute("erase /f /q " & l_FileName$) endif gosub CREATE_COORDF ! create coord file if (g_StitchType <> ManualStitch) then ! this has already been done for manual stitching gosub SAVE_SEQ endif l_msg$ = g_MPBinDir$ & "stitch " & g_CoordFile$ if (g_bUNIX = 1) then l_nTemp = execute(" csh -c rm -f " & g_LogFile$ ) ! delete the log file in case its read only l_nTemp = execute(" csh -c " & l_msg$ & " > " & g_LogFile$) ! redirect stdout to log else l_nTemp = execute(" cmd /c del /f /q " & g_LogFile$ ) ! delete the log file in case its read only l_nTemp = execute(" cmd /c " & l_msg$ & " > " & g_LogFile$) ! redirect stdout to log endif if (l_nTemp <> 0) then gosub STCH_ERROR endif g_MesaureMessage$ = " Complete " gosub UPDATE_CNTRLS ! we need to update these, when data loaded these are cleared g_Error = 0 ! for Zip Stitch goto DOSTITCH_EXIT DOSTITCH_EXIT: gosub EXIT_STITCH return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub DOSTITCH_2() | ! ! | Do stitch runs stitch.exe to combine all the data files, once for the upper | ! ! | surface and again for the lower surface. | ! ! | | ! ! | In Parameters: | ! ! | g_NumMeas | ! ! | g_bUNIX | ! ! | g_MPBinDir$ | ! ! | g_CoordFile$ | ! ! | | ! ! | Out Parameters: | ! ! | | ! ! | Local Variables: | ! ! | l_msg$ | ! ! | ret_Dialog | ! ! | l_FileName$ | ! ! | l_nTemp | ! ! | | ! ! | Procedures Called: | ! ! | CREATE_COORDF | ! ! | SAVE_SEQ | ! ! | UPDATE_CNTRLS | ! ! | STCH_ERROR | ! ! | GENERAL_ERROR (on error) | ! ! | EXIT_STITCH | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! DOSTITCH_2: ! flag to say that we tried stitching the data g_DoStitch = 1 if (g_NumMeas = 0) then g_dlgMessage$ = " No Valid measurements, Stitching Aborted " g_dlgStyle = DlgError_OK gosub DO_DIALOG goto DOSTITCH_2_EXIT endif gosub CREATE_COORDF_2 ! create coord file l_FileName$ = "stitch.dat" if (g_bUNIX = 1) then l_nTemp = execute("rm -f " & l_FileName$) else l_nTemp = execute("erase /f /q " & l_FileName$) endif l_msg$ = g_MPBinDir$ & "stitch " & g_TempDir$ & g_PathSep$ & "stch_upper" & g_PathSep$ & "coords.crd" if (g_bUNIX = 1) then l_nTemp = execute(" csh -c rm -f " & g_LogFile$ ) ! delete the log file in case its read only l_nTemp = execute(" csh -c " & l_msg$ & " > " & g_LogFile$) ! redirect stdout to log l_nTemp = execute(" csh -c mv " & l_FileName$ & " stitch_upper.dat") else l_nTemp = execute(" cmd /c del /f /q " & g_LogFile$ ) ! delete the log file in case its read only l_nTemp = execute(" cmd /c " & l_msg$ & " > " & g_LogFile$) ! redirect stdout to log l_nTemp = execute(" cmd /c move " & l_FileName$ & " stitch_upper.dat") endif if (l_nTemp <> 0) then gosub STCH_ERROR endif if (g_bUNIX = 1) then l_nTemp = execute("rm -f " & l_FileName$) else l_nTemp = execute("erase /f /q " & l_FileName$) endif if (g_StitchType <> ManualStitch) then ! this has already been done for manual stitching gosub SAVE_SEQ endif l_msg$ = g_MPBinDir$ & "stitch " & g_TempDir$ & g_PathSep$ & "stch_lower" & g_PathSep$ & "coords.crd" if (g_bUNIX = 1) then l_nTemp = execute(" csh -c rm -f " & g_LogFile$ ) ! delete the log file in case its read only l_nTemp = execute(" csh -c " & l_msg$ & " > " & g_LogFile$) ! redirect stdout to log l_nTemp = execute(" csh -c mv " & l_FileName$ & " stitch_lower.dat") else l_nTemp = execute(" cmd /c del /f /q " & g_LogFile$ ) ! delete the log file in case its read only l_nTemp = execute(" cmd /c " & l_msg$ & " > " & g_LogFile$) ! redirect stdout to log l_nTemp = execute(" cmd /c move " & l_FileName$ & " stitch_lower.dat") endif if (l_nTemp <> 0) then gosub STCH_ERROR endif g_MesaureMessage$ = " Complete " gosub UPDATE_CNTRLS ! we need to update these, when data loaded these are cleared g_Error = 0 ! for Zip Stitch goto DOSTITCH_2_EXIT DOSTITCH_2_EXIT: gosub EXIT_STITCH return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub STCH_ERROR() | ! ! | Displays an error message and asks if the user wants to view the pasted image. | ! ! | | ! ! | In Parameters: | ! ! | g_LogFile$ | ! ! | g_MPBinDir$ | ! ! | g_bUNIX | ! ! | | ! ! | Out Parameters: | ! ! | g_bFit | ! ! | g_bAverageOverlap | ! ! | g_Error (for Zip) | ! ! | | ! ! | Local Variables: | ! ! | #ErrFile | ! ! | l_tmpmsg1$ | ! ! | l_tmpmsg2$ | ! ! | l_tmpmsg3$ | ! ! | l_msg$ | ! ! | ret_Dialog | ! ! | | ! ! | Procedures Called: | ! ! | CREATE_COORDF | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! STCH_ERROR: assign @ErrFile to g_LogFile$ "r" l_tmpmsg2$ = "" g_FileReadProcess = 1 KEEPREADING: enterline @ErrFile; l_tmpmsg3$ l_tmpmsg2$ = l_tmpmsg2$ & l_tmpmsg3$ & " \n " goto KEEPREADING ENDOFFILE: g_FileReadProcess = 0 assign @ErrFile to "" if (g_bFit <> 1) then goto STCH_ERROR_EXIT l_tmpmsg1$ = " error in Stitch Algorithm \n DIAGNOSTIC INFO \n " l_msg$ = "\n Do You Wish to view the Pasted Image? " g_dlgMessage$ = l_tmpmsg1$ & l_tmpmsg2$ & l_msg$ g_dlgStyle = DlgError_YesNo gosub DO_DIALOG if (ret_Dialog <> DlgOK_Yes) then goto STCH_ERROR_EXIT g_bFit = 0 g_bAverageOverlap = 0 gosub CREATE_COORDF ! create coord file l_msg$ = g_MPBinDir$ & "stitch " & g_CoordFile$ if (g_bUNIX = 1) then l_nTemp = execute(l_msg$ & " > " & g_LogFile$ & " 2>&1") !redirect stderr to log else l_nTemp = execute(l_msg$ & " > " & g_LogFile$) !redirect to log endif if (l_nTemp = 0) then g_Error = 0 ! for Zip Stitch else g_dlgMessage$ = " error in Stitch Algorithm with fitting removed " g_dlgStyle = DlgError_OK gosub DO_DIALOG endif STCH_ERROR_EXIT: gosub EXIT_STITCH return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub EXIT_STITCH() | ! ! | Does a clean up of the temp and moves the stage to the first position. | ! ! | | ! ! | In Parameters: | ! ! | g_bDiagnostic | ! ! | g_bUNIX | ! ! | g_XPos | ! ! | g_YPos | ! ! | g_ZPos | ! ! | g_DoStitch | ! ! | g_NumMeas | ! ! | g_ReturnWhenDone | ! ! | | ! ! | Out Parameters: | ! ! | | ! ! | Local Variables: | ! ! | tmp_x_pos | ! ! | tmp_y_pos | ! ! | tmp_z_pos | ! ! | ret_Dialog | ! ! | l_msg$ | ! ! | | ! ! | Procedures Called: | ! ! | CLEAN_TMP_DIR | ! ! | MOVE_XY | ! ! | GET_Z | ! ! | MOVE_Z | ! ! | DOSTITCH | ! ! | | ! ! | Algorithm: | ! ! +-----------------------------------------------------------------------------------------+ ! EXIT_STITCH: g_IgnoreError = g_IgnoreError + 1 on error gosub RESUME_NEXT if ((g_DoStitch = 0) and (g_HaveData = 1)) then g_dlgStyle = DlgNormal_YesNo g_dlgMessage$ = " data has not been stitched. \n Stitch data now? " ret_Dialog = DlgNo gosub DO_DIALOG if (ret_Dialog = DlgOK_Yes) then ! last measurement doesn't count g_NumMeas = l_MeasIndex - 1 gosub DOSTITCH endif endif g_IgnoreError = g_IgnoreError - 1 if ( g_IgnoreError = 0 ) then on error goto CENTRAL_ERROR_HANDLER if ((g_bDiagnostic <> 1) and (g_bUNIX = 1)) then gosub CLEAN_TMP_DIR if (g_ReturnWhenDone = 1 and g_bStageRetry = 0) then tmp_x_pos = g_XPos(1) tmp_y_pos = g_YPos(1) gosub MOVE_XY_NO_ERROR ! only move Z if move is in the positive direction gosub GET_Z_NO_ERROR if (tmp_z_pos < g_ZPos(1)) then tmp_z_pos = g_ZPos(1) gosub MOVE_Z_NO_ERROR endif endif EXIT_STITCH_EXIT: !gosub CHK_USER_ABORT !goto HALT_SCRIPT return ! +-----------------------------------------------------------------------------------------+ ! ! | Sub CENTRAL_ERROR_HANDLER() | ! ! | Handles errors of various types in a central place. Input parameters specify which | ! ! | type of error needs to be handled. | ! ! | | ! ! | In Parameters: | ! ! | | ! ! | Out Parameters: | ! ! | | ! ! | Local Variables: | ! ! | | ! ! | Procedures Called: | ! ! | | ! ! | Algorithm: | ! ! | 1) Always check for user abort. If ESC pressed during measurement, then ask if the | ! ! | wants to continue. Otherwise display abort message and exit the script. | ! ! | 2) Get the type of handler from the top of the stack, defaulting to | ! ! | "Display and Halt". Take the appropriate action for the handler type. | ! ! | | ! ! | Type of Error Handlers | ! ! | RESUME_NEXT --> Ignores errors. | ! ! | DISPLAY_AND_HALT --> Display error message and exit script. | ! ! | END_OF_FILE --> goto ENDOFFILE | ! ! | FILE_SAVE_ERROR --> Display error message exit script. | ! ! | MEASURE_ERROR --> Action depends on Failure Action Control setting. | ! ! | STAGE_ERROR --> Display error and exit script. | ! ! +-----------------------------------------------------------------------------------------+ ! CENTRAL_ERROR_HANDLER: joyon ! Check for user abort gosub CHK_USER_ABORT if ( g_bUserAbort <> 0 ) then goto CEH_CONTINUE_OR_ABORT ! Check for the type of handler if ( g_IgnoreError <> 0 ) then goto CEH_RESUME_NEXT if ( g_FileSaveProcess <> 0 ) then goto CEH_FILE_SAVE if ( g_FileReadProcess <> 0 ) then goto CEH_END_OF_FILE if ( g_MeasureProcess <> 0 ) then goto CEH_MEASURE if ( g_StageProcess <> 0 ) then goto CEH_STAGE goto CEH_DISPLAY_AND_HALT CEH_CONTINUE_OR_ABORT: if ( g_CollectingData <> 0 ) then ! Ask if they want to continue g_dlgMessage$ = " Do you want to continue with the stitch? " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG if ( ret_Dialog = DlgOK_Yes ) then gosub CLEAR_USER_ABORT goto STITCH_LOOP_CONT endif endif goto CEH_EXIT_STITCH CEH_RESUME_NEXT: error return CEH_END_OF_FILE: g_FileReadProcess = 0 goto ENDOFFILE CEH_FILE_SAVE: ! Turn off the process flag g_FileSaveProcess = 0 g_dlgMessage$ = " Error saving temp file " & l_FileName$ & ". \n Check file permissions and restart. " g_dlgStyle = DlgError_OK gosub DO_DIALOG goto CEH_EXIT_STITCH CEH_MEASURE: ! Turn off the process flag g_MeasureProcess = 0 if ( g_OnStitchMeasureError = oeaStop ) then g_dlgMessage$ = " Measurement error, Stitching Stopped " g_dlgStyle = DlgError_OK gosub DO_DIALOG g_ReturnWhenDone = 0 goto CEH_EXIT_STITCH endif if ( g_OnStitchMeasureError = oeaAbort ) then g_dlgMessage$ = " Measurement error, Stitching Aborted " g_dlgStyle = DlgError_OK gosub DO_DIALOG g_ErrorReturn = 0 goto CEH_EXIT_STITCH endif if ( g_OnStitchMeasureError = oeaRetry ) then if ( g_RetryCount = 0 ) then g_RetryCount = 1 goto STITCH_LOOP_CONT else g_dlgMessage$ = " Second Measurement error, Stitching Aborted " g_dlgStyle = DlgError_OK gosub DO_DIALOG endif goto CEH_EXIT_STITCH endif ! Otherwise g_OnStitchMeasureError = oeaContinue l_CurrentPosition = l_CurrentPosition + 1 ! want to inc this g_NumMeas = g_NumMeas - 1 goto STITCH_LOOP_CONT CEH_STAGE: ! Turn off the process flag g_StageProcess = 0 l_msg$ = "" if ( x_axis_active = 0 ) then l_msg$ = " Stage error. \n X axis is inactive. " else if ( y_axis_active = 0 ) then l_msg$ = " Stage error. \n Y axis is inactive. " else l_msg$ = " Stage error. \n Stage must be homed to stitch. " endif endif g_dlgMessage$ = l_msg$ & "\n Stitching Aborted. " g_dlgStyle = DlgError_OK gosub DO_DIALOG goto CEH_EXIT_STITCH CEH_DISPLAY_AND_HALT: g_dlgMessage$ = " Error running script: \n " & errm$ g_dlgStyle = DlgError_OK gosub DO_DIALOG goto CEH_CONTINUE_OR_ABORT CEH_EXIT_STITCH: !if ( g_CentralErrorHalt <> 0 ) then if ( g_ExitStitchExists <> 0 ) then gosub EXIT_STITCH ! Increment the Zip-Stitch RealNumZips if value = 0 and stitched data if ( g_ExitZipStitchExists <> 0 ) then if ( (g_RealNumZips = 0) and (g_DoStitch <> 0) ) then g_IncrementedRealNumZips = 1 g_RealNumZips = g_RealNumZips + 1 ! Copy the stitched data file to the expected zip filename if ((g_bUNIX = 1)) then l_sTemp$ = g_TempDir$ & "/zipx" & val$(l_nZipLoop) & ".dat" l_nTemp = execute("mv " & g_StitchFile$ & " " & l_sTemp$) else l_sTemp$ = g_TempDir$ & "\\zipx" & val$(l_nZipLoop) & ".dat" l_nTemp = execute("copy " & g_StitchFile$ & " " & l_sTemp$) endif endif endif g_dlgMessage$ = " Stitch Aborted " g_dlgStyle = DlgError_OK gosub DO_DIALOG endif if ( g_ExitZipScanExists <> 0 ) then g_dlgMessage$ = " Do you want to view the data? " g_dlgStyle = DlgError_YesNo gosub DO_DIALOG if (ret_Dialog = DlgOK_Yes) then goto VIEWDATA else goto EXIT_ZIP_SCAN endif endif if ( g_ExitZipStitchExists <> 0 ) then if ( (g_CollectingZipData <> 0) and (g_DoStitch = 1) ) then ! Ask if they want to continue g_dlgMessage$ = " Do you want to continue with the zip-stitch? " g_dlgStyle = DlgNormal_YesNo gosub DO_DIALOG if ( ret_Dialog = DlgOK_Yes ) then ! Undo the increment of RealNumZips if needed if ( g_IncrementedRealNumZips <> 0 ) then g_IncrementedRealNumZips = 0 g_RealNumZips = g_RealNumZips - 1 endif gosub CLEAR_USER_ABORT goto ZIP_STITCH_LOOP_CONT endif endif gosub ZIP_EXIT endif ! reset Auto Focus and Tilt back to the original values if ( g_idAutoFocusCntl <> 0 ) then setnum(g_idAutoFocusCntl, tmpFocus, "") endif if ( g_idAutoTiltCntl <> 0 ) then setnum(g_idAutoTiltCntl, tmpTilt, "") endif goto HALT_SCRIPT !endif error return loadsub 'reStitchSubs.scr'