]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Added IpBus Support and first script using it
authorAdrian Weber <adrian.a.weber@exp2.physik.uni-giessen.de>
Wed, 19 Dec 2018 10:37:25 +0000 (11:37 +0100)
committerAdrian Weber <adrian.a.weber@exp2.physik.uni-giessen.de>
Wed, 19 Dec 2018 10:37:25 +0000 (11:37 +0100)
dmon/code/getIpBus.py [new file with mode: 0755]
dmon/scripts/dmon_pulser.pl [new file with mode: 0755]

diff --git a/dmon/code/getIpBus.py b/dmon/code/getIpBus.py
new file mode 100755 (executable)
index 0000000..8a1d32f
--- /dev/null
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+## Had to add LD_LIBRARY_PATH to /etc/ld.so.conf.d/ipbus.conf  afterwards: sudo ldconfig
+## Install IpBus uHal on the server maschine
+## 
+
+import cgi
+import cgitb; cgitb.enable()
+import os
+import uhal
+import sys
+import json
+
+
+
+
+# Create instance of FieldStorage 
+form = cgi.FieldStorage() 
+
+# Get data from fields
+regName = form.getvalue('reg')
+
+if len(sys.argv) > 1:
+  regName = "CTRL"
+else:
+  print('Content-Type: application/json')
+  print('')
+  
+if regName is None:
+  print "Invalid Register Name";
+else:
+
+  XmlPATH = "/home/hadaq/mRICH/ipBus/";
+  connectionFilePath = XmlPATH+"rich_DPB.xml";#sys.argv[1];
+  deviceId = "rich_DPB";
+  registerName = "rich."+regName;
+
+  uhal.disableLogging()
+  connectionMgr = uhal.ConnectionManager("file://" + connectionFilePath);
+  hw = connectionMgr.getDevice(deviceId);
+  node = hw.getNode(registerName)
+
+  reg = node.read();
+  hw.dispatch();
+
+  #print "Value =", hex(reg);
+
+  x = {}
+  x[regName] = hex(reg)
+  
+  y = json.dumps(x)
+  print(y)
diff --git a/dmon/scripts/dmon_pulser.pl b/dmon/scripts/dmon_pulser.pl
new file mode 100755 (executable)
index 0000000..a25a398
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use strict;
+use Time::HiRes qw( gettimeofday usleep time );
+use FileHandle;
+use Data::Dumper;
+use POSIX qw/floor ceil/;;
+use JSON::XS;
+
+use Dmon;
+
+my $fqa  = Dmon::OpenQAFile();
+
+
+sub status {
+  my ($val) = shift(@_);
+
+  my $status = "";
+  if ($val == 0) {
+    $status = "OFF";
+  } else {
+    $status = "ON";
+  }
+  
+  return $status;
+}
+
+
+while (1) {
+  
+  my $test = qx(/dev/shm/dmon/code/getIpBus.py CTRL);
+  my $data = decode_json $test;
+  
+  my $pulserVal = (hex($data->{CTRL}) >>1) & 0x1;
+
+  my $qastate    = Dmon::OK; 
+ # my $status = status($pulserVal);
+  Dmon::WriteQALog($fqa,"pulser", 40, $qastate, "Pulser", status($pulserVal) ,status($pulserVal));
+  
+  my $extClkVal = (hex($data->{CTRL}) >> 0) & 0x1;
+  Dmon::WriteQALog($fqa,"extClk", 40, $qastate, "ext. Clock", status($extClkVal) ,status($extClkVal));
+  sleep 5;
+}