]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Improved error messages
authorManuel Penschuck <manuel.penschuck@stud.uni-frankfurt.de>
Fri, 1 Nov 2013 20:06:02 +0000 (21:06 +0100)
committerManuel Penschuck <manuel.penschuck@stud.uni-frankfurt.de>
Fri, 1 Nov 2013 20:06:02 +0000 (21:06 +0100)
Support for Cts AddOn
Fix for bug, that causes firefox not to reload page in case of an error

web/CtsPlugins/CtsMod10.pm
web/CtsPlugins/CtsMod12.pm [new file with mode: 0644]
web/CtsPlugins/CtsModStatic.pm
web/cts
web/htdocs/cts.htm
web/htdocs/cts.pl
web/htdocs/layout/base.css
web/htdocs/scripts/cts.js [moved from web/htdocs/scripts/base.js with 89% similarity]
web/include/Cts.pm

index 47e7ad220a307d335ba20aded01b1cc49ffa88d8..43f7063bcc70c144d5ba229f9e61ddef08806716 100755 (executable)
@@ -40,7 +40,9 @@ sub init {
    }
 
    for(my $i = 0; $i < $header->{'itc_len'}; $i++) {
-      $self->{'_cts'}->getProperties->{'itc_assignments'}[$i + $header->{'itc_base'}] = "Trigger Input $i";
+      if ($self->{'_cts'}->getProperties->{'itc_assignments'}[$i + $header->{'itc_base'}] eq 'unconnected') {
+        $self->{'_cts'}->getProperties->{'itc_assignments'}[$i + $header->{'itc_base'}] = "Trigger Input $i";
+      }
    }
 
 # properties
diff --git a/web/CtsPlugins/CtsMod12.pm b/web/CtsPlugins/CtsMod12.pm
new file mode 100644 (file)
index 0000000..7713b47
--- /dev/null
@@ -0,0 +1,54 @@
+# Module: AddOn Input Multiplexer (Type 0x12)
+package CtsMod12;
+
+@ISA = (CtsBaseModule);
+
+use warnings;
+use strict;
+use TrbRegister;
+
+sub moduleName {"AddOn Input Multiplexer"}
+
+sub init {
+   my $self    = $_[0];
+   my $address = $_[1];
+   
+   my $trb  = $self->{'_cts'}{'_trb'};
+   
+   my $regs = $self->{'_registers'};
+   my $prop = $self->{'_properties'};
+
+   my $header = $self->{'_cts'}{'_enum'}{0x12}->read();
+   
+# registers
+   for(my $i = 0; $i < $header->{'len'}; $i++) {
+      my $key = "trg_addon_config$i";
+      
+      $regs->{$key} = new TrbRegister($address + 1 + $i, $trb, {
+         'input'  => {'lower' =>  0, 'len' => 7, 'type' => 'enum', 'enum' => 
+            {
+              0 => 'jeclin[0]', 1 => 'jeclin[1]', 2 => 'jeclin[2]', 3 => 'jeclin[3]', 
+              4 => 'jin1[0]',   5 => 'jin1[1]',   6 => 'jin1[2]',   7 => 'jin1[3]', 
+              8 => 'jin2[0]',   9 => 'jin2[1]',  10 => 'jin2[2]',  11 => 'jin2[3]',
+             12 => 'nimin1',   13 => 'nimin2'
+            }
+         }
+      }, {
+         'accessmode' => "rw",
+         'export'     => 1,
+         'monitor' => '1',
+         'label' => "AddOn Multiplexer $i"
+      });
+   }
+
+   for(my $i = 0; $i < $header->{'itc_len'}; $i++) {
+      $self->{'_cts'}->getProperties->{'itc_assignments'}[$i + $header->{'itc_base'}] = "AddOn Multiplexer $i";
+   }
+
+# properties
+   $prop->{"trg_addon_count"} = $header->{'len'};
+   $prop->{"trg_addon_itc_base"} = $header->{'itc_base'};
+
+}
+
+1;
\ No newline at end of file
index f8e7b32d8791189809597a5d7d15f2d8cb36e61c..5662620565b9e77eb217635e45508884a4a6ec7b 100755 (executable)
@@ -23,6 +23,10 @@ sub init {
    my $trb = $self->{'_cts'}->{'_trb'};
    
    my $debug_block = 0xa000;
+
+   $prop->{'cts_clock_frq'} = 1e8;
+   $prop->{'trb_endpoint'} = $trb->getEndpoint;
+   $prop->{'trb_compiletime'} = $trb->read(0x40);
    
    $regs->{'cts_cnt_trg_asserted'} = TrbRegister->new(0x00 + $debug_block, $trb, {}, {
       'accessmode' => "ro",
@@ -156,10 +160,30 @@ sub init {
       'monitor' => 1,
       'export' => 1
    });
+   
+   if ($prop->{'trb_compiletime'} > 1366287468) {
+      eval {
+         # really ugly solution, but we currently have to read the register in order
+         # to verify its existing ...
+         $regs->{'cts_eventbuilder'} = TrbRegister->new(0x0d + $debug_block, $trb, {
+            'mask'         => {'lower' =>  0, 'len' => 16,'type' => 'mask'},
+            'rr_interval'  => {'lower' => 16, 'len' => 8, 'type' => 'uint'},
+            'cal_eb'       => {'lower' => 24, 'len' => 4, 'type' => 'uint'},
+            'use_cal_eb'   => {'lower' => 28, 'len' => 1, 'type' => 'bool'}
+         
+         }, {
+            'accessmode' => "rw",
+            'label' => "Event Builder Selection",
+            'monitor' => 1,
+            'export' => 1
+         });
+         $regs->{'cts_eventbuilder'}->read();
+         1;
+      } and do {
+         $prop->{'cts_eventbuilder_rr'} = 1;
+      }
+   }
 
-   $prop->{'cts_clock_frq'} = 1e8;
-   $prop->{'trb_endpoint'} = $trb->getEndpoint;
-   $prop->{'trb_compiletime'} = $trb->read(0x40);
 }
 
 1;
diff --git a/web/cts b/web/cts
index c104f3db6ee004d62a758eca02dc82f23d865bed..73999744593303e6ab4f0a9cb458c0bd0d1cd06d 100755 (executable)
--- a/web/cts
+++ b/web/cts
@@ -3,8 +3,7 @@
 # Debugging
    use warnings;
    use strict;
-   use Carp;
-   $SIG{ __DIE__ } = sub { Carp::confess( @_ ) };
+
 
 use lib "./include";
    
@@ -33,6 +32,30 @@ use lib "./include";
       }
    }
 
+   our $endpoint;
+   use Carp;
+   $SIG{ __DIE__ } = sub { 
+      my $error = $_[0];
+
+      if ($error =~ /unknown address/ and $error =~ /trb_register_read/ and $error =~ /0xa[012]/) {
+         printf("Endpoint (0x%04x) responded, but could not read CTS registers. Does the endpoint contain a CTS?\n" . 
+         "If the CTS uses a different address, change the default endpoint address in\n" . 
+         "htdocs/CtsConfig.pm, or use the --endpoint parameter when starting the CTS tool.", $endpoint);
+         
+      } elsif ($error =~ /no endpoint has been reached/) {
+         printf("Endpoint (0x%04x) not reached. Please ensure that \n" . 
+         "(1) the correct DAQOPSERVER is used and\n" .
+         "(2) the CTS is configured to this address.\n" .
+         "If the CTS uses a different address, change the default endpoint address in\n" . 
+         "htdocs/CtsConfig.pm, or use the --endpoint parameter when starting the CTS tool.", $endpoint);
+      }
+      
+      print "\n\n\n--------------------- More details error description ------------------------------\n";
+      Carp::confess( @_ );
+      
+      exit;
+   };   
+   
 
    use FileHandle;
    
@@ -93,7 +116,7 @@ sub connectToCTS {
 }
 
 ####################################################################################
-my $endpoint = CtsConfig->getDefaultEndpoint;
+$endpoint = CtsConfig->getDefaultEndpoint;
 
 my $updateInterval = 1000;
 my $quiet = 0;
index d126f26a52624906633777d0fab172088eb6f188..bb77b2359dc2a8583d15b77032480272aeac9bc3 100644 (file)
@@ -5,7 +5,7 @@
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
       <link href="layout/base.css" rel="Stylesheet" type="text/css" />
       <script src="scripts/mootools-core-1.4.5.js" type="text/javascript"></script>
-      <script src="scripts/base.js" type="text/javascript"></script>
+      <script src="scripts/cts.js" type="text/javascript"></script>
    </head>
 
    <body lang="en">
             </div>
          </div>
 
+         <div class="expandable expanded" id="addon-board-expander">
+            <div class="header"><span class="indicator"></span> AddOn-Board Input Multiplexer</div>
+            
+            <div class="content">
+                  <table id="addon-board-tab">
+                     <tr>
+                        <th class="num">#</th>
+                        <th class="source">Source</th>
+                        <th class="rate">Inp. Rate</th>
+                        <th class="invert">Invert</th>
+                        <th class="delay">Delay</th>
+                        <th class="spike"><abbr title="Noise reducing. High pulses shorter than this values are rejeted">Spike Rej.</abbr></th>
+                        <th class="override">Override</th>
+                     </tr>
+                  </table>
+            </div>
+         </div>
+         
          <div class="expandable expanded" id="coin-expander">
             <div class="header"><span class="indicator"></span> Pulsers</div>
             
                         <td class="value"><input type="checkbox" class="autoupdate autocommit" slice="cts_readout_config.trg_cnt" /> Trigger statistics</td>
                      </tr>
 
-                     <tr class="alt">
+                     <tr class="">
                         <td> </td>
                         <td class="value"><input type="checkbox" class="autoupdate autocommit" slice="cts_readout_config.timestamp" /> Timestamp</td>
                      </tr>
                      
-                     <tr class="alt">
-                        <td class="label">TD FSM Limit (debug only):</td>
+                     <tr class="eventbuilder_rr alt"><td colspan="2">&nbsp;</td><tr>
+<!--                     
+                     <tr class="eventbuilder_rr">
+                        <td>Active Event Builder</td>
                         <td class="value">
-                           <input class="autocommit autoupdate text" slice="cts_fsm_limits.td" 
-                                  format="var f=function(x){return parseInt(x)==0xffff ? 'disabled' : (parseInt(x) ? x + ' events' : 'active')}; f"
-                                  interpret="var f=function(x){return (x.trim() == '' || x.match(/disabled|off/)) ? 0xffff : (isNaN(parseInt(x))?0:parseInt(x))}; f" />
+                           <pre>15</pre> <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[15]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[14]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[13]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[12]">&nbsp;&nbsp;&nbsp;
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[11]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[10]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[9]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[8]"> <pre>8</pre> <br />
+                           <pre> 7</pre> <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[7]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[6]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[5]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[4]">&nbsp;&nbsp;&nbsp;
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[3]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[2]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[1]">
+                           <input type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.mask[0]"> <pre>0</pre> 
+                        </td>
+                     </tr>
+                     
+                     <tr class="alt eventbuilder_rr">
+                        <td>Round-Robin Bin Size</td>
+                        <td class="value">
+                           <input class="text autoupdate autocommit" slice="cts_eventbuilder.rr_interval" /> events
                         </td>
                      </tr>
 
-                     <tr>
-                        <td class="label">RO FSM Limit (debug only):</td>
+                     <tr class="eventbuilder_rr">
+                        <td>Event Builder for Calibration <br /> Trigger (Type 0xe)</td>
                         <td class="value">
-                           <input class="autocommit autoupdate text" slice="cts_fsm_limits.ro" 
-                                  format="var f=function(x){return parseInt(x)==0xffff ? 'disabled' : (parseInt(x) ? x + ' events' : 'active')}; f"
-                                  interpret="var f=function(x){return (x.trim() == '' || x.match(/disabled|off/)) ? 0xffff : (isNaN(parseInt(x))?0:parseInt(x))}; f" />
+                           <input id="eb_rr_use" type="checkbox" class="autoupdate autocommit" slice="cts_eventbuilder.use_cal_eb" /> use dedicated EB with Id:
+                           <input id="eb_rr" class="text autoupdate autocommit" slice="cts_eventbuilder.cal_eb"  />  
                         </td>
                      </tr>                     
+-->                     
                   </table>               
                </div>
                
                         <td class="label">Buffered Trigger (15:0)</td>
                         <td class="value autoupdate" slice="cts_buf_trg_state" format="var x=function(x,data){return '<pre>'+ data.f.mask + '</pre>, Type: '+data.f.type}; x">n/a</td>
                      </tr>
+
+                     <tr><td colspan="2">&nbsp;</td><tr>
+                     
+                     <tr class="alt">
+                        <td class="label">TD FSM Limit (debug only):</td>
+                        <td class="value">
+                           <input class="autocommit autoupdate text" slice="cts_fsm_limits.td" 
+                                  format="var f=function(x){return parseInt(x)==0xffff ? 'disabled' : (parseInt(x) ? x + ' events' : 'active')}; f"
+                                  interpret="var f=function(x){return (x.trim() == '' || x.match(/disabled|off/)) ? 0xffff : (isNaN(parseInt(x))?0:parseInt(x))}; f" />
+                        </td>
+                     </tr>
+
+                     <tr>
+                        <td class="label">RO FSM Limit (debug only):</td>
+                        <td class="value">
+                           <input class="autocommit autoupdate text" slice="cts_fsm_limits.ro" 
+                                  format="var f=function(x){return parseInt(x)==0xffff ? 'disabled' : (parseInt(x) ? x + ' events' : 'active')}; f"
+                                  interpret="var f=function(x){return (x.trim() == '' || x.match(/disabled|off/)) ? 0xffff : (isNaN(parseInt(x))?0:parseInt(x))}; f" />
+                        </td>
+                     </tr>                     
                   </table>
                </div>
             </div>
index d25697cf29141d3210dd7d0d6c9b9bcfadb07efa..23872df487ee212d1825c8bbdeb57e2841b110f0 100755 (executable)
@@ -10,6 +10,34 @@ use CtsCommands;
 
 use File::Basename;
 
