]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
added a web based editor that can be called comfortably from the testgui
authorwww@jspc55 <www@jspc55>
Fri, 27 Jun 2014 14:59:23 +0000 (16:59 +0200)
committerwww@jspc55 <www@jspc55>
Fri, 27 Jun 2014 14:59:23 +0000 (16:59 +0200)
layout/editor.css [new file with mode: 0644]
tools/editor.js [new file with mode: 0644]
tools/editor.pl [new file with mode: 0755]
tools/run.pl
tools/start.pl
tools/testgui.js
tools/testgui.pl
tools/unpacker/run.sh

diff --git a/layout/editor.css b/layout/editor.css
new file mode 100644 (file)
index 0000000..571e84b
--- /dev/null
@@ -0,0 +1,18 @@
+
+
+
+#textarea {
+/*    float:left; */
+   position:absolute;
+/*    position:fixed; */
+/*    width:320px; */
+   left:0px;
+   top:50px;
+   min-width: 60px;
+   min-height: 40px;
+   padding:10px;
+   margin-top:30px;
+   margin-left:30px;
+
+   }
+   
\ No newline at end of file
diff --git a/tools/editor.js b/tools/editor.js
new file mode 100644 (file)
index 0000000..d208103
--- /dev/null
@@ -0,0 +1,82 @@
+
+var timer;
+
+$(document).ready(function(){
+
+  activate_components();
+  load_file();
+  set_clear_timer();
+  
+});
+
+
+function load_file(){
+  
+  $.ajax({
+        url:       "editor.pl",
+        cache:     false,
+       async:     false,
+        dataType:  "text",
+        data:      {
+         sub        : "print_file",
+         file       : shared["file"]
+       },
+        success:   function(result) {
+         $("#text_field").val(result);
+         $("#report").html("file loaded");
+       }
+     });
+}
+
+
+function write_file(){
+      $.ajax({
+        url:       "editor.pl",
+        cache:     false,
+       async:     false,
+        dataType:  "text",
+        data:      {
+         sub        : "write_file",
+         file       : shared["file"],
+         text       : get_textarea_content()
+       },
+        success:   function(result) {
+         $("#report").html(result);
+       }
+     }); 
+}
+
+
+function activate_components(){
+  
+  
+   $("#reloadbutton").click(function(){
+    load_file();
+    set_clear_timer();
+   });
+   $("#savebutton").click(function(){
+    write_file();
+    set_clear_timer();
+   }); 
+   
+  timer = $.timer(function() {
+    clear_report();
+    timer.stop();
+  });
+  
+}
+
+function get_textarea_content () {
+   return $("#text_field").val();
+}
+
+
+function set_clear_timer(){
+     timer.set({time:3000,autostart: true});
+}
+
+function clear_report (){
+   $("#report").html(" ... ");
+}
+   
+  
\ No newline at end of file
diff --git a/tools/editor.pl b/tools/editor.pl
new file mode 100755 (executable)
index 0000000..0d46f01
--- /dev/null
@@ -0,0 +1,159 @@
+#!/usr/bin/perl -w
+
+
+
+my $me = "editor.pl";
+
+use strict;
+use warnings;
+use POSIX;
+use CGI ':standard';
+use CGI::Carp qw(fatalsToBrowser);
+use Widgets;
+require Common;
+use FindBin;
+use lib "$FindBin::Bin/..";
+use Environment;
+use File::Basename;
+
+
+my $shared;
+
+##############
+## dispatch table (subs that are callable via CGI)
+##############
+my $dispatch = {
+  table_hash => \&table_hash,
+  print_file => \&print_file,
+  write_file => \&write_file
+};
+
+
+#recieve new CGI request
+my $q = CGI->new;
+
+
+print header;
+
+if ($q->param('sub')){
+  my $subname = $q->param('sub');
+  $dispatch->{$subname}->($q); # give the sub the query
+} else { 
+  page_body($q);
+}
+exit;
+
+
+#################### SUBLAND ######################
+
+###############################
+## subs generating html output
+###############################
+
+
+sub page_body{
+
+  init_html();
+  my $q = shift;
+
+  $shared->{file}=$q->param('file');
+  my @stuff = split("/",$shared->{file});
+  my $filename=@stuff[-1];
+  
+  print h2 "Text editor";
+
+  print '<div id="textarea" class="stylishBox">';
+  print "<div class='header' title='".$shared->{file}."'>"
+  .$filename."</div>";
+  print qq%
+  <TEXTAREA NAME="Address" id="text_field" ROWS=42 COLS=100 >
+  [Platzhalter]
+  </TEXTAREA>
+  <br>
+  <input id="savebutton" type="button" value="save">
+  <input id="reloadbutton" type="button" value="reload">
+  %;
+
+
+  print '<span id="report"> ... </span>';
+
+  print '</div>';
+
+  print '<div id="controls" class="stylishBox">';
+  print '</div>';
+
+  # print '<div id="debugStuff" class="debugFeature">';
+  # print_debugStuff($q);
+  # print '</div>';
+
+  passHashToJs($shared,'shared');
+}
+
+sub table_hash{
+  my $q = shift;
+  
+  print '<table>';
+  for my $key ( $q->param()){
+    print '<tr>';
+    print '<td>'.$key.'</td><td>=></td><td>'.$q->param($key).'</td>';
+    print '</tr>';
+  }
+  print '</table>';
+}
+
+sub print_file {
+  my $q = shift;
+  my $file = $q->param('file');
+  
+  open(READ,"$file")
+  or print "Error while opening : $file\n";
+  while(defined(my $i = <READ>)) {
+    print $i;
+  }
+}
+
+
+sub write_file {
+  my $q = shift;
+  my $file = $q->param('file');
+  my $text = $q->param('text');
+  
+  open(WRITE,">$file")
+  or print "Error while opening : $file\n";
+  print WRITE $text;
+  close(WRITE);
+
+  print "saved!";
+}
+
+
+sub passHashToJs {
+
+  my $hashref = shift();
+  my $objname = shift();
+  $objname = 'fromPerl' unless (defined($objname));
+  print "<script language='javascript'>\n";
+  print "var $objname = new Object();\n";
+  for my $key (keys %$hashref){
+    print $objname.qq%["$key"]="%.$hashref->{$key}.qq%";\n%;
+  }
+  print "</script>";
+
+}
+
+
+sub init_html{
+  print start_html(
+  -title=>'Text editor',
+  -style=>[{'src'=>'../layout/styles.css'},
+  {'src'=>'../layout/jtageditor_blue.css'},
+  {'src'=>'../layout/editor.css'}
+  ],
+  -script=>[
+#   { -type => 'text/javascript', -src => 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'},
+  { -type => 'text/javascript', -src => '../scripts/jquery.min.js'},
+  { -type => 'text/javascript', -src => './editor.js'},
+  { -type => 'text/javascript', -src => '../scripts/jquery.timer.js'}
+  ]
+  );
+}
index 0c9bde8326b1567c5994e5d8966cc56aeb24cc99..42d1e2f745be726fd85bb49e920c8fe95df8c09c 100755 (executable)
@@ -79,14 +79,22 @@ unless(-e $picPath or mkdir $picPath) {
 
 my $dummy;
 
-$dummy =qx"./startup.pl $setupFile";
+$dummy  =qx|date|;
+$dummy .=qx"./startup.pl $setupFile";
+
 unless($q->param('startupOnly') eq 'true'){
+  $dummy.=qx|date|;
   $dummy.=qx"rm $dumpPath/te1*.hld 2>&1";
   $dummy.=qx"./preview/exec_evtbuild_t.pl -t $runtime -p $dumpPath -s $systemName -d $ports 2>&1";
+  $dummy.=qx|date|;
   $dummy.=qx"rm $dumpPath/temp.hld 2>&1";
   $dummy.=qx"mv $dumpPath/te1* $dumpPath/temp.hld 2>&1";
+  $dummy.=qx|ls -lh  $dumpPath/temp.hld|;
+  $dummy.=qx|date|;
   $dummy.=qx"rm $picPath/$systemName*.png 2>&1"; # delete old pictures
-  $dummy.=qx"./preview/unpack_hld.pl -r -f $dumpPath/temp.hld -p $picPath -s $systemName 2>&1";
+#  $dummy.=qx"./preview/unpack_hld.pl -r -f $dumpPath/temp.hld -p $picPath -s $systemName 2>&1";
+  $dummy.=qx"./unpacker/run.sh $dumpPath/temp.hld $picPath $systemName 2>&1";
+  $dummy.=qx|date|;
 }
 my $escapedDummy = escapeHTML($dummy);
 $escapedDummy =~ s/\n/<br>/g;
index 877fe47c74bd3ee386cf9ef653a8683da419acf1..403ac41e6d3efdc49e522f9ac45999e0fa618671 100755 (executable)
@@ -67,9 +67,9 @@ if($system eq 'Vacuum') {
   trb_write($ccu,0x00c3,0x00ff);   #only slowcontrol for unused FPGA
   }
 if($system eq 'ELab') {
-  trb_write($ccu,0x00c0,0x00ed);   
-  trb_write($ccu,0x00c1,0x00ed);
-  trb_write($ccu,0x00c3,0x00fd); # only 0x00, 0x02, 0x03 active 
+  trb_write($ccu,0x00c0,0x00ec);   
+  trb_write($ccu,0x00c1,0x00ec);
+  trb_write($ccu,0x00c3,0x00fc); # only 0x00, 0x02, 0x03 active 
   }
 
 #Send arbiter start signal
index 28f0e63a85136c1e00707390970b1ed4cb1f341a..46611c58cc79272be25837abaac1197cb98adbb9 100644 (file)
@@ -47,4 +47,18 @@ function startupOnly(){
 
   
   
-}
\ No newline at end of file
+}
+
+
+$(document).ready(function(){
+
+//   $("#editorlink").click( function() {
+//     var setupFile_ = encodeURIComponent(setupFile);
+//     var url='editor.pl?file='+setupFile_;
+//     window.open(url, '_blank');
+//     });
+
+  $("#setupeditorlink").attr("href","editor.pl?file="+encodeURIComponent(setupFile));
+  $("#systemeditorlink").attr("href","editor.pl?file="+encodeURIComponent(systemFile));
+  
+});
index 7a5dc396bce60d7796673e5ab599c04cffc56878..cc82c780e6f67c330ab026db317756e1c9c78355 100755 (executable)
@@ -137,6 +137,7 @@ sub init_html{
   {'src'=>'../layout/testgui.css'}
   ],
   -script=>[
+  { -type => 'text/javascript', -src => '../scripts/jquery.min.js'},
   { -type => 'text/javascript', -src => './testgui.js'},
   { -type => 'text/javascript', -src => './hideAndShow.js'},
   { -type => 'text/javascript', -src => './getdata.js'},
@@ -158,6 +159,10 @@ sub init_html{
   print "chose setup: ";
   print "</td><td>";
   $setup_selector->print_html();
+  print "</td><td>";
+  print "<a href='#' id='setupeditorlink' >edit setup file</a>";
+  print "</td><td>";
+  print "<a href='#' id='systemeditorlink' >edit system file</a>";
   print "</td></tr></table>";
   
   print_setupStructure();
@@ -180,6 +185,7 @@ sub init_html{
   # so the javascript knows which placeholders to fill with actual plots
   print "<script language='javascript'>\n";
   print q%var setupFile = '%.$setupFile.q%';%."\n";
+  print q%var systemFile = '%.SYSTEMDIR."/".$systemName.".xml".q%';%."\n";
   print "var previewAreaIdHash = new Object();\n";
   for my $sensorId (keys %previewAreaIdHash){
     print "previewAreaIdHash[\"$sensorId\"]=\"".$previewAreaIdHash{$sensorId}."\";\n";
index 8dfeb34892694b6ec6ba002a430188e903a5125c..21873084f2cd92d26d19b0efe28537dcfaa26f5b 100755 (executable)
@@ -1,2 +1,2 @@
 export LD_LIBRARY_PATH=/d/jspc22/dabc/lib/:$LD_LIBRARY_PATH
-./unpacker $1 $2 $3
+time ./unpacker/unpacker $1 $2 $3