--+-----------------------------------------------------------------------------+ --+ SOHO Project -- Control File --+ ---------------------------- --+ --+ Name : MDI_LASER , !Proc_s , !Print --+ Purpose : (See Procedure header) --+ --+ Sub_system : PLM --+ Drawing No : 3137-ZA042-SCB Issue : A/00 --+ Project No : SH-MAR-SW-70224 --+ Origin : UK --+ Author : Jon B. CARTER --+-----------------------------------------------------------------------------+ --+ Principle : --+ --------- --+ Holding CF for a group of related Procedures, originally written in --+ MDI's own Control File language. --+ --+ --+ Passed parameters : --+ ----------------- --+ !Proc_s : Name of required Procedure. --+ !Print : CF Log print indicator ( "yes" (default) | "no" ). --+ --+ Prerequisites : --+ ------------- --+ Control File MDI_ON must have been successfully performed. --+ --+ History : --+ ------- --+ Issue SIC Note Time Date Name / Updates --+ +---+ +------+ +---+ +------+ +------------------------------------------+ --+ 1/00 289 20:42 08/02/94 Jon B. CARTER -- First Issue. --+ 1/02 360 10:30 26/04/94 Ed COBB -- Rationalization. --+ 1/03 393 10:05 20/05/94 Ed COBB -- MDI Updates. --+ 1/04 406 13:13 24/05/94 Ed COBB -- MDI Updates. --+ 1/07 443 15:39 17/06/94 Ed COBB -- CF Errors. --+ 2/01 477 19:16 19/09/94 Ed COBB / Ph. IATRINO -- MDI Updates. --+ 2/02 486 13:15 11/10/94 Ph. IATRINO -- modified. --+ 2/03 544 17:43 01/02/95 Ph. IATRINO -- MDI Updates. --+ 2/04 572 19:00 17/03/95 O. MICHEL -- MDI Updates. --+ --+-----------------------------------------------------------------------------+ Common Var Bool !GZ_Window -- Open window flag (on CF start) Bool !GZ_Spool -- Automatic Spool (at End of CF exec) Bool !GZ_Halt -- Check Error flag (to halt if error) Bool !GZ_Test -- Execution test flag (to not send TC) Int !GZ_Trace -- Level of Trace (TBD) Int !GM_NbErr -- MDI Global Error Count Int !GM_Conf -- MDI Configuration Str(80) !GM_S0 Str(80) !GM_S8 Int !GM_I0 Int !GM_I1 Int !GM_I2 Int !GM_I3 Int !GM_I4 Int !GM_I5 Int !GM_I9 End Common --------------------------------------------------------------------------------+ Extern Cfile MDI_LSRETC , MDI_LLT , MDI_LAM , MDI_LIP , MDI_MODE , PLM_BLOCK Cfile MDI_INTRRPT Group MWTM , PWP12TM Procedure AskReal , AskStr , AskInt Procedure CheckAna , CheckDig , CheckReg Procedure CheckArgReal , CheckArgStr , CheckArgInt Procedure DispMess Procedure ExConnect , ExDisconnect Procedure ExitCF Procedure Message Procedure OpenWindow Procedure PrintAna , PrintDig , PrintReg , PrintParam Procedure SendCommand Procedure Lower , Upper Procedure WaitAna , WaitDig , WaitReg , WaitTime End Extern --------------------------------------------------------------------------------+ Program MDI_LASER , Unique Defarg Str(80) !Proc_s Str(3) !Print = "yes" End Defarg Var Str( 3) !ExpName = "MDI" Int !NbErr = 0 Str(49) !Title = " " str(80) !S = &80s(" ") Main @OpenWindow() Select !Proc_s Case "mdilaser" @mdilaser() Default !Title = "*ERROR: UNKNOWN PROCEDURE: "+!Proc_s @Message("DCL" , "date" , !ExpName , " " , !Title , *!S) -- Beep Halt !Title = "*Operator CONTinue" @Message("DC" , "date" , !ExpName , " " , !Title , *!S) Return !Rstat End Select @ExitCF (!NbErr) @PrintCF ( !ExpName , !Print ) Return !Rstat End Program --------------------------------------------------------------------------------+ Procedure mdilaser ( ) --. --. Moves the legs to the 9 positions "around the clock" if --. desired (else stays at centre pointing) and performs a --. "dust-hunt" and a short de-tune at each position. --. Var Str( 3) !ExpName = "MDI" Str(10) !Phase = "" Str(49) !Title = "" Str(80) !S = &80s("") Int !NbErr = 0 Str(80) !Question = "" Str(80) !Check = "" Str(80) !Resp_s = "" Str(10) !Time = "" Str(80) !Get_Dig = "" Real !Get_Real = 0.0 Int !LM_I0 Int !LM_I1 Int !LM_I2 Int !LM_I3 Int !LM_I9 Int !RI Main !Title = "-EXECUTING PROCEDURE: mdilaser." @Message( "DCL" , "date" , !ExpName , !Phase , !Title , *!S ) @SendCommand ( "MBCMSUMM" , "1 , 1" ) PERFORM/NO MDI_LIP , "liplbic5" , "no" !Title = "~Taking full (summed) 256x256" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ( "MBCMAADC" , "3" ) !Title = "~CCD amplifier A, offset: 3" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !Question = "NEED TO ALIGN LASER? (Y/N)" !Check = "in Y, N, y, n" @AskStr (!Question, !Check, *!Resp_s, *!S, *!NbErr) @Upper (!Resp_s, *!Resp_s) !GM_I0 = 2000 !GM_I9 = 7 If !Resp_s = "Y" then PERFORM/NO MDI_MODE , "lobsmode" , "no" EXECUTE MDI_INTRRPT , "Type 'YES' when image is centered" @WaitTime ("00h00m05s" , *!S) PERFORM/NO MDI_LLT , "llttaps" , "no" End If @WaitTime ( "00h00m05s" , *!S ) !Question = "READY FOR DETUNE? (Y/N)" !Check = "in Y, N, y, n" @AskStr (!Question, !Check, *!Resp_s, *!S, *!NbErr) @Upper (!Resp_s, *!Resp_s) If !Resp_s = "Y" then !GM_I4 = 51 !GM_I5 = 103 !GM_I0 = 8000 @varcmd ("MBDPCONF", &d( !GM_I4 ) + ", " + &d( !GM_I5 ) + \ ", 125, 19, 125") PERFORM/NO MDI_LSRETC , "lasdtune" , "no" PERFORM/NO MDI_MODE , "lcalmode" , "no" End If !Question = "Best MTM 1 tuning?" @AskInt ( !Question , ">=0 and <=179" , *!GM_I4 , *!S , *!NbErr ) !Title = "Using MTM 1 tuning " + &d( !GM_I4 ) @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !Question = "Best MTM 2 tuning?" @AskInt ( !Question , ">=0 and <=179" , *!GM_I5 , *!S , *!NbErr ) !Title = "Using MTM 2 tuning " + &d( !GM_I5 ) @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @varcmd ( "MBDPCONF" , &d( !GM_I4 ) + " , " + &d( !GM_I5 ) + \ " , 125 , 19 , 125" ) @SendCommand ( "MBCMTP1R" , "0XC014 , 1000 , 1000" ) @WaitTime ("00h00m15s",*!S) @SendCommand ( "MBCMTP1R" , "0XC014 , 2000 , 2000" ) @WaitTime ("00h00m15s",*!S) @SendCommand ( "MBCMTP1R" , "0XC014 , 4000 , 4000" ) @WaitTime ("00h00m15s",*!S) @SendCommand ( "MBCMTP1R" , "0XC014 , 8000 , 8000" ) @WaitTime ("00h00m15s",*!S) @SendCommand ( "MBCMTP1R" , "0XC014 , 16000 , 16000" ) @WaitTime ("00h00m20s",*!S) !GM_I0 = 8000 !Question = "Exposure time ?('0' for default)" @AskInt ( !Question , ">= 0 and <= 64000" , *!RI , *!S , *!NbErr ) If !RI > 0 Then !GM_I0 = !RI End If !GM_I1 = 120 !GM_I9 = !GM_I0 / 4000 !GM_I9 = !GM_I9 + 2 If !GM_I9 < 15 Then !GM_I9 = 15 End If @Time_To_Text( !GM_I9 , *!Time ) !Title = "Exposure time (ticks) = " + &d( !GM_I0 ) @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !Title = "Wait time (seconds) = " + &d( !GM_I9 ) @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !Get_Dig = Get( "MKPWAM" ) If !Get_Dig <> "ON" Then !Title = "Legs are OFF; Turning them ON" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) PERFORM/NO MDI_LAM , "lamon" , "no" End If ##AGAIN !Question = "Centre the legs? (Y/N)" !Check = "in Y, y, N, n" @AskStr ( !Question , !Check , *!GM_S0 , *!S , *!NbErr ) @Upper (!GM_S0 , *!GM_S0) If (!GM_S0 = "Y") Then PERFORM/NO MDI_LAM , "lamcntr" , "no" End If !Question = "Enter radius in arcsec" @AskInt ( !Question , ">= 0 and <= 770" , *!LM_I9 , *!S , *!NbErr ) @WaitTime ("00h00m05s" , *!S ) !Question = "MDI Open Decom file(Y)" !Check = "in Y, y" @AskStr ( !Question , !Check , *!GM_S0 , *!S , *!NbErr ) !Title = "Soft DARK " + &d( !GM_I1 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d( !GM_I1 ) + ", " + &d( !GM_I1 ) ) @WaitTime ( !Time , *!S ) !GM_S0 = "centre" PERFORM/NO MDI_LSRETC , "lasdust" , "no" @WaitTime ( !Time , *!S ) !Title = "Soft DARK " + &d( !GM_I0 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d( !GM_I0 ) + ", " + &d( !GM_I0 ) ) @WaitTime ( !Time , *!S ) @LaserPrn () If !LM_I9 <> 0 Then !GM_I2 = 0 !GM_I3 = !LM_I9 PERFORM/NO MDI_LSRETC , "legsgoto" , "no" !Title = "~Going to 12 o'clock" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !GM_S0 = "12 o'clock" PERFORM/NO MDI_LSRETC , "lasdust" , "no" @WaitTime ( !Time , *!S ) !Title = "Soft DARK " + &d( !GM_I0 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d(!GM_I0) + ", " + &d(!GM_I0)) @WaitTime ( !Time , *!S ) @LaserPrn () -- !GM_I2 = Int( Real( !LM_I9 ) * 0.7071 ) !GM_I3 = Int( Real( !LM_I9 ) * -0.2929 ) PERFORM/NO MDI_LSRETC , "legsgoto" , "no" !Title = "~Going to 1:30 o'clock" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !GM_S0 = "1:30" PERFORM/NO MDI_LSRETC , "lasdust" , "no" @WaitTime ( !Time , *!S ) !Title = "Soft DARK " + &d( !GM_I0 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d(!GM_I0) + ", " + &d(!GM_I0)) @WaitTime ( !Time , *!S ) @LaserPrn () -- !GM_I2 = Int( Real( !LM_I9 ) * 0.2929 ) !GM_I3 = Int( Real( !LM_I9 ) * -0.7071 ) PERFORM/NO MDI_LSRETC , "legsgoto" , "no" !Title = "~Going to 3 o'clock" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !GM_S0 = "3 o'clock" PERFORM/NO MDI_LSRETC , "lasdust" , "no" @WaitTime ( !Time , *!S ) !Title = "Soft DARK " + &d( !GM_I0 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d(!GM_I0) + ", " + &d(!GM_I0)) @WaitTime ( !Time , *!S ) @LaserPrn () -- !GM_I2 = Int( Real( !LM_I9 ) * -0.2929 ) !GM_I3 = Int( Real( !LM_I9 ) * -0.7071 ) PERFORM/NO MDI_LSRETC , "legsgoto" , "no" !Title = "~Going to 4:30 o'clock" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !GM_S0 = "4:30" PERFORM/NO MDI_LSRETC , "lasdust" , "no" @WaitTime ( !Time , *!S ) !Title = "Soft DARK " + &d( !GM_I0 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d(!GM_I0) + ", " + &d(!GM_I0)) @WaitTime ( !Time , *!S ) @LaserPrn () -- !GM_I2 = Int( Real( !LM_I9 ) * -0.7071 ) !GM_I3 = Int( Real( !LM_I9 ) * -0.2929 ) PERFORM/NO MDI_LSRETC , "legsgoto" , "no" !Title = "~Going to 6 o'clock" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !GM_S0 = "6 o'clock" PERFORM/NO MDI_LSRETC , "lasdust" , "no" @WaitTime ( !Time , *!S ) !Title = "Soft DARK " + &d( !GM_I0 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d(!GM_I0) + ", " + &d(!GM_I0)) @WaitTime ( !Time , *!S ) @LaserPrn () -- !GM_I2 = Int( Real( !LM_I9 ) * -0.7071 ) !GM_I3 = Int( Real( !LM_I9 ) * 0.2929 ) PERFORM/NO MDI_LSRETC , "legsgoto" , "no" !Title = "~Going to 7:30 o'clock" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !GM_S0 = "7:30" PERFORM/NO MDI_LSRETC , "lasdust" , "no" @WaitTime ( !Time , *!S ) !Title = "Soft DARK " + &d( !GM_I0 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d(!GM_I0) + ", " + &d(!GM_I0)) @WaitTime ( !Time , *!S ) @LaserPrn () -- !GM_I2 = Int( Real( !LM_I9 ) * -0.2929 ) !GM_I3 = Int( Real( !LM_I9 ) * 0.7071 ) PERFORM/NO MDI_LSRETC , "legsgoto" , "no" !Title = "~Going to 9 o'clock" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !GM_S0 = "9 o'clock" PERFORM/NO MDI_LSRETC , "lasdust" , "no" @WaitTime ( !Time , *!S ) !Title = "Soft DARK " + &d( !GM_I0 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d(!GM_I0) + ", " + &d(!GM_I0)) @WaitTime ( !Time , *!S ) @LaserPrn () -- !GM_I2 = Int( Real( !LM_I9 ) * 0.2929 ) !GM_I3 = Int( Real( !LM_I9 ) * 0.7071 ) PERFORM/NO MDI_LSRETC , "legsgoto" , "no" !Title = "~Going to 10:30 o'clock" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) !GM_S0 = "10:30" Perform/No MDI_LSRETC , "lasdust" , "no" @WaitTime ( !Time , *!S ) !Title = "Soft DARK " + &d( !GM_I0 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d(!GM_I0) + ", " + &d(!GM_I0)) @WaitTime ( !Time , *!S ) @LaserPrn () -- !GM_I2 = Int( Real( !LM_I9 ) * 0.7071 ) !GM_I3 = Int( Real( !LM_I9 ) * -0.7071 ) PERFORM/NO MDI_LSRETC , "legsgoto" , "no" !Title = "~Going back to start position" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @WaitTime ( "00h00m45s" , *!S ) @PrintParam ( "MXAM1POS" , "ANA" ) @PrintParam ( "MXAM2POS" , "ANA" ) End If !Title = " Soft DARK " + &d( !GM_I1 ) + " ticks" @Message( "DC" , "time" , !ExpName , !Phase , !Title , *!S ) @SendCommand ("MBCMDRKR", "0XC014, " + &d(!GM_I1) + ", " + &d(!GM_I1)) @WaitTime ( !Time , *!S ) !Question = "MDI Close Decom file(Y)" !Check = "in Y, y" @AskStr ( !Question , !Check , *!GM_S0 , *!S , *!NbErr ) @WaitTime ( "00h00m05s" , *!S ) !Question = "Repeat the circle? (Y/N)" !Check = "in Y, y, N, n" @AskStr ( !Question , !Check , *!GM_S0 , *!S , *!NbErr ) @Upper( !GM_S0 , *!GM_S0 ) If !GM_S0 = "Y" Then Goto ##AGAIN End If !GM_NbErr = !GM_NbErr + !NbErr !Title = "-FINISHED PROCEDURE: mdilaser." @Message( "DCL" , "date" , !ExpName , !Phase , !Title , *!S ) Return End Procedure --------------------------------------------------------------------------------+ Procedure varcmd( Str(10) !Cmd_name , Str(80) !Cmd_data ) Var Str(1) !Expt_s Int !Code_i Int !Cmd_data_i(30) Int !No_of_cmds_i Int !Data_len_i Str(10) !Data_item_s Int !Commas_i Int !Count Int !Char_pos Str(1) !Char Str(80) !Cmd_data_s Str(80) !S = &80s(" ") Str( 3) !ExpName = "MDI" Str(10) !Phase = " " Str(49) !Title = " " Main !Expt_s = Extract( !Cmd_name , 1 , 1 ) If !Expt_s <> "M" Then !Title = "*ERROR: Non-MDI Command " + !Cmd_name @Message("DC" , "time" , !ExpName , " " , !Title , *!S) -- Beep Halt !Title = "*Operator CONTinue" @Message("DC" , "time" , !ExpName , " " , !Title , *!S) Return End If Select !Cmd_name Case "MBIPCMD" !Code_i = 0x0E !No_of_cmds_i = 0 Case "MBIPLDIN" !Code_i = 0x12 !No_of_cmds_i = 1 !Cmd_data_i(0) = 4 Case "MBDPML" !Code_i = 0x0A !No_of_cmds_i = 0 Case "MBDPCONF" !Code_i = 0x1D !No_of_cmds_i = 0 Default !Title ="*ERROR: Unrecognised Command " + !Cmd_name @Message("DC" , "time" , !ExpName , " " , !Title , *!S) -- Beep Halt !Title = "*Operator CONTinue" @Message("DC" , "time" , !ExpName , " " , !Title , *!S) Return End Select !Cmd_data_s = !Cmd_data + "," !Data_len_i = Len( !Cmd_data_s ) !Commas_i = 0 For !Char_pos = 1 to !Data_len_i !Char = Extract( !Cmd_data_s , !Char_pos , 1 ) If !Char = "," Then !Commas_i = !Commas_i + 1 End If End For For !Count = 1 To !Commas_i !Data_item_s = Splitstr( !Cmd_data_s , "," , !Count ) !Cmd_data_i( !No_of_cmds_i ) = Int( Val( !Data_item_s ) ) !No_of_cmds_i = !No_of_cmds_i + 1 End For PERFORM/NO PLM_BLOCK , "MDI" , !Code_i , !Cmd_data_i() , !No_of_cmds_i Return End Procedure --------------------------------------------------------------------------------+ Procedure PrintCF( str(3) !ExpName, str(8) !Print) --. Print the control file log file if required by !Print ; --. - using the 'Spool' statement if the variable !GZ_Spool is TRUE, --. - using the dialog box window if the variable !GZ_Spool is FALSE. --. Var str(80) !S = &80s("") Main If !Print = "yes" Then If !GZ_Spool = TRUE Then Spool CF Else Cflog @Message( "DC", "date", !ExpName, " ", \ "++++Print the CFLog, then type CONT+++", *!S) Halt @Message( "DC", "date", !ExpName, " ", \ "+Operator continue.", *!S) End If End If Return End Procedure --------------------------------------------------------------------------------+ Procedure Time_To_Text (Int !Stime, Str(10) *!Text) --. Convert a time passed in seconds to a string as "hh:mn:ss". --. The number of hours is limited to 999 with no error reported. Var Int !hour = 0 Int !minute = 0 Int !second = 0 Main CALL Hh_mn_ss(!Stime, *!hour, *!minute, *!second) !Text = &02d(!hour) + "h" + &02d(!minute)+ "m"+ &02d(!second) +"s" Return End Procedure --------------------------------------------------------------------------------+ Procedure Hh_mn_ss(Int !STime, Int *!hour, Int *!minute, Int *!second) --. Compute and return the number of hour, minute and second from an interger --. number of seconds. Var Int !Tmp Main !Tmp = !STime !hour = !Tmp / 3600 !Tmp = !Tmp Mod 3600 !minute = !Tmp / 60 !second = !Tmp Mod 60 Return End Procedure --------------------------------------------------------------------------------+ Procedure LaserPrn( ) Var Str(1) !Expt_s Str(49) !Title = "Short Detune" Str(80) !S = &80s("") Main @Message( "DC", "time", "MDI", " ", !Title , *!S) PERFORM/NO MDI_LSRETC , "lasdtune" , "no" @PrintParam ( "MXAM1POS" , "ANA" ) @PrintParam ( "MXAM2POS" , "ANA" ) Return End Procedure --------------------------------------------------------------------------------+