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

misc fixes

parent 8439d8d8
No related branches found
No related tags found
1 merge request!18Resolve #2021 "04 16 branched from master state bug fix"
......@@ -11,10 +11,11 @@
# PyTango imports
from tango.server import run
from tango import AttrWriteType
# Additional import
from src.attribute_wrapper import *
from src.hardware_device import *
from src.attribute_wrapper import attribute_wrapper
from src.hardware_device import hardware_device
__all__ = ["HW_dev"]
......
......@@ -15,11 +15,12 @@
from tango import DebugIt
from tango.server import run, command
from tango.server import device_property
from tango import AttrWriteType
# Additional import
from clients.opcua_connection import OPCUAConnection
from src.attribute_wrapper import *
from src.hardware_device import *
from src.attribute_wrapper import attribute_wrapper
from src.hardware_device import hardware_device
from src.lofar_logging import device_logging_to_python
__all__ = ["PCC", "main"]
......
......@@ -14,14 +14,16 @@
# PyTango imports
from tango.server import run
from tango.server import device_property
from tango import AttrWriteType
# Additional import
from clients.opcua_connection import OPCUAConnection
from src.attribute_wrapper import *
from src.hardware_device import *
from src.attribute_wrapper import attribute_wrapper
from src.hardware_device import hardware_device
from src.lofar_logging import device_logging_to_python
import numpy
__all__ = ["SDP", "main"]
......
from src.comms_client import *
from src.comms_client import CommClient
import numpy
import os
# <class 'numpy.bool_'>
class example_client(CommClient):
class test_client(CommClient):
"""
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.
......@@ -47,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
example annotation may include:
- a file path and file line/location
- COM object path
- server address
- IDs
- data structures
"""
# as this is an example, just print the annotation
......
......@@ -84,7 +84,6 @@ class attribute_wrapper(attribute):
self.write_function(value)
device.value_dict[self] = value
self.fget = read_RW
self.fset = write_RW
......@@ -96,8 +95,8 @@ class attribute_wrapper(attribute):
@fault_on_error
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"
"""
device.value_dict[self] = self.read_function()
return device.value_dict[self]
......@@ -109,8 +108,8 @@ class attribute_wrapper(attribute):
def initial_value(self):
"""
returns a numpy array filled with zeroes fit to the size of the attribute. Or if init_value is not the default None, return that value
"""
returns a numpy array filled with zeroes fit to the size of the attribute. Or if init_value is not the default None, return that value
"""
if self.init_value is not None:
return self.init_value
......@@ -130,16 +129,16 @@ class attribute_wrapper(attribute):
def set_comm_client(self, client):
"""
takes a communications client as input arguments This client should be of a class containing a "get_mapping" function
and return a read and write function that the wrapper will use to get/set data.
"""
takes a communications client as input arguments This client should be of a class containing a "get_mapping" function
and return a read and write function that the wrapper will use to get/set data.
"""
try:
self.read_function, self.write_function = client.setup_attribute(self.comms_annotation, self)
except Exception as e:
def pass_func(value=None):
pass
logger.error("Exception while setting %s read/write functions. using pass function instead.", self.comms_annotation)
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.write_function = pass_func
......
......@@ -44,7 +44,6 @@ class CommClient(Thread):
# keep trying to connect
if not self.connected:
if self.connect():
# self.standby_func()
pass
else:
# we retry only once, to catch exotic network issues. if the infra or hardware is down,
......
......@@ -16,7 +16,7 @@ from tango.server import Device, command
from tango import DevState, DebugIt
# Additional import
from src.attribute_wrapper import *
from src.attribute_wrapper import attribute_wrapper
from src.lofar_logging import log_exceptions
__all__ = ["hardware_device"]
......
......@@ -16,7 +16,7 @@ from tango.server import device_property
from tango import DevState
# Additional import
from clients.test_client import example_client
from clients.test_client import test_client
from src.attribute_wrapper import *
from src.hardware_device import *
......@@ -71,13 +71,13 @@ class test_device(hardware_device):
self.set_state(DevState.INIT)
# 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
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()
# ----------
......
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