From: www@jspc55 Date: Fri, 27 Jun 2014 14:59:23 +0000 (+0200) Subject: added a web based editor that can be called comfortably from the testgui X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=633992ddbe160e171dfd7d4998cca2276fc65d4d;p=mvdsensorcontrol.git added a web based editor that can be called comfortably from the testgui --- diff --git a/layout/editor.css b/layout/editor.css new file mode 100644 index 0000000..571e84b --- /dev/null +++ b/layout/editor.css @@ -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 index 0000000..d208103 --- /dev/null +++ b/tools/editor.js @@ -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 index 0000000..0d46f01 --- /dev/null +++ b/tools/editor.pl @@ -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 '
'; + print "
" + .$filename."
"; + print qq% + +
+ + + %; + + + print ' ... '; + + print '
'; + + print '
'; + print '
'; + + # print '
'; + # print_debugStuff($q); + # print '
'; + + passHashToJs($shared,'shared'); +} + +sub table_hash{ + my $q = shift; + + print ''; + for my $key ( $q->param()){ + print ''; + print ''; + print ''; + } + print '
'.$key.'=>'.$q->param($key).'
'; +} + +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 = )) { + 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 ""; + +} + + +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'} + ] + ); +} diff --git a/tools/run.pl b/tools/run.pl index 0c9bde8..42d1e2f 100755 --- a/tools/run.pl +++ b/tools/run.pl @@ -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/
/g; diff --git a/tools/start.pl b/tools/start.pl index 877fe47..403ac41 100755 --- a/tools/start.pl +++ b/tools/start.pl @@ -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 diff --git a/tools/testgui.js b/tools/testgui.js index 28f0e63..46611c5 100644 --- a/tools/testgui.js +++ b/tools/testgui.js @@ -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)); + +}); diff --git a/tools/testgui.pl b/tools/testgui.pl index 7a5dc39..cc82c78 100755 --- a/tools/testgui.pl +++ b/tools/testgui.pl @@ -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 ""; $setup_selector->print_html(); + print ""; + print "edit setup file"; + print ""; + print "edit system file"; print ""; print_setupStructure(); @@ -180,6 +185,7 @@ sub init_html{ # so the javascript knows which placeholders to fill with actual plots print "