Skip to content
Snippets Groups Projects
Commit 6947f1c7 authored by Pieter Donker's avatar Pieter Donker
Browse files

Merge branch 'L2SDP-349' into 'master'

L2 sdp 349

See merge request lofar2.0/sdptr!18
parents 5bb2e1bb dcd87661
No related branches found
No related tags found
1 merge request!18L2 sdp 349
*log
__pycache__
*pyc
*.bak
.*.s??
*.o
*.a
*.in
.deps*
Makefile
configure
config.*
config/
aclocal.m4
autom4te.cache/
sdptr
\ No newline at end of file
...@@ -19,11 +19,23 @@ ...@@ -19,11 +19,23 @@
# ########################################################################## # ##########################################################################
# Author: # Author:
# . [name] # . Leon Hiemstra, Pieter Donker
# Purpose: # Purpose:
# . " " # . script to test (control/monitor) opc-ua server
# Description: # Description:
# . " " # Client.py is used to connect (TCP/IP) to an opc-ua server and test (read/write)
# opc-ua points (registers on a fpga).
# For LTS the server is running on DOP36 port 4840, this client can not run
# on DOP36 itself (too old system).
#
# In this version the following is working:
# . --info, read info from server, list all available points on the server.
# . --all, read all *_R point and print needed time.
# . --wg, turn off WG or setup for XST (to generate crosslets plot).
# . --setup, setup SST, BST and XST stream.
# . --stream, turn off or on SST, BST or XST stream.
#
# . run ./Client.py -h for help
# ########################################################################## # ##########################################################################
import sys import sys
...@@ -199,34 +211,15 @@ def read_subband_weights(obj): ...@@ -199,34 +211,15 @@ def read_subband_weights(obj):
vals = var.get_value() vals = var.get_value()
@timing def setup_wg_xst_mode(obj):
def write_subband_weights(obj):
weights = [8192, 0, 0, 0] * N_SUB * N_NODES * (S_PN//4)
#weights = [8192] * N_SUB * N_NODES * S_PN
print(len(weights))
var = obj.get_child("2:FPGA_subband_weights_RW")
#dv = ua.DataValue(ua.Variant(value=weights, varianttype=ua.VariantType.UInt32))
#dv.ServerTimestamp = None
#dv.SourceTimestamp = None
var.set_value(ua.Variant(value=list(weights), varianttype=ua.VariantType.UInt32))
def write_xst_subband_select(obj):
subsel = [7, 102, 103, 104, 105, 106, 107, 108] * N_NODES # fill all fields
var = obj.get_child("2:FPGA_xst_subband_select_RW")
var.set_value(ua.Variant(value=list(subsel), varianttype=ua.VariantType.UInt32))
def write_xst_wg_setup(obj, on=False):
''' '''
setup wg for xst stream setup wg for xst stream
''' '''
if on is True:
# Write WG configuration with phases from 0 - 360 and 1 to 1/12 amplitudes # Write WG configuration with phases from 0 - 360 and 1 to 1/12 amplitudes
wg_ampl = [0.01 * (1 - (i / S_PN)) for i in range(S_PN)] * N_NODES wg_ampl = [0.01 * (1 - (i / S_PN)) for i in range(S_PN)] * N_NODES
var = obj.get_child("2:FPGA_wg_amplitude_RW") var = obj.get_child("2:FPGA_wg_amplitude_RW")
var.set_value(ua.Variant(value=list(wg_ampl), varianttype=ua.VariantType.Double)) var.set_value(ua.Variant(value=list(wg_ampl), varianttype=ua.VariantType.Double))
print(len(wg_ampl))
wg_phase = [i * (360 / S_PN) for i in range(S_PN)] * N_NODES wg_phase = [i * (360 / S_PN) for i in range(S_PN)] * N_NODES
var = obj.get_child("2:FPGA_wg_phase_RW") var = obj.get_child("2:FPGA_wg_phase_RW")
var.set_value(ua.Variant(value=list(wg_phase), varianttype=ua.VariantType.Double)) var.set_value(ua.Variant(value=list(wg_phase), varianttype=ua.VariantType.Double))
...@@ -235,21 +228,68 @@ def write_xst_wg_setup(obj, on=False): ...@@ -235,21 +228,68 @@ def write_xst_wg_setup(obj, on=False):
var = obj.get_child("2:FPGA_wg_frequency_RW") var = obj.get_child("2:FPGA_wg_frequency_RW")
var.set_value(ua.Variant(value=list(wg_freq), varianttype=ua.VariantType.Double)) var.set_value(ua.Variant(value=list(wg_freq), varianttype=ua.VariantType.Double))
print("wg on")
enable = [True for i in range(S_PN)] * N_NODES # enable wg enable = [True for i in range(S_PN)] * N_NODES # enable wg
var = obj.get_child("2:FPGA_wg_enable_RW") var = obj.get_child("2:FPGA_wg_enable_RW")
var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean)) var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean))
else:
def turn_wg_off(obj):
print("wg off")
enable = [False for i in range(S_PN)] * N_NODES # enable wg enable = [False for i in range(S_PN)] * N_NODES # enable wg
var = obj.get_child("2:FPGA_wg_enable_RW") var = obj.get_child("2:FPGA_wg_enable_RW")
var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean)) var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean))
def write_xst_stream_setup(obj, on=False): def setup_sst_stream(obj):
'''
setup bst stream, use git/upe_gear/peripherals/pi_satistics_stream.py for recording and plotting.
- pi_statistic_stream.py --unb2 2 --pn2 0 --cmd 4 -s=BST
'''
port = [5001] * N_NODES # use port 5002
var = obj.get_child("2:FPGA_sst_offload_hdr_udp_destination_port_RW")
var.set_value(ua.Variant(value=list(port), varianttype=ua.VariantType.UInt16))
dest_mac = ["00:1B:21:71:76:B9"] * N_NODES # use mac of dop36
var = obj.get_child("2:FPGA_sst_offload_hdr_eth_destination_mac_RW")
var.set_value(ua.Variant(value=list(dest_mac), varianttype=ua.VariantType.String))
dest_addr = ["10.99.0.254"] * N_NODES # use addr of dop36
var = obj.get_child("2:FPGA_sst_offload_hdr_ip_destination_address_RW")
var.set_value(ua.Variant(value=list(dest_addr), varianttype=ua.VariantType.String))
weights = [8192] * N_SUB * N_NODES * S_PN # set weights for subbands to default
var = obj.get_child("2:FPGA_subband_weights_RW")
var.set_value(ua.Variant(value=list(weights), varianttype=ua.VariantType.UInt32))
enable = [True] * N_NODES # enable weighted subbands
var = obj.get_child("2:FPGA_sst_offload_weighted_subbands_RW")
var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean))
def setup_bst_stream(obj):
'''
setup bst stream, use git/upe_gear/peripherals/pi_satistics_stream.py for recording and plotting.
- pi_statistic_stream.py --unb2 2 --pn2 0 --cmd 4 -s=BST
'''
port = [5002] * N_NODES # use port 5002
var = obj.get_child("2:FPGA_bst_offload_hdr_udp_destination_port_RW")
var.set_value(ua.Variant(value=list(port), varianttype=ua.VariantType.UInt16))
dest_mac = ["00:1B:21:71:76:B9"] * N_NODES # use mac of dop36
var = obj.get_child("2:FPGA_bst_offload_hdr_eth_destination_mac_RW")
var.set_value(ua.Variant(value=list(dest_mac), varianttype=ua.VariantType.String))
dest_addr = ["10.99.0.254"] * N_NODES # use addr of dop36
var = obj.get_child("2:FPGA_bst_offload_hdr_ip_destination_address_RW")
var.set_value(ua.Variant(value=list(dest_addr), varianttype=ua.VariantType.String))
def setup_xst_stream(obj):
''' '''
setup xst stream, use git/upe_gear/peripherals/pi_satistics_stream.py for recording and plotting. setup xst stream, use git/upe_gear/peripherals/pi_satistics_stream.py for recording and plotting.
- pi_statistic_stream.py --unb2 2 --pn2 0 --cmd 4 -s=XST - pi_statistic_stream.py --unb2 2 --pn2 0 --cmd 4 -s=XST
''' '''
if on is True:
port = [5003] * N_NODES # use port 5001 port = [5003] * N_NODES # use port 5001
var = obj.get_child("2:FPGA_xst_offload_hdr_udp_destination_port_RW") var = obj.get_child("2:FPGA_xst_offload_hdr_udp_destination_port_RW")
var.set_value(ua.Variant(value=list(port), varianttype=ua.VariantType.UInt16)) var.set_value(ua.Variant(value=list(port), varianttype=ua.VariantType.UInt16))
...@@ -274,13 +314,31 @@ def write_xst_stream_setup(obj, on=False): ...@@ -274,13 +314,31 @@ def write_xst_stream_setup(obj, on=False):
var = obj.get_child("2:FPGA_xst_processing_enable_RW") var = obj.get_child("2:FPGA_xst_processing_enable_RW")
var.set_value(ua.Variant(value=list(processing), varianttype=ua.VariantType.Boolean)) var.set_value(ua.Variant(value=list(processing), varianttype=ua.VariantType.Boolean))
enable = [True] * N_NODES # enable offload
def set_enable_stream(obj, mode):
if mode == 'OFF':
enable = [False] * N_NODES # disable offload
var = obj.get_child("2:FPGA_sst_offload_enable_RW")
var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean))
var = obj.get_child("2:FPGA_bst_offload_enable_RW")
var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean))
var = obj.get_child("2:FPGA_xst_offload_enable_RW") var = obj.get_child("2:FPGA_xst_offload_enable_RW")
var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean)) var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean))
else: return
enable = [False] * N_NODES # enable offload
enable = [True] * N_NODES # enable offload
if mode == 'SST':
var = obj.get_child("2:FPGA_sst_offload_enable_RW")
var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean))
elif mode == 'BST':
var = obj.get_child("2:FPGA_bst_offload_enable_RW")
var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean))
elif mode == 'XST':
var = obj.get_child("2:FPGA_xst_offload_enable_RW") var = obj.get_child("2:FPGA_xst_offload_enable_RW")
var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean)) var.set_value(ua.Variant(value=list(enable), varianttype=ua.VariantType.Boolean))
else:
print('Wrong mode "{}"'.format(mode))
return
if __name__ == "__main__": if __name__ == "__main__":
# Parse command line arguments # Parse command line arguments
...@@ -288,8 +346,9 @@ if __name__ == "__main__": ...@@ -288,8 +346,9 @@ if __name__ == "__main__":
parser.add_argument('-n', '--nodes', dest='nodes', type=int, nargs='+', help="nodes to use") parser.add_argument('-n', '--nodes', dest='nodes', type=int, nargs='+', help="nodes to use")
parser.add_argument('-i', '--info', dest='info', action='store_true', help="print point infor from server") parser.add_argument('-i', '--info', dest='info', action='store_true', help="print point infor from server")
parser.add_argument('-a', '--all', dest='all_r', action='store_true', help="recv all*_R points and show time") parser.add_argument('-a', '--all', dest='all_r', action='store_true', help="recv all*_R points and show time")
parser.add_argument('--wgxst', dest='wg_xst_mode', type=bool, help="turn on/off wg for xst") parser.add_argument('--wg', dest='wg_mode', type=str, choices=['OFF', 'XST'], help="turn wg off/on for xst")
parser.add_argument('--offloadxst', dest='offload_xst', type=bool, help="turn on/off xst offload") parser.add_argument('--setup', dest='offload_setup', type=str, choices=['SST', 'BST', 'XST'], help="setup offload for selected mode")
parser.add_argument('--stream', dest='stream', type=str, choices=['OFF', 'SST', 'BST', 'XST'], help="turn off/on selected offload stream")
parser.add_argument('--verbosity', default='INFO', help="stdout log level can be [ERROR | WARNING | INFO | DEBUG]") parser.add_argument('--verbosity', default='INFO', help="stdout log level can be [ERROR | WARNING | INFO | DEBUG]")
args = parser.parse_args() args = parser.parse_args()
...@@ -299,9 +358,13 @@ if __name__ == "__main__": ...@@ -299,9 +358,13 @@ if __name__ == "__main__":
# logger = logging.getLogger("KeepAlive") # logger = logging.getLogger("KeepAlive")
# logger.setLevel(logging.DEBUG) # logger.setLevel(logging.DEBUG)
host = 'dop36'
port = 4840
client = Client("opc.tcp://{}:{}/".format(host, port))
# client = Client("opc.tcp://LAPTOP-N0VQ3UDT:4840/") # client = Client("opc.tcp://LAPTOP-N0VQ3UDT:4840/")
# client = Client("opc.tcp://192.168.137.102:4840/") # client = Client("opc.tcp://192.168.137.102:4840/")
client = Client("opc.tcp://dop36:4840/") # client = Client("opc.tcp://dop36:4840/")
# client = Client("opc.tcp://169.254.91.66:4840/") # client = Client("opc.tcp://169.254.91.66:4840/")
# I hope this is secure, because I have zero clue about security # I hope this is secure, because I have zero clue about security
# client.set_security_string("Basic256Sha256,SignAndEncrypt,certificate-example.der,private-key-example.pem") # client.set_security_string("Basic256Sha256,SignAndEncrypt,certificate-example.der,private-key-example.pem")
...@@ -317,7 +380,7 @@ if __name__ == "__main__": ...@@ -317,7 +380,7 @@ if __name__ == "__main__":
while clientRunning: while clientRunning:
try: try:
client.connect() client.connect()
print("I'm in") print("Connected to {}:{}".format(host, port))
################ ################
# this section contains some code about navigating around the address space # this section contains some code about navigating around the address space
...@@ -346,11 +409,22 @@ if __name__ == "__main__": ...@@ -346,11 +409,22 @@ if __name__ == "__main__":
for i in range(len(children)): for i in range(len(children)):
print("\t\tchild", i, ": ", children[i].get_browse_name()) print("\t\tchild", i, ": ", children[i].get_browse_name())
if args.wg_xst_mode: if args.wg_mode is not None:
write_xst_wg_setup(Object, on=args.wg_xst_mode) if args.wg_mode == 'OFF':
turn_wg_off(obj)
if args.offload_xst: elif args.wg_mode == 'XST':
write_xst_stream_setup(Object, on=args.offload_xst) setup_wg_xst_mode(Object)
if args.offload_setup is not None:
if args.offload_setup == 'SST':
setup_sst_stream(Object)
elif args.offload_setup == 'BST':
setup_bst_stream(Object)
elif args.offload_setup == 'XST':
setup_xst_stream(Object)
if args.stream is not None:
set_enable_stream(Object, mode=args.stream)
if args.all_r is True: if args.all_r is True:
check_get_all_R_time(Object) check_get_all_R_time(Object)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment