#!/bin/sh
#
# Takes picture using IndyCam and stores in WWW page on gold; cantin may 96.
#

#copy_image_file()
#{
#   rcp ${TMP_FILE}.gif gold:${REST_DIR}/$FILE.gif
#   rm -f ${TMP_FILE}-00000.rgb ${TMP_FILE}.gif
#}

copy_html_file()
{

  cat << 'eoi' > $TMP_HTML_FILE
<!-- cantin, sept 97; generated by cantin@nickel:bin/video-capture>
<HTML>
<HEAD>
 <TITLE>Claude's IndyCAM output</TITLE>
</HEAD>

<BODY>
<H1> Corner of King Edward and Sussex. </H1>
The following image is the output from the IndyCAM located on
<em>nickel.sao.nrc.ca</em> in room 2025 at Sussex.

<A HREF="howto.html"><i>How it is done.</i></A>

<P>

Things to be aware of:
<UL>
  <LI> An image is captured every minute. 
  <P>
  <LI> To see the new image you must manually "reload" the image 
       to your browser.
  <P>
  <LI> The camera shutter speed is currently set for a bright day.
  <P>
  <LI> A cloudy/overcast day will show a much darker image.  
  <P>
  <LI> At night, all you'll see is the lights from the traffic signals.
  <P>
eoi

cat << eoi >> $TMP_HTML_FILE

  <LI> This picture was taken on $DATE.

eoi

cat << eoi >> $TMP_HTML_FILE

</UL>
<P>
<IMG SRC="picture.gif" ALT="[Image: from IndyCAM]" >
<P>
<HR>
<A HREF="/rpso/scsg/scsg/claude/claude.html">-<i>cpc</i></A>   (claude.cantin@nrc.ca)

</BODY>
</HTML>
eoi

#  rcp $TMP_HTML_FILE gold:${REST_DIR}/index.html
#  rm -f $TMP_HTML_FILE
   
}
REST_DIR=$HOME/public_html/indycam
FILE=picture
TMP_FILE=/tmp/indycam.$$
TMP_HTML_FILE=/tmp/html.$$
DATE=`date`
vidtomem -f $TMP_FILE 2> /dev/null
#togif ${TMP_FILE}-00000.rgb ${TMP_FILE}.gif 2> /dev/null
imgcopy ${TMP_FILE}-00000.rgb ${TMP_FILE}.gif 2> /dev/null
#/usr/local/bin/imtools/imconv ${TMP_FILE}-00000.rgb ${TMP_FILE}.gif 2> /dev/null
if [ $? -eq 0 ]
then
   copy_image_file
   copy_html_file
#   rcp ${TMP_FILE}.gif gold:${REST_DIR}/$FILE.gif
   #rm -f ${TMP_FILE}-00000.rgb ${TMP_FILE}.gif
fi
