From 7ede764dead519713428d32526dc679033f7c0ed Mon Sep 17 00:00:00 2001
From: kruger <kruger@astron.nl>
Date: Thu, 10 Feb 2022 15:59:09 +0100
Subject: [PATCH] test HBAT BF update

---
 scripts/SetHBAT_BF.py  | 16 +++++++++-------
 scripts/SetHBAT_BFs.py | 19 ++++++++++---------
 scripts/test_common.py | 13 +++++++++++--
 3 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/scripts/SetHBAT_BF.py b/scripts/SetHBAT_BF.py
index 9147882..341dc09 100644
--- a/scripts/SetHBAT_BF.py
+++ b/scripts/SetHBAT_BF.py
@@ -1,24 +1,26 @@
-RCU=3
-HBAT=1 #HBAT on RCU 0..2
+RCU=0
+HBAT=0 #HBAT on RCU 0..2
 #HBA=5; #HBA Element in HBAT
 #BFX=11 #delay in 0.5ns
 #BFY=BFX+1
-name="HBA_element_beamformer_delays"
-
+name="HBAT_BF_delay_steps"
 from test_common import *
 import numpy as np
 
+connect()
 AntMask=[(x==HBAT) for x in range(3)]
+#AntMask=[True,True,True]
 setAntmask([RCU],AntMask)
 
 i=(RCU*3+HBAT)*32
 
-val=get_value(name+"_R")
+val,tp=get_value_type(name+"_R")
 print("old:",val[i:i+32])
 
-val[i:i+32]=np.array(range(32))[::]*0+1
+val[i:i+32]=np.array(range(32))[::]
+print("set:",val[i:i+32])
 
-set_value(name+"_RW",val)
+set_value(name+"_RW",val,tp)
 time.sleep(1)
 val=get_value(name+"_R")
 print("new:",val[i:i+32])
diff --git a/scripts/SetHBAT_BFs.py b/scripts/SetHBAT_BFs.py
index 1d1a9e1..83eec5b 100644
--- a/scripts/SetHBAT_BFs.py
+++ b/scripts/SetHBAT_BFs.py
@@ -1,20 +1,21 @@
 RCU=0
-name="HBA_element_beamformer_delays"
+name="HBAT_BF_delay_steps"
+busy="RECVTR_translator_busy_R"
 AntMask=[True,True,True]
 NewVal1=range(32)
 NewVal2=[1]*32
-NewValues=[NewVal1,NewVal2,NewVal1,NewVal2,NewVal1,NewVal2,NewVal1,NewVal2,NewVal1,NewVal2]
-#NewValues=[NewVal1,NewVal2]
-DEBUG=False
+#NewValues=[NewVal1,NewVal2,NewVal1,NewVal2,NewVal1,NewVal2,NewVal1,NewVal2,NewVal1,NewVal2]
+NewValues=[NewVal1,NewVal2]
+DEBUG=True
 
 from test_common import *
 import numpy as np
-
+connect()
 setAntmask([RCU],AntMask)
 
 i=(RCU*3)*32
 
-val=get_value(name+"_R")
+val,tp=get_value_type(name+"_R")
 if DEBUG:
   print("Current values:");
   for x in range(3): print(val[i+x*32:i+(x+1)*32])
@@ -23,12 +24,12 @@ for cnt,NewVal in enumerate(NewValues):
 
  for x in range(3): val[i+x*32:i+(x+1)*32]=NewVal
 
- set_value(name+"_RW",val)
+ set_value(name+"_RW",val,tp)
  if DEBUG:
    print("set:")
    for x in range(3): print(val[i+x*32:i+(x+1)*32])
- time.sleep(0.5)
- wait_not_busy("RCU_translator_busy_R",timeout_sec=2)
+ time.sleep(1)
+ wait_not_busy(busy,timeout_sec=4)
 # time.sleep(0.1)
  val=get_value(name+"_R")
  if DEBUG:
diff --git a/scripts/test_common.py b/scripts/test_common.py
index 5828380..634fc80 100644
--- a/scripts/test_common.py
+++ b/scripts/test_common.py
@@ -29,9 +29,18 @@ def get_value(name):
   var1 = root.get_child(["0:Objects", "2:"+name])
   return var1.get_value()
 
-def set_value(name,value):
+def get_value_type(name):
   var1 = root.get_child(["0:Objects", "2:"+name])
-  var1.set_value(value)
+  print(var1)
+  return var1.get_value(),var1.get_data_value().Value.VariantType
+
+def set_value(name,value,tp=None):
+  var1 = root.get_child(["0:Objects", "2:"+name])
+  if tp is None:
+    var1.set_value(value)
+  else:
+    var1.set_value(value,tp)
+
 
 def get_debug_value(name):
   var1 = root.get_child(["0:Objects", "2:DEBUG", "2:"+name])
-- 
GitLab