#!/bin/sh
# IFe_radiance
# if no /tmp/DAR directory and default file create...
if test ! -d /tmp/def_rad ; then
  mkdir /tmp/def_rad
fi
if test ! -d /tmp/def_rad/rad ; then
  mkdir /tmp/def_rad/rad
fi
chmod a+w /tmp/def_rad
chmod a+w /tmp/def_rad/*
chmod a+w /tmp/def_rad/rad
if test ! -f /tmp/def_rad/def_2zone.cfg ; then
  cp -r ${IFE_HOME}/misc/def_rad /tmp
fi

# first see if radiance desktop is available on this machine, if
# so then run it otherwise show an image
# << need to show e2r application + a pic file >>
if test ! -f ${IFE_HOME}/sys/bin/e2r ; then
	echo    "emulation	radiance	${IFE_HOME}/lib/images/radiance.ex"
	${IFE_HOME}/sys/bin/vww -ex ${IFE_HOME}/lib/images/radiance.ex

	# get petri to shift token to the subsequent transition.
	#echo "shift_next_transition"
	echo "Lighting DTF has exited"

	exit 0
fi

cd /tmp/def_rad

finish=no
while ( [ X$finish != "Xyes" ] )
do

   # Running e2r

   ${IFE_HOME}/sys/bin/e2r -file /tmp/ESP/demo_building+

   cp -r ${IFE_HOME}/model/pic /tmp/def_rad
   cd /tmp/def_rad/pic

   echo "Lighting DTF focussing on (ill)luminance distribution"

   rview -vf view.vp -av .1 .1 .1 -ab 2 internal.oct
#   rview -i -vf view.vp -av .1 .1 .1 -ab 2 internal.oct

   finish=`${IFE_HOME}/sys/bin/dialog -p "Are you finished with this DTF ?" -file "yes" -d "yes" -h1 "type yes or no" -h2 "type yes or no"`

done

# Ask user for summary of performance.
schema=`${IFE_HOME}/sys/bin/dialog -p "Please give a performance summary." -file " " -d "Classroom 4 has glare problems" -h1 "Give a brief statement on performance" -h2 "A one line summary is required."`

echo "$schema"
echo "$schema" > /tmp/lighting_summary

# get petri to shift token to the subsequent transition.
#echo "shift_next_transition"
echo "Lighting DTF has exited"

exit 0

