]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Added more powersuplies to the control GUI
authorJan Michel <j.michel@gsi.de>
Fri, 12 Jul 2013 17:48:59 +0000 (19:48 +0200)
committerJan Michel <j.michel@gsi.de>
Fri, 12 Jul 2013 17:48:59 +0000 (19:48 +0200)
web/htdocs/layout/styles.css
web/htdocs/tools/pwr/build_index.pl
web/htdocs/tools/pwr/pwr.conf
web/htdocs/tools/pwr/pwr.htm
web/htdocs/tools/pwr/pwr.pl
web/htdocs/tools/pwr/pwr_hmp.htm [new file with mode: 0644]
web/htdocs/tools/pwr/styles.css

index e738a0ec63ac5d83524401140d546b66e3e6eeed..05ed6458464e341f137d3729e252e09aedc48973 100644 (file)
@@ -257,3 +257,7 @@ table#server-details pre {
 }
    
 
+.smallboxes input {
+  width:40px;
+  }  
+   
\ No newline at end of file
index e7b88eff70c946a04219d8268345b26ea3c91e53..62af2e4c47d7170b8bbd0de137846d0d4e57ab9a 100755 (executable)
@@ -10,18 +10,35 @@ open(LESEN,"htdocs/tools/pwr/pwr.conf")
 
 while(defined(my $i = <LESEN>)) {
 
-       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;
 <p>
 <iframe name="inlineframe" src="pwr.htm?device=$ser_dev&id=$dev_id" frameborder="0" scrolling="auto" width="800" height="340" ></iframe>
 </p>
 EOF
+}
+
+if($type =~ /HMP/) {
+print <<EOF;
+<p>
+<iframe name="inlineframe" src="pwr_hmp.htm?device=$ser_dev&id=$dev_id&type=$type&channels=$channels" frameborder="0" scrolling="auto" width="1000" height="400" ></iframe>
+</p>
+EOF
+}
+
+
+
        }
 }
 
+
+
 #print "CWD: ".$pwd."<br>(for debug)\n";
 
 
index 5e6e030dc1bb1cf3eecfde997ecf353364320c25..d7aad6dabb69568fd100c266c62743becc0723d0 100644 (file)
@@ -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
index bf4f3af3353705a353e5d3be331c5b3a7da57817..f7cfd0f5ff7ef59627372b06430d80b3db271d81 100644 (file)
@@ -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();
 }
index 2e174ef8d0617acfe08906159dbaa812efad2aa1..676e1d5c78ca0bbd47d099176d6b4f71ab1979a3 100755 (executable)
@@ -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 <br>";
-       } else {
-               print "!!! power supply not responding !!!<br>";
        }
-       
-       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 (file)
index 0000000..c9b402b
--- /dev/null
@@ -0,0 +1,158 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+<link href="styles.css" rel="stylesheet" type="text/css"/>
+<script src="scripts.js" type="text/javascript"></script>
+<title>Power Supply Monitor and Access</title>
+</head>
+<body style="font-family: sans-serif;" >
+
+
+<p style="bold" id="headline">Power Supply Access</p>
+
+
+
+<form acion="">
+<table id="settings" class="smallboxes">
+<tr><th><th colspan=2>Chan 1<th colspan=2>Chan 2<th colspan=2>Chan 3<th colspan=2>Chan 4
+<tr class="sep"><td align="right">Voltage [V]
+  <td><input type="text" id="form_v1" name="voltage" value=""><td><input type="button" onClick="set_v(1)" value="set">
+  <td><input type="text" id="form_v2" name="voltage" value=""><td><input type="button" onClick="set_v(2)" value="set">
+  <td><input type="text" id="form_v3" name="voltage" value=""><td><input type="button" onClick="set_v(3)" value="set">
+  <td><input type="text" id="form_v4" name="voltage" value=""><td><input type="button" onClick="set_v(4)" value="set">
+
+<tr><td align="right">Actual[V/A]
+  <td> <input type="text" id="vol1" disabled>  <td> <input type="text" id="cur1" disabled>
+  <td> <input type="text" id="vol2" disabled>  <td> <input type="text" id="cur2" disabled>
+  <td> <input type="text" id="vol3" disabled>  <td> <input type="text" id="cur3" disabled>
+  <td> <input type="text" id="vol4" disabled>  <td> <input type="text" id="cur4" disabled>
+
+<tr><td align="right">Limits[V/A]
+  <td><input type="text" id="form_v_lim1" name="voltage_limit" onChange="set_v_lim(1)" value=""><td><input type="text" id="form_c_lim1" name="current_limit" onChange="set_c_lim(1)" value="">
+  <td><input type="text" id="form_v_lim2" name="voltage_limit" onChange="set_v_lim(2)" value=""><td><input type="text" id="form_c_lim2" name="current_limit" onChange="set_c_lim(2)" value="">
+  <td><input type="text" id="form_v_lim3" name="voltage_limit" onChange="set_v_lim(3)" value=""><td><input type="text" id="form_c_lim3" name="current_limit" onChange="set_c_lim(3)" value="">
+  <td><input type="text" id="form_v_lim4" name="voltage_limit" onChange="set_v_lim(4)" value=""><td><input type="text" id="form_c_lim4" name="current_limit" onChange="set_c_lim(4)" value="">
+
+<tr class="sep"><td>Output Relais
+  <td><td><input type="button" onClick="turn_on(1)" value="on"><br><input type="button" onClick="turn_off(1)" value="off">
+  <td><td><input type="button" onClick="turn_on(2)" value="on"><br><input type="button" onClick="turn_off(2)" value="off">
+  <td><td><input type="button" onClick="turn_on(3)" value="on"><br><input type="button" onClick="turn_off(3)" value="off">
+  <td><td><input type="button" onClick="turn_on(4)" value="on"><br><input type="button" onClick="turn_off(4)" value="off">
+
+<tr><td colspan=9><input type="checkbox" value="1" id="showreadings">Enable read-back of values.
+</table>
+</form>
+
+
+
+
+<div id="readings" width="300" >
+</div>
+
+
+<script language="javascript">
+var updaterate = 500;
+var updateTask;
+var new_commands = new Array();
+var ser_dev = getParameterByName("device");
+var dev_id = getParameterByName("id");
+var type = getParameterByName("type");
+var channels = getParameterByName("channels");
+
+
+function set_v(chan) {
+       var value = parseFloat(document.getElementById("form_v"+chan).value);
+       var command;
+  if(type=="HMP") command = "INST OUT"+chan+"&VOLT "+value.toFixed(3);
+       new_commands.push(command);
+}
+
+function set_v_lim(chan) {
+       var value = parseInt(document.getElementById("form_v_lim"+chan).value);
+       var command;
+  if(type=="HMP") command = "INST OUT"+chan+"&VOLT:PROT "+value.toFixed(3);
+       new_commands.push(command);
+}
+
+function set_c_lim(chan) {
+       var value = parseFloat(document.getElementById("form_c_lim"+chan).value);
+       var command;
+  if(type=="HMP") command = "INST OUT"+chan+"&CURR "+value.toFixed(3);
+       new_commands.push(command);
+}
+
+function turn_on(chan) {
+       if(type=="HMP") new_commands.push("INST OUT"+chan+"&OUTP ON");
+}
+
+function turn_off(chan) {
+  if(type=="HMP") new_commands.push("INST OUT"+chan+"&OUTP OFF");
+}
+
+
+function update(data) {
+  updateTask = setInterval("communication()",updaterate);
+  }
+
+  
+function updatereads(data) {
+  if(document.getElementById("readings"))
+    document.getElementById("readings").innerHTML=data;
+  var e = data.split("&");
+  for(i=0;i<channels;i++) {
+    document.getElementById("vol"+(i+1)).value=e[i*2];
+    document.getElementById("cur"+(i+1)).value=e[i*2+1];
+    }
+  updateTask = setInterval("communication()",updaterate);
+  }  
+
+function communication() {
+  cmds = new_commands.join('&');
+  if (cmds != "") {
+    clearInterval(updateTask);
+    getdata('pwr.pl?'+ser_dev+'&'+type+'&'+cmds,update);
+    }
+  else if(document.getElementById("showreadings").checked) {
+    clearInterval(updateTask);
+    cmds = "";
+    for(i=1;i<=channels;i++)
+      cmds +="&INST OUT"+i+"&MEAS:VOLT%3F&MEAS:CURR%3F";
+    getdata('pwr.pl?'+ser_dev+'&'+type+cmds,updatereads);
+    }
+       new_commands = new Array();
+}
+
+
+function padZeros(theNumber, max) {
+    var numStr = String(theNumber);
+    
+    while ( numStr.length < max) {
+        numStr = '0' + numStr;
+    }
+    
+    return numStr;
+}
+
+
+function getParameterByName(name)
+{
+  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
+  var regexS = "[\\?&]" + name + "=([^&#]*)";
+  var regex = new RegExp(regexS);
+  var results = regex.exec(window.location.search);
+  if(results == null)
+    return "";
+  else
+    return decodeURIComponent(results[1].replace(/\+/g, " "));
+}
+
+
+
+
+updateTask = setInterval("communication()",updaterate);
+document.getElementById("headline").innerHTML  = "Power Supply "+'<b>'+dev_id+'</b>'+" [connected to "+'<b>'+ser_dev+'</b>'+"]" ;
+  
+  
+</script>
+</body></html>
index b7e3b6f099362559fa1e183642273f3f7fc106f0..7951704b2d223d9ed2706bf12fc900a6231dcd05 100644 (file)
@@ -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