From 9a4ea4b760d2f02fb50a6f574610dfc6eaabd35b Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Mon, 15 Jul 2013 14:11:50 +0200 Subject: [PATCH] improved power supply handling --- web/htdocs/tools/pwr/pwr.pl | 29 ++++++++++++--- web/htdocs/tools/pwr/pwr_hmp.htm | 64 ++++++++++++++++++++++++-------- web/htdocs/tools/pwr/styles.css | 12 ++++++ 3 files changed, 84 insertions(+), 21 deletions(-) diff --git a/web/htdocs/tools/pwr/pwr.pl b/web/htdocs/tools/pwr/pwr.pl index 5363c53..23aa218 100755 --- a/web/htdocs/tools/pwr/pwr.pl +++ b/web/htdocs/tools/pwr/pwr.pl @@ -48,7 +48,7 @@ transmit_command() if $ser_type eq "PSP"; #if new command, send it! receive_answer() if $ser_type eq "PSP"; # always called -receive_answer_HMP() if $ser_type eq "HMP"; # always called +print receive_answer_HMP() if $ser_type eq "HMP"; # always called # transmit_command(); # send relais off in case current maximum is reached! @@ -150,20 +150,37 @@ sub receive_answer { } sub receive_answer_HMP { - + my $ret =""; while ( my $command = shift(@new_command) ) { $port->lookclear; + usleep(1000); $command = uri_unescape($command); $port->write("$command\r\n"); # print "i sent the command: $command\n"; #print "\n\nokay.\n"; - usleep 5E4; - while(my $a = $port->lookfor) { - print $a."&"; # debug output + usleep(1000); + if($command =~ m/\?/) { +# print "waiting...\n"; + READBACK: for (my $i = 0; ($i<500) ;$i++) { + $a = $port->lookfor(3); + if ($a =~ m/\d/) { + print $a."&"; + last READBACK; + } + usleep(1000); + } + } + else { + usleep(50000); } } + return $ret; } -print "\n"; +print "\n"; exit 1; + + + + diff --git a/web/htdocs/tools/pwr/pwr_hmp.htm b/web/htdocs/tools/pwr/pwr_hmp.htm index 036f774..36aa4bf 100644 --- a/web/htdocs/tools/pwr/pwr_hmp.htm +++ b/web/htdocs/tools/pwr/pwr_hmp.htm @@ -35,12 +35,13 @@ Output Relais -
-
-
-
+ + + + -Enable read-back of values. +Enable read-back of valuesRead Settings +  @@ -60,6 +61,8 @@ var dev_id = getParameterByName("id"); var type = getParameterByName("type"); var channels = getParameterByName("channels"); var speed = getParameterByName("speed"); +var readSettingsRequest = 1; +var forceShowReadings = 1; if (channels<2) { document.getElementById("chan2").style.color = "#eee"; @@ -77,6 +80,7 @@ function set_v(chan) { var command; if(type=="HMP") command = "INST OUT"+chan+"&VOLT "+value.toFixed(3); new_commands.push(command); + forceShowReadings = 1; } function set_v_lim(chan) { @@ -85,6 +89,7 @@ function set_v_lim(chan) { var command; if(type=="HMP") command = "INST OUT"+chan+"&VOLT:PROT "+value.toFixed(3); new_commands.push(command); + forceShowReadings = 1; } function set_c_lim(chan) { @@ -93,45 +98,72 @@ function set_c_lim(chan) { var command; if(type=="HMP") command = "INST OUT"+chan+"&CURR "+value.toFixed(3); new_commands.push(command); + forceShowReadings = 1; } function turn_on(chan) { if (chan > channels) return; if(type=="HMP") new_commands.push("INST OUT"+chan+"&OUTP ON"); + forceShowReadings = 1; } function turn_off(chan) { if (chan > channels) return; if(type=="HMP") new_commands.push("INST OUT"+chan+"&OUTP OFF"); + forceShowReadings = 1; } function update(data) { - updateTask = setInterval("communication()",updaterate); + updateTask = setTimeout("communication()",updaterate); } function updatereads(data) { var e = data.split("&"); for(i=0;i'+dev_id+''+" [connected to "+''+ser_dev+''+"]" ; diff --git a/web/htdocs/tools/pwr/styles.css b/web/htdocs/tools/pwr/styles.css index 7951704..d3529c1 100644 --- a/web/htdocs/tools/pwr/styles.css +++ b/web/htdocs/tools/pwr/styles.css @@ -23,4 +23,16 @@ body { .smallboxes td { padding:1px; +} + +td.state { + padding-left:10px; + text-align:center; + +} + + +#info { +font-size:70%; +text-align:right; } \ No newline at end of file -- 2.43.0