From d5d61fb819eb09fba45d37408a495b6e57d2bac6 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Fri, 12 Jul 2013 19:48:59 +0200 Subject: [PATCH] Added more powersuplies to the control GUI --- web/htdocs/layout/styles.css | 4 + web/htdocs/tools/pwr/build_index.pl | 21 +++- web/htdocs/tools/pwr/pwr.conf | 6 +- web/htdocs/tools/pwr/pwr.htm | 12 +-- web/htdocs/tools/pwr/pwr.pl | 65 +++++++----- web/htdocs/tools/pwr/pwr_hmp.htm | 158 ++++++++++++++++++++++++++++ web/htdocs/tools/pwr/styles.css | 50 +++------ 7 files changed, 241 insertions(+), 75 deletions(-) create mode 100644 web/htdocs/tools/pwr/pwr_hmp.htm diff --git a/web/htdocs/layout/styles.css b/web/htdocs/layout/styles.css index e738a0e..05ed645 100644 --- a/web/htdocs/layout/styles.css +++ b/web/htdocs/layout/styles.css @@ -257,3 +257,7 @@ table#server-details pre { } +.smallboxes input { + width:40px; + } + \ No newline at end of file diff --git a/web/htdocs/tools/pwr/build_index.pl b/web/htdocs/tools/pwr/build_index.pl index e7b88ef..62af2e4 100755 --- a/web/htdocs/tools/pwr/build_index.pl +++ b/web/htdocs/tools/pwr/build_index.pl @@ -10,18 +10,35 @@ 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; + +if($type eq "PSP") { print <

EOF +} + +if($type =~ /HMP/) { +print < + +

+EOF +} + + + } } + + #print "CWD: ".$pwd."
(for debug)\n"; diff --git a/web/htdocs/tools/pwr/pwr.conf b/web/htdocs/tools/pwr/pwr.conf index 5e6e030..d7aad6d 100644 --- a/web/htdocs/tools/pwr/pwr.conf +++ b/web/htdocs/tools/pwr/pwr.conf @@ -1,2 +1,4 @@ -//PWRSPLY:/path/to/device:Device_ID -PWRSPLY:/dev/ttyUSB0:PWR_DEFAULT \ No newline at end of file +//PWRSPLY:/path/to/device:Device_ID: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 diff --git a/web/htdocs/tools/pwr/pwr.htm b/web/htdocs/tools/pwr/pwr.htm index bf4f3af..f7cfd0f 100644 --- a/web/htdocs/tools/pwr/pwr.htm +++ b/web/htdocs/tools/pwr/pwr.htm @@ -69,8 +69,8 @@ var updaterate = 500; var updateTask; var new_commands = new Array(); var ser_dev = getParameterByName("device"); -var dev_id = getParameterByName("id") - +var dev_id = getParameterByName("id"); +var type = getParameterByName("type"); function set_v() { var value = parseFloat(document.getElementById("form_v").value); @@ -97,15 +97,15 @@ function set_p_lim() { } function turn_on() { - new_commands.push("KOE"); + if(type=="PSP") new_commands.push("KOE"); } function turn_off() { - new_commands.push("KOD"); + if(type=="PSP") new_commands.push("KOD"); } function save_to_eep() { - new_commands.push("EEP"); + if(type=="PSP") new_commands.push("EEP"); } function update(data) { @@ -120,7 +120,7 @@ function communication() { cmds = new_commands.join('&'); if (cmds != "" || document.getElementById("showreadings").checked) { clearInterval(updateTask); - getdata('pwr.pl?'+ser_dev+'&'+cmds,update); + getdata('pwr.pl?'+ser_dev+'&'+type+'&'+cmds,update); } new_commands = new Array(); } diff --git a/web/htdocs/tools/pwr/pwr.pl b/web/htdocs/tools/pwr/pwr.pl index 2e174ef..676e1d5 100755 --- a/web/htdocs/tools/pwr/pwr.pl +++ b/web/htdocs/tools/pwr/pwr.pl @@ -6,6 +6,7 @@ use strict; use warnings; use Device::SerialPort; use feature 'state'; +use URI::Escape; use Time::HiRes qw( usleep); my $envstring = $ENV{'QUERY_STRING'}; @@ -16,7 +17,8 @@ my @new_command = split('&',$envstring); my $ser_dev = shift(@new_command); $ser_dev = "/dev/ttyUSB0" unless defined $ser_dev; - +my $ser_type = shift(@new_command); +$ser_type = "PSP" unless defined $ser_type; my $port = new Device::SerialPort($ser_dev); unless ($port) @@ -26,19 +28,25 @@ unless ($port) } $port->user_msg('ON'); -$port->baudrate(2400); +$port->baudrate(2400) if $ser_type eq "PSP"; +$port->baudrate(115200) if $ser_type eq "HMP"; $port->parity("none"); $port->databits(8); $port->stopbits(1); -$port->handshake("xoff"); +$port->handshake("xoff"); +$port->handshake("none") if $ser_type eq "HMP"; $port->write_settings; # debug output #print "attempting to communicate with power supply connected to interface:\n$ser_dev\n\n"; -transmit_command(); #if new command, send it! -receive_answer(); # always called +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 + # transmit_command(); # send relais off in case current maximum is reached! @@ -61,12 +69,12 @@ sub transmit_command { $port->lookclear; while ( my $command = shift(@new_command) ) { - - $port->write("$command\r"); - #print "i sent the command: $command"; - #print "\n\nokay.\n"; - usleep 1E5; - } + $command = uri_unescape($command); + $port->write("$command\r\n"); + print "i sent the command: $command"; + #print "\n\nokay.\n"; + usleep 1E5; + } } @@ -136,24 +144,23 @@ sub receive_answer { } } - - - - - if($found) { - - print "connection ok
"; - } else { - print "!!! power supply not responding !!!
"; } - - print " \n"; - - - - - - -} +sub receive_answer_HMP { + + while ( my $command = shift(@new_command) ) { + $port->lookclear; + $command = uri_unescape($command); + $port->write("$command\r\n"); +# print "i sent the command: $command\n"; + #print "\n\nokay.\n"; + usleep 1E5; + while(my $a = $port->lookfor) { + print $a."&"; # debug output + } + } + } + +print "\n"; + exit 1; diff --git a/web/htdocs/tools/pwr/pwr_hmp.htm b/web/htdocs/tools/pwr/pwr_hmp.htm new file mode 100644 index 0000000..c9b402b --- /dev/null +++ b/web/htdocs/tools/pwr/pwr_hmp.htm @@ -0,0 +1,158 @@ + + + + + + +Power Supply Monitor and Access + + + + +

