]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
-> CTS GUI moved into a dedicated directory and depedencies (CSS/JS files renamed)
authorManuel Penschuck <manuel.penschuck@stud.uni-frankfurt.de>
Thu, 19 Dec 2013 19:58:21 +0000 (20:58 +0100)
committerManuel Penschuck <manuel.penschuck@stud.uni-frankfurt.de>
Thu, 19 Dec 2013 19:58:21 +0000 (20:58 +0100)
-> Ability to set labels for input channels

web/cts_gui
web/htdocs/cts/cts.htm [moved from web/htdocs/cts.htm with 87% similarity]
web/htdocs/cts/cts.pl [moved from web/htdocs/cts.pl with 100% similarity]
web/htdocs/cts/empty_plot.png [moved from web/htdocs/layout/empty_plot.png with 100% similarity]
web/htdocs/index.pl
web/htdocs/layout/cts.css [moved from web/htdocs/layout/base.css with 82% similarity]
web/htdocs/scripts/cts.js

index 33c29befb134b2b570aec4b9e9cb5e714b218423..3763dc1a3612bda939e7655109627c138fa53ed4 100755 (executable)
@@ -97,7 +97,7 @@ EOFHELP
    
    
    my $sharedDir     = "/dev/shm/cts-monitor-$port";
-   my $htdocsDumpDir = "htdocs/monitor-$port";
+   my $htdocsDumpDir = "htdocs/cts/monitor-$port";
    my $quietParam    = $quiet ? '--quiet ' : '';
    my $logParam      = $log ? "--log $log" : '';
 
similarity index 87%
rename from web/htdocs/cts.htm
rename to web/htdocs/cts/cts.htm
index da577dba01c55074fefda9b6961b23135b2e4ca7..a882def40879850f6449be77fac6492536ffb874 100644 (file)
@@ -3,9 +3,9 @@
    <head>
       <title>Central Trigger System</title>
       <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/cts.js" type="text/javascript"></script>
+      <link href="../layout/cts.css" rel="Stylesheet" type="text/css" />
+      <script src="../scripts/mootools-core-1.4.5.js" type="text/javascript"></script>
+      <script src="../scripts/cts.js" type="text/javascript"></script>
    </head>
 
    <body lang="en">
       </div>
 
       <div id="content-area">
+         <div class="warning-box" id="nameDB-match-warning">
+            The name database was created for another FPGA design (<span class="old-date"></span>). Please ensure, that the defined labels are still valid.<br />
+            The database can be found in <span class="path">web/htdocs/cts/names.json</span> in your daqtools-directory. 
+            After verification set the <span class="path">cts-compiletime</span> property to <span class="new-date"></span> to stop this message from reappearing.
+         </div>
+      
          <div class="expandable expanded" id="itc-overview">
             <div class="header"><span class="indicator"></span> Status overview</div>
             
             <div class="content">
                <div id="rate-plot-cotainer">
-                  <img src="layout/empty_plot.png" id="rate-plot" title="Click to switch between short and long plot interval" />
+                  <img src="empty_plot.png" id="rate-plot" title="Click to switch between short and long plot interval" />
                   Click on the image to switch between short and long plotting intervals
                </div>
                <table id="overview-tab">
                         <td class="label">Design compiled</td>
                         <td class="value" id="trb_compiletime">n/a</td>
                      </tr>
+
+                     <tr><td colspan="2">&nbsp;</td></tr>
+
+                     <tr class="alt">
+                        <td class="label">Export Renaming Template</td>
+                        <td class="value">
+                           <a href="#" id="gui_export_name_template">to define setup specific names</a>
+                        </td>
+                     </tr>                     
                      
+<!--                     
                      <tr class="alt">
                         <td class="label">TD FSM Limit (debug only):</td>
                         <td class="value">
                                   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 class="right">
             </div>
          </div>
       </div>
+      
+      <div id="win-nameDB" class="window">
+         <div class="header">
+            <div class="tools"><a href="javascript:window.location.reload()">close and reload</a></div>
+            <div class="title">Export NameDB template</div>
+         </div>
+         
+         <div class="content">
+            <p>
+               You can change the name of most IO-related ports by copying the template from below
+               into a text file and placing it under <span class="path">web/htdocs/cts/names.json</span>
+               in your daqtools-directory. Ensure that the file is NOT executable (chmod -x names.json).
+               Then reload the page. 
+            </p>
+            <p>If you omit any value, the GUI uses the default value send by
+               the CTS tool. If a <span class="path">cts-compiletime</span> option is included in the file, the
+               GUI warns you, when it connects to a different hardware version (which could have a
+               different IO mapping - Those change cannot be tracked automatically). It is, hence, highly recommended
+               to use this security measure !!!
+            </p>
+            
+            <pre class="template"></pre>
+         </div>
+      </div>
+         
+            
+      
    </body>
 </html>
\ No newline at end of file
similarity index 100%
rename from web/htdocs/cts.pl
rename to web/htdocs/cts/cts.pl
index ae9ed1b8be55aec6f8c125bb95916a25f2a27a6f..a85c26f655ed466765be776ede7243a1d311c27b 100755 (executable)
@@ -47,7 +47,7 @@ The main documentation of the network can be found in these documents and locati
 <h3>Network &amp; CTS</h3>
 <div class="index">
 <ul>
-<li><a href="cts.htm">CTS Control</a>
+<li><a href="cts/cts.htm">CTS Control</a>
 <li><a href="network/trbnet.pl">TrbNet status</a>
 <li><a href="network/hub.pl">Network Hubs</a>
 <li><a href="network/gbe.htm">GbE status</a>
similarity index 82%
rename from web/htdocs/layout/base.css
rename to web/htdocs/layout/cts.css
index fbad7e705b2dea175850a9e5994a678107f635a5..95b4459d4645415dedda6edeefb23ae7e8bc80a5 100644 (file)
       font-style: italic;
       color: #a03010;
       display: none;
+   }
+   
+/* Name DB */
+   #win-nameDB {
+      display: none;
+      position: fixed;
+      top: 60px;
+      left: 50%;
+      width: 900px;
+      margin: 0 auto 0 -450px;
+
+      text-align: left;
+      
+      background: #f0f0f8;
+      border: 1px solid #dddddd;
+      box-shadow: 5px 10px 10px 0px rgba(0,0,0,0.5);
+   }
+   
+   .window .header {
+      border-bottom: 1px solid #dddddd;
+      padding: 5px;
+      
+   }
+   
+   .window .title {
+      font-size: 120%;
+      font-weight: bold;
+      color: #6B7B95;
+   }
+   
+   .window .tools {
+      float: right;
+   }
+   
+   .window .content {
+      padding: 10px;
+   }
+   
+   span.path {
+      font-family: monospace;
+   }
+   
+   .window .content pre {
+      background: white;
+      border: 1px solid #6b8b95;
+      border-left: 5px solid #6b8b95;
+      padding: 5px 0 5px 10px;
+      
+      max-height: 600px;
+      overflow: auto;
+   }
+   
+   .warning-box {
+      padding: 10px;
+      text-align: left;
+      background: #ffffe0;
+      border: 2px solid #ffff00;
+      margin-bottom: 20px;
+      display: none;
    }
\ No newline at end of file
index f8b38b50528ac765d0e3b43a6c0378a23cf06ffc..5454c14216ae7e97566ef2aeca326cb69b477138 100644 (file)
@@ -58,19 +58,28 @@ function parseCallback(elem, func, fallback) {
    
    return fallback ? fallback : id;
 }
-   
+
 var CTS = new Class({
    Implements: [Events],
    defs: null,
 
    autoCommitInhibit: false,
+   nameDB: {},
    
    currentData: {},
    dataUpdateConstantFor: 0,
    dataUpdateActive: true,
    
-   initialize: function(defs) {
+   initialize: function(defs, nameDB) {
       this.defs = defs;
+      if (nameDB) {
+         this.nameDB = nameDB;
+         if (nameDB['cts-compiletime'] && this.nameDB['cts-compiletime'] != this.defs.properties.trb_compiletime) {
+            $$('#nameDB-match-warning .old-date').set('text', timestamp2Date(this.nameDB['cts-compiletime']) + ' - ' +this.nameDB['cts-compiletime']);
+            $$('#nameDB-match-warning .new-date').set('text', this.defs.properties.trb_compiletime);
+            $('nameDB-match-warning').setStyle('display', 'block');
+         }
+      }
       this.monitorPrefix = 'monitor-' + this.defs.server.port + '/';
 
       this.renderTriggerChannels();
@@ -100,7 +109,7 @@ var CTS = new Class({
    },
    
    readRegisters: function(regs, callback, formated) {
-      var opts = {'onFailure':xhrFailure, 'url': 'cts.pl?' + (formated ? "format" : "read") + ',' + Array.from(regs).join(",")};
+      var opts = {'onFailure':requestFailure, 'url': '/cts/cts.pl?' + (formated ? "format" : "read") + ',' + Array.from(regs).join(",")};
       if (callback) {
          opts['onSuccess'] = callback;
          return (new Request.JSON(opts)).send();
@@ -115,7 +124,7 @@ var CTS = new Class({
       var arrValues = [];
       Object.each(values, function(v,r) {arrValues.push(r); arrValues.push(v)});
       (new Request.JSON({
-         url: 'cts.pl?write,' + arrValues.join(','),
+         url: '/cts/cts.pl?write,' + arrValues.join(','),
          onSuccess: function(json, text) {
             console.log(json)
             console.log(text)
@@ -129,7 +138,7 @@ var CTS = new Class({
                else  alert("An unknown error occured while writing register");
             }
          },
-         onFailure: xhrFailure
+         onFailure: requestFailure
       })).send();
    },
    
@@ -198,7 +207,7 @@ var CTS = new Class({
             
          onFailure:    function(xhr) {
             window.clearTimeout(manualTimeout);
-            //xhrFailure(xhr);
+            //requestFailure(xhr);
             this.dataUpdate.delay(1000, this);
             dup.addClass('error').set('text', 'Update failed').setStyle('display', 'block');
             $('status-indicator').set('class', 'error');
@@ -374,6 +383,20 @@ var CTS = new Class({
       }.bind(this));
    },
    
+/**
+ * Translate Names, such as channel assignments into user-overrideable values.
+ */   
+   
+   translateName: function(category, key, def) {
+      if (this.nameDB[category] == undefined)
+         this.nameDB[category] = {};
+      
+      if (this.nameDB[category][key] == undefined)
+         this.nameDB[category][key] = def;
+      
+      return def;
+   },
+   
 /**
  * Creates all active elements of the Trigger Input Configuration
  * section. It is called by the class' constructor and hence
@@ -453,10 +476,11 @@ var CTS = new Class({
                
                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('select', {'class': 'text autocommit autoupdate', 'slice': areg + '.input'})
+                  .adopt(
+                        Object.values(en).map(function (r) {
+                           return new Element('option', {'value': r, 'text': this.translateName('addon-input-multiplexer', r, r)})
+                        }, this)
                   )
                ),
                
@@ -505,14 +529,14 @@ var CTS = new Class({
          $('itc-tab') // + (i / 8).toInt())
          .adopt(
             new Element('tr', {'class': i%2?'':'alt', 'flashgroup': 'itc-' + i})
-           .adopt([
+            .adopt([
                new Element('td', {'text': i, 'class': 'channel'}),
                new Element('td', {'class': 'enable'})
                .adopt(
                   new Element('input', {'type': 'checkbox', 'id': 'itc-enable'+i, 'class': 'autocommit autoupdate', 'slice': 'trg_channel_mask.mask[' + i + ']'})
                ),
 
-              new Element('td', {'class': 'edge'})
+               new Element('td', {'class': 'edge'})
                .adopt(
                   edgeType = new Element('select', {'type': 'checkbox', 'class': 'autocommit autoupdate', 'slice': 'trg_channel_mask.edge[' + i + ']'})
                   .adopt([
@@ -520,28 +544,28 @@ var CTS = new Class({
                      new Element('option', {'value': '1', 'text': 'R. Edge'})
                    ])
                ),
-           
-               itc = new Element('td', {'class': 'assign', 'text': this.defs.properties.itc_assignments[i]}),
+    
+               itc = new Element('td', {'class': 'assign', 'text': (this.defs.properties['trg_periph_itc_base'] == i) ? '' : this.translateName('itc-names', 'itc-' + i, this.defs.properties.itc_assignments[i])}),
                new Element('td', {'class': 'type'})
                .adopt(
                      ddType = new Element('select', {'class': 'autocommit autoupdate autoupdate-value', 'slice': '_trg_trigger_types' + (i < 8 ? '0' : '1') + '.type' + i})
                ),
-           
+   
                assertedRate = new Element('td', {'class': 'rate autorate', 'slice': 'trg_channel_asserted_cnt' + i + '.value', 'text': 'n/a', 'id': 'itc-asserted-rate' + i}),
                edgeRate = new Element('td', {'class': 'rate autorate', 'slice': 'trg_channel_edge_cnt' + i + '.value', 'text': 'n/a', 'id': 'itc-edge-rate' + i})
             ])
          );
          
-        if (this.defs.properties['trg_periph_itc_base'] == i) {
-           itc.set('html', '').adopt([
-              new Element('span', {'html': 'Trigger from FPGA:&nbsp;&nbsp;'}),
-              new Element('sub', {'text': '4'})
-           ]);
-           for(var j=3; j>=0; j--)
-              itc.adopt(new Element('input', {'type': 'checkbox', 'class': 'autocommit autoupdate', 'slice': 'trg_periph_config.mask[' + j + ']'}));
-
-           itc.adopt(new Element('sub', {'text': '1'}));
-        }
+         if (this.defs.properties['trg_periph_itc_base'] == i) {
+            itc.set('html', '').adopt([
+               new Element('span', {'html': 'Trigger from FPGA:&nbsp;&nbsp;'}),
+               new Element('sub', {'text': '4'})
+            ]);
+            for(var j=3; j>=0; j--)
+               itc.adopt(new Element('input', {'type': 'checkbox', 'class': 'autocommit autoupdate', 'slice': 'trg_periph_config.mask[' + j + ']'}));
+
+            itc.adopt(new Element('sub', {'text': '1'}));
+         }
         
          for(var j=0; j < 16; j++)
             ddType.adopt(new Element('option', {'value': j, 'text': this.defs.registers['_trg_trigger_types' + (i < 8 ? '0' : '1')]._defs['type' + i].enum[j]}));
@@ -740,7 +764,7 @@ var CTS = new Class({
    },
    
    renderCTSDetails: function() {
-      $('trb_compiletime').set('text', new Date(this.defs.properties.trb_compiletime * 1000 - new Date().getTimezoneOffset() * 60000).toGMTString().replace('GMT', ''));
+      $('trb_compiletime').set('text', timestamp2Date(this.defs.properties.trb_compiletime));
       $('trb_endpoint').set('text', "0x" + this.defs.properties.trb_endpoint.toString(16));
       $('trb_daqopserver').set('text', this.defs.properties.daqopserver);
    },
@@ -764,30 +788,46 @@ var CTS = new Class({
    }
 });
 
-function xhrFailure(xhr){
-   console.log(xhr);
-   var m = xhr.responseText.match(/<pre>([\s\S]*)<\/pre>/im);
+function timestamp2Date(ts) {
+   return new Date(ts * 1000 - new Date().getTimezoneOffset() * 60000).toGMTString().replace('GMT', '');
+}
+   
+
+function requestFailure(obj){
+   console.log(obj);
+   
+   var text = (obj.responseText) ? obj.responseText : obj;
+   var m = text.match(/<pre>([\s\S]*)<\/pre>/im);
    
    
-   if (m) {
+   if (obj.responseText && m) {
       text = m[1];
       m = text.match(/^\s*-+ More[\w\s]+ -+\s+(.+)$/im)
       if (m) text = m[1];
       
       alert("Server send error response:\n"+text.trim());
+   } else {
+      alert("An unknown error while contacting the sever. Did you open this file locally? Did the connection or server crash?\nHint:\n" + text);
    }
-   
-   
-   
-   else  alert("An unknown error while contacting the sever. Did you open this file locally? Did the connection or server crash?");
 }
 
 
 var cts;
-(new Request.JSON({'url': 'cts.pl?init',
-                   'onSuccess': function(json) {cts = new CTS(json)},
-                   'onFailure': xhrFailure})).send();
+function loadCTS(nameDB) {
+   if (typeOf(nameDB) != 'object')
+      nameDB = {};
    
+   (new Request.JSON({'url': 'cts.pl?init',
+                     'onSuccess': function(json) {cts = new CTS(json, nameDB)},
+                     'onFailure': requestFailure,
+                     'onError': requestFailure})).send();   
+}
+
+(new Request.JSON({'url': 'names.json',
+                   'onSuccess': loadCTS,
+                   'onFailure': loadCTS,
+                   'onError': loadCTS})).send();
+
 function countToTime(val) {return (1.0*val / cts.defs.properties.cts_clock_frq * 1e9).toFixed(0);}
 function countToFreq(val) {return formatFreq (1 / (val / cts.defs.properties.cts_clock_frq)); }
 function timeToCount(val) {return (parseNum(val) / 1.0e9 * cts.defs.properties.cts_clock_frq).round();}
@@ -1007,4 +1047,41 @@ window.addEvent('load', function() {
    });
 });
 
-function id(x) {return x;}
\ No newline at end of file
+function id(x) {return x;}
+
+
+function prettyJSON(obj, indent=""){
+   if (obj && obj.toJSON) obj = obj.toJSON();
+
+   switch (typeOf(obj)){
+      case 'string':
+         return '"' + obj.replace(/[\x00-\x1f\\"]/g, escape) + '"';
+      case 'array':
+         return '[' + obj.map(JSON.encode).clean() + ']';
+      case 'object': case 'hash':
+         var string = [];
+         Object.each(obj, function(value, key){
+            var json = prettyJSON(value, indent + '  ');
+            if (json) string.push(prettyJSON(key) + ':  ' + json);
+         });
+         
+         return string ? ('{\n' + indent + "  " + string.join(",\n  " + indent) + "\n" + indent + '}') : "{}";
+      case 'number': case 'boolean': return '' + obj;
+      case 'null': return 'null';
+   }
+
+   return null;
+};
+
+
+window.addEvent('domready', function() {
+   $('gui_export_name_template').addEvent('click', function(e) {
+      e.stop();
+      cts.nameDB['cts-compiletime'] = cts.defs.properties.trb_compiletime;
+      $$('#win-nameDB .template')[0].set('text', prettyJSON(cts.nameDB));
+      $('win-nameDB').fade('hide').setStyle('display', 'block').fade('in');
+   });
+});
+      
+      
+