Index: trunk/tools/roboczar.pl
===================================================================
--- trunk/tools/roboczar.pl	(revision 28715)
+++ trunk/tools/roboczar.pl	(revision 28719)
@@ -4,4 +4,5 @@
 use strict;
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+use POSIX qw/strftime/;
 
 # local classes
@@ -9,13 +10,17 @@
 use czartool::Gpc1Db;
 use czartool::Pantasks;
+use czartool::Czarplot;
 
 
 my $period = 60;
 my $czarDbName = "czardb"; # TODO variables for other Db stuff, host etc
-my $save_temps = 1;
+my $save_temps = 0;
 
 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp");
 my $gpc1Db = new czartool::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser");
 my $pantasks = new czartool::Pantasks();
+my $czarplot = new czartool::Czarplot($czarDb, "%Y%m%d-%H%M%S", "png", "~/", $save_temps);
+$czarDb->setDateFormat("%Y%m%d-%H%i%s");
+
 my @stages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
 
@@ -79,5 +84,4 @@
     my $full;
     my $faults;
-    my $currentTime;
     my $stage;
     my ($totalNew,$totalFull,$totalFaults);
@@ -88,4 +92,7 @@
     my $rows = undef;
     my $row = undef;
+    my $begin = undef;
+    my $end = undef;
+    my $priority = undef;
 
     while (1) {
@@ -94,4 +101,22 @@
         updateLabels();
         if (!$czarDb->getCurrentLabels("stdscience", \$rows)) {next;}
+
+        my $size = @{$rows};
+        if($size < 1) {
+            
+            print "* WARNING: no stdscience labels found in Db\n";
+            next;
+        }
+
+        # get priority
+        foreach $row ( @{$rows} ) {
+            my ($label) = @{$row};
+            $priority = $gpc1Db->getPriority($label);
+            $czarDb->setLabelPriority($label, $priority);
+        }
+
+        # sort out times
+        $begin =  strftime('%Y-%m-%d 07:00',localtime);
+        $end = $czarDb->getNowTimestamp();
 
         foreach $stage (@stages) {
@@ -112,5 +137,4 @@
                 $full = $gpc1Db->countExposures($label, $stage, "full");
                 $faults = $gpc1Db->countFaults($label, $stage);
-                $currentTime = time();
 
                 #printf("%ld, %s, %s, %d, %d\n", $currentTime, $label, $stage, $new, $faults);
@@ -125,8 +149,15 @@
         }
 
+        print "* Generating plots\n";
         foreach $row ( @{$rows} ) {
             my ($label) = @{$row};
+
+            $czarplot->createTimeSeries($label, undef, $begin, $end);
+            $czarplot->createHistogram($label, $begin, $end);
+
             #routineChecks($label, "1 HOUR");
         }
+            $czarplot->createTimeSeries("all_labels", undef, $begin, $end);
+            $czarplot->createHistogram("all_labels", $begin, $end);
         print "--------------------------------------------------------------------------\n";
         print "* Going to sleep\n";
