From c4ed2cb1dd09580627bddc2c8e551dc3e67a4987 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Fri, 12 Jul 2013 20:09:34 +0200 Subject: [PATCH] more options to the power supply config file --- web/htdocs/index.html | 2 +- web/htdocs/tools/pwr/build_index.pl | 13 +++++++------ web/htdocs/tools/pwr/pwr.conf | 6 +++--- web/htdocs/tools/pwr/pwr.pl | 9 ++++++--- web/htdocs/tools/pwr/pwr_hmp.htm | 23 ++++++++++++++++++----- 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/web/htdocs/index.html b/web/htdocs/index.html index 2b0c8bf..4a2e2a1 100755 --- a/web/htdocs/index.html +++ b/web/htdocs/index.html @@ -47,7 +47,7 @@ The main documentation of the network can be found in these two documents:

Further Tools

diff --git a/web/htdocs/tools/pwr/build_index.pl b/web/htdocs/tools/pwr/build_index.pl index 62af2e4..efcfa57 100755 --- a/web/htdocs/tools/pwr/build_index.pl +++ b/web/htdocs/tools/pwr/build_index.pl @@ -10,16 +10,17 @@ open(LESEN,"htdocs/tools/pwr/pwr.conf") while(defined(my $i = )) { - if( $i =~ /^PWRSPLY:([^:]+):([^:]+):([^:]+):([^:]+)/g ) { + if( $i =~ /^PWRSPLY:([^:]+):([^:]+):([^:]+):([^:]+):([^:]+)/g ) { my $ser_dev=$1; - my $dev_id=$2; - my $type=$3; - my $channels=$4; + my $speed=$2; + my $dev_id=$3; + my $type=$4; + my $channels=$5; if($type eq "PSP") { print < - +

EOF } @@ -27,7 +28,7 @@ EOF if($type =~ /HMP/) { print < - +

EOF } diff --git a/web/htdocs/tools/pwr/pwr.conf b/web/htdocs/tools/pwr/pwr.conf index d7aad6d..e23ad05 100644 --- a/web/htdocs/tools/pwr/pwr.conf +++ b/web/htdocs/tools/pwr/pwr.conf @@ -1,4 +1,4 @@ -//PWRSPLY:/path/to/device:Device_ID:Type:Channels +//PWRSPLY:/path/to/device:speed:Name:Type:Channels //type can be HMP, PSP -PWRSPLY:/dev/ttyUSB0:PWR_DEFAULT:HMP:3 -PWRSPLY:/dev/ttyUSB1:PWR_OLD:PSP:1 \ No newline at end of file +PWRSPLY:/dev/ttyUSB0:38400:HMP4030:HMP:3 +PWRSPLY:/dev/ttyUSB1:2400:PSP-405:PSP:1 \ No newline at end of file diff --git a/web/htdocs/tools/pwr/pwr.pl b/web/htdocs/tools/pwr/pwr.pl index 676e1d5..5363c53 100755 --- a/web/htdocs/tools/pwr/pwr.pl +++ b/web/htdocs/tools/pwr/pwr.pl @@ -20,6 +20,10 @@ $ser_dev = "/dev/ttyUSB0" unless defined $ser_dev; my $ser_type = shift(@new_command); $ser_type = "PSP" unless defined $ser_type; +my $ser_speed = shift(@new_command); +$ser_speed = "2400" unless defined $ser_speed; + + my $port = new Device::SerialPort($ser_dev); unless ($port) { @@ -28,8 +32,7 @@ unless ($port) } $port->user_msg('ON'); -$port->baudrate(2400) if $ser_type eq "PSP"; -$port->baudrate(115200) if $ser_type eq "HMP"; +$port->baudrate($ser_speed); $port->parity("none"); $port->databits(8); $port->stopbits(1); @@ -154,7 +157,7 @@ sub receive_answer_HMP { $port->write("$command\r\n"); # print "i sent the command: $command\n"; #print "\n\nokay.\n"; - usleep 1E5; + usleep 5E4; while(my $a = $port->lookfor) { print $a."&"; # debug output } diff --git a/web/htdocs/tools/pwr/pwr_hmp.htm b/web/htdocs/tools/pwr/pwr_hmp.htm index c9b402b..036f774 100644 --- a/web/htdocs/tools/pwr/pwr_hmp.htm +++ b/web/htdocs/tools/pwr/pwr_hmp.htm @@ -15,7 +15,7 @@
-
Chan 1Chan 2Chan 3Chan 4 +
Chan 1Chan 2Chan 3Chan 4
Voltage [V] @@ -59,9 +59,20 @@ var ser_dev = getParameterByName("device"); var dev_id = getParameterByName("id"); var type = getParameterByName("type"); var channels = getParameterByName("channels"); +var speed = getParameterByName("speed"); +if (channels<2) { + document.getElementById("chan2").style.color = "#eee"; + } +if (channels<3) { + document.getElementById("chan3").style.color = "#eee"; + } +if (channels<4) { + document.getElementById("chan4").style.color = "#eee"; + } function set_v(chan) { + if (chan > channels) return; var value = parseFloat(document.getElementById("form_v"+chan).value); var command; if(type=="HMP") command = "INST OUT"+chan+"&VOLT "+value.toFixed(3); @@ -69,6 +80,7 @@ function set_v(chan) { } function set_v_lim(chan) { + if (chan > channels) return; var value = parseInt(document.getElementById("form_v_lim"+chan).value); var command; if(type=="HMP") command = "INST OUT"+chan+"&VOLT:PROT "+value.toFixed(3); @@ -76,6 +88,7 @@ function set_v_lim(chan) { } function set_c_lim(chan) { + if (chan > channels) return; var value = parseFloat(document.getElementById("form_c_lim"+chan).value); var command; if(type=="HMP") command = "INST OUT"+chan+"&CURR "+value.toFixed(3); @@ -83,10 +96,12 @@ function set_c_lim(chan) { } function turn_on(chan) { + if (chan > channels) return; if(type=="HMP") new_commands.push("INST OUT"+chan+"&OUTP ON"); } function turn_off(chan) { + if (chan > channels) return; if(type=="HMP") new_commands.push("INST OUT"+chan+"&OUTP OFF"); } @@ -97,8 +112,6 @@ function update(data) { function updatereads(data) { - if(document.getElementById("readings")) - document.getElementById("readings").innerHTML=data; var e = data.split("&"); for(i=0;i