From 7af254a9ef77cadd33d8fbf533426900f149c564 Mon Sep 17 00:00:00 2001
From: Menno Norden <norden@astron.nl>
Date: Tue, 19 Jan 2010 10:27:20 +0000
Subject: [PATCH] bug 1315: beamctl used to switch on HBA

---
 LCU/StationTest/test/hbatest/determinepeak.py |  7 +++--
 .../test/hbatest/hbaelementtest.py            |  9 ++++--
 LCU/StationTest/test/hbatest/hbaquicktest.py  |  9 +++---
 LCU/StationTest/test/hbatest/modemtest.sh     | 29 +++++++++++++++----
 4 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/LCU/StationTest/test/hbatest/determinepeak.py b/LCU/StationTest/test/hbatest/determinepeak.py
index e93ad1899e9..fe885c7c33e 100644
--- a/LCU/StationTest/test/hbatest/determinepeak.py
+++ b/LCU/StationTest/test/hbatest/determinepeak.py
@@ -79,8 +79,11 @@ def main() :
     #---------------------------------------------
     # capture reference data (all HBA elements off)
     rm_files(dir_name,'*')
-    os.popen("rspctl --rcumode=5 2>/dev/null")
-    os.popen("rspctl --enable 2>/dev/null")
+    os.popen3("swlevel 3");
+    time.sleep(5)
+    os.popen("beamctl --array=HBA --rcus=0:95 --rcumode=5 --subbands=100:110 --beamlets=0:10 --direction=0,0,J2000&")
+    #os.popen("rspctl --rcumode=5 2>/dev/null")
+    #os.popen("rspctl --rcuenable=1 2>/dev/null")
     for ind in range(hba_elements) :
         ctrl_string=ctrl_string + '128,'
     strlength=len(ctrl_string)
diff --git a/LCU/StationTest/test/hbatest/hbaelementtest.py b/LCU/StationTest/test/hbatest/hbaelementtest.py
index 790ea2da509..61ca38b1aa3 100644
--- a/LCU/StationTest/test/hbatest/hbaelementtest.py
+++ b/LCU/StationTest/test/hbatest/hbaelementtest.py
@@ -45,7 +45,7 @@ def open_file(files, file_nr) :
 		f=open(file_name,'rb')
 		max_frames = size/(512*8)
 		frames_to_process=max_frames
-    		rcu_nr = int(files[file_nr][-7:-4])
+    		rcu_nr = int(files[file_nr][-6:-4])
 		#print 'File nr ' + str(file_nr) + ' RCU nr ' + str(rcu_nr) + '  ' + files[file_nr][-6:-4]
 	else :
 		frames_to_process=0
@@ -121,8 +121,11 @@ def main() :
         #---------------------------------------------
 	# capture reference data (all HBA elements off)
         rm_files(dir_name,'*')
-        os.popen("rspctl --rcumode=5 2>/dev/null")
-        os.popen("rspctl --rcuenable=1 2>/dev/null")
+        os.popen3("swlevel 3");
+        time.sleep(5)
+        os.popen("beamctl --array=HBA --rcus=0:95 --rcumode=5 --subbands=100:110 --beamlets=0:10 --direction=0,0,J2000&")
+        #os.popen("rspctl --rcumode=5 2>/dev/null")
+        #os.popen("rspctl --rcuenable=1 2>/dev/null")
         time.sleep(2)
         for ind in range(hba_elements) :
 		ctrl_string=ctrl_string + '2,'
diff --git a/LCU/StationTest/test/hbatest/hbaquicktest.py b/LCU/StationTest/test/hbatest/hbaquicktest.py
index 4d325b67b27..8bbcc028820 100644
--- a/LCU/StationTest/test/hbatest/hbaquicktest.py
+++ b/LCU/StationTest/test/hbatest/hbaquicktest.py
@@ -94,10 +94,11 @@ def main() :
         #---------------------------------------------
 	# capture reference data (all HBA elements off)
         rm_files(dir_name,'*')
-        os.popen("rspctl --rcumode=5 2>/dev/null")
-        time.sleep(2)
-        os.popen("rspctl --rcuenable=1 2>/dev/null")
-        time.sleep(2)
+        os.popen3("swlevel 3");
+        time.sleep(5)
+        os.popen("beamctl --array=HBA --rcus=0:95 --rcumode=5 --subbands=100:110 --beamlets=0:10 --direction=0,0,J2000&")
+        #os.popen("rspctl --rcumode=5 2>/dev/null")
+        #os.popen("rspctl --rcuenable=1 2>/dev/null")
         for ind in range(hba_elements) :
 		ctrl_string=ctrl_string + '2,'
 	strlength=len(ctrl_string)
diff --git a/LCU/StationTest/test/hbatest/modemtest.sh b/LCU/StationTest/test/hbatest/modemtest.sh
index 485460998ea..e9be466d016 100644
--- a/LCU/StationTest/test/hbatest/modemtest.sh
+++ b/LCU/StationTest/test/hbatest/modemtest.sh
@@ -3,18 +3,37 @@
 # Send delays from RCU to HBA and compare results with the expected golden result.
 # To verify modem communication between RCU and HBA
 #
-# Version 1.1   55555 2009   M.J.Norden
+# Version 1.2  18-01-10   M.J.Norden
 
 rm -f hba_modem*.log
 rm -f hba_modem*.diff
 
-declare ontime=4
-
+let ontime=4
 let hbamode=5
 
-eval "rspctl --rcumode=$hbamode"
+station=`hostname -s`
+
+if [ -e /opt/lofar/etc/RemoteStation.conf ]; then
+  let rspboards=`sed -n  's/^\s*RS\.N_RSPBOARDS\s*=\s*\([0-9][0-9]*\).*$/\1/p' /opt/lofar/etc/RemoteStation.conf`
+  let rcus=$rspboards*8
+  let nrcus=$rcus-1
+else
+  echo "Could not find /opt/lofar/etc/RemoteStation.conf"
+  let rspboards=12
+  let rcus=$rspboards*8
+  let nrcus=$rcus-1
+fi
+
+echo "This is station "$station
+echo "The number of RCU's is "$rcus
+
+rspctl --splitter=0
 sleep 2
-eval "rspctl --rcuenable=1"
+
+swlevel 3
+beamctl --array=HBA --rcus=0:$nrcus --rcumode=$hbamode --subbands=100:110 --beamlets=0:10 --direction=0,0,J2000&
+
+sleep 5
 
 echo "The rcumode is "$hbamode 
 sleep 2
-- 
GitLab