!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Switch setup
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
begin procedure 30m-setup-switch-definitions
  if .not.exist(setup30m%switch) then
     define structure setup30m%switch /global
     define integer setup30m%switch%mode /global
     define double setup30m%switch%wobthrow /global
     define double setup30m%switch%freqthrow[2] /global
     define double setup30m%switch%offpos[2] /global
  endif
  ! Definition of switch modes
  if .not.exist(switch) then
     define structure switch /global
     define integer switch%psw switch%wsw switch%fsw /global
     define character switch%names*3[3] /global
     let switch%psw 1
     let switch%wsw 2
     let switch%fsw 3
     let switch%names "psw" "wsw" "fsw"
  endif
  ! Commands
  symbol psw "@ 30m-setup-switch-psw"
  symbol wsw "@ 30m-setup-switch-wsw"
  symbol fsw "@ 30m-setup-switch-fsw"
end procedure 30m-setup-switch-definitions
!
begin procedure 30m-setup-switch-defaults
  let setup30m%switch%mode switch%psw
  let setup30m%switch%offpos -600 0      ! [arcsec] Offset positions
  let setup30m%switch%wobthrow 120       ! [arcsec] Wobbler throw
  let setup30m%switch%freqthrow 3.9 11.7 ! [MHz   ] Frequency throw for receiver e090 and e230
end procedure 30m-setup-switch-defaults
!
begin procedure 30m-setup-switch-reset-out
end procedure 30m-setup-switch-reset-out
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
begin procedure 30m-setup-switch-psw
  let setup30m%switch%mode switch%psw
  if (pro%narg.eq.2) then
     let setup30m%switch%offpos '&1' '&2'
  else
     message e psw "Usage: PSW offpos1 offpos2. The offset values must be in arcsec"
  endif
end procedure 30m-setup-switch-psw
!
begin procedure 30m-setup-switch-wsw
  let setup30m%switch%mode switch%wsw
  if (pro%narg.eq.1) then
     let setup30m%switch%wobthrow '&1'
  else
     message e wsw "Usage: WSW throw. The throw value must be in arcsec"
  endif
end procedure 30m-setup-switch-wsw
!
begin procedure 30m-setup-switch-fsw
  let setup30m%switch%mode switch%fsw
  if (pro%narg.eq.1) then
     let setup30m%front%n 1
     let setup30m%switch%freqthrow '&1'
  else if (pro%narg.eq.2) then
     let setup30m%front%n 2
     let setup30m%switch%freqthrow '&1' '&2'
  else
     message e fsw "Usage: FSW fthrow [fthrow2]. The fthrow values must be in MHz"
  endif
end procedure 30m-setup-switch-fsw
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! User feed back
!
begin procedure 30m-setup-switch-dump-inp
  say 'switch%names[setup%30m%switch%mode]'" switch parameters:"
  if (setup30m%switch%mode.eq.switch%psw) then
     say " * Reference offsets [arcsec]: "'setup30m%switch%offpos[1]'" "'setup30m%switch%offpos[2]'
  else if (setup30m%switch%mode.eq.switch%wsw) then
     say " * Wobbler throw [arcsec]: "'setup30m%switch%wobthrow'
  else if (setup30m%switch%mode.eq.switch%fsw) then
     say " * Frequency throw [MHz]: "'setup30m%switch%freqthrow[1]'" "'setup30m%switch%freqthrow[2]'
  else
     message e 30m-setup-switch-dump-inp "Unsupported switching mode: "'setup30m%switch%mode'
     return base
  endif
end procedure 30m-setup-switch-dump-inp
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
