Index: trunk/DataCheck/QuickLook/FlareAlerts.sh
===================================================================
--- trunk/DataCheck/QuickLook/FlareAlerts.sh	(revision 18794)
+++ trunk/DataCheck/QuickLook/FlareAlerts.sh	(revision 18799)
@@ -30,5 +30,5 @@
    finish
 fi
-voeventpath=$flarealertspath"/amon"
+voeventpath="/home/fact/amon/flare_alerts/"
 
 logfile=$runlogpath"/FlareAlerts-"$datetime".log"
@@ -113,5 +113,4 @@
       bin2=$bin
    fi
-   echo "binning:-"$bin2"- 1+"$1"+ b_"$bin"_"
    # query to get information from DB
    query="SELECT MAX(o.b) AS num, "
@@ -150,18 +149,18 @@
    query=$query"CROSS JOIN (SELECT @night :=0, @ot :=0, @os :=0, @bl:=0) PARAMS "
    query=$query"WHERE fSourceKey="$sourcekey" AND fNight="$night" AND NOT ISNULL(fNumExcEvts) "
-   if [ "$1" != "" ]
-   then
-      query=$query" AND fRunID <="${results[$num+3]}
-   fi
+#   if [ "$1" != "" ]
+#   then
+#      query=$query" AND fRunID <="${results[$num+3]}
+#   fi
    query=$query" ORDER BY fRunStart "
-   if [ "$1" != "" ]
-   then
-      query=$query"DESC"
-   fi
+#   if [ "$1" != "" ]
+#   then
+#      query=$query"DESC"
+#   fi
    query=$query" ) o GROUP BY b HAVING ontime > "$bin2"*0.75 ORDER BY start "
-   if [ "$1" != "" ]
-   then
-      query=$query"DESC"
-   fi
+#   if [ "$1" != "" ]
+#   then
+#      query=$query"DESC"
+#   fi
    #echo $query
 }
@@ -475,22 +474,28 @@
             if [ $checkstatus -gt 0 ]
             then
-               rm $donetriggerfile
+               # keep history of non-sent triggers
+               donetriggerfile2=$donetriggerfile"-changed-"`date +%Y%m%d%H%M%S`
+               mv $donetriggerfile $donetriggerfile2
             fi
          fi
          # missing: get summary of whole observation
          
-         # AMON case: create VOEvent-File
-         if [ $triggertype -eq 4 ]
-         then
-            voeventfile=$voeventpath"/"$night"_"`printf %03d $runid`"-"$exclimit"_"$siglimit"-source"$sourcekey".trigger"$triggertype".xml"
-            echo $voeventfile
-            echo ${sourceinfo[@]}
-            #print_voevent_file
-            print_voevent_file > $voeventfile
-         fi
-
          # send email only of $donetriggerfile doesn't exists
          if ! [ -e $donetriggerfile ]
          then 
+            # AMON case: create VOEvent-File
+            if [ $triggertype -eq 4 ]
+            then
+               voeventfile=$voeventpath"/"`basename $triggerfile`".xml"
+               # missing: check for archive file
+               #   if exist -> do revision
+               echo "creating "$voeventfile
+               echo "Creating "$voeventfile >> $logfile
+               #print_voevent_file
+               print_voevent_file > $voeventfile
+               # in amon-case no email needs to be sent
+               continue
+            fi
+
             cat $triggerfile | mail -s 'test flare alert ' -b $emailfrom -r $emailfrom $emailto
          fi
