#!/bin/csh -f
#+
#OSIRIS library of scripts
#
#NAME
#     osirisSetTempRanges - set temperature range keywords
#
#SYNOPSIS
#     osirisSetTempRanges (no args)
#
#DESCRIPTION
#     Sets the temperature range keywords in a way that bypasses
#     the <service>_keyword_config_files
#
#OPTIONS
#     None
#
#EXAMPLES
#     osirisSetTempRanges 
#
#ENVIRONMENT VARIABLES
#     None
#
#FILES
#     None
#
#SERVERS & KEYWORDS
#     list of the servers and keywords used, for example:
#
#     service = osiris
#          keywords: dtmp[1-8], icurtmp, itrgtmp, scurtmp, strgtmp
#                    dtmplogdir, dtmplogfile, dtmplogging
#                    otcslogdir, otcslogfile, otcslogging
#
#SCRIPTS CALLED
#     list of the scripts called by this script, for example:
#
#     help, syncheck
#
#EXIT STATUS
#     0 - normal exit, no error
#
#SEE ALSO
#     ???
#-
#
# Modification History:
# 2018 mar 14 jlyke Original

#----------------------------------------------------------------------
set lockengpw = `date '+%y%m%d'`
# Define services we will set
set services = (ot1s ot2s otcs oprs )
foreach service ($services)
  switch ($service)
    case ot1s:
      set range = ( \
	"[35,45]" \
	"[50,60]" \
	"[45,55]" \
	"[50,60]" \
	"[45,55]" \
	"[50,60]" \
	"[50,60]" \
	"[55,75]" \
	)
	# CCR Head
	# Primary Plate
	# Secondary Plate 
	# Front Splitter Mirror
	# Scale Turret 2
	# Lenslet Mask Stage 
	# TMA Housing
	# Cold Shield
      breaksw
    case ot2s:
      set range = ( \
	"[280,300]" \
	"[280,300]" \
	"[280,300]" \
	"[270,290]" \
	"[280,300]" \
	"[280,300]" \
	"[280,300]" \
	"[280,300]" \
	)
	# ECCS1 Intake
	# ECCS1 Exhaust
	# EC1 Top of Cabinet
	# Ambient Air
	# ECCS2 Intake
	# ECCS2 Exhaust
	# EC2 Mid of Cabinet
	# EC2 Top of Cabinet
      breaksw
    case otcs:
      set range = ( "[69.5,70.5]" "[69.5,70.5]" )
      # csh needs integers here...will have to get a different solution
      set range = ( "[69,72]" "[69,72]" )
	# SPEC
	# IMAG
      breaksw
    case oprs: 
      set range = ( "[1.0e-04,1.0e-02]" )
	# Pressure range
      breaksw
    default:
      breaksw
  endsw
  set num = 1
  if (`show -s $service -terse lockeng` == 1 ) then
    modify -s $service lockeng=$lockengpw
  endif
  while ($num <= $#range)
    if ( $service == oprs ) then
      modify -s $service pressrng="$range[$num]"
    else
      modify -s $service tmprng${num}="$range[$num]"
    endif
    @ num++
  end
  if (`show -s $service -terse lockeng` == 0 ) then
    modify -s $service lockeng=$lockengpw
  endif
end

exit 
