Skip to content
Snippets Groups Projects
Commit 0137a7f0 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-271: Make hardware_device and statistics device proper ABCs.

parent 60374227
No related branches found
No related tags found
1 merge request!85L2SS-271: Split statistics base classes off SSTs, cleaned those classes up a bit
......@@ -11,8 +11,10 @@
"""
from abc import ABCMeta, abstractmethod
# PyTango imports
from tango.server import Device, command
from tango.server import Device, command, DeviceMeta
from tango import DevState, DebugIt
# Additional import
......@@ -26,8 +28,12 @@ from devices.device_decorators import only_in_states, fault_on_error
import logging
logger = logging.getLogger()
class AbstractDeviceMetas(DeviceMeta, ABCMeta):
''' Collects meta classes to allow hardware_device to be both a Device and an ABC. '''
pass
#@log_exceptions()
class hardware_device(Device):
class hardware_device(Device, metaclass=AbstractDeviceMetas):
"""
**Properties:**
......@@ -155,13 +161,18 @@ class hardware_device(Device):
self.set_state(DevState.FAULT)
# functions that can be overloaded
# functions that can or must be overloaded
def configure_for_fault(self):
pass
@abstractmethod
def configure_for_off(self):
pass
def configure_for_on(self):
pass
@abstractmethod
def configure_for_initialise(self):
pass
......
......@@ -18,6 +18,8 @@ parentdir = os.path.dirname(currentdir)
parentdir = os.path.dirname(parentdir)
sys.path.append(parentdir)
from abc import ABCMeta, abstractmethod
# PyTango imports
from tango.server import run
from tango.server import device_property, attribute
......@@ -37,10 +39,13 @@ import numpy
__all__ = ["Statistics"]
class Statistics(hardware_device):
class Statistics(hardware_device, metaclass=ABCMeta):
# In derived classes, set this to a subclass of StatisticsCollector
STATISTICS_COLLECTOR_CLASS = NotImplementedError
@property
@abstractmethod
def STATISTICS_COLLECTOR_CLASS(self):
pass
# -----------------
# Device Properties
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment