#!/bin/sh
# summer overheating show_graphs script: version 1.1 of Nov 1994
echo
echo " Determining the cause of the discomfort in the worst zone"
echo

					# Get worst zone from lock file
					# or user if no lock file.
comfort_lock=$comf_dir/tmp/comfort_lock
comfort_results=$comf_dir/tmp/comfort_results
if [ "X$comfort_lock" = "X" ]; then
   echo -n "Zone to be examined? "
   read WZ
   echo $comfort_results
else
   WZ=`cat $comfort_lock`
fi

echo enquiring about the worst zone $WZ
					# Now get frequency distribution.
graphpic="f"				# include resultant temperature.

echo "***** comfort_cause started: worst zone is ${WZ}" >>$comf_dir/tmp/comfort_trace
echo "***** comfort_cause: get freq. dist. from res" >>$comf_dir/tmp/comfort_trace
echo "***** graphpic is ${graphpic}" >>$comf_dir/tmp/comfort_trace


# Here we want to get several images and indices from res, this can
# be done in a single run with a separate command image generated for
# each one...
# first get a fequency distribution
# second get a drybulb and resultant temperature graph
# third get an energy balance for worst zone ( write to a file ).

rm -f $comf_dir/tmp/frqd.ww
rm -f $comf_dir/tmp/wz_temp_graph
frq_file=$comf_dir/tmp/frqd.ww
wz_temp_graph=$comf_dir/tmp/wz_temp_graph

echo
echo "Getting a frequency distribution as well as a graph of"
echo "conditions within the worst zone...."

res -mode script -file ${comfort_results} >>$comf_dir/tmp/comfort_trace  2>$comf_dir/tmp/comfort_graph  <<.
${comfort_results}
y
a
n
4
<
1
${WZ}
b          
d
>
b
${frq_file}
f
10
y
a
-
-
a
>
b
${wz_temp_graph}
b
a
f
g
!
>
-
-
_
y
.

echo
echo frequency distribution acquired...
echo graph of worst zone conditions acquired...
echo PLEASE NOTE: images of the analysis may overlap!

vww -g 200 50 -ww $comf_dir/tmp/frqd.ww &
sleep 2
vww -g 400 60 -ww $wz_temp_graph &

# Create graph of temp of worst zone.
echo "***** comfort_cause; get graph of worst zone from res" >>$comf_dir/tmp/comfort_trace
echo
echo " Type return to continue to the next part of the summer overheating assessment"

read xb						# hang around.
exit 0