Power Supply Access

+ + + +
+ +
Chan 1Chan 2Chan 3Chan 4 +
Voltage [V] + + + + + +
Actual[V/A] + + + + + +
Limits[V/A] + + + + + +
Output Relais +
+

+

+

+ +
Enable read-back of values. +
+
+ + + + +
+
+ + + + diff --git a/web/htdocs/tools/pwr/styles.css b/web/htdocs/tools/pwr/styles.css index b7e3b6f..7951704 100644 --- a/web/htdocs/tools/pwr/styles.css +++ b/web/htdocs/tools/pwr/styles.css @@ -1,48 +1,26 @@ body { background:#eee; } - - -table#content, table#contentregs { - border:1px solid #aaa; - border-collapse:collapse; + +.smallboxes { + border-collapse:collapse; + border:1px solid black; } -table#content td, table#content th, table#contentregs td, table#contentregs th{ - border:1px solid #aaa; - width:100px; - text-align:right; - padding-right:15px; -} - -table#content, table#contentregs { - border:1px solid #aaa; -} - -div#bar1 { - width:900px; - overflow-x:scroll; - } +.smallboxes input { + width:50px; + } -div#bar1 div { - width:66500px; - height:0px; +.smallboxes .sep { + border-bottom:1px solid black; } -div#bar2 { - width:900px; - overflow-x:scroll; +.smallboxes td:nth-child(even), .smallboxes th { + border-left:1px solid black; } -div#bar2 div { - width:65536px; - height:0px; -} - - -#total { - text-align:center; - font-weight:bold; - } \ No newline at end of file +.smallboxes td { + padding:1px; +} \ No newline at end of file -- 2.43.0