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

parsed review points

parent 2e8a8089
Branches
Tags
1 merge request!18Resolve #2021 "04 16 branched from master state bug fix"
# -*- coding: utf-8 -*-
#
# This file is part of the PCC project
#
#
# This file wraps around a tango device class and provides a number of abstractions useful for hardware devices. It works together
#
# Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info.
""" Hardware Device Server for LOFAR2.0
"""
"""
......@@ -30,7 +28,7 @@ class HW_dev(hardware_device):
# Attributes
# ----------
"""
attribute wrapper objects can be declared here. All attribute wrapper objects will get automatically put in a ist (attr_list) for easy access
attribute wrapper objects can be declared here. All attribute wrapper objects will get automatically put in a list (attr_list) for easy access
example = attribute_wrapper(comms_annotation="this is an example", datatype=numpy.double, dims=(8, 2), access=AttrWriteType.READ_WRITE)
...
......
......@@ -20,10 +20,11 @@ from tango.server import device_property
from clients.opcua_connection import OPCUAConnection
from src.attribute_wrapper import *
from src.hardware_device import *
from src.lofar_logging import device_logging_to_python
__all__ = ["PCC", "main"]
@device_logging_to_python({"device": "PCC"})
class PCC(hardware_device):
"""
......
......@@ -20,9 +20,12 @@ from clients.opcua_connection import OPCUAConnection
from src.attribute_wrapper import *
from src.hardware_device import *
from src.lofar_logging import device_logging_to_python
__all__ = ["SDP", "main"]
@device_logging_to_python({"device": "SDP"})
class SDP(hardware_device):
"""
......
from src.comms_client import *
from threading import Thread
import socket
from src.comms_client import CommClient
import numpy
import opcua
from opcua import Client
__all__ = ["OPCUAConnection"]
......
from src.comms_client import *
import numpy
<<<<<<< HEAD
<<<<<<< HEAD
import os
=======
>>>>>>> 99e3d08... fixed 'illegal state transition' bug and off->initialise state bug
=======
>>>>>>> 99e3d08... fixed 'illegal state transition' bug and off->initialise state bug
# <class 'numpy.bool_'>
......@@ -35,14 +30,6 @@ class example_client(CommClient):
"""
this function provides a location for the code neccecary to connect to the client
"""
<<<<<<< HEAD
<<<<<<< HEAD
self.streams.debug_stream(os.path.dirname(os.path.abspath(__file__)))
=======
=======
>>>>>>> 99e3d08... fixed 'illegal state transition' bug and off->initialise state bug
>>>>>>> 99e3d08... fixed 'illegal state transition' bug and off->initialise state bug
self.streams.debug_stream("the example client doesn't actually connect to anything silly")
self.connected = True # set connected to true
......
......@@ -11,8 +11,6 @@ logger = logging.getLogger()
class attribute_wrapper(attribute):
"""
<<<<<<< HEAD
<<<<<<< HEAD
Wraps all the attributes in a wrapper class to manage most of the redundant code behind the scenes
"""
......@@ -26,26 +24,6 @@ class attribute_wrapper(attribute):
dims: dimensions of the
init_value: value
"""
=======
Wraps all the attributes in a wrapper class to manage most of the redundant code behind the scenes
"""
def __init__(self, comms_annotation=None, datatype=None, dims=(1,), access=AttrWriteType.READ, init_value=None, **kwargs):
"""
wraps around the tango Attribute class. Provides an easier interface for 1d or 2d arrays. Also provides a way to abstract
managing the communications interface.
"""
>>>>>>> 99e3d08... fixed 'illegal state transition' bug and off->initialise state bug
=======
Wraps all the attributes in a wrapper class to manage most of the redundant code behind the scenes
"""
def __init__(self, comms_annotation=None, datatype=None, dims=(1,), access=AttrWriteType.READ, init_value=None, **kwargs):
"""
wraps around the tango Attribute class. Provides an easier interface for 1d or 2d arrays. Also provides a way to abstract
managing the communications interface.
"""
>>>>>>> 99e3d08... fixed 'illegal state transition' bug and off->initialise state bug
# ensure the type is a numpy array
if "numpy" not in str(datatype) and datatype != str:
......@@ -162,7 +140,7 @@ class attribute_wrapper(attribute):
def pass_func(value=None):
pass
logger.error("setting comm_client failed. using pass function instead")
logger.error("Exception while setting %s read/write functions. using pass function instead.", self.comms_annotation)
self.read_function = pass_func
self.write_function = pass_func
......
from threading import Thread
import socket
import time
import numpy
import opcua
from opcua import Client
from tango import DevState
class CommClient(Thread):
"""
......@@ -75,7 +67,7 @@ class CommClient(Thread):
self.fault_func()
def ping(self):
pass
return
def stop(self):
"""
......
......@@ -17,13 +17,13 @@ from tango import DevState, DebugIt
# Additional import
from src.attribute_wrapper import *
from src.lofar_logging import log_exceptions
__all__ = ["hardware_device"]
from src.wrappers import only_in_states
@log_exceptions()
class hardware_device(Device):
"""
......@@ -87,17 +87,6 @@ class hardware_device(Device):
self.set_state(DevState.STANDBY)
# @only_in_states([DevState.INIT])
# def Standby(self):
# """
# Command to ask for initialisation of this device. Can only be called in FAULT or OFF state.
#
# :return:None
# """
#
# self.standby()
# self.set_state(DevState.STANDBY)
@command()
@only_in_states([DevState.STANDBY])
@DebugIt()
......@@ -154,8 +143,6 @@ class hardware_device(Device):
pass
def on(self):
pass
def standby(self):
pass
def initialise(self):
pass
......
......@@ -7,8 +7,7 @@
# Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info.
""" PCC Device Server for LOFAR2.0
""" test Device Server
"""
# PyTango imports
......@@ -71,7 +70,7 @@ class test_device(hardware_device):
self.set_state(DevState.INIT)
# set up the OPC ua client
# set up the test client
self.example_client = example_client(self.Fault, self)
# map an access helper class
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment