]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
still working on nxyter
authorHadaq@styx <hadaq@styx>
Fri, 11 Oct 2013 09:18:30 +0000 (11:18 +0200)
committerHadaq@styx <hadaq@styx>
Fri, 11 Oct 2013 09:18:30 +0000 (11:18 +0200)
users/cosy_test/config/nxyter/read_i2cregs.sh [new file with mode: 0755]
users/cosy_test/config/nxyter/setup.sh
users/cosy_test/config/nxyter/write_i2cregs.sh [new file with mode: 0755]
web/htdocs/layout/styles.css
web/htdocs/nxyter/blue.css [new file with mode: 0644]
web/htdocs/nxyter/index.pl [new file with mode: 0755]
web/htdocs/nxyter/scripts.js [new file with mode: 0644]
web/htdocs/xml-db [new symlink]
xml-db/database/Nxyter.xml
xml-db/get.pl

diff --git a/users/cosy_test/config/nxyter/read_i2cregs.sh b/users/cosy_test/config/nxyter/read_i2cregs.sh
new file mode 100755 (executable)
index 0000000..8fb4b6e
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+trbcmd w  0x3800 0x8240 1
+trbcmd rm 0x3800 0x8200 46 0
index 6e7ce33c3f0d1e81e96758aee7f6eb130eb4f701..23b3188561b65fad5b512572c4bdfe4bfc25c957 100755 (executable)
@@ -45,3 +45,8 @@ trbcmd w 0x3800 0x8120 0       # reset all counters
 
 # Enable nxyter
 trbcmd w 0x3800 0x8103 0
+
+#Debugging to test ADC alignment / reset feature
+sleep 1;
+trbcmd w 0x3800 0x8501 1
+
diff --git a/users/cosy_test/config/nxyter/write_i2cregs.sh b/users/cosy_test/config/nxyter/write_i2cregs.sh
new file mode 100755 (executable)
index 0000000..1800741
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+trbcmd wm 0x3800 0x8200 0 nxsetup.dat
+
index 0711cd309d6bf9983279a696858851168468d933..8b15a8a8e7c3d217f037228559997d461a21d352 100644 (file)
@@ -3,6 +3,7 @@ body {
     font-size:10pt;
     margin:0px 0 0 25px;
     padding:0;
+    font-family:sans-serif;
 
 }
 
@@ -10,12 +11,13 @@ body.index {
       background:#f5f5f5 url("/layout/background.png") fixed no-repeat;
 }
 
+table {
+ font-size: 10pt;
+ }
+
+
 h2 {
-/*   position:absolute; */
   width:100%;
-/*   top:-15px; */
-/*   left:0px; */
-/*   float:left; */
   background:#f9f9f9;
   border-bottom:1px solid #ccc;
   padding:10px 10px 5px 10px;
diff --git a/web/htdocs/nxyter/blue.css b/web/htdocs/nxyter/blue.css
new file mode 100644 (file)
index 0000000..65e1b06
--- /dev/null
@@ -0,0 +1,293 @@
+body {
+    background:#efeff5;
+    color:#445;
+}
+
+
+
+#roterBereich, #blauerBereich, #fileSelection, #debug, #overview, #debugpane {
+  float:left;
+  position:relative;
+  width:320px;
+  padding:10px;
+  margin:50px 10px 0 30px;
+  border-radius:5px;
+  background:#eef;
+  box-shadow: 0 0 10px 5px #fff,  0 0 4px 1px #78b inset;
+  }
+
+#fileSelection {
+   width:700px;
+   min-height:50px;
+   margin:50px 0 0 20px;
+}
+
+#roterBereich {
+  clear:both;
+  }
+  
+#debug {
+   position:absolute;
+   top:100px;
+   left:800px;
+   width:220px;
+   margin:0px;
+}
+
+#debugpane {
+  float:left;
+  width:1000px;
+  margin:50px 0 0 20px;  
+
+}
+
+#overview {
+  width:1000px;
+  margin:50px 0 0 20px;  
+  }
+
+  
+input[type="text"] {
+    background-color:#dde;
+    color:#444;
+    font-size:10px;
+    height:20px;
+    width:90px;
+    text-align:right;
+    padding-right:5px;
+    border:1px solid #78b;
+    transition:background .4s;
+}
+
+select {
+    background:#dde;
+    color:#444;
+    border:1px solid #78b;
+    transition:background .4s;
+}
+
+input:hover, input:active, input:focus, select:hover, select:active {
+background:#eed;
+}
+
+.stdbutton, input.stdbutton:active, input.stdbutton:focus {
+    width:100px;
+    height:25px;
+    background:#dde;
+    color:#444;
+    border:1px solid #78b;
+    margin:0 5px;
+    padding:0 0 3px 0;
+    transition: background .4s;
+}
+
+input.stdbutton:hover {
+    background:#eed;
+    }
+
+
+table.registers {
+  border-collapse:collapse;
+  border:0px solid #eef;
+  color:#336;
+  cursor:default; 
+}
+
+
+table.registers td {
+  border: 2px solid #eef;
+  height:25px;
+}
+
+table.fields {
+  background:#dea;
+  border-collapse:collapse;
+  border:hidden;
+  cursor:default;
+}
+
+table.fields td {
+  border:solid #eef;
+  border-width:2px 0;
+  border-collapse:collapse;
+  height:25px;
+}
+
+table.registers>tbody>tr>td:nth-child(2) {
+  background:#dde;
+  }
+
+
+.fileLevel tr{
+    vertical-align:center;
+
+}
+
+.fieldError {background:red;}
+
+.fileLevel  {background:#dde;}
+.fileLevel1 {background:#ded;}
+.fileLevel2 {background:#ede;}
+.fileLevel3 {background:#fdf;}
+.fileLevel4 {background:#fdd;}
+.fileLevel5 {background:#ffd;}
+.fileLevel6 {background:#fff;}
+
+table.fields td.button_move, table.registers td.button_move, .button_move {
+  background:#dde;
+  cursor:pointer;
+  text-align:center;
+  color:#228;
+  width:25px;
+  border:2px solid #eef;
+  transition:background .4s;
+}
+
+
+table.fields td.button_move_deac {
+  background:#eef;
+  cursor:normal;
+  text-align:center;
+  color:transparent;
+  width:25px;
+  border:2px solid #eef;
+}
+
+.regheader {
+  background:lightgrey;
+  font-variant:small-caps;
+}
+
+.bitfield {
+  background:#dea;
+  visibility:collapse;
+}
+
+table.registers td.fieldcontainer {
+    margin:0;
+    padding:0;
+    border:0;
+}
+
+table.registers tr td:first-child {
+    cursor:pointer;
+    background:#dde;
+    transition: background .4s;
+    }
+
+table.registers tr td:first-child:hover {
+    background:#eed;
+} 
+
+table.fields tr td:nth-child(3){
+    font-family:monospace;
+    padding-right:10px;
+    color:#228;
+}
+
+tr.bitfield{
+    background:transparent;
+    cursor:auto;
+}
+
+
+
+
+
+table.registers tr.bitfield td:first-child{
+    background:transparent;
+    cursor:default;
+}
+
+table.fields td.button_move:hover, table.registers td.button_move:hover{
+    background:#eed;
+}
+
+
+div.header {
+  font-size:13pt;
+  position:absolute;
+  font-weight:bold;
+  top:-20px;
+  color:#88a;
+  z-index:-1;
+  }
+
+ul    {  padding-left:20px;}
+
+div.header span{
+  display:block;
+  float:left;
+  position:relative;
+  top:-2px;
+  margin:0 10px 0 0;
+  padding:2px 0px 0 0px;
+  border:0px solid transparent;
+  width:100px;
+  list-style:none;
+  cursor:hand;
+/*   text-align:center; */
+  border-radius:5px;
+}
+
+div.header span.inactive a:hover {
+/*   background:#78b; */
+/*   box-shadow: 0 0 10px 5px #78b; */
+  color:#78b;
+}
+
+div.header span.selected a{
+  color:#88a;  
+}
+
+div.header span.inactive a{
+  color:#bbd;  
+  transition:all .4s;  
+}
+
+div.header span a {
+  text-decoration:none;
+}
+
+div.header span a:hover {
+}
+
+
+.high {
+  background:#ded;
+}
+.low {
+  background:#edd;
+}
+
+.good {
+  background:#cfc;
+}
+.bad {
+  background:#fcc;
+}
+
+
+table.conversion {
+  visibility:collapse;
+  font-size:9pt;
+  background:transparent;
+}
+table.conversion tr td{
+  background:transparent!important;
+  border:none!important;
+  height:10px;
+}
+
+table.queryresult td:first-child, table.queryresult th:first-child{
+  width:130px;
+  max-width:100px;
+  overflow:hidden;
+  text-align:left;
+}
+
+hr.queryresult  {
+  border:none;
+  width:100%;
+  border-top:1px solid #aaa;
+}
diff --git a/web/htdocs/nxyter/index.pl b/web/htdocs/nxyter/index.pl
new file mode 100755 (executable)
index 0000000..49fdb04
--- /dev/null
@@ -0,0 +1,116 @@
+&htsponse(200, "OK");
+print "Content-type: text/html\r\n\r\n";
+
+
+use CGI ':standard';
+use XML::LibXML;
+use POSIX;
+use CGI::Carp qw(fatalsToBrowser);
+
+# use FindBin;
+# use lib "$FindBin::Bin/..";
+# use Environment;
+
+
+my $configFile = SETUPFILE;
+my $setup;
+
+
+my ($command,$style) = split("-",$ENV{'QUERY_STRING'});
+
+$command = "" unless defined $command;
+$style   = ""  unless defined $style;
+
+#   my $isSetup  = $command eq "setup";
+  my $isDataValidate = $command eq "DataValidate";
+  my $isTriggerValidate = $command eq "TriggerValidate";
+#   my $isErrors = $command eq "errors";
+
+
+initPage();
+
+
+
+
+
+sub getDataValidate {
+print <<EOF;
+  <input type="button" class="stdbutton" onClick="getdataprint('../xml-db/get.pl?Nxyter-0x3800-DataValidate','content',false);" value="Refresh">
+  <script language="javascript">setTimeout("getdataprint('../xml-db/get.pl?Nxyter-0x3800-DataValidate','content',false)",400);</script>
+  <div id="content"></div>
+EOF
+  }
+
+sub getTriggerValidate {
+print <<EOF;
+  <input type="button" class="stdbutton" onClick="getdataprint('../xml-db/get.pl?Nxyter-0x3800-TriggerValidate','content',false);" value="Refresh">
+  <script language="javascript">setTimeout("getdataprint('../xml-db/get.pl?Nxyter-0x3800-TriggerValidate','content',false)",400);</script>
+  <div id="content"></div>
+EOF
+  }
+  
+  
+
+sub initPage {
+  
+  print <<EOF;
+<HTML>
+<HEAD>
+<title>NXyter Status</title>
+<link href="../layout/styles.css" rel="stylesheet" type="text/css"/>
+<link href="blue.css" rel="stylesheet" title="Light Blue" type="text/css"/>
+EOF
+  printJavaScripts();
+  print qq(
+</HEAD>
+<BODY>
+<h2>NXyter Status</h2>
+<div id="overview">
+<div class="header">
+  <span class=").($isDataValidate?"selected":"inactive").qq("><a href="?DataValidate">DataVal.</a></span>
+  <span class=").($isTriggerValidate?"selected":"inactive").qq("><a href="?TriggerValidate">TrigVal.</a></span>
+</div>
+
+);
+if($isSetup) {
+  print '<div class="content">';
+  print '</div>';
+  }
+if ($isDataValidate) {
+  getDataValidate();
+  }
+if ($isTriggerValidate) {
+  getTriggerValidate();
+  }
+print <<EOF ;
+
+</div>
+<div id="debugpane">
+<div class="header">Debug Output</div>
+debug text
+</div>
+
+
+</BODY>
+</HTML>
+EOF
+}
+
+
+
+
+sub printJavaScripts {
+
+####### javascript function land ################
+
+  print <<EOF;
+<script language="javascript" src="scripts.js"></script>
+
+<script language="javascript">
+
+</script>
+EOF
+}
+
+
+
diff --git a/web/htdocs/nxyter/scripts.js b/web/htdocs/nxyter/scripts.js
new file mode 100644 (file)
index 0000000..dfdf5a4
--- /dev/null
@@ -0,0 +1,102 @@
+
+
+function getdata(command,callback) {
+  var xmlhttp = null;
+  var cb = null;
+  xmlhttp=new XMLHttpRequest();
+  cb = callback;
+  
+  xmlhttp.onreadystatechange = function() {
+    if(xmlhttp.readyState == 4) {
+      if(cb)
+        cb(xmlhttp.responseText);
+      }
+    }
+  xmlhttp.open("GET",command,true);
+  xmlhttp.send(null);
+  }
+
+  
+function getdataprint(command,dId,async) {
+  //async==true : do what you can when you can do it :D
+  //async==false : do the task after you finished the previous task!
+  
+  // super duper debug line!
+//   alert("caller is " + arguments.callee.caller.toString());
+  
+  var xmlhttp = null;
+  //var cb = null;
+  xmlhttp=new XMLHttpRequest();
+  //cb = callback;
+  var destId = dId;
+  
+  xmlhttp.onreadystatechange = function() {
+    if(xmlhttp.readyState == 4 && xmlhttp.status==200) {
+      //if(cb)
+  if(document.getElementById(destId)){
+  document.getElementById(destId).innerHTML  = xmlhttp.responseText;  
+  }
+        //cb(xmlhttp.responseText);
+  //document.getElementById(destId).innerHTML  = xmlhttp.responseText;  
+      }
+    }
+
+  xmlhttp.open("GET",command,async);
+  xmlhttp.send(null);
+  }  
+  
+
+function SciNotation(v) {
+  if (v == 0) return "0";
+  if (v < 1000) return  v;
+  if (v < 20000) return  (v/1E3).toFixed(3)+"k" ;
+  if (v < 1E6) return  (v/1E3).toFixed(2)+"k" ;
+  if (v < 20E6) return  (v/1E6).toFixed(3)+"M" ;
+  if (v < 1E9) return  (v/1E6).toFixed(2)+"M" ;
+  if (v < 20E9) return  (v/1E9).toFixed(3)+"G" ;
+  if (v < 1E12) return  (v/1E9).toFixed(2)+"G" ;
+  return  v;
+  }
+  
+  
+
+function findcolor(v,min,max,lg) {
+  if (!(v>0)){    v = 0;}
+  if (v && lg){        v = log(v);}
+  if (min && lg){      min = log(min);}
+  if (max && lg){      max = log(max);}
+  if (max == undefined){max  = 1;}
+
+  step = ((max-min)/655);
+  v =  Math.round(v);
+
+  if (v == 0 || v<min) {
+    return "transparent";
+  } else {
+    v -= min;
+    if (step) {
+      v  = v/step;
+      }
+    if (v<156) {
+      r = 0;
+      g = v+100;
+      b = 0;
+    } else if (v<412) {
+      v -= 156;
+      r = v;
+      g = 255;
+      b = 0;
+    } else {
+      v -= 412;
+      r = 255;
+      g = 255-v;
+      b = 0;
+    }
+  }
+r = Math.floor(r);
+g = Math.floor(g);
+b = Math.floor(b);
+
+  return "rgb("+(r%256)+","+(g%256)+","+(b%256)+")";
+  
+}
\ No newline at end of file
diff --git a/web/htdocs/xml-db b/web/htdocs/xml-db
new file mode 120000 (symlink)
index 0000000..efb563b
--- /dev/null
@@ -0,0 +1 @@
+../../xml-db/
\ No newline at end of file
index a7fdd616fb335f1f1ea4db833d87518dbe85ff42..fa8289f5d6e4cf8acd2119268440555d7d162b30 100644 (file)
       <description>Number of hit overflows</description>
       <field name="ParityErrorCount" start="0" bits="16" format="unsigned" />
     </register>
-    <register name="TriggerRate" address="0004" purpose="status">
-      <description>Trigger Rate</description>
-      <field name="TriggerRate" start="0" bits="32" format="unsigned" unit="Hz"/>
-    </register>
-    <register name="FrameRate" address="0005" purpose="status">
-      <description>Number of Hits on nxyter</description>
-      <field name="FrameRate" start="0" bits="32" format="unsigned" unit="Hz"/>
-    </register>
+    <group name="NxyterRates"
+         address="0004"  size="2"  purpose="status"  mode="r"  continuous="true">
+      <register name="HitRate" address="0000" purpose="status">
+        <description>Total hit rate summed over all channels</description>
+        <field name="HitRate" start="0" bits="32" format="unsigned" unit="Hz"/>
+      </register>
+      <register name="FrameRate" address="0001" purpose="status">
+        <description>Number of Hits on nxyter</description>
+        <field name="FrameRate" start="0" bits="32" format="unsigned" unit="Hz"/>
+      </register>
+    </group>
   </group>
 
 
index 4530549d56737f1790a420b5ed4c70f966a61ebf..37a009e5b5f2db623cfbf3c2a392948ccb1961ee 100755 (executable)
@@ -128,15 +128,16 @@ sub FormatPretty {
       when ("integer")  {$ret .= sprintf("$cl>%i",$value);}
       when ("unsigned") {$ret .= sprintf("$cl>%u",$value);}
       when ("signed")   {$ret .= sprintf("$cl>%d",$value);}
-      when ("binary"|"bitmask")   {$ret .= sprintf("%0".$obj->{bits}."b",$value);}
+      when ("binary")   {$ret .= sprintf("$cl>%0".$obj->{bits}."b",$value);}
+      when ("bitmask")  {$ret .= sprintf("$cl>%0".$obj->{bits}."b",$value);}
       when ("time")     {$ret .= time2str('>%Y-%m-%d %H:%M',$value);}
       when ("hex")      {$ret .= sprintf("$cl>%8x",$value);}
-      when ("enum")     { my $t = sprintf(">%x",$value);
+      when ("enum")     { my $t = sprintf("%x",$value);
                           if (exists $obj->{enumItems}->{$t}) {
-                            $ret .= $obj->{enumItems}->{$t} 
+                            $ret .= '>'.$obj->{enumItems}->{$t} 
                             }
                           else {
-                            $ret .= $t;
+                            $ret .= '>'.$t;
                             }
                           }
       default           {$ret .= sprintf(">%08x",$value);}
@@ -219,6 +220,7 @@ sub requestdata {
 sub generateoutput {
   my ($obj,$name,$slice,$once) = @_;
   my $t = "";
+  $t = "<table class='queryresult'>";
   if($obj->{type} eq "group") {
     foreach my $c (@{$obj->{children}}) {
       generateoutput($db->{$c},$c,$slice,$once);
@@ -228,25 +230,25 @@ sub generateoutput {
     my $stepsize = $obj->{stepsize} || 1;
        $slice = 0 unless defined $slice;
 
-  
     do {  
       my $addr = $obj->{address}+$slice*$stepsize;
       #### Prepare table header line
       
-      $t = "<table class='queryresult'><tr>";
-      $t .= sprintf("<th title=\"(0x%04x)\n$obj->{description}\">".$name,$addr);
+      $t .= sprintf("<tr><th title=\"$name (0x%04x)\n$obj->{description}\">".$name,$addr);
 
       if($obj->{type} eq "registerfield" || $obj->{type} eq "field"){
         $t .= "<th title=\"$obj->{description}\">$name";
+        $t .= ".$slice" if(defined $obj->{repeat});
         }
       elsif($obj->{type} eq "register"){
         foreach my $c (@{$obj->{children}}){
           $oc = $db->{$c};
-          $t .= sprintf("<th title=\"(%u Bit @ %u)\n$oc->{description}\">$c",$oc->{bits},$oc->{start});
+          $t .= sprintf("<th title=\"%s (%u Bit @ %u)\n$oc->{description}\">$c",$c,$oc->{bits},$oc->{start});
           }
-        }    
+        }   
+
 #       print DumpTree($data->{$addr});
-      foreach my $b (sort keys %$data->{$addr}) {
+      foreach my $b (sort keys %{$data->{$addr}}) {
         $t .= sprintf("<tr><td title=\"raw: 0x%x\">%04x",$data->{$addr}->{$b},$b);
         if($obj->{type} eq "register") {
           foreach my $c (@{$obj->{children}}) {
@@ -257,10 +259,10 @@ sub generateoutput {
           $t .= FormatPretty($data->{$addr}->{$b},$obj,"td");
           }
         }
-
+      
       } while($once != 1 && defined $obj->{repeat} && ++$slice < $obj->{repeat});
-    $t .= "</table>";
     }
+    $t .= "</table><hr class=\"queryresult\">";
   print $t;
   }