Index: trunk/ippMonitor/czartool/czarconfig.xml.in
===================================================================
--- trunk/ippMonitor/czartool/czarconfig.xml.in	(revision 40834)
+++ trunk/ippMonitor/czartool/czarconfig.xml.in	(revision 40840)
@@ -10,4 +10,5 @@
     <size>8</size>
     <path>PATH/TO/czartool_plots</path>
+    <exec>PATH/TO/gnuplot</exec>
   </gnuplot>
 
Index: trunk/ippMonitor/czartool/czarpoll.pl
===================================================================
--- trunk/ippMonitor/czartool/czarpoll.pl	(revision 40834)
+++ trunk/ippMonitor/czartool/czarpoll.pl	(revision 40840)
@@ -102,12 +102,18 @@
     foreach $server (@servers) {
 
-        my @dates = @{$pantasks->getDates($server)};
+        my @dates = @{$pantasks->getDates($server,'gpc1')};
         if (@dates) {
-
-            $czarDb->updateServerDates($server, \@dates);
+            $czarDb->updateServerDates($server, \@dates,'gpc1');
         }
         else {
-
-            print "WARNING: No dates to update for '$server'\n";
+            print "WARNING: No dates to update for '$server' in gpc1\n";
+        }
+
+        my @dates2 = @{$pantasks->getDates($server,'gpc2')};
+        if (@dates2) {
+            $czarDb->updateServerDates($server, \@dates2,'gpc2');
+        }
+        else {
+            print "WARNING: No dates to update for '$server' in gpc2\n";
         }
     }
@@ -126,22 +132,80 @@
 
     print "* Updating labels\n";
-    # my @servers = ("stdscience", "distribution", "publishing", "update");
     my @servers = ("stdscience", "distribution");
 
     my @allLabels = ();
-
+    my @allLabels2 = ();
+    my @fields = ();
+
+    #first grab the labels fom the relevant pantasks
     my $server = undef;
     foreach $server (@servers) {
-        my @labels = @{$pantasks->getLabels($server)};
+        my @labels = @{$pantasks->getLabels($server,'gpc1')};
 	push (@allLabels, @labels);
-    }
+
+        my @labels2 = @{$pantasks->getLabels($server,'gpc2')};
+	push (@allLabels2, @labels2);
+    }
+
+    ## adding extra labels from external file
+    my $filename = 'extra_labels.dat';
+    if (open(my $fh, '<:encoding(UTF-8)', $filename)) {
+      my $header = <$fh>;     
+      $header = <$fh>;     
+      while (my $row = <$fh>) {
+          chomp $row;
+          @fields = split(' ', $row);
+          if ($fields[1] eq 'gpc1') {
+	      push (@allLabels, $fields[0]);
+          }
+          if ($fields[1] eq 'gpc2') {
+	      push (@allLabels2, $fields[0]);
+          }
+      }
+    } else {
+      warn "No extra labels found in '$filename' $!";
+    }
+
+    # Now, grab the priorities for each label
+    my @priorities = ();
+    my $row = undef;
+    my $label = undef;
+    my $priority = undef;
+    foreach $label ( @allLabels ) {
+        $priority = $gpc1Db->getPriority($label);
+        push(@priorities, $priority);
+    }
+
+    #also grab gpc2 priorities from the gpc2 Label table
+    my @priorities2 = ();
+    my $priority2 = undef;
+    foreach $label ( @allLabels2 ) {
+        $priority2 = $gpc2Db->getPriority($label);
+        push(@priorities2, $priority2);
+    }
+
+    #sort labels by priority
+    my @idx = sort {$priorities[$a] <=> $priorities[$b]} 0 ..$#priorities;
+    @allLabels = @allLabels[@idx];
+    @priorities = @priorities[@idx]; 
+
+    my @idx2 = sort {$priorities2[$a] <=> $priorities2[$b]} 0 ..$#priorities2;
+    @allLabels2 = @allLabels2[@idx2];
+    @priorities2 = @priorities2[@idx2]; 
 
     # store them all in stdscience:
     $server = "stdscience";
     if (@allLabels) {
-	$czarDb->updateCurrentLabels($server, \@allLabels);
+	$czarDb->updateCurrentLabels($server, \@allLabels,'gpc1', \@priorities);
     } else {
-	print "WARNING: No labels to update for '$server'\n";
-    }
+	print "WARNING: No labels to update for gpc1 for '$server'\n";
+    }
+
+    if (@allLabels2) {
+	$czarDb->updateCurrentLabels($server, \@allLabels2,'gpc2', \@priorities2);
+    } else {
+	print "WARNING: No labels to update for gpc2 for '$server'\n";
+    }
+    return(\@allLabels,\@allLabels2);
 }
 
@@ -160,8 +224,9 @@
     my $running = undef;
     foreach $server (@{$servers}) {
-
-        $pantasks->getServerStatus($server, \$alive, \$running);
-        $czarDb->updateServerStatus($server, $alive, $running);
-    }
+        $pantasks->getServerStatus($server,'gpc1', \$alive, \$running);
+        $czarDb->updateServerStatus($server,'gpc1', $alive, $running);
+        $pantasks->getServerStatus($server,'gpc2', \$alive, \$running);
+        $czarDb->updateServerStatus($server,'gpc2', $alive, $running);
+   }
 }
 
@@ -182,4 +247,5 @@
     my $str = undef;
     my $labels = undef;
+    my $labels2 = undef;
     my $updateLabels = undef;
     my $row = undef;
@@ -187,4 +253,5 @@
     my $end = undef;
     my $priority = undef;
+    my $priority2 = undef;
     my $newState = undef;
     my $nsStatus = undef;
@@ -227,8 +294,10 @@
 
                 # now cleanup tables from yesterday and optimize
-                print "* Performing database cleanup\n";
-                $czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval());
-                print "* Optimizing the database\n";
-                $czarDb->optimize();
+                #TdB20190703: The ipp113 and ipp117 instances of czarpoll use the same stage DBs in czarDB. 
+                #Therefore, it makes no sense to run the cleanup+optimising twice
+                #print "* Performing database cleanup\n";
+                #$czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval());
+                #print "* Optimizing the database\n";
+                #$czarDb->optimize();
                 $lastDayDailyTasks = $yesterday;
             }
@@ -237,6 +306,8 @@
         # check nightly science status
         print "* Checking nightly science status\n";
-        if (!$pantasks->getNightlyScienceStatus(\$nsStatus)) {$nsStatus = "Unknown";}
-        $czarDb->updateNightlyScience($nsStatus);
+        if (!$pantasks->getNightlyScienceStatus(\$nsStatus,'gpc1')) {$nsStatus = "Unknown";}
+        $czarDb->updateNightlyScience($nsStatus,'gpc1');
+        if (!$pantasks->getNightlyScienceStatus(\$nsStatus,'gpc2')) {$nsStatus = "Unknown";}
+        $czarDb->updateNightlyScience($nsStatus,'gpc2');
 
         # check nebulous
@@ -252,5 +323,7 @@
 
         # check labels
-        updateLabels();
+        my ($labels, $labels2) = updateLabels();
+        my @labels = @$labels;
+        my @labels2 = @$labels2;
 
         # servers to check
@@ -265,20 +338,10 @@
 
             # deal with stdscience labels
-            if (!$czarDb->getCurrentLabels($thisServer, \$labels)) {next;}
             my $size = @{$labels};
             if($size > 0) {
-
-                # get priority
-                foreach $row ( @{$labels} ) {
-                    my ($label) = @{$row};
-                    # for now use priorities from gpc1 database
-                    $priority = $gpc1Db->getPriority($label);
-                    $czarDb->setLabelPriority($label, $priority);
-                }
-
-                updateAllStages($thisServer, $newState, $labels, $begin, $end);
+                updateAllStages($thisServer, $newState, $labels,$labels2, $begin, $end);
                 if ($thisServer eq "stdscience") {
                     createPlots($thisServer, $plotter1, $labels, $begin, $end);
-                    createPlots($thisServer, $plotter2, $labels, $begin, $end);
+                    createPlots($thisServer, $plotter2, $labels2, $begin, $end);
                 }
             }
