#!/bin/bash
#==============================================================
#  Name:  lclshomeOld
#
#  Rem:   This script launches Stephen&Stephen's LCLS EPICS Home Screen.
# 
#  Usage: lclshome
#
#  Auth:  07-Dec-2006, Jingchen Zhou   (jingchen)
#  Rev:   dd-mmm-yyyy,  Whoever    (user):
#         08-Dec-2006, Jingchen Zhou (jingchen)
#         - added OS check
#         23-Mar-2007, Jingchen Zhou (jingchen)
#         - set up the LCLS environment if not
#         27-Mar-2007, Jingchen Zhou (jingchen)
#         - set edm as noedit mode if used by production accounts
#         18-Jun-2008, Jingchen Zhou (jingchen)
#         - updated the account list for the CA network 
#         31-Aug-2010, Sonya Hoobler (sonya)
#         - temporarily rename to lclshomeOld; once Linac Upgrade
#         displays are in the standard edm tree, we can revert
#         29-Feb-2012, Terri Lahey (lahey)
#         - Timing Usability Screens: change EDMDATAFILES to pick up
#         generated files from $EDM/install
#         28-Aug-2012, Judy Rock (jrock)
#         version with edm putlogging turned off
#--------------------------------------------------------------

CMD="edm"
ACCLIST="laci physics acclegr eoicdesk linac mccops1 lclsops1 lclsops2 lclsops3 lclsops4 lclsops5"

if [ `uname -s` != "Linux" ] ; then
    echo "Please run $0 on a public Linux machine"
    exit 1
fi

if [ -z "${EDM}" ] ; then
#    . /usr/local/lcls/epics/setup/epicsReset.bash
    . ~/.bashrc
fi

cmdpath=`which ${CMD}`
if [ ! -x "${cmdpath}" ] ; then
    echo "ERROR: cannot find ${CMD}"
    exit 1
fi

if [ ! -f ${EDM}/lcls/lcls_main.edl ] ; then
    echo "ERROR: cannot find lcls_main.edl"
    exit 1
fi 

#export EDMFILTERS=$TOOLS/edm/config/homeFilter
export EDMFILTERS=/usr/local/lcls/tools/edm/config/homeFilter
export EDMDATAFILES=/home/softegr/jrock/test_edm_putlogging/tools/edm/display/lcls:.:$EDM/install:$EDMDATAFILES


# now try unsetting!
export -n EDMPUTLOGGER
export EDMPVOBJECTS=/usr/local/lcls/tools/edm/config

USER=`whoami` 
INLIST=`echo ${ACCLIST} | grep ${USER}`
mode="-x"
if [ -n "${INLIST}" ]; then  
    mode="-x -noedit"
fi

${cmdpath} -eolc ${mode} -m "EVGLOCA=IN20" lcls_mainNOLOG

if [ $? -ne 0 ]; then
    echo "ERROR: $0 failed" 
    exit 1
fi

exit 0

