From 652e9ce0dab42c70a99a524faf0c48efc84c885d Mon Sep 17 00:00:00 2001 From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl> Date: Thu, 7 May 2020 16:46:19 +0200 Subject: [PATCH] Update Femto-DS to match the Femto OPC-UA device --- Femto-DS/Femto.py | 203 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 154 insertions(+), 49 deletions(-) diff --git a/Femto-DS/Femto.py b/Femto-DS/Femto.py index 9885b70cc..ea236a91a 100644 --- a/Femto-DS/Femto.py +++ b/Femto-DS/Femto.py @@ -54,7 +54,7 @@ class Femto(Device): OPC_Server_Name = device_property( dtype='DevString', - default_value="localhost" + default_value="okeanos" ) OPC_Server_Port = device_property( @@ -71,12 +71,40 @@ class Femto(Device): # Attributes # ---------- - RCU_modes = attribute( - dtype=('DevString',), - max_dim_x=1024, + end_freq = attribute( + dtype='DevDouble', ) - crosslet_stat = attribute( + error = attribute( + dtype='DevString', + ) + + obs_id = attribute( + dtype='DevLong64', + ) + + rcu = attribute( + dtype='DevLong64', + ) + + rcumode = attribute( + dtype='DevLong64', + ) + + start_freq = attribute( + dtype='DevDouble', + ) + + timestamp = attribute( + dtype='DevDouble', + ) + + average_spectrum = attribute( + dtype=('DevDouble',), + max_dim_x=10240, + ) + + spectrum = attribute( dtype=('DevDouble',), max_dim_x=10240, ) @@ -85,8 +113,9 @@ class Femto(Device): # Pipes # ----- - xlt_stat = pipe( - label="xlt", + spectrum_pipe = pipe( + ) + average_spectrum_pipe = pipe( ) # --------------- @@ -97,8 +126,6 @@ class Femto(Device): """Initialises the attributes and properties of the Femto.""" Device.init_device(self) # PROTECTED REGION ID(Femto.init_device) ENABLED START # - self._rcu_modes = ('',) - self._crosslet_stat = (0.0,) try: self.client = Client("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), self.OPC_time_out) self.client.connect() @@ -106,13 +133,56 @@ class Femto(Device): objects = self.client.get_objects_node() idx = self.client.get_namespace_index("http://lofar.eu") - # Now getting a variable node using its browse path - self.opc_obj = self.client.get_root_node().get_child(["0:Objects", + # Now getting a variable nodes using their browse path + self.MP = {} + + self.MP["RCU_error_spectra"] = self.client.get_root_node().get_child(["0:Objects", + "2:FEMTO".format(idx), + "2:RCU_error_spectra".format(idx)]) + + self.MP["end_freq"] = self.client.get_root_node().get_child(["0:Objects", + "2:FEMTO".format(idx), + "2:RCU_error_spectra".format(idx), + "2:end_freq".format(idx)]) + + self.MP["start_freq"] = self.client.get_root_node().get_child(["0:Objects", + "2:FEMTO".format(idx), + "2:RCU_error_spectra".format(idx), + "2:start_freq".format(idx)]) + + self.MP["timestamp"] = self.client.get_root_node().get_child(["0:Objects", + "{}:FEMTO".format(idx), + "{}:RCU_error_spectra".format(idx), + "{}:timestamp".format(idx)]) + + self.MP["rcu"] = self.client.get_root_node().get_child(["0:Objects", + "{}:FEMTO".format(idx), + "{}:RCU_error_spectra".format(idx), + "{}:rcu".format(idx)]) + + self.MP["rcumode"] = self.client.get_root_node().get_child(["0:Objects", + "{}:FEMTO".format(idx), + "{}:RCU_error_spectra".format(idx), + "{}:rcumode".format(idx)]) + + self.MP["error"] = self.client.get_root_node().get_child(["0:Objects", + "{}:FEMTO".format(idx), + "{}:RCU_error_spectra".format(idx), + "{}:error".format(idx)]) + + self.MP["spectrum"] = self.client.get_root_node().get_child(["0:Objects", "{}:FEMTO".format(idx), - "{}:RCU_error_spectra".format(idx)]) + "{}:RCU_error_spectra".format(idx), + "{}:spectrum".format(idx)]) + + self.MP["average_spectrum"] = self.client.get_root_node().get_child(["0:Objects", + "{}:FEMTO".format(idx), + "{}:RCU_error_spectra".format(idx), + "{}:average_spectrum".format(idx)]) + print("Connected to the OPC-UA server %s" % (self.OPC_Server_Name)) except Exception as e: - print("Failed to connect to the OPC-UA server %s. Traceback: %s" % (self.OPC_Server_Name, traceback.format_exc())) + print("Failed to connect to the OPC-UA server %s. Trace: %s" % (self.OPC_Server_Name, traceback.format_exc())) self.delete_device() raise e # PROTECTED REGION END # // Femto.init_device @@ -138,52 +208,87 @@ class Femto(Device): # Attributes methods # ------------------ - def read_RCU_modes(self): - # PROTECTED REGION ID(Femto.RCU_modes_read) ENABLED START # - """Return the RCU_modes attribute.""" - return self._rcu_modes - # PROTECTED REGION END # // Femto.RCU_modes_read - - def read_crosslet_stat(self): - # PROTECTED REGION ID(Femto.crosslet_stat_read) ENABLED START # - """Return the crosslet_stat attribute.""" - return self._crosslet_stat - # PROTECTED REGION END # // Femto.crosslet_stat_read + def read_end_freq(self): + # PROTECTED REGION ID(Femto.end_freq_read) ENABLED START # + """Return the end_freq attribute.""" + self._end_freq = self.MP["end_freq"].get_value() + return self._end_freq + # PROTECTED REGION END # // Femto.end_freq_read + + def read_error(self): + # PROTECTED REGION ID(Femto.error_read) ENABLED START # + """Return the error attribute.""" + self._error = self.MP["error"].get_value() + return self._error + # PROTECTED REGION END # // Femto.error_read + + def read_obs_id(self): + # PROTECTED REGION ID(Femto.obs_id_read) ENABLED START # + """Return the obs_id attribute.""" + self._obs_id = self.MP["obs_id"].get_value() + return self._obs_id + # PROTECTED REGION END # // Femto.obs_id_read + + def read_rcu(self): + # PROTECTED REGION ID(Femto.rcu_read) ENABLED START # + """Return the rcu attribute.""" + self._rcu = self.MP["rcu"].get_value() + return self._rcu + # PROTECTED REGION END # // Femto.rcu_read + + def read_rcumode(self): + # PROTECTED REGION ID(Femto.rcumode_read) ENABLED START # + """Return the rcumode attribute.""" + self._rcumode = self.MP["rcumode"].get_value() + return self._rcumode + # PROTECTED REGION END # // Femto.rcumode_read + + def read_start_freq(self): + # PROTECTED REGION ID(Femto.start_freq_read) ENABLED START # + """Return the start_freq attribute.""" + self._start_freq = self.MP["start_freq"].get_value() + return self._start_freq + # PROTECTED REGION END # // Femto.start_freq_read + + def read_timestamp(self): + # PROTECTED REGION ID(Femto.timestamp_read) ENABLED START # + """Return the timestamp attribute.""" + self._timestamp = self.MP["timestamp"].get_value() + return self._timestamp + # PROTECTED REGION END # // Femto.timestamp_read + + def read_average_spectrum(self): + # PROTECTED REGION ID(Femto.average_spectrum_read) ENABLED START # + """Return the average_spectrum attribute.""" + self._average_spectrum = self.MP["average_spectrum"].get_value() + return self._average_spectrum + # PROTECTED REGION END # // Femto.average_spectrum_read + + def read_spectrum(self): + # PROTECTED REGION ID(Femto.spectrum_read) ENABLED START # + """Return the spectrum attribute.""" + self._spectrum = self.MP["spectrum"].get_value() + return self._spectrum + # PROTECTED REGION END # // Femto.spectrum_read # ------------- # Pipes methods # ------------- - def read_xlt_stat(self): - # PROTECTED REGION ID(Femto.xlt_stat_read) ENABLED START # - return dict(x=self._crosslet_stat, y=self._rcu_modes) - # PROTECTED REGION END # // Femto.xlt_stat_read + def read_spectrum_pipe(self): + # PROTECTED REGION ID(Femto.spectrum_pipe_read) ENABLED START # + return dict(x=0, y=0) + # PROTECTED REGION END # // Femto.spectrum_pipe_read + + def read_average_spectrum_pipe(self): + # PROTECTED REGION ID(Femto.average_spectrum_pipe_read) ENABLED START # + return dict(x=0, y=0) + # PROTECTED REGION END # // Femto.average_spectrum_pipe_read # -------- # Commands # -------- - @command( - ) - @DebugIt() - def record_cross(self): - # PROTECTED REGION ID(Femto.record_cross) ENABLED START # - """ - - :return:None - """ - if self.is_record_cross_allowed() is True: - timeStamp, self._crosslet_stat, self._rcu_modes = self.opc_obj.call_method("{}:record_cross".format(idx), self.subBand, self.integrationTime) - print("Timestamp is ", timeStamp) - print("Crosscorrelations are ", self._crosslet_stat) - print("RCU modes are", self._rcu_modes) - # PROTECTED REGION END # // Femto.record_cross - - def is_record_cross_allowed(self): - # PROTECTED REGION ID(Femto.is_record_cross_allowed) ENABLED START # - return self.get_state() not in [DevState.OFF,DevState.INIT,DevState.FAULT] - # PROTECTED REGION END # // Femto.is_record_cross_allowed - # ---------- # Run server # ---------- -- GitLab