From: Michael Wiebusch
Date: Mon, 13 May 2013 13:56:08 +0000 (+0200)
Subject: added support for Vacom MVC-3 pressure readout controller
X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=c5e2f143199425641515dfd87fb29562bcd11999;p=labtools.git
added support for Vacom MVC-3 pressure readout controller
---
diff --git a/RasPi_slow_control_suite/README.txt b/RasPi_slow_control_suite/README.txt
index f721324..be00ea6 100644
--- a/RasPi_slow_control_suite/README.txt
+++ b/RasPi_slow_control_suite/README.txt
@@ -1,4 +1,4 @@
-Raspberry Pi slow control suite v0.1
+Raspberry Pi slow control suite v0.2
by Michael Wiebusch
mwiebusch@stud.uni-frankfurt.de
@@ -11,6 +11,8 @@ This package includes:
"pwr" - a simple tool to monitor and control one or more laboratory power supplies of the type "GW Instek PSP-405"
+"pressure" - a tool that monitors, plots and logs data coming from a Vacom MVC-3 pressure readout controller
+
Installation:
@@ -18,6 +20,10 @@ Installation:
Step 1:
Install an Apache2 webserver on your Raspberry Pi.
+(sudo apt-get install apache2)
+
+If you want to use the pressure tool also install gnuplot.
+(sudo apt-get install gnuplot)
Step 2:
@@ -48,3 +54,9 @@ Point your browser to http://[IP of the raspberry]/tools/
and use the tools.
You can configure the monitoring/control tools (especially what serial device to use) on each webinterface.
+
+
+
+Change log:
+
+since v0.2: added the support for the pressure readout controller
diff --git a/RasPi_slow_control_suite/www/tools/pressure/.pwr.pl.swp b/RasPi_slow_control_suite/www/tools/pressure/.pwr.pl.swp
new file mode 100644
index 0000000..f357731
Binary files /dev/null and b/RasPi_slow_control_suite/www/tools/pressure/.pwr.pl.swp differ
diff --git a/RasPi_slow_control_suite/www/tools/pressure/build_index.pl b/RasPi_slow_control_suite/www/tools/pressure/build_index.pl
new file mode 100755
index 0000000..1cc18a5
--- /dev/null
+++ b/RasPi_slow_control_suite/www/tools/pressure/build_index.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl -w
+use Cwd;
+print "Content-type: text/html\n\n";
+
+my $pwd = &Cwd::cwd();
+my $iframewidth = 800;
+my $iframeheight = 340;
+
+
+open(LESEN,"devices.conf")
+ or die "Fehler beim oeffnen von : $!\n";
+
+while(defined(my $i = )) {
+
+ if( $i =~ /^iframesize:(\d+)x(\d+)/g ) {
+ $iframewidth = $1;
+ $iframeheight = $2;
+ }
+
+ if( $i =~ /^DEVICE:([^:]+):([^:]+)/g ) {
+ my $ser_dev=$1;
+ my $dev_id=$2;
+
+print <
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RasPi_slow_control_suite/www/tools/pressure/devices.conf b/RasPi_slow_control_suite/www/tools/pressure/devices.conf
new file mode 100644
index 0000000..97c17fd
--- /dev/null
+++ b/RasPi_slow_control_suite/www/tools/pressure/devices.conf
@@ -0,0 +1,5 @@
+iframesize:800x1250
+
+
+//DEVICE:/path/to/device:Device_ID
+DEVICE:/dev/ttyUSB0:PressureReadoutController
\ No newline at end of file
diff --git a/RasPi_slow_control_suite/www/tools/pressure/index.html b/RasPi_slow_control_suite/www/tools/pressure/index.html
new file mode 100644
index 0000000..e4f4e1b
--- /dev/null
+++ b/RasPi_slow_control_suite/www/tools/pressure/index.html
@@ -0,0 +1,76 @@
+
+
+
+
+
+ Pressure Readout
+
+
+
+
+
+
Vacom MVC-3 Webinterface
+
+Platzhalter
+
+
+
+
+
+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.
+Feel free to alter the config file to accommodate your needs!
+Please don't use the # character to comment out lines
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RasPi_slow_control_suite/www/tools/pressure/plot.pl b/RasPi_slow_control_suite/www/tools/pressure/plot.pl
new file mode 100755
index 0000000..2ec5460
--- /dev/null
+++ b/RasPi_slow_control_suite/www/tools/pressure/plot.pl
@@ -0,0 +1,323 @@
+#!/usr/bin/perl
+print "Content-type: text/html\n\n";
+#print "Hello, World.";
+use Device::SerialPort;
+use Time::HiRes;
+
+
+
+
+
+# parse the environment string, set some variables
+
+my $envstring = $ENV{'QUERY_STRING'};
+$envstring =~ s/%20/ /g;
+my $port;
+
+my @new_command = split('&',$envstring);
+my $ser_dev = shift(@new_command);
+$ser_dev = "/dev/null" unless defined $ser_dev;
+my $last_n = shift(@new_command);
+
+my $ser_dev_id = $ser_dev;
+$ser_dev_id =~ s/\///g;
+
+my $directory="shm/pressure_".$ser_dev_id."/";
+#my $plotfile=$directory."plot.gif";
+my $datafile=$directory."data";
+my $random_number = rand();
+
+my %report_table;
+
+my $now = sprintf "%02d.%02d.%02d_%02d:%02d:%02d",(localtime)[3],((localtime)[4] +1),((localtime)[5] -100),(localtime)[2],(localtime)[1],(localtime)[0];
+
+# create directory in the shm (somewhere in RAM) for data and plot files, does not have to be stored permanently,
+# as user can download the logfile if needed
+
+unless( -e $directory or mkdir $directory) {
+ print "Unable to create directory for temporary files!\n";
+ exit;
+ }
+
+
+
+
+init_port();
+
+
+
+
+
+
+
+
+
+
+# open logfile for writing
+
+open(LOG,">>$datafile")
+ or print "Fehler beim oeffnen von : $!\n";
+
+
+
+# write random number in the log, for debug purpose
+#print LOG $now."\t".rand()."\t".rand()."\t".rand()."\n";
+#close(LOG);
+
+# read sensor data and write report tables
+my $pressure_unit = UNIT();
+
+if ( -z $datafile ) {
+ print LOG "#time [DD.MM.YY_HH:MM:SS]\t#Sensor 1 pressure [$pressure_unit]\t#Sensor 1 status\t#Sensor 2 pressure [$pressure_unit]\t#Sensor 2 status\t#Sensor 3 pressure [$pressure_unit]\t#Sensor 3 status\n";
+}
+
+# print current time to logfile
+print LOG $now;
+
+for (my $i=1;$i<=3;$i++){
+
+ my $sensor_id = RID($i);
+ my ($pressure, $status) = RPV($i);
+
+ $report_table{$i}= "
";
+ $report_table{$i}.= "
Sensor $i
";
+ $report_table{$i}.= "
Pressure:
$pressure $pressure_unit
";
+ $report_table{$i}.= "
Status:
$status
";
+ $report_table{$i}.= "
Sensor ID:
$sensor_id
";
+ $report_table{$i}.= "
";
+ # print pressure value to logfile
+ $status =~ s/\s/_/g;
+ print LOG "\t$pressure\t$status";
+
+}
+# print newline to logfile and close logfile
+print LOG "\n";
+close(LOG);
+
+
+# print reports and gnuplot pictures to html output
+print '