diff --git a/tangostationcontrol/tangostationcontrol/devices/sdp/beamlet.py b/tangostationcontrol/tangostationcontrol/devices/sdp/beamlet.py index dbbc644364cab4706f2b46e21b798b671b487455..35d484139e2dcc0462211bbb6a4542062e06ff01 100644 --- a/tangostationcontrol/tangostationcontrol/devices/sdp/beamlet.py +++ b/tangostationcontrol/tangostationcontrol/devices/sdp/beamlet.py @@ -92,14 +92,6 @@ class Beamlet(opcua_device): FPGA_beamlet_output_scale_R = attribute_wrapper(comms_annotation=["FPGA_beamlet_output_scale_R"], datatype=numpy.double, dims=(16,)) FPGA_beamlet_output_scale_RW = attribute_wrapper(comms_annotation=["FPGA_beamlet_output_scale_RW"], datatype=numpy.double, dims=(16,), access=AttrWriteType.READ_WRITE) - # List of OPC-UA CP for BF beamlets - S_pn = SDP.S_pn - N_pn = SDP.N_pn - A_pn = 6 - N_pol = 2 - N_beamlets_ctrl = 488 - N_pol_bf = 2 - FPGA_beamlet_output_nof_packets_R = attribute_wrapper(comms_annotation=["FPGA_beamlet_output_nof_packets_R"], datatype=numpy.int32, dims=(N_beamlets_ctrl, N_pn)) FPGA_beamlet_output_nof_valid_R = attribute_wrapper(comms_annotation=["FPGA_beamlet_output_nof_valid_R"], datatype=numpy.int32, dims=(N_beamlets_ctrl, N_pn)) @@ -152,8 +144,18 @@ class Beamlet(opcua_device): # internal functions # -------- def _calculate_bf_weights(self, phases: numpy.ndarray): - pass - + """ Helper function that converts a difference in phase (in radiants) + to a FPGA weight (in complex number) """ + + # Convert array values in complex numbers + unit = numpy.power(2,14) + real = numpy.array(unit * numpy.sin(phases), dtype=numpy.short) + imag = numpy.array(unit * numpy.cos(phases), dtype=numpy.short) + # join 16 bits of imaginary part (MSB) with 16 bits of real part (LSB) + bf_weights = numpy.array( numpy.frombuffer( b''.join(imag,real), dtype=numpy.uint32 ) ) + + return bf_weights + # -------- # Commands # --------