#!/bin/bash

REPOPATH="/home/Course-Admin/training/co-simulator_ESP-r"

arg=$1
err=0
if [ "$arg" == "" ]; then

  err=1

fi

case "$arg" in
  intro1) echo "Skipping to introductory course: databases complete"
          group="intro"
          step="01_dbs_complete"
          filename="Demonstration.cfg"
          ;;
  intro2) echo "Skipping to introductory course: opaque envelope complete"
          group="intro"
          step="02_opaque_complete"
          filename="Demonstration.cfg"
          ;;
  intro3) echo "Skipping to introductory course: windows complete"
          group="intro"
          step="03_windows_complete"
          filename="Demonstration.cfg"
          ;;
  intro4) echo "Skipping to introductory course: connections complete"
          group="intro"
          step="04_cnn_complete"
          filename="Demonstration.cfg"
          ;;
  intro5) echo "Skipping to introductory course: operations complete"
          group="intro"
          step="05_opr_complete"
          filename="Demonstration.cfg"
          ;;
  intro6) echo "Skipping to introductory course: controls complete"
          group="intro"
          step="06_ctl_complete"
          filename="Demonstration.cfg"
          ;;
  intro7) echo "Skipping to introductory course: obstructions complete"
          group="intro"
          step="07_obs_complete"
          filename="Demonstration.cfg"
          ;;          
  plant0) echo "Skipping to plant modelling course: starting point"
            group="plant_network"
            step="pln_00_start"
            filename="bld_basic.cfg"
            ;;
  plant1) echo "Skipping to plant modelling course: components done"
            group="plant_network"
            step="pln_01_components_done"
            filename="bld_basic.cfg"
            ;;          
  plant2) echo "Skipping to plant modelling course: connections done"
            group="plant_network"
            step="pln_02_connections_done"
            filename="bld_basic.cfg"
            ;;
  plant3) echo "Skipping to plant modelling course: containments done"
            group="plant_network"
            step="pln_03_containments_done"
            filename="bld_basic.cfg"
            ;;
  plant4) echo "Skipping to plant modelling course: controls done"
            group="plant_network"
            step="pln_04_ctls_done"
            filename="bld_basic.cfg"
            ;;   
  elec0) echo "Skipping to elec modelling course: starting point"
            group="elec_network"
            step="eln_00_start"
            filename="bld_basic.cfg"
            ;;
  elec1) echo "Skipping to elec modelling course: roof done"
            group="elec_network"
            step="eln_01_roof_done"
            filename="bld_basic.cfg"
            ;;          
  elec2) echo "Skipping to elec modelling course: plant-components done"
            group="elec_network"
            step="eln_02_plncomp_done"
            filename="bld_basic.cfg"
            ;;
  elec3) echo "Skipping to elec modelling course: complete"
            group="elec_network"
            step="eln_03_complete"
            filename="bld_basic.cfg"
            ;;
  *)      err=1
          ;;
esac

if [ "$err" == "1" ]; then

  echo $REPOPATH
  echo " skipto: ERROR!"
  echo " Arguement \"$arg\" not understood. Arguement must be one of"
  echo " the following:"
  echo " " 
  echo "  - intro1 "
  echo "  - intro2 "
  echo "  - intro3 "
  echo "  - intro4 "
  echo "  - intro5 "
  echo "  - intro6 "
  echo "  - intro7 "
  echo " " 
  echo "  - plant0"
  echo "  - plant1"
  echo "  - plant2"
  echo "  - plant3"
  echo "  - plant4"
  echo " "
  echo "  - elec0"
  echo "  - elec1"
  echo "  - elec2"
  echo "  - elec3"

else
  $my_path=`pwd`
  echo " About to copy: $REPOPATH/$group/esp-r_files/$step/ to ./ ($my_path)"
  cp -fr "$REPOPATH/$group/esp-r_files/$step/" ./
  cd ./$step/cfg
  prj -file $filename &

fi