]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Fallback when enum.js is empty or not present
authorhadeshyp <hadeshyp>
Tue, 6 Nov 2012 21:32:57 +0000 (21:32 +0000)
committerhadeshyp <hadeshyp>
Tue, 6 Nov 2012 21:32:57 +0000 (21:32 +0000)
cts/htdocs/cts.pl

index c1227f4440f97d90ad990725313b1dee51a94d31..2873d5d6a37762de321e982edf4eebe545e8dc0d 100755 (executable)
@@ -22,18 +22,24 @@ BEGIN {
 sub connectToCTS {
    my $trb;
 
+   my $endpoint = CtsConfig->getDefaultEndpoint;
+   my $cache = {'enumCache' => 0};
 
  # open cache create by monitor process to
  #  a) reduce the number of read accesses
  #  b) ensure the same interface is used
    open FH, "<" .  dirname(__FILE__) . "/monitor/enum.js";
-   my $json = join ' ', <FH>;
-   close FH;
-   
-   my $cache = JSON_BIND->new->decode( $json );
+   if (tell(FH) != -1) {
+      my $json = join ' ', <FH>;
+      close FH;
+      
+      if ($json) {
+         $cache = JSON_BIND->new->decode( $json );
 
-   $ENV{'DAQOPSERVER'} = $cache->{'daqop'};
-   my $endpoint = hex $cache->{'endpoint'};
+         $ENV{'DAQOPSERVER'} = $cache->{'daqop'};
+         $endpoint = hex $cache->{'endpoint'};
+      }
+   }
    
    eval {require "TrbNet.pm"};
    $trb = TrbNet->new($endpoint);