]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Support for cached enums and new parameter passing from monitoring process to CGI...
authorhadeshyp <hadeshyp>
Sun, 4 Nov 2012 21:37:04 +0000 (21:37 +0000)
committerhadeshyp <hadeshyp>
Sun, 4 Nov 2012 21:37:04 +0000 (21:37 +0000)
cts/htdocs/cts.pl

index b2b10f864a373b2f7d4800ea79c0a213fc0fabab..c1227f4440f97d90ad990725313b1dee51a94d31 100755 (executable)
@@ -1,11 +1,14 @@
 use strict;
 use warnings;
+use warnings::register;
 
 use lib "./include/";
 
 use Cts;
 use CtsConfig;
 
+use File::Basename;
+
 BEGIN {
    if (eval "require JSON::PP;") {
       *JSON_BIND:: = *JSON::PP::;
@@ -17,17 +20,28 @@ BEGIN {
 
 
 sub connectToCTS {
-   my $endpoint = shift;
-   
    my $trb;
 
+
+ # 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 );
+
+   $ENV{'DAQOPSERVER'} = $cache->{'daqop'};
+   my $endpoint = hex $cache->{'endpoint'};
+   
    eval {require "TrbNet.pm"};
    $trb = TrbNet->new($endpoint);
-      
-   return Cts->new($trb);
+   
+   return Cts->new($trb, $cache->{'enumCache'});
 }
 
-my $cts = connectToCTS( CtsConfig->getDefaultEndpoint );
+my $cts = connectToCTS( );
 
 my $query = $ENV{'QUERY_STRING'};