#!/bin/bash
#
#    Project: EDNA MXv1
#             http://www.edna-site.org
#
#    File: "$Id: edna-prototype 589 2008-12-15 14:32:35Z incardon $"
#
#    Copyright (C) 2008 European Synchrotron Radiation Facility
#                       Grenoble, France
#
#    Principal authors: Marie-Francoise Incardona (incardon@esrf.fr)
#                       Olof Svensson (svensson@esrf.fr) 
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#


if [ -z "${EDNA_HOME}" ] || [ -z "${EDNA_SITE}" ]; then
  echo ""
  echo "Cannot start the EDNA MXv1 characterisation application:"
  echo "Make sure that \$EDNA_HOME and \$EDNA_SITE are set up before running edna-mxv1-characterisation."
  echo "Example:"
  echo "\$ export EDNA_HOME=/<path>/<to>/edna"
  echo "\$ export EDNA_SITE=<SUFFIX> (should be the configuration file suffix XSConfiguration_<SUFFIX>.xml)"
  echo "Please read the INSTALL.txt file under the \"\$EDNA_HOME/mxv1\" directory for more details"
  echo ""
  exit 1
fi

# Set up the PYTHONPATH
export PYTHONPATH=${EDNA_HOME}/libraries/20090518-PyAALib-JyAALib-111/modules:${EDNA_HOME}/kernel/src

xsConfigurationFile=${EDNA_HOME}/mxv1/conf/XSConfiguration_${EDNA_SITE}.xml
if [ -f ${xsConfigurationFile} ]; then
	echo
	echo "  Executing EDNA MXv1 Characterisation"
	echo
    echo "  Using configuration file ${xsConfigurationFile}"
	echo 
    python ${EDNA_HOME}/mxv1/src/EDApplicationMXv1CharacterisationMain.py --conf ${xsConfigurationFile} --verbose $*
else
    echo 
    echo "  Cannot start the EDNA prototype:"
    echo
    echo "  Configuration file ${xsConfigurationFile} does not exist."
    echo
    exit 1
fi