@@ -376,5 +439,4 @@
     #  #  $plotter->createTimeSeries($label, undef, $begin, $end, 1, 1, 1);
 
-    #    #TdB 20190411: Make the all stages plots for the nightlyscience labels only
     #    if ($label =~ m/nightlyscience/) {
     #      $plotter->createTimeSeries($label, undef, $begin, $end, 1, 0, 1);
@@ -382,11 +444,10 @@
     #}
 
-    $allServerLabels = "all_".$server."_labels";
-
-    $plotter->createTimeSeries($allServerLabels, undef, $begin, $end, 1, 0, 1);
-
-    #TdB 20190411: We are turning off these plots for the time being. They take up a lot of time and are rarely looked at. If need be, can be generated on the fly using czartool.
+    $allServerLabels = $server."_labels";
+
+    $plotter->createTimeSeries($allServerLabels, undef, $begin, $end, 1, 1, 1);
+
     foreach $stage (@stages) {
-        $plotter->createTimeSeries($allServerLabels, $stage, $begin, $end, 1, 0, 1); # TODO must be a neater way...
+        $plotter->createTimeSeries($allServerLabels, $stage, $begin, $end, 1, 0, 0); # TODO must be a neater way...
     }
 }
@@ -398,5 +459,5 @@
 ###########################################################################
 sub updateAllStages {
-    my ($labelServer, $newState, $rows, $begin, $end) = @_;
+    my ($labelServer, $newState, $rows, $rows2, $begin, $end) = @_;
 
     print "* Updating stage data\n";
@@ -419,6 +480,9 @@
     foreach $stage (@stages) {
         $server = $pantasks->getServerForThisStage($stage);
-        $pantasks->getRevertStatus($stage, \$reverting);
-        $czarDb->updateRevertStatus($stage, $reverting);
+        $pantasks->getRevertStatus($stage,'gpc1', \$reverting);
+        $czarDb->updateRevertStatus($stage,'gpc1', $reverting);
+
+        $pantasks->getRevertStatus($stage,'gpc2', \$reverting);
+        $czarDb->updateRevertStatus($stage,'gpc2', $reverting);
 
         print "* Checking labels for $stage stage\n";
@@ -427,17 +491,16 @@
 	if (($stage eq 'summitExp')||($stage eq 'downloadExp')||($stage eq 'newExp')||($stage eq 'rawExp')) { 
 	    ($new,$full,$faults) = $gpc1Db->countRawExposures($today,$stage);
-	    $czarDb->insertNewTimeData($stage, "all_".$labelServer."_labels", 'gpc1', $new, $full, $faults);
+	    $czarDb->insertNewTimeData($stage, $labelServer."_labels", 'gpc1', $new, $full, $faults);
 
 	    ($new,$full,$faults) = $gpc2Db->countRawExposures($today,$stage);
-	    $czarDb->insertNewTimeData($stage, "all_".$labelServer."_labels", 'gpc2', $new, $full, $faults);
+	    $czarDb->insertNewTimeData($stage, $labelServer."_labels", 'gpc2', $new, $full, $faults);
 
 	    next;
 	}
 
-
+        #count the number of exposures under each label, and their faults
         $totalNew1=$totalFaults1=$totalFull1=0;
-        $totalNew2=$totalFaults2=$totalFull2=0;
         foreach $row ( @{$rows} ) {
-            my ($label) = @{$row};
+            my ($label) = $row;
 
             chomp($label);
@@ -447,5 +510,4 @@
             $full = $gpc1Db->countExposures($label, $stage, "full");
             $faults = $gpc1Db->countFaults($label, $stage, $newState);
-            #printf("%s  %s, %s, %d, %d\n", $labelServer, $label, $stage, $new, $faults);
             $totalNew1 += $new;
             $totalFull1 += $full;
@@ -453,9 +515,16 @@
 
             $czarDb->insertNewTimeData($stage, $label, 'gpc1', $new, $full, $faults);
-
+        }
+
+        $totalNew2=$totalFaults2=$totalFull2=0;
+        foreach $row ( @{$rows2} ) {
+            my ($label) = $row;
+
+            chomp($label);
+
+            # Move this to a function and pass in the database
             $new = $gpc2Db->countExposures($label, $stage, $newState);
             $full = $gpc2Db->countExposures($label, $stage, "full");
             $faults = $gpc2Db->countFaults($label, $stage, $newState);
-            #printf("%s  %s, %s, %d, %d\n", $labelServer, $label, $stage, $new, $faults);
             $totalNew2 += $new;
             $totalFull2 += $full;
@@ -465,7 +534,7 @@
         }
 
-        $czarDb->insertNewTimeData($stage, "all_".$labelServer."_labels", 'gpc1', $totalNew1, $totalFull1, $totalFaults1);
-        $czarDb->insertNewTimeData($stage, "all_".$labelServer."_labels", 'gpc2', $totalNew2, $totalFull2, $totalFaults2);
-    }
-}
-
+        $czarDb->insertNewTimeData($stage, $labelServer."_labels", 'gpc1', $totalNew1, $totalFull1, $totalFaults1);
+        $czarDb->insertNewTimeData($stage, $labelServer."_labels", 'gpc2', $totalNew2, $totalFull2, $totalFaults2);
+    }
+}
+
Index: trunk/ippMonitor/czartool/czartool.pl
===================================================================
--- trunk/ippMonitor/czartool/czartool.pl	(revision 40834)
+++ trunk/ippMonitor/czartool/czartool.pl	(revision 40840)
@@ -15,10 +15,11 @@
 my $save_temps = 1;
 my $interval = undef;
+my $telescope = "gpc1";
 
 GetOptions (
         "dbname|d=s" => \$czarDbName,
         "interval|i=s" => \$interval,
+        "telescope|t=s" => \$telescope,
         );
-
 
 my @states = ("full", "new", "drop", "wait");
@@ -26,4 +27,5 @@
 my $czarDb = $config->getCzarDbInstance();
 my $gpc1Db = $config->getGpc1Instance();
+my $gpc2Db = $config->getGpc2Instance();
 my $pantasks = new czartool::Pantasks();
 
@@ -55,9 +57,9 @@
 sub promptPoll {
 
-    @stdscienceLabels = @{$pantasks->getLabels("stdscience")};
-    @distributionLabels = @{$pantasks->getLabels("distribution")};
-    # @publishingLabels = @{$pantasks->getLabels("publishing")};
+    @stdscienceLabels = @{$pantasks->getLabels("stdscience",$telescope)};
+    @distributionLabels = @{$pantasks->getLabels("distribution",$telescope)};
+    # @publishingLabels = @{$pantasks->getLabels("publishing", $telescope)};
     @publishingLabels = @stdscienceLabels;
-    checkAllLabels("new");
+    checkAllLabels("new", $telescope);
     printInstructions();
 
@@ -68,7 +70,7 @@
 
         if ($key eq "s") {checkServers();}
-        elsif ($key eq "l") {checkAllLabels("new");}
-        elsif ($key eq "u") {$pantasks->getServerCurrentStatus("stdscience");}
-        elsif ($key =~ m/[0-9]/) {my $key2=getc; checkOneLabel($stdscienceLabels[($key.$key2)-1]);}
+        elsif ($key eq "l") {checkAllLabels("new", $telescope);}
+        elsif ($key eq "u") {$pantasks->getServerCurrentStatus("stdscience",$telescope);}
+        elsif ($key =~ m/[0-9]/) {my $key2=getc; checkOneLabel($stdscienceLabels[($key.$key2)-1], $telescope);}
         printInstructions();
 
@@ -139,4 +141,5 @@
 ###########################################################################
 sub labelDetails {
+    my ($telescope) = @_;
 
     print "\nPlease enter the label name, or number from table above: ";
@@ -144,8 +147,8 @@
     chomp($input);
     if ($input =~ m/^([0-9]|[1-9][0-9]|[1-9][0-9][0-9])$/) {
-        return checkOneLabel($stdscienceLabels[$input]);
-    }
-
-    checkOneLabel($input);
+        return checkOneLabel($stdscienceLabels[$input], $telescope);
+    }
+
+    checkOneLabel($input, $telescope);
 }
 
@@ -156,5 +159,5 @@
 ###########################################################################
 sub checkOneLabel {
-    my ($label) = @_;
+    my ($label, $telescope) = @_;
 
     chomp($label);
@@ -188,5 +191,5 @@
         foreach $stage (@stages) {
 
-            printf("|%14s", getStateAndFaultsString($label, $state, $stage));
+            printf("|%14s", getStateAndFaultsString($label, $state, $stage, $telescope));
         }
 
@@ -209,5 +212,5 @@
 ###########################################################################
 sub checkAllLabels {
-    my ($state) = @_;
+    my ($state, $telescope) = @_;
 #print time, $/;
     my $stage;
@@ -259,5 +262,5 @@
         foreach $stage (@stages) {
 
-            printf("|%14s", getStateAndFaultsString($stdsLabel, $state, $stage));
+            printf("|%14s", getStateAndFaultsString($stdsLabel, $state, $stage, $telescope));
         }
 
@@ -280,11 +283,24 @@
 ###########################################################################
 sub getStateAndFaultsString {
-    my ($label, $state, $stage) = @_;
-
-    my $new = $gpc1Db->countExposures($label, $stage, $state);
-
-    #if ($state ne "new") {return $new;}
-
-    my $faults = $gpc1Db->countFaults($label, $stage, $state);
+    my ($label, $state, $stage, $telescope) = @_;
+
+    my $new = undef;
+    my $faults = undef;
+
+    if ($telescope eq 'gpc1') {
+      $new = $gpc1Db->countExposures($label, $stage, $state);
+      #if ($state ne "new") {return $new;}
+
+      $faults = $gpc1Db->countFaults($label, $stage, $state);
+    }
+    elsif ($telescope eq 'gpc2') {
+      $new = $gpc2Db->countExposures($label, $stage, $state);
+      #if ($state ne "new") {return $new;}
+
+      $faults = $gpc2Db->countFaults($label, $stage, $state);
+    }
+    else {
+        print "WARNING: Must specify a telescope for connecting to the right pantask\n";
+    }
 
     if ($faults < 1) {return $new;}
Index: trunk/ippMonitor/czartool/czartool/CzarDb.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/CzarDb.pm	(revision 40834)
+++ trunk/ippMonitor/czartool/czartool/CzarDb.pm	(revision 40840)
@@ -137,11 +137,11 @@
 ###########################################################################
 sub updateServerStatus {
-    my ($self, $server, $alive, $running) = @_;
-
-    my $query = $self->{_db}->prepare(<<SQL);
-    INSERT INTO servers
-        (server, alive, running)
+    my ($self, $server,$telescope, $alive, $running) = @_;
+
+    my $query = $self->{_db}->prepare(<<SQL);
+    INSERT INTO science_servers
+        (server,telescope, alive, running)
         VALUES
-        ('$server', $alive, $running);
+        ('$server','$telescope', $alive, $running);
 SQL
 
@@ -173,28 +173,10 @@
 ###########################################################################
 sub updateRevertStatus {
-    my ($self, $stage, $reverting) = @_;
-
-    my $query = $self->{_db}->prepare(<<SQL);
-     UPDATE reverts
+    my ($self, $stage,$telescope, $reverting) = @_;
+
+    my $query = $self->{_db}->prepare(<<SQL);
+     UPDATE science_reverts
          SET reverting = $reverting
-         WHERE stage LIKE '$stage';
-SQL
-
-    $query->execute;
-}
-
-###########################################################################
-#
-# Sets priority for this label
-#
-###########################################################################
-sub setLabelPriority {
-    my ($self, $label, $priority) = @_;
-
-    my $query = $self->{_db}->prepare(<<SQL);
-     UPDATE current_labels
-         SET priority = $priority
-         WHERE label LIKE '$label'
-         AND server LIKE 'stdscience';
+         WHERE stage LIKE '$stage' AND telescope LIKE '$telescope';
 SQL
 
@@ -211,5 +193,6 @@
 
     my $query = $self->{_db}->prepare(<<SQL);
-    DELETE FROM server_dates;
+    DELETE FROM science_server_dates;
+
 SQL
 
@@ -223,5 +206,5 @@
 ###########################################################################
 sub updateServerDates {
-    my ($self, $server, $dates) = @_;
+    my ($self, $server, $dates,$telescope) = @_;
 
     my $size = scalar @{$dates};
@@ -233,8 +216,8 @@
 
         my $query = $self->{_db}->prepare(<<SQL);
-        INSERT INTO server_dates
-            (server, date)
+        INSERT INTO science_server_dates
+            (server, telescope, date)
             VALUES
-            ('$server', '$date');
+            ('$server','$telescope', '$date');
 SQL
 
@@ -249,8 +232,8 @@
 ###########################################################################
 sub updateNightlyScience {
-    my ($self, $status) = @_;
-
-    my $query = $self->{_db}->prepare(<<SQL);
-    DELETE FROM nightlyscience;
+    my ($self, $status,$telescope) = @_;
+
+    my $query = $self->{_db}->prepare(<<SQL);
+    DELETE FROM science_nightlyscience WHERE telescope LIKE '$telescope';
 SQL
 
@@ -258,8 +241,8 @@
 
     $query = $self->{_db}->prepare(<<SQL);
-    INSERT INTO nightlyscience
-        (status)
+    INSERT INTO science_nightlyscience
+        (status, telescope)
         VALUES
-        ('$status');
+        ('$status', '$telescope');
 SQL
 
@@ -269,22 +252,24 @@
 ###########################################################################
 #
-# Updates current_labels table
+# Updates science_labels table
 #
 ###########################################################################
 sub updateCurrentLabels {
-    my ($self, $server, $labels) = @_;
+    my ($self, $server, $labels, $telescope,$priorities) = @_;
 
     my $size = scalar @{$labels};
     if ($size < 1) { return; }
-    if ($server eq 'stdscience') {
+#    if (($server eq 'stdscience') && ($telescope eq 'gpc1')) {
 	## EAM 20180510 : manually adding label used for Pole reprocessing
 	## I would like to add an external file to manage these extra 
 	## labels, but this suffices for now
-        push @{$labels}, 'PV3.Pole.Reprocess.20180510';
-	push @{$labels}, 'ps_ud_QUB';
-    }
-
-    my $query = $self->{_db}->prepare(<<SQL);
-    DELETE FROM current_labels WHERE server LIKE '$server';
+#        push @{$labels}, 'PV3.Pole.Reprocess.20180510';
+#	push @{$labels}, 'ps_ud_QUB';
+#        push @{priorities}, 50000;
+#	push @{priorities}, 415;
+#    }
+
+    my $query = $self->{_db}->prepare(<<SQL);
+    DELETE FROM science_labels WHERE server LIKE '$server' AND telescope LIKE '$telescope';
 SQL
 
@@ -292,12 +277,15 @@
 
     my $label = undef;
-
-    foreach $label (@{$labels}) {
+    my $priority = undef;
+
+    foreach my $i (0 .. $#$labels) {
+        $label = @{$labels}[$i];
+        $priority = @{$priorities}[$i];
 
         my $query = $self->{_db}->prepare(<<SQL);
-        INSERT INTO current_labels
-            (server, label)
+        INSERT INTO science_labels
+            (server, label,telescope,priority)
             VALUES
-            ('$server', '$label');
+            ('$server', '$label','$telescope',$priority);
 SQL
 
Index: trunk/ippMonitor/czartool/czartool/Pantasks.pm
===================================================================
--- trunk/ippMonitor/czartool/czartool/Pantasks.pm	(revision 40834)
+++ trunk/ippMonitor/czartool/czartool/Pantasks.pm	(revision 40840)
@@ -24,6 +24,4 @@
         );
 
-my $ipphome = "/data/ippc64.1/ippitc";
-
 ###########################################################################
 #
@@ -86,7 +84,18 @@
 ###########################################################################
 sub getNightlyScienceStatus {
-    my ($self, $status) = @_;
+    my ($self, $status,$telescope) = @_;
 
     my @labels;
+    my $ipphome;
+
+    if ($telescope eq 'gpc1') {
+       $ipphome = "/data/ippc64.1/ippitc";
+    }
+    elsif ($telescope eq 'gpc2') {
+       $ipphome = "/data/ippc18.0/home/ippps2";
+    }
+    else {
+        print "WARNING: Must specify a telescope for connecting to the right pantask\n";
+    }
 
     my ($day, $month, $year) = (localtime)[3,4,5];
@@ -102,4 +111,8 @@
         if ($line =~ m/$today\s+(.+)/) {
             ${$status} = $1;
+            if (${$status} =~ m/ $telescope/) {
+            ${$status} = $`;
+            }
+
             return 1;
         }
@@ -111,13 +124,23 @@
 ###########################################################################
 #
-# Gets labels for provided server 
+# Gets labels for provided server for gpc1
 #
 ###########################################################################
 sub getLabels {
-    my ($self, $server) = @_;
+    my ($self, $server,$telescope) = @_;
 
     my @labels;
-
-    # print "stdscience : $ipphome/$server/ptolemy.rc\n";
+    my $ipphome;
+
+    if ($telescope eq 'gpc1') {
+       $ipphome = "/data/ippc64.1/ippitc";
+    }
+    elsif ($telescope eq 'gpc2') {
+       $ipphome = "/data/ippc18.0/home/ippps2";
+    }
+    else {
+        print "WARNING: Must specify a telescope for connecting to the right pantask\n";
+    }
+
     my @cmdOut = `echo "show.labels;quit" | pantasks_client -c $ipphome/$server/ptolemy.rc 2>&1`;
     my $line;
@@ -149,5 +172,17 @@
 ###########################################################################
 sub getServerStatus {
-    my ($self, $server, $alive, $running) = @_;
+    my ($self, $server,$telescope, $alive, $running) = @_;
+
+    my $ipphome;
+
+    if ($telescope eq 'gpc1') {
+       $ipphome = "/data/ippc64.1/ippitc";
+    }
+    elsif ($telescope eq 'gpc2') {
+       $ipphome = "/data/ippc18.0/home/ippps2";
+    }
+    else {
+        print "WARNING: Must specify a telescope for connecting to the right pantask\n";
+    }
 
     my @cmdOut = `echo "status ; quit" | pantasks_client -c $ipphome/$server/ptolemy.rc 2>&1`;
@@ -170,5 +205,16 @@
 ###########################################################################
 sub getServerCurrentStatus {
-    my ($self, $server) = @_;
+    my ($self, $server,$telescope) = @_;
+
+    my $ipphome;
+    if ($telescope eq 'gpc1') {
+       $ipphome = "/data/ippc64.1/ippitc";
+    }
+    elsif ($telescope eq 'gpc2') {
+       $ipphome = "/data/ippc18.0/home/ippps2";
+    }
+    else {
+        print "WARNING: Must specify a telescope for connecting to the right pantask\n";
+    }
 
     my @cmdOut = `echo "status;quit" | pantasks_client -c $ipphome/$server/ptolemy.rc 2>&1`;
@@ -189,5 +235,16 @@
 ###########################################################################
 sub getRevertStatus {
-    my ($self, $stage, $reverting) = @_;
+    my ($self, $stage,$telescope, $reverting) = @_;
+
+    my $ipphome;
+    if ($telescope eq 'gpc1') {
+       $ipphome = "/data/ippc64.1/ippitc";
+    }
+    elsif ($telescope eq 'gpc2') {
+       $ipphome = "/data/ippc18.0/home/ippps2";
+    }
+    else {
+        print "WARNING: Must specify a telescope for connecting to the right pantask\n";
+    }
 
     my $server = $self->getServerForThisStage($stage);
@@ -214,9 +271,20 @@
 ###########################################################################
 sub getDates {
-    my ($self, $server) = @_;
+    my ($self, $server,$telescope) = @_;
 
     my @dates;
 
     my $prefix;
+    my $ipphome;
+
+    if ($telescope eq 'gpc1') {
+       $ipphome = "/data/ippc64.1/ippitc";
+    }
+    elsif ($telescope eq 'gpc2') {
+       $ipphome = "/data/ippc18.0/home/ippps2";
+    }
+    else {
+        print "WARNING: Must specify a telescope for connecting to the right pantask\n";
+    }
 
     if ($server eq "stdscience") {$prefix = "ns";}