+our $endpoint;
+use Carp;
+$SIG{ __DIE__ } = sub { 
+   my $error = $_[0];
+
+   print 'HTTP/1.0 500 INTERNAL SERVER ERROR';
+   print "\r\nContent-Type: text/html;\r\n\r\n";
+
+   print "<pre>\r\n";
+
+   if ($error =~ /unknown address/ and $error =~ /trb_register_read/ and $error =~ /0xa[012]/) {
+      printf("Endpoint (0x%04x) responded, but could not read CTS registers. Does the endpoint contain a CTS?\n" . 
+      "If the CTS uses a different address, change the default endpoint address in\n" . 
+      "htdocs/CtsConfig.pm, or use the --endpoint parameter when starting the CTS tool.", $endpoint);
+      
+   } elsif ($error =~ /no endpoint has been reached/) {
+      printf("Endpoint (0x%04x) not reached. Please ensure that \n" . 
+      "(1) the correct DAQOPSERVER is used and\n" .
+      "(2) the CTS is configured to this address.\n" .
+      "If the CTS uses a different address, change the default endpoint address in\n" . 
+      "htdocs/CtsConfig.pm, or use the --endpoint parameter when starting the CTS tool.", $endpoint);
+   }
+   
+   print "\n\n\n--------------------- More details error description ------------------------------\n";
+   print $error;
+   
+   print "</pre>\r\n";
+};   
 
 BEGIN {
    if (eval "require JSON::PP;") {
@@ -41,7 +69,7 @@ sub printHeader {
 sub connectToCTS {
    my $trb;
 
-   my $endpoint = CtsConfig->getDefaultEndpoint;
+   $endpoint = CtsConfig->getDefaultEndpoint;
    my $cache = {'enumCache' => 0};
    
    my $port = int $ENV{'SERVER_PORT'};
@@ -72,6 +100,8 @@ sub connectToCTS {
 
 my $cts = connectToCTS( );
 
+#print Dumper $cts;
+
 my $query = $ENV{'QUERY_STRING'};
 
 if ($query eq "init") {
index 547ddec223f3817d321ed54b530dc1e832850639..5e8f197534b0c3aa1217111b55c3df5cca33d15d 100644 (file)
       text-align: right;
    }
 
+   .eventbuilder_rr {visibility: hidden;}
       
\ No newline at end of file
similarity index 89%
rename from web/htdocs/scripts/base.js
rename to web/htdocs/scripts/cts.js
index 69254b98a6d21470fb57953e415cbe9407a5ca59..84a2dbe8fa216c1c64031330f515cc408f409fa3 100644 (file)
@@ -76,6 +76,7 @@ var CTS = new Class({
       this.renderTriggerChannels();
       this.renderTriggerInputs();
       this.renderCoins();
+      this.renderTriggerAddOnInputs();
       this.renderRegularPulsers();
       this.renderRandPulsers();
       this.renderCTSDetails();
@@ -90,9 +91,11 @@ var CTS = new Class({
       });
       
       this.addEvent('dataUpdate', this.updateStatusIndicator.bind(this));
+      //this.addEvent('dataUpdate', function() {$('eb_rr').set('disabled', !this.currentData.
+
+      this.initEventBuilderRR();
       
       this.initAutoCommit();
-      
       this.initSliceTitle();
    },
    
@@ -107,6 +110,7 @@ var CTS = new Class({
       }
    },
    
+   
    writeRegisters: function(values) {
       var arrValues = [];
       Object.each(values, function(v,r) {arrValues.push(r); arrValues.push(v)});
@@ -147,7 +151,11 @@ var CTS = new Class({
       dup.removeClass('error').set('text', 'Update').setStyle('display', 'block');
       
       // hard-reset. if request's timeout fails, this is the last resort ...
-      var manualTimeout = window.location.reload.delay(10000);
+      var manualTimeout = (function(e) {
+        if (console) 
+          console.log(e.stack);
+        window.location.reload.delay(10000);
+      }).delay(10000, this, new Error());
       
       new Request.JSON({
          url: this.monitorPrefix + 'dump.js',
@@ -194,6 +202,11 @@ var CTS = new Class({
          }.bind(this)
       }).send();
    },
+   
+   initEventBuilderRR: function() {
+      if (!this.defs.properties.cts_eventbuilder_rr) return;
+      $$('.eventbuilder_rr').setStyle('visibility', 'visible');
+   },
 
 /**
  * This method handles all "autorate"-elements. It is registered
@@ -358,7 +371,9 @@ var CTS = new Class({
  * should not by called manually.
  */
    renderTriggerInputs: function() {
-      for(var i=0; i < this.defs.properties.trg_input_count; i++) {
+      var num = this.defs.properties.trg_input_count;
+      num -= (this.defs.properties.trg_addon_count) ? this.defs.properties.trg_addon_count : 0;
+      for(var i=0; i < num; i++) {
          var reg = 'trg_input_config' + i;
          $('inputs-tab')
          .adopt(
@@ -403,6 +418,74 @@ var CTS = new Class({
       }
    },
 
+/**
+ * Creates all active elements of the AddOn Multiplexer Input Configuration
+ * section. It is called by the class' constructor and hence
+ * should not by called manually.
+ */
+   renderTriggerAddOnInputs: function() {
+      if (!this.defs.properties.trg_addon_count) {
+         $('addon-board-expander').setStyle('display', 'none');
+         return;
+      }
+      
+      var from = this.defs.properties.trg_input_count - this.defs.properties.trg_addon_count;
+      var to = this.defs.properties.trg_input_count;
+      
+      for(var i=from; i < to; i++) {
+         var reg = 'trg_input_config' + i;
+         var areg = 'trg_addon_config' + (i-from);
+         var en = this.defs.registers[areg]._defs.input.enum;
+         $('addon-board-tab')
+         .adopt(
+            new Element('tr', {'class': i%2?'':'alt', 'flashgroup': 'itc-' + (i + parseInt(this.defs.properties.trg_input_itc_base))})
+            .adopt(
+               new Element('td', {'class': 'num', 'text': i}),
+               
+               new Element('td', {'class': 'source'})
+               .adopt(
+                  new Element('select', {'class': 'text autocommit autoupdate', 'slice': areg + '.input'})
+                  .adopt(
+                     Object.values(en).map(function (r) {
+                        return new Element('option', {'value': r, 'text': r})
+                     })
+                   )
+               ),
+               
+               new Element('td', {'class': 'rate autorate', 'slice': 'trg_input_edge_cnt' + i + '.value', 'text': 'n/a', 'id': 'inp-rate' + i}),
+               
+               new Element('td', {'class': 'invert'})
+               .adopt(
+                  new Element('input', {'type': 'checkbox', 'class': 'autocommit autoupdate', 'slice': reg + '.invert'})
+               ),
+
+               new Element('td', {'class': 'delay'})
+               .adopt([
+                  new Element('input', {'class': 'text autocommit autoupdate', 'slice': reg + '.delay', 'format': 'countToTime', 'interpret': 'timeToCount'}),
+                  new Element('span', {'text': ' ns'})
+               ]),
+
+               new Element('td', {'class': 'spike'})
+               .adopt([
+                  new Element('input', {'class': 'text autocommit autoupdate', 'slice': reg + '.spike_rej', 'format': 'countToTime', 'interpret': 'timeToCount'}),
+                  new Element('span', {'text': ' ns'})
+               ]),
+               
+               new Element('td', {'class': 'override'})
+               .adopt(
+                  new Element('select', {'class': 'text autocommit autoupdate', 'slice': reg + '.override'})
+                  .adopt([
+                     new Element('option', {'value': 'off', 'text': 'bypass'}),
+                     new Element('option', {'value': 'to_low', 'text': '-> 0'}),
+                     new Element('option', {'value': 'to_high', 'text': '-> 1'}),
+                  ])
+               )
+            )
+         );
+      }
+   },
+   
+   
 /**
  * Creates all active elements of the Trigger Channel Configuration
  * section. It is called by the class' constructor and hence
@@ -670,6 +753,7 @@ var CTS = new Class({
 });
 
 function xhrFailure(xhr){
+   console.log(xhr.responseText);
    var m = xhr.responseText.match(/<pre>([\s\S]*)<\/pre>/im);
    if (m) alert("Server send error response:\n"+m[1].trim());
    else  alert("An unknown error while contacting the sever. Did you open this file locally? Did the connection or server crash?");
index 22d29743060746a77ff0d9cc23ff82a1ca8b36e7..2a81688074fb345dd8308c09f7da909bd4212fee 100644 (file)
@@ -34,7 +34,8 @@ sub new {
    
    $self->{'_enumCache'} =  $enumCache if ref $enumCache;
    
-   my $static = $self->_loadModule("Static") or die("Error while loading mandantory module >CtsModStatic<");
+   my $static = $self->_loadModule("Static") or exit; #die("Error while loading mandantory module >CtsModStatic<");
    $static->register();
    
    $self->_enumerateTriggerLogic();