Name: nirpsec_start
Directory: /kroot/kss/nirspec/ui/run_ui
Purpose: Complete start up of NIRSPEC server and client (GUI) software.



#!/bin/csh
#
# nirspec_start
#
# Main script to run NIRSPEC.  Performs the following procedures:
#	with (script calls);
#  1. Prompts user for day or night-time operation.
#  2. Starts up the NIRSPEC server process. (run_nirspec_server)
#  3. Prompts the user for observer-specific keyword values. (nirspec_setup)
#  4. Starts up the NIRSPEC DataViews and IDL clients. 
#	(run_nirspec_client_by_host)
#  5. Initializes all motors. (nirspec_init)
#
# Usage:  nirspec_start hostname
#
# Author: TAB 3dec99
#
#--------------------------------------------------------------------------
#

set hostname = $1
set display = ":0.0"

# Prompt to continue.

echo ""
echo "   Welcome to the NIRSPEC user interface startup script."
echo ""
echo " This script should be run every time that NIRSPEC operations"
echo " are started or re-started."
echo ""
echo -n "Do you want to continue running the startup script? (y/n) [y]: "
set input = $<
if( "$input" != "" && $input != y && $input != Y ) exit

# Prompt user for day or night-time operation.

echo ""
echo "Enter d for daytime or offline operation, "
echo -n "   or n for nightime on-sky operation [d]:"
set optime = $<
if ($optime == 'n') then
 set period = night
else 
 set period = day
endif

# Run up NIRSPEC server processes.

echo ""
echo " Re-Starting NIRSPEC server processes..."
if ($period == 'day') then
 xterm -sb -sl 10000 -geometry 80x25+10+10 -display $hostname$display \
  -e $RELDIR/run_nirspec_server -nodcs -noacs -sleep -restart &
else
 xterm -sb -sl 10000 -geometry 80x25+10+10 -display $hostname$display \
  -e $RELDIR/run_nirspec_server -sleep -restart &
endif
sleep 1

# Run nirspec_setup OR reload cached keyword values in nirspec_reset.

echo ""
echo "Enter s to set new observer and data directory keyword values, "
echo -n "   or c to reload values set previously today [c]: " 
set reset = $<
if ($reset == 's') then
 nirspec_setup
else
 nirspec_reset
endif
sleep 1

# Run up NIRSPEC clients.

echo ""
echo " Starting XNIRSPEC, SPEC/SCAM Displays, EFS GUI, and Rotator GUI (night only)..."
if ($period == 'day') then
 xterm -sb -sl 10000 -geometry 80x25+10+400 -display $hostname$display \
  -e $RELDIR/run_nirspec_client_by_host $hostname -nodcs -noimrot
else
 xterm -sb -sl 10000 -geometry 80x25+10+400 -display $hostname$display \
  -e $RELDIR/run_nirspec_client_by_host $hostname 
endif
sleep 5

# Initialize motors.

echo ""
echo " Checking motor initializations..."
nirspec_init
sleep 1

# Turn on rotator tracking if it is nightime.

if ($period == 'night') then
 modify -s nirspec track = 1
endif

# Script done!

echo ""
echo -n "NIRSPEC startup is complete\!  Press Enter to exit."
set out = $<
sleep 2

exit 0