Skip to content
Snippets Groups Projects
Commit 1e24f45d authored by Taya Snijder's avatar Taya Snijder
Browse files

merged master

parents 18fda380 d38353a7
No related branches found
No related tags found
1 merge request!27Resolve #2021 "04 16 branched from master apsctl device"
Showing
with 168 additions and 116 deletions
File moved
File moved
File moved
File moved
File moved
File moved
...@@ -14,11 +14,20 @@ ...@@ -14,11 +14,20 @@
# PyTango imports # PyTango imports
from tango.server import run from tango.server import run
from tango.server import device_property from tango.server import device_property
<<<<<<< HEAD
#attribute extention and hardware device imports #attribute extention and hardware device imports
from src.attribute_wrapper import * from src.attribute_wrapper import *
from src.hardware_device import * from src.hardware_device import *
=======
from tango import AttrWriteType
#attribute extention and hardware device imports
from src.attribute_wrapper import attribute_wrapper
from src.hardware_device import hardware_device
import numpy
>>>>>>> master
# Additional import # Additional import
from clients.opcua_connection import OPCUAConnection from clients.opcua_connection import OPCUAConnection
...@@ -99,7 +108,11 @@ class APSCTL(hardware_device): ...@@ -99,7 +108,11 @@ class APSCTL(hardware_device):
# monitor points per FPGA # monitor points per FPGA
UNB2_FPGA_DDR4_SLOT_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_DDR4_SLOT_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) UNB2_FPGA_DDR4_SLOT_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_DDR4_SLOT_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
<<<<<<< HEAD
UNB2_FPGA_DDR4_SLOT_PART_NUMBER_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_DDR4_SLOT_PART_NUMBER_R"], datatype=numpy.str, dims=(N_unb,N_fpga)) UNB2_FPGA_DDR4_SLOT_PART_NUMBER_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_DDR4_SLOT_PART_NUMBER_R"], datatype=numpy.str, dims=(N_unb,N_fpga))
=======
UNB2_FPGA_DDR4_SLOT_PART_NUMBER_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_DDR4_SLOT_PART_NUMBER_R"], datatype=numpy.str, dims=(N_unb * N_qsfp,N_fpga))
>>>>>>> master
UNB2_FPGA_QSFP_CAGE_0_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_QSFP_CAGE_0_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) UNB2_FPGA_QSFP_CAGE_0_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_QSFP_CAGE_0_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
UNB2_FPGA_QSFP_CAGE_1_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_QSFP_CAGE_1_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) UNB2_FPGA_QSFP_CAGE_1_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_QSFP_CAGE_1_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
UNB2_FPGA_QSFP_CAGE_2_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_QSFP_CAGE_2_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) UNB2_FPGA_QSFP_CAGE_2_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_QSFP_CAGE_2_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
...@@ -123,10 +136,14 @@ class APSCTL(hardware_device): ...@@ -123,10 +136,14 @@ class APSCTL(hardware_device):
UNB2_FPGA_POL_RXGXB_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_POL_RXGXB_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) UNB2_FPGA_POL_RXGXB_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_POL_RXGXB_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
UNB2_FPGA_POL_TXGXB_VOUT_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_POL_TXGXB_VOUT_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) UNB2_FPGA_POL_TXGXB_VOUT_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_POL_TXGXB_VOUT_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
UNB2_FPGA_POL_TXGXB_IOUT_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_POL_TXGXB_IOUT_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) UNB2_FPGA_POL_TXGXB_IOUT_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_POL_TXGXB_IOUT_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
<<<<<<< HEAD
# listed as 'POL_FPGA_TXGXB_TEMP_R' on https://support.astron.nl/confluence/pages/viewpage.action?spaceKey=L2M&title=L4+SDPHW+Decision%3A+UniBoard2+Monitor+and+Control+points # listed as 'POL_FPGA_TXGXB_TEMP_R' on https://support.astron.nl/confluence/pages/viewpage.action?spaceKey=L2M&title=L4+SDPHW+Decision%3A+UniBoard2+Monitor+and+Control+points
# probably a typo # probably a typo
POL_FPGA_TXGXB_TEMP_R = attribute_wrapper(comms_annotation=["2:POL_FPGA_TXGXB_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) POL_FPGA_TXGXB_TEMP_R = attribute_wrapper(comms_annotation=["2:POL_FPGA_TXGXB_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
=======
UNB2_FPGA_POL_TXGXB_TEMP_R = attribute_wrapper(comms_annotation=["2:PCC", "2:UNB2_FPGA_POL_TXGXB_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
>>>>>>> master
UNB2_FPGA_POL_HGXB_VOUT_R = attribute_wrapper(comms_annotation=["2:UNB2_FPGA_POL_HGXB_VOUT_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) UNB2_FPGA_POL_HGXB_VOUT_R = attribute_wrapper(comms_annotation=["2:UNB2_FPGA_POL_HGXB_VOUT_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
UNB2_FPGA_POL_HGXB_IOUT_R = attribute_wrapper(comms_annotation=["2:UNB2_FPGA_POL_HGXB_IOUT_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) UNB2_FPGA_POL_HGXB_IOUT_R = attribute_wrapper(comms_annotation=["2:UNB2_FPGA_POL_HGXB_IOUT_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
UNB2_FPGA_POL_HGXB_TEMP_R = attribute_wrapper(comms_annotation=["2:UNB2_FPGA_POL_HGXB_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga)) UNB2_FPGA_POL_HGXB_TEMP_R = attribute_wrapper(comms_annotation=["2:UNB2_FPGA_POL_HGXB_TEMP_R"], datatype=numpy.double, dims=(N_unb,N_fpga))
......
...@@ -15,15 +15,20 @@ ...@@ -15,15 +15,20 @@
from tango import DebugIt from tango import DebugIt
from tango.server import run, command from tango.server import run, command
from tango.server import device_property from tango.server import device_property
from tango import AttrWriteType
import numpy
# Additional import # Additional import
from util.wrappers import *
from clients.opcua_connection import OPCUAConnection from clients.opcua_connection import OPCUAConnection
from src.attribute_wrapper import * from util.attribute_wrapper import attribute_wrapper
from src.hardware_device import * from util.hardware_device import hardware_device
from util.lofar_logging import device_logging_to_python, log_exceptions
__all__ = ["PCC", "main"] __all__ = ["PCC", "main"]
@device_logging_to_python({"device": "PCC"})
class PCC(hardware_device): class PCC(hardware_device):
""" """
...@@ -95,6 +100,7 @@ class PCC(hardware_device): ...@@ -95,6 +100,7 @@ class PCC(hardware_device):
RCU_monitor_rate_RW = attribute_wrapper(comms_annotation=["2:PCC", "2:RCU_monitor_rate_RW"], datatype=numpy.float64, RCU_monitor_rate_RW = attribute_wrapper(comms_annotation=["2:PCC", "2:RCU_monitor_rate_RW"], datatype=numpy.float64,
access=AttrWriteType.READ_WRITE) access=AttrWriteType.READ_WRITE)
@log_exceptions()
def delete_device(self): def delete_device(self):
"""Hook to delete resources allocated in init_device. """Hook to delete resources allocated in init_device.
...@@ -110,11 +116,13 @@ class PCC(hardware_device): ...@@ -110,11 +116,13 @@ class PCC(hardware_device):
# -------- # --------
# overloaded functions # overloaded functions
# -------- # --------
@log_exceptions()
def off(self): def off(self):
""" user code here. is called when the state is set to OFF """ """ user code here. is called when the state is set to OFF """
# Stop keep-alive # Stop keep-alive
self.OPCua_client.stop() self.OPCua_client.stop()
@log_exceptions()
def initialise(self): def initialise(self):
""" user code here. is called when the state is set to INIT """ """ user code here. is called when the state is set to INIT """
...@@ -141,13 +149,15 @@ class PCC(hardware_device): ...@@ -141,13 +149,15 @@ class PCC(hardware_device):
self.OPCua_client.start() self.OPCua_client.start()
# -------- # --------
# Commands # Commands
# -------- # --------
@command() @command()
@DebugIt() @DebugIt()
@only_when_on @only_when_on()
@fault_on_error @fault_on_error()
def RCU_off(self): def RCU_off(self):
""" """
...@@ -157,8 +167,8 @@ class PCC(hardware_device): ...@@ -157,8 +167,8 @@ class PCC(hardware_device):
@command() @command()
@DebugIt() @DebugIt()
@only_when_on @only_when_on()
@fault_on_error @fault_on_error()
def RCU_on(self): def RCU_on(self):
""" """
...@@ -168,8 +178,8 @@ class PCC(hardware_device): ...@@ -168,8 +178,8 @@ class PCC(hardware_device):
@command() @command()
@DebugIt() @DebugIt()
@only_when_on @only_when_on()
@fault_on_error @fault_on_error()
def ADC_on(self): def ADC_on(self):
""" """
...@@ -179,8 +189,8 @@ class PCC(hardware_device): ...@@ -179,8 +189,8 @@ class PCC(hardware_device):
@command() @command()
@DebugIt() @DebugIt()
@only_when_on @only_when_on()
@fault_on_error @fault_on_error()
def RCU_update(self): def RCU_update(self):
""" """
...@@ -190,8 +200,8 @@ class PCC(hardware_device): ...@@ -190,8 +200,8 @@ class PCC(hardware_device):
@command() @command()
@DebugIt() @DebugIt()
@only_when_on @only_when_on()
@fault_on_error @fault_on_error()
def CLK_off(self): def CLK_off(self):
""" """
...@@ -201,8 +211,8 @@ class PCC(hardware_device): ...@@ -201,8 +211,8 @@ class PCC(hardware_device):
@command() @command()
@DebugIt() @DebugIt()
@only_when_on @only_when_on()
@fault_on_error @fault_on_error()
def CLK_on(self): def CLK_on(self):
""" """
...@@ -212,8 +222,8 @@ class PCC(hardware_device): ...@@ -212,8 +222,8 @@ class PCC(hardware_device):
@command() @command()
@DebugIt() @DebugIt()
@only_when_on @only_when_on()
@fault_on_error @fault_on_error()
def CLK_PLL_setup(self): def CLK_PLL_setup(self):
""" """
......
...@@ -14,15 +14,20 @@ ...@@ -14,15 +14,20 @@
# PyTango imports # PyTango imports
from tango.server import run from tango.server import run
from tango.server import device_property from tango.server import device_property
from tango import AttrWriteType
# Additional import # Additional import
from clients.opcua_connection import OPCUAConnection from clients.opcua_connection import OPCUAConnection
from src.attribute_wrapper import * from util.attribute_wrapper import attribute_wrapper
from src.hardware_device import * from util.hardware_device import hardware_device
from util.lofar_logging import device_logging_to_python, log_exceptions
import numpy
__all__ = ["SDP", "main"] __all__ = ["SDP", "main"]
@device_logging_to_python({"device": "SDP"})
class SDP(hardware_device): class SDP(hardware_device):
""" """
...@@ -77,6 +82,7 @@ class SDP(hardware_device): ...@@ -77,6 +82,7 @@ class SDP(hardware_device):
"""Method always executed before any TANGO command is executed.""" """Method always executed before any TANGO command is executed."""
pass pass
@log_exceptions()
def delete_device(self): def delete_device(self):
"""Hook to delete resources allocated in init_device. """Hook to delete resources allocated in init_device.
...@@ -92,15 +98,17 @@ class SDP(hardware_device): ...@@ -92,15 +98,17 @@ class SDP(hardware_device):
# -------- # --------
# overloaded functions # overloaded functions
# -------- # --------
@log_exceptions()
def off(self): def off(self):
""" user code here. is called when the state is set to OFF """ """ user code here. is called when the state is set to OFF """
# Stop keep-alive # Stop keep-alive
self.opcua_connection.stop() self.opcua_connection.stop()
@log_exceptions()
def initialise(self): def initialise(self):
""" user code here. is called when the sate is set to INIT """ """ user code here. is called when the sate is set to INIT """
"""Initialises the attributes and properties of the PCC.""" """Initialises the attributes and properties of the SDP."""
# set up the OPC ua client # set up the OPC ua client
self.OPCua_client = OPCUAConnection("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), "http://lofar.eu", self.OPC_Time_Out, self.Fault, self) self.OPCua_client = OPCUAConnection("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), "http://lofar.eu", self.OPC_Time_Out, self.Fault, self)
......
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
from threading import Thread from threading import Thread
import socket import socket
<<<<<<< HEAD
from src.comms_client import * from src.comms_client import *
=======
from util.comms_client import CommClient
>>>>>>> master
import numpy import numpy
import opcua import opcua
from opcua import Client from opcua import Client
......
from src.comms_client import * from util.comms_client import CommClient
import numpy
import os
# <class 'numpy.bool_'> # <class 'numpy.bool_'>
class example_client(CommClient): class test_client(CommClient):
""" """
this class provides an example implementation of a comms_client. this class provides an example implementation of a comms_client.
Durirng initialisation it creates a correctly shaped zero filled value. on read that value is returned and on write its modified. Durirng initialisation it creates a correctly shaped zero filled value. on read that value is returned and on write its modified.
...@@ -28,7 +30,6 @@ class example_client(CommClient): ...@@ -28,7 +30,6 @@ class example_client(CommClient):
""" """
this function provides a location for the code neccecary to connect to the client this function provides a location for the code neccecary to connect to the client
""" """
self.streams.debug_stream("the example client doesn't actually connect to anything silly") self.streams.debug_stream("the example client doesn't actually connect to anything silly")
self.connected = True # set connected to true self.connected = True # set connected to true
...@@ -46,7 +47,9 @@ class example_client(CommClient): ...@@ -46,7 +47,9 @@ class example_client(CommClient):
the annotation can be in whatever format may be required. it is up to the user to handle its content the annotation can be in whatever format may be required. it is up to the user to handle its content
example annotation may include: example annotation may include:
- a file path and file line/location - a file path and file line/location
- COM object path - server address
- IDs
- data structures
""" """
# as this is an example, just print the annotation # as this is an example, just print the annotation
......
...@@ -11,10 +11,16 @@ ...@@ -11,10 +11,16 @@
# PyTango imports # PyTango imports
from tango.server import run from tango.server import run
from tango import AttrWriteType
# Additional import # Additional import
<<<<<<< HEAD:devices/HW_device_template.py
from src.attribute_wrapper import * from src.attribute_wrapper import *
from src.hardware_device import * from src.hardware_device import *
=======
from util.attribute_wrapper import attribute_wrapper
from util.hardware_device import hardware_device
>>>>>>> master:devices/examples/HW_device_template.py
__all__ = ["HW_dev"] __all__ = ["HW_dev"]
......
# See the docstring in versioneer.py for instructions. Note that you must
# re-run 'versioneer.py setup' after changing this section, and commit the
# resulting files.
[versioneer]
#VCS = git
#style = pep440
#versionfile_source =
#versionfile_build =
#tag_prefix =
#parentdir_prefix =
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
# Distributed under the terms of the APACHE license. # Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info. # See LICENSE.txt for more info.
""" PCC Device Server for LOFAR2.0 """ test Device Server
""" """
# PyTango imports # PyTango imports
...@@ -17,9 +16,9 @@ from tango.server import device_property ...@@ -17,9 +16,9 @@ from tango.server import device_property
from tango import DevState from tango import DevState
# Additional import # Additional import
from clients.test_client import example_client from clients.test_client import test_client
from src.attribute_wrapper import * from util.attribute_wrapper import *
from src.hardware_device import * from util.hardware_device import *
__all__ = ["test_device", "main"] __all__ = ["test_device", "main"]
...@@ -71,14 +70,14 @@ class test_device(hardware_device): ...@@ -71,14 +70,14 @@ class test_device(hardware_device):
self.set_state(DevState.INIT) self.set_state(DevState.INIT)
# set up the OPC ua client # set up the test client
self.example_client = example_client(self.Fault, self) self.test_client = test_client(self.Fault, self)
# map an access helper class # map an access helper class
for i in self.attr_list(): for i in self.attr_list():
i.set_comm_client(self.example_client) i.set_comm_client(self.test_client)
self.example_client.start() self.test_client.start()
# ---------- # ----------
......
File moved
...@@ -3,7 +3,7 @@ from tango import AttrWriteType ...@@ -3,7 +3,7 @@ from tango import AttrWriteType
import numpy import numpy
from src.wrappers import only_when_on, fault_on_error from util.wrappers import only_when_on, fault_on_error
import logging import logging
logger = logging.getLogger() logger = logging.getLogger()
...@@ -61,8 +61,8 @@ class attribute_wrapper(attribute): ...@@ -61,8 +61,8 @@ class attribute_wrapper(attribute):
if access == AttrWriteType.READ_WRITE: if access == AttrWriteType.READ_WRITE:
""" if the attribute is of READ_WRITE type, assign the RW and write function to it""" """ if the attribute is of READ_WRITE type, assign the RW and write function to it"""
@only_when_on @only_when_on()
@fault_on_error @fault_on_error()
def read_RW(device): def read_RW(device):
# print("read_RW {}, {}x{}, {}, {}".format(me.name, me.dim_x, me.dim_y, me.attr_type, me.value)) # print("read_RW {}, {}x{}, {}, {}".format(me.name, me.dim_x, me.dim_y, me.attr_type, me.value))
""" """
...@@ -74,17 +74,15 @@ class attribute_wrapper(attribute): ...@@ -74,17 +74,15 @@ class attribute_wrapper(attribute):
raise Exception("Attribute read_RW function error, attempted to read value_dict with key: `%s`, are you sure this exists?", raise Exception("Attribute read_RW function error, attempted to read value_dict with key: `%s`, are you sure this exists?",
self) from e self) from e
@only_when_on @only_when_on()
@fault_on_error @fault_on_error()
def write_RW(device, value): def write_RW(device, value):
""" """
_write_RW writes a value to this attribute _write_RW writes a value to this attribute
""" """
try:
self.write_function(value) self.write_function(value)
device.value_dict[self] = value device.value_dict[self] = value
except Exception as e:
raise e
self.fget = read_RW self.fget = read_RW
self.fset = write_RW self.fset = write_RW
...@@ -93,8 +91,8 @@ class attribute_wrapper(attribute): ...@@ -93,8 +91,8 @@ class attribute_wrapper(attribute):
else: else:
""" if the attribute is of READ type, assign the read function to it""" """ if the attribute is of READ type, assign the read function to it"""
@only_when_on @only_when_on()
@fault_on_error @fault_on_error()
def read_R(device): def read_R(device):
""" """
_read_R reads the attribute value, stores it and returns it" _read_R reads the attribute value, stores it and returns it"
...@@ -140,7 +138,7 @@ class attribute_wrapper(attribute): ...@@ -140,7 +138,7 @@ class attribute_wrapper(attribute):
def pass_func(value=None): def pass_func(value=None):
pass pass
logger.error("setting comm_client failed. using pass function instead") logger.error("Exception while setting %s attribute with annotation: '%s' read/write functions. using pass function instead to to keep running", client.__class__.__name__, self.comms_annotation)
self.read_function = pass_func self.read_function = pass_func
self.write_function = pass_func self.write_function = pass_func
......
from threading import Thread from threading import Thread
import socket
import time import time
import numpy
import opcua
from opcua import Client
from tango import DevState
class CommClient(Thread): class CommClient(Thread):
""" """
...@@ -52,7 +44,6 @@ class CommClient(Thread): ...@@ -52,7 +44,6 @@ class CommClient(Thread):
# keep trying to connect # keep trying to connect
if not self.connected: if not self.connected:
if self.connect(): if self.connect():
# self.standby_func()
pass pass
else: else:
# we retry only once, to catch exotic network issues. if the infra or hardware is down, # we retry only once, to catch exotic network issues. if the infra or hardware is down,
...@@ -75,7 +66,7 @@ class CommClient(Thread): ...@@ -75,7 +66,7 @@ class CommClient(Thread):
self.fault_func() self.fault_func()
def ping(self): def ping(self):
pass return
def stop(self): def stop(self):
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment