!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Simple observing modes (pointing and tracked) setup
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
begin procedure 30m-setup-simple-mode-definitions
  if .not.exist(setup30m%front) then
     define structure setup30m%front /global
     define integer setup30m%front%n /global
     define character setup30m%front%name*4[2] /global
  endif
  !
  define command 30MSETUP\TRACK    "@ 30m-setup-track-def"
  define command 30MSETUP\POINTING "@ 30m-setup-point-create-pro"
end procedure 30m-setup-simple-mode-definitions
!  
begin procedure 30m-setup-simple-mode-defaults
  let setup30m%front%n 2
  let setup30m%front%name "e090" "e230"
end procedure 30m-setup-simple-mode-defaults
!
begin procedure 30m-setup-simple-mode-reset-out
end procedure 30m-setup-simple-mode-reset-out
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Pointing
!
begin procedure 30m-setup-point-create-pro
  sic output 'setup30m%file%point'
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    say "!"
    say "if (""&"'1'"none"".eq.""none"") then"
    say "   say ""E-POINT, Only one parameter needed: source name"""
    say "   return base"
    say "endif"
    say "!"
    say "source ""&"'1'""" /cat * /vel lsr "'setup30m%source%inp%vlsr'
    say "offset /clear"
!!$    for ifront 1 to setup30m%front%n
!!$       if (setup30m%front%numb[ifront].ge.9) then
!!$          say "rece hera1 /derot 0 f"
!!$       endif
!!$    next ifront
    say "!"
    say "back /clear"
    say "backend bbc /default"
    say "!"
    say "swbeam"
    say "!"
    say "cal /def"
    say "start"
    say "!"
    say "point /def"
    say "start"
    say "!"
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  sic output
end procedure 30m-setup-point-create-pro
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Track observing mode 
!
begin procedure 30m-setup-track-psw-create-pro
  sic output 'setup30m%file%psw'
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    say "!"
    say "! J.Pety (2006-2019)"
    say "!"
    say "! Simple procedure for position switch track observations"
    say "!"
    say "! Mandatory input parameters:"
    say "!     #1: source name"
    say "!     #2: on  lambda offset [arcsec]"
    say "!     #3: on  beta   offset [arcsec]"
    say "!     #4: off lambda offset [arcsec]"
    say "!     #5: off beta   offset [arcsec]"
    say "!"
    say "! Observing mode: Position switch"
    say "! 1 start = 3 min on source"
    say "!"
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    say "!"
    say "if (""&"'5'"none"".eq.""none"") then"
    say "   say ""E-TRACK-PSW, Missing input parameters"""
    say "   say ""E-TRACK-PSW, Calling sequence: @ ~/"'setup30m%file%psw'" source lam-on-pos bet-on-pos lam-off-pos bet-off-pos"""
    say "   return base"
    say "endif"
    say "!"
    say "@ ~/"'setup30m%file%back'
    say "!"
    ! *** JP I changed the tphase from 0.5 to 1.25 to save disk space when using FTS
    !        However, we loose 5% of observing time doing this...
    say "swtotal /tphase 1.25 ! small value to avoid loosing time at start and end of subscan"
    say "!"
    say "set angle arcsec"
    say "source ""&"'1'""""
    say "offset /clear"
    say "!"
    say "cal /def"
    say "start"
    say "!"
    say "! OFF positions"
    say "define double offpos[2]"
    say "let offpos '&"'4'"' '&"'5'"'"
    say "! 3 minutes on source per scan (6 * 30 sec)"
    say "onoff '&"'2'"' '&"'3'"' /sww no /sys proj /tsub 30 /nsub 12 /symmetric yes /ref 'offpos[1]' 'offpos[2]' proj"
    say "start"
    say "!"
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  sic output
end procedure 30m-setup-track-psw-create-pro
!
begin procedure 30m-setup-track-wsw-create-pro
  sic output 'setup30m%file%wsw'
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    say "!"
    say "! J.Pety (2006-2019)"
    say "!"
    say "! Simple procedure for wobbler switch track observations"
    say "!"
    say "! Mandatory input parameters:"
    say "!     #1: source name"
    say "!     #2: x offset"
    say "!     #3: y offset"
    say "!     #4: throw amplitude"
    say "!     #5: phase time"
    say "!"
    say "! Observing mode: Position switch"
    say "! 1 start = 3 min on source"
    say "!"
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    say "!"
    say "if (""&"'5'"none"".eq.""none"") then"
    say "   say ""E-TRACK-WSW, Missing input parameters"""
        say "   say ""E-TRACK-WSW, Calling sequence: @ ~/"'setup30m%file%wsw'" source xoff yoff"""
!    say "   say ""E-TRACK-WSW, Calling sequence: @ ~/"'setup30m%file%wsw'" source xoff yoff [throw tphase]"""
    say "   return base"
    say "endif"
    say "!"
    say "@ ~/"'setup30m%file%back'
    say "!"
    say "swwobbler " '-setup30m%switch%wobthrow' '+setup30m%switch%wobthrow' " /tphase 1.0" -
           /format a10 f8.3 f8.3 a
!    say "swwobbler '-&"'4'"' '&"'4'"' /tphase '&"'5'"'"
    say "!"
    say "set angle arcsec"
    say "source ""&"'1'""""
    say "offset /clear"
    say "offset '&"'2'"' '&"'3'"'"
    say "!"
    say "cal /def"
    say "start"
    say "!"
    say "! 3 minutes on source per scan (6 * 30 sec)"
    say "onoff /sww yes /tsub 30 /nsub 12 /symmetric yes"
    say "start"
    say "!"
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  sic output
end procedure 30m-setup-track-wsw-create-pro
!
begin procedure 30m-setup-track-fsw-create-pro
  sic output 'setup30m%file%fsw'
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    say "!"
    say "! J.Pety (2006-2019)"
    say "!"
    say "! Simple procedure for frequency switch track observations"
    say "!"
    say "! Mandatory input parameters:"
    say "!     #1: source name"
    say "!     #2: on lambda offset [arcsec]"
    say "!     #3: on beta   offset [arcsec]"
    say "!"
    say "! Observing mode: Frequency switch"
    say "! 1 start = 2.5 min on source"
    say "!"
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    say "!"
    say "if (""&"'3'"none"".eq.""none"") then"
    say "   say ""E-TRACK-FSW, Missing input parameters"""
    say "   say ""E-TRACK-FSW, Calling sequence: @ ~/"'setup30m%file%fsw'" source lam-offset bet-offset"""
    say "   return base"
    say "endif"
    say "!"
    say "@ ~/"'setup30m%file%back'
    say "!"
    pause
    for ifront 1 to setup30m%front%n
       say "swf " '-setup30m%switch%freqthrow[ifront]' '+setup30m%switch%freqthrow[ifront]' " /tphase 0.5 /rece "'setup30m%front%name[ifront]' -
           /format a3 f8.3 f8.3 a
    next ifront
    say "!"
    say "set angle arcsec"
    say "source ""&"'1'""""
    say "offset /clear"
    say "!"
    say "cal /def"
    say "start"
    say "!"
    say "! 2.5 minutes on source per scan (5 * 30 sec)"
    say "track '&"'2'"' '&"'3'"' /sys proj /tsub 30 /nsub 5"
    say "start"
    say "!"
    say "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  sic output
end procedure 30m-setup-track-fsw-create-pro
!
begin procedure 30m-setup-track-def
  if (pro%narg.ne.1) then
     message e track "Usage: TRACK PSW|WSW|FSW"
     return base
  else
     define character mode*12
     let mode 'pro%arg[1]' /lower
     if (mode.eq."psw") then
        @ 30m-setup-track-psw-create-pro
     else if (mode.eq."wsw") then
        @ 30m-setup-track-wsw-create-pro
     else if (mode.eq."fsw") then
        @ 30m-setup-track-fsw-create-pro
     else
        message e track "Needs PSW, WSW, or FSW as argument"
     endif
  endif
end procedure 30m-setup-track-def
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Widget
!
begin procedure 30m-setup-simple-mode-widget
  gui\panel "30m Heterodyne Simple Mode Setup Facility (J.Pety)" gag_scratch:30m-setup-switch.hlp
     @ 30m-setup-widget-step simple
     gui\menu "MODE" /choices
        gui\button "@ 30m-setup-point-create-pro"   "Pointing"
        gui\button "@ 30m-setup-track-def psw"      "PSW"
        gui\button "@ 30m-setup-track-def wsw"      "WSW"
        gui\button "@ 30m-setup-track-def fsw"      "FSW"
     say ""
     say "PSW parameters"
     let setup30m%switch%offpos 'setup30m%switch%offpos[1]' 'setup30m%switch%offpos[2]' /prompt "PSW reference offsets [arcsec]"
     say ""
     say "WSW parameters"
     let setup30m%switch%wobthrow 'setup30m%switch%wobthrow' /prompt "WSW throw [arcsec]"
     say ""
     say "FSW parameters"
     let setup30m%front%n 'setup30m%front%n' /prompt "Number of receiver bands (1 or 2)"
     let setup30m%front%name[1] 'setup30m%front%name[1]' /prompt "band name #1"
     let setup30m%switch%freqthrow[1] 'setup30m%switch%freqthrow[1]' /prompt "throw #1 [MHz] "
     let setup30m%front%name[2] 'setup30m%front%name[2]' /prompt "Optional: band name #2"
     let setup30m%switch%freqthrow[2] 'setup30m%switch%freqthrow[2]' /prompt "Optional: throw #2 [MHz] "
     @ 30m-setup-widget-status
  gui\go ""
end procedure 30m-setup-simple-mode-widget
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
