From 1e04502b08c477bfb40539320e4f7474f7bb5115 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Fri, 18 Aug 2017 10:56:15 +0200 Subject: [PATCH] Update power supply controller. Enable individual power supplies in GUI, fix some links and timings --- powersupplies/web/htdocs/build_index.pl | 22 +++++++++++----------- powersupplies/web/htdocs/index.html | 1 + powersupplies/web/htdocs/pwr.conf | 10 ++++++---- powersupplies/web/htdocs/pwr.pl | 7 +++++-- powersupplies/web/htdocs/pwr_hmp.htm | 8 ++++---- powersupplies/web/htdocs/pwr_psp.htm | 8 ++++---- powersupplies/web/htdocs/pwr_switch.htm | 8 ++++---- powersupplies/web/htdocs/scripts.js | 20 +++++++++++++++++++- powersupplies/web/htdocs/styles.css | 10 +++++++++- 9 files changed, 63 insertions(+), 31 deletions(-) diff --git a/powersupplies/web/htdocs/build_index.pl b/powersupplies/web/htdocs/build_index.pl index 0683b2a..c416157 100755 --- a/powersupplies/web/htdocs/build_index.pl +++ b/powersupplies/web/htdocs/build_index.pl @@ -18,9 +18,9 @@ if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { open(LESEN,$file) or die "Fehler beim oeffnen von : $!\n"; - +my $j = 0; while(defined(my $i = )) { - + $j++; if( $i =~ /^PWRSPLY:([^:]+):([^:]+):([^:]+):([^:]+):([^:]+)/g ) { my @arr = split(':',$i); shift @arr; @@ -33,25 +33,25 @@ while(defined(my $i = )) { if($type eq "PSP") { print < - -

+

Power Supply $dev_id [connected to $ser_dev]

+ + EOF } if($type =~ /HMP/ or $type =~ /HMC/ or $type =~ /PST/) { print < - -

+

Power Supply $dev_id [connected to $ser_dev]

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

+

Power Supply $dev_id [connected to $ser_dev]

+ + EOF } diff --git a/powersupplies/web/htdocs/index.html b/powersupplies/web/htdocs/index.html index a3b834c..4f167ec 100644 --- a/powersupplies/web/htdocs/index.html +++ b/powersupplies/web/htdocs/index.html @@ -24,6 +24,7 @@ function update(data) { getdata('build_index.pl',update); +

Configuration File

Note that you need to have libdevice-serialport-perl or perl-Device-SerialPort
installed and that the /dev/ttyUSBn need to be accessible by normal users.
diff --git a/powersupplies/web/htdocs/pwr.conf b/powersupplies/web/htdocs/pwr.conf index 578af96..bb515a2 100644 --- a/powersupplies/web/htdocs/pwr.conf +++ b/powersupplies/web/htdocs/pwr.conf @@ -4,12 +4,14 @@ //PWRSPLY:/dev/ttyUSB0:9600:PST3202:PST:3 //PWRSPLY:/dev/ttyUSB0:115200:HMP4030:HMP:3 //PWRSPLY:IP192.168.0.56:5050:HMP4040:HMP:4 -PWRSPLY:/dev/FTDI_FT232R_USB_UART_AH02HFZW:2400:PSP2010:PSP:1 //PWRSPLY:/dev/FTDI_FT232R_USB_UART_A702HE33:2400:PSP405:PSP:1 //PWRSPLY:IP192.168.0.56:5050:HMP4040 DiRich:HMP:4:LP1:LP2:LP3:DCDC -PWRSPLY:/dev/FTDI_Xmatter_TTL_ALR1AJS:57600:Desk:PWRSW:6:TestAdrian:Pulser:::TrgDistr:ADC //PWRSPLY:SERpi@192.168.0.230/dev/FTDI_FT232R_USB_UART_AH02HFZW:2400:PSP2010:PSP:1 //PWRSPLY:SERpi@192.168.0.230/dev/TRB3_Power48_00002:0:Rack48:PWRSW:4:Crate::: -//PWRSPLY:/dev/HAMEG_HO732_VCP023842636:0:HMP4040:HMP:4 -//PWRSPLY:IP192.168.0.56:5050:HMP4040 DiRich:HMP:4:LP1:LP2:LP3:DCDC //PWRSPLY:/dev/TRB3_Power48_00002:0:Rack48:PWRSW:4:Desk::: + +PWRSPLY:/dev/FTDI_FT232R_USB_UART_AH02HFZW:2400:PSP2010:PSP:1 +PWRSPLY:/dev/FTDI_Xmatter_TTL_ALR1AJS:57600:Desk:PWRSW:6:TestAdrian:Pulser:::TrgDistr:ADC +PWRSPLY:/dev/HAMEG_HO732_VCP023842636:0:HMP4040:HMP:4 +PWRSPLY:IP192.168.0.56:5050:HMP4040 DiRich:HMP:4:LP1:LP2:LP3:DCDC +PWRSPLY:IP192.168.0.139:5025:HMC8043:HMC:3::: diff --git a/powersupplies/web/htdocs/pwr.pl b/powersupplies/web/htdocs/pwr.pl index aa6c0bc..561678d 100755 --- a/powersupplies/web/htdocs/pwr.pl +++ b/powersupplies/web/htdocs/pwr.pl @@ -186,7 +186,6 @@ sub HMP_ethernet { my $port = IO::Socket::INET->new(PeerAddr => $ser_dev, PeerPort => $ser_speed, Proto => "tcp", Type => SOCK_STREAM, Timeout => 1) or (print("Device not found") && return); - while ( my $command = shift(@new_command) ) { $command = uri_unescape($command); my $x = getValue($port,$command,$cnt++); @@ -202,6 +201,7 @@ sub serial_rw { my $x = ""; if ($ser_type eq 'PSP') {$command .= "\r";} else {$command .= "\n";} print $fh "$command"; +# print $command; if($ser_type eq 'PWRSW' || $forceread || $command =~ /\?/) { for my $i (0..500) { $x .= <$fh>; @@ -212,13 +212,16 @@ sub serial_rw { usleep(1000); } } + else { + usleep(1000); + } return $x; } sub getValue { my ($fh,$cmd,$cnt,$forceread) = @_; - if (defined $db->{$cmd.$cnt}{tim} && $db->{$cmd.$cnt}{tim} > time()-2) { + if (0 && defined $db->{$cmd.$cnt}{tim} && $db->{$cmd.$cnt}{tim} > time()-2) { return $db->{$cmd.$cnt}{val}; } else { diff --git a/powersupplies/web/htdocs/pwr_hmp.htm b/powersupplies/web/htdocs/pwr_hmp.htm index edf020f..8b840dc 100644 --- a/powersupplies/web/htdocs/pwr_hmp.htm +++ b/powersupplies/web/htdocs/pwr_hmp.htm @@ -2,14 +2,14 @@ - - + + Power Supply Monitor and Access -

Power Supply Access

+ @@ -226,7 +226,7 @@ function readSettings() { } updateTask = setTimeout("update()",updaterate); -document.getElementById("headline").innerHTML = "Power Supply "+''+dev_id+''+" [connected to "+''+ser_dev+''+"]" ; +//document.getElementById("headline").innerHTML = "Power Supply "+''+dev_id+''+" [connected to "+''+ser_dev+''+"]" ; for(i=1;i<=channels;i++) { if(typeof Vnames[i-1] !== 'undefined') diff --git a/powersupplies/web/htdocs/pwr_psp.htm b/powersupplies/web/htdocs/pwr_psp.htm index 004d682..2dcb1e4 100644 --- a/powersupplies/web/htdocs/pwr_psp.htm +++ b/powersupplies/web/htdocs/pwr_psp.htm @@ -2,14 +2,14 @@ - - + + Power Supply Monitor and Access -

Power Supply Access

+ '+dev_id+''+" [connected to "+''+ser_dev+''+"]" ; +//document.getElementById("headline").innerHTML = "Power Supply "+''+dev_id+''+" [connected to "+''+ser_dev+''+"]" ; diff --git a/powersupplies/web/htdocs/pwr_switch.htm b/powersupplies/web/htdocs/pwr_switch.htm index 3b84c0b..c06486b 100644 --- a/powersupplies/web/htdocs/pwr_switch.htm +++ b/powersupplies/web/htdocs/pwr_switch.htm @@ -2,14 +2,14 @@ - - + +Power Supply Monitor and Access -

+ @@ -152,7 +152,7 @@ function readSettings() { } updateTask = setTimeout("communication()",updaterate); -document.getElementById("headline").innerHTML = "Power Switch "+''+dev_id+''+" [connected to "+''+ser_dev+''+"]" ; +//document.getElementById("headline").innerHTML = "Power Switch "+''+dev_id+''+" [connected to "+''+ser_dev+''+"]" ; maketable(); diff --git a/powersupplies/web/htdocs/scripts.js b/powersupplies/web/htdocs/scripts.js index 3e2a5c1..e0faa62 100644 --- a/powersupplies/web/htdocs/scripts.js +++ b/powersupplies/web/htdocs/scripts.js @@ -17,7 +17,25 @@ function getdata(command,callback,option) { xmlhttp.open("GET",command,true); xmlhttp.send(null); } + + +function Enable(ob) { + frob = "iframe"+ob; + var frame = document.getElementById(frob); + var h = document.getElementById(ob); + + if(frame.getAttribute("height") == 0) { + frame.setAttribute("height", frame.getAttribute("data-height")); + frame.setAttribute("src",frame.getAttribute("data-src")); + h.style.color = "black"; + } + else { + frame.setAttribute("height", "0"); + frame.setAttribute("src",""); + h.style.color = "darkblue"; + } + } // function reload() { // xmlhttp=new XMLHttpRequest(); @@ -41,4 +59,4 @@ function getdata(command,callback,option) { // xmlhttp.open("GET","get.cgi?$.$ENV{'QUERY_STRING'}.qq$",true); // xmlhttp.send(null); // document.getElementById("stop").style.background="#111"; -// } \ No newline at end of file +// } diff --git a/powersupplies/web/htdocs/styles.css b/powersupplies/web/htdocs/styles.css index 7d6a735..4ee34db 100644 --- a/powersupplies/web/htdocs/styles.css +++ b/powersupplies/web/htdocs/styles.css @@ -54,4 +54,12 @@ tfoot>tr:first-child { .powerswitch td { border-left:1px solid black; text-align:center; -} \ No newline at end of file +} + +h3 { + cursor : pointer; + margin-bottom:5px; + padding-bottom:5px; + font-weight:normal; + color:darkblue; +} -- 2.43.0