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

Finish (again) the crossecho client for Tango API

parent 630821cb
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ from PyTango import AttrQuality, DispLevel, DevState
from PyTango import AttrWriteType, PipeWriteType
# Additional import
# PROTECTED REGION ID(Crossecho.additionnal_import) ENABLED START #
from lib.opc_interface import connect_to_server, DEFAULT_URI
from opcua import Client
import numpy
# PROTECTED REGION END # // Crossecho.additionnal_import
......@@ -50,6 +50,10 @@ class Crossecho(Device):
dtype='str', default_value="55555"
)
OPC_time_out = device_property(
dtype=, default_value=1000
)
# ----------
# Attributes
# ----------
......@@ -79,20 +83,26 @@ class Crossecho(Device):
def init_device(self):
Device.init_device(self)
# PROTECTED REGION ID(Crossecho.init_device) ENABLED START #
self.client = connect_to_server(self.OPC_Server_Name, self.OPC_Server_Port)
self.objects = self.client.get_objects_node()
self.idx = self.client.get_namespace_index(DEFAULT_URI)
# Now getting a variable node using its browse path
self.opc_obj = self.client.get_root_node().get_child(["0:Objects",
"{}:StationMetrics".format(idx),
"{}:RCU".format(idx)])
try:
self.client = Client("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), self.OPC_time_out)
self.client.connect()
self.client.load_type_definitions()
objects = self.client.get_objects_node()
idx = self.client.get_namespace_index(DEFAULT_URI)
# Now getting a variable node using its browse path
self.opc_obj = self.client.get_root_node().get_child(["0:Objects",
"{}:StationMetrics".format(idx),
"{}:RCU".format(idx)])
self.logger.info("Connected to the OPC-UA server %s", self.OPC_Server_Name)
except:
self.logger.error("Failed to connect to the OPC-UA server %s. Traceback: %s", self.OPC_Server_Name, traceback.format_exc())
# PROTECTED REGION END # // Crossecho.init_device
def always_executed_hook(self):
# PROTECTED REGION ID(Crossecho.always_executed_hook) ENABLED START #
pass
# PROTECTED REGION END # // Crossecho.always_executed_hook
# PROTECTED REGION EloggND # // Crossecho.always_executed_hook
def delete_device(self):
# PROTECTED REGION ID(Crossecho.delete_device) ENABLED START #
......@@ -106,12 +116,12 @@ class Crossecho(Device):
def read_RCU_modes(self):
# PROTECTED REGION ID(Crossecho.RCU_modes_read) ENABLED START #
return ['']
return self.RCU_modes
# PROTECTED REGION END # // Crossecho.RCU_modes_read
def read_crosslet_stat(self):
# PROTECTED REGION ID(Crossecho.crosslet_stat_read) ENABLED START #
return [0.0]
return crosslet_stat
# PROTECTED REGION END # // Crossecho.crosslet_stat_read
......@@ -121,7 +131,7 @@ class Crossecho(Device):
def read_xlt_stat(self):
# PROTECTED REGION ID(Crossecho.xlt_stat_read) ENABLED START #
return dict(x=0,y=0)
return dict(x=self.crosslet_stat, y=self.RCU_modes)
# PROTECTED REGION END # // Crossecho.xlt_stat_read
# --------
......@@ -134,10 +144,10 @@ class Crossecho(Device):
def record_cross(self):
# PROTECTED REGION ID(Crossecho.record_cross) ENABLED START #
if self.is_record_cross_allowed() is True:
timeStamp, crossletStats, rcuModes = self.opc_obj.call_method("{}:record_cross".format(idx), self.subBand, self.integrationTime)
print("Timestamp is ", result[0])
print("Crosscorrelations are ", numpy.array(result[1]))
print("RCU modes are", numpy.array(result[2]))
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 # // Crossecho.record_cross
......
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