From 21058cac60033995081c9f695e4cf4df0898c076 Mon Sep 17 00:00:00 2001 From: hadeshyp Date: Sun, 4 Nov 2012 21:37:04 +0000 Subject: [PATCH] Support for cached enums and new parameter passing from monitoring process to CGI script --- cts/htdocs/cts.pl | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/cts/htdocs/cts.pl b/cts/htdocs/cts.pl index b2b10f8..c1227f4 100755 --- a/cts/htdocs/cts.pl +++ b/cts/htdocs/cts.pl @@ -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 ' ', ; + 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'}; -- 2.43.0