diff --git a/scripts/ADCreset.py b/scripts/ADCreset.py new file mode 100644 index 0000000000000000000000000000000000000000..b0f208abaf03277f350b210cc2ee279566f3c96a --- /dev/null +++ b/scripts/ADCreset.py @@ -0,0 +1,13 @@ +from test_common import * + +RCUs=[0]; +setRCUmask(RCUs) + +callmethod("RCU_off") +time.sleep(1) +callmethod("RCU_on") +callmethod("RCU_on") +time.sleep(1) +callmethod("ADC_on") + +disconnect(); diff --git a/scripts/Att.py b/scripts/Att.py new file mode 100644 index 0000000000000000000000000000000000000000..91fcf28ab3a8269a88ac5a6f0b60de8f3a0282f5 --- /dev/null +++ b/scripts/Att.py @@ -0,0 +1,20 @@ +from test_common import * + +name="RCU_attenuator" +RCU=0; +Att=[5,5,5] + + +setAntmask([RCU]) + +att=get_value(name+"_R") +print("Att old:",att[3*RCU:3*RCU+3]) + +att[3*RCU:3*RCU+3]=Att +set_value(name+"_RW",att) + +time.sleep(0.5) +att=get_value(name+"_R") +print("Att new:",att[3*RCU:3*RCU+3]) + +disconnect() \ No newline at end of file diff --git a/scripts/LED.py b/scripts/LED.py new file mode 100644 index 0000000000000000000000000000000000000000..acb861c3261c8feb0defd1dfbc1d3c399fc589b0 --- /dev/null +++ b/scripts/LED.py @@ -0,0 +1,18 @@ +from test_common import * + +name="RCU_LED0" +RCU=0; +LEDvalue=0; + +setRCUmask([RCU]) + +led=get_value(name+"_R") +print("LED old:",led) +led[RCU]=LEDvalue + +set_value(name+"_RW",led) +time.sleep(0.1) + +print("LED new:",get_value(name+"_R")) + +disconnect() diff --git a/scripts/RCUupdate.py b/scripts/RCUupdate.py new file mode 100644 index 0000000000000000000000000000000000000000..42dde847e5ad4c65793086b57396c55856d6d292 --- /dev/null +++ b/scripts/RCUupdate.py @@ -0,0 +1,8 @@ +from test_common import * + +RCUs=[0]; +setRCUmask(RCUs) + +callmethod("RCU_update") + +disconnect(); \ No newline at end of file diff --git a/scripts/SetHBA_BF.py b/scripts/SetHBA_BF.py new file mode 100644 index 0000000000000000000000000000000000000000..263e91cbff7577a7f02aa5ba3f692dd7a40c6cd5 --- /dev/null +++ b/scripts/SetHBA_BF.py @@ -0,0 +1,27 @@ +RCU=0 +HBAT=1 #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" + +from test_common import * +import numpy as np + +AntMask=[(x==HBAT) for x in range(3)] +setAntmask([RCU],AntMask) + +i=(RCU*3+HBAT)*32+HBA*2 + +val=get_value(name+"_R") +print("old:",val[i:i+2]) + +val[i]=BFX +val[i+1]=BFY + +set_value(name+"_RW",val) +time.sleep(1) +val=get_value(name+"_R") +print("new:",val[i:i+2]) + +disconnect() diff --git a/scripts/SetHBA_LED.py b/scripts/SetHBA_LED.py new file mode 100644 index 0000000000000000000000000000000000000000..5cfc1b10063f2499e7834415eb82f047f39100bf --- /dev/null +++ b/scripts/SetHBA_LED.py @@ -0,0 +1,26 @@ +RCU=0 +HBAT=1 #HBAT on RCU 0..2 +HBA=5; #HBA Element in HBAT +LED=1 #on +name="HBA_element_led" + +from test_common import * +import numpy as np + +AntMask=[(x==HBAT) for x in range(3)] +setAntmask([RCU],AntMask) + +i=(RCU*3+HBAT)*32+HBA*2 + +val=get_value(name+"_R") +print("old:",val[i:i+2]) + +val[i]=LED #Not needed for LED +val[i+1]=LED + +set_value(name+"_RW",val) +time.sleep(1) +val=get_value(name+"_R") +print("new:",val[i:i+2]) + +disconnect() diff --git a/scripts/SetMonitor.py b/scripts/SetMonitor.py new file mode 100644 index 0000000000000000000000000000000000000000..fa97710d7db14ece16520288bb451e8a60d83b89 --- /dev/null +++ b/scripts/SetMonitor.py @@ -0,0 +1,10 @@ +from test_common import * + +rate= 60 #seconds +name="RCU_monitor_rate_RW" + +print("old:",get_value(name)) +set_value(name,rate) +print("new:",get_value(name)) + +disconnect() diff --git a/scripts/test_common.py b/scripts/test_common.py new file mode 100644 index 0000000000000000000000000000000000000000..40d6ba107fd920f89112bc833860c17634eec1c9 --- /dev/null +++ b/scripts/test_common.py @@ -0,0 +1,63 @@ +Address="opc.tcp://odroidRCU2:4842/" +import sys +sys.path.insert(0, "..") +import logging +import time + +from opcua import Client +from opcua import ua +#import numpy as np + +def connect(): + global client,root +# logging.basicConfig(level=logging.INFO) + logging.basicConfig(level=logging.WARN) +# client = Client("opc.tcp://localhost:4840/freeopcua/server/") + client = Client(Address) + client.connect() + client.load_type_definitions() # load definition of server specific structures/extension objects + root = client.get_root_node() + return root + +root=connect() + +def disconnect(): + client.disconnect() + +def get_value(name): + var1 = root.get_child(["0:Objects", "2:PCC", "2:"+name]) + return var1.get_value() + +def set_value(name,value): + var1 = root.get_child(["0:Objects", "2:PCC", "2:"+name]) + var1.set_value(value) + +def setRCUmask(rcu=[]): + name="RCU_mask_RW" + M=get_value(name) + print(name," old:",M) + M=[0 for m in M] + for r in rcu: + M[r]=1 + set_value(name,M) + print(name," new:",get_value(name)) + +def setAntmask(rcu=[],ant=[True,True,True]): + name="Ant_mask_RW" + M=get_value(name) + print(name," old:",M) + for i,j in enumerate(M): + M[i]=False + for r in rcu: + for i in range(3): + M[r*3+i]=ant[i] + set_value(name,M) + print(name," new:",get_value(name)) + +def callmethod(name): + try: + obj = root.get_child(["0:Objects", "2:PCC"])# + return obj.call_method("2:"+name) + except: +# print("error") + return None