Skip to content
Snippets Groups Projects
Commit 652e9ce0 authored by Thomas Juerges's avatar Thomas Juerges
Browse files

Update Femto-DS to match the Femto OPC-UA device

parent 8589f452
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,7 @@ class Femto(Device): ...@@ -54,7 +54,7 @@ class Femto(Device):
OPC_Server_Name = device_property( OPC_Server_Name = device_property(
dtype='DevString', dtype='DevString',
default_value="localhost" default_value="okeanos"
) )
OPC_Server_Port = device_property( OPC_Server_Port = device_property(
...@@ -71,12 +71,40 @@ class Femto(Device): ...@@ -71,12 +71,40 @@ class Femto(Device):
# Attributes # Attributes
# ---------- # ----------
RCU_modes = attribute( end_freq = attribute(
dtype=('DevString',), dtype='DevDouble',
max_dim_x=1024,
) )
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',), dtype=('DevDouble',),
max_dim_x=10240, max_dim_x=10240,
) )
...@@ -85,8 +113,9 @@ class Femto(Device): ...@@ -85,8 +113,9 @@ class Femto(Device):
# Pipes # Pipes
# ----- # -----
xlt_stat = pipe( spectrum_pipe = pipe(
label="xlt", )
average_spectrum_pipe = pipe(
) )
# --------------- # ---------------
...@@ -97,8 +126,6 @@ class Femto(Device): ...@@ -97,8 +126,6 @@ class Femto(Device):
"""Initialises the attributes and properties of the Femto.""" """Initialises the attributes and properties of the Femto."""
Device.init_device(self) Device.init_device(self)
# PROTECTED REGION ID(Femto.init_device) ENABLED START # # PROTECTED REGION ID(Femto.init_device) ENABLED START #
self._rcu_modes = ('',)
self._crosslet_stat = (0.0,)
try: try:
self.client = Client("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), self.OPC_time_out) self.client = Client("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), self.OPC_time_out)
self.client.connect() self.client.connect()
...@@ -106,13 +133,56 @@ class Femto(Device): ...@@ -106,13 +133,56 @@ class Femto(Device):
objects = self.client.get_objects_node() objects = self.client.get_objects_node()
idx = self.client.get_namespace_index("http://lofar.eu") idx = self.client.get_namespace_index("http://lofar.eu")
# Now getting a variable node using its browse path # Now getting a variable nodes using their browse path
self.opc_obj = self.client.get_root_node().get_child(["0:Objects", 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), "{}: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)) print("Connected to the OPC-UA server %s" % (self.OPC_Server_Name))
except Exception as e: 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() self.delete_device()
raise e raise e
# PROTECTED REGION END # // Femto.init_device # PROTECTED REGION END # // Femto.init_device
...@@ -138,52 +208,87 @@ class Femto(Device): ...@@ -138,52 +208,87 @@ class Femto(Device):
# Attributes methods # Attributes methods
# ------------------ # ------------------
def read_RCU_modes(self): def read_end_freq(self):
# PROTECTED REGION ID(Femto.RCU_modes_read) ENABLED START # # PROTECTED REGION ID(Femto.end_freq_read) ENABLED START #
"""Return the RCU_modes attribute.""" """Return the end_freq attribute."""
return self._rcu_modes self._end_freq = self.MP["end_freq"].get_value()
# PROTECTED REGION END # // Femto.RCU_modes_read return self._end_freq
# PROTECTED REGION END # // Femto.end_freq_read
def read_crosslet_stat(self):
# PROTECTED REGION ID(Femto.crosslet_stat_read) ENABLED START # def read_error(self):
"""Return the crosslet_stat attribute.""" # PROTECTED REGION ID(Femto.error_read) ENABLED START #
return self._crosslet_stat """Return the error attribute."""
# PROTECTED REGION END # // Femto.crosslet_stat_read 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 # Pipes methods
# ------------- # -------------
def read_xlt_stat(self): def read_spectrum_pipe(self):
# PROTECTED REGION ID(Femto.xlt_stat_read) ENABLED START # # PROTECTED REGION ID(Femto.spectrum_pipe_read) ENABLED START #
return dict(x=self._crosslet_stat, y=self._rcu_modes) return dict(x=0, y=0)
# PROTECTED REGION END # // Femto.xlt_stat_read # 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 # 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 # Run server
# ---------- # ----------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment