Skip to content
Snippets Groups Projects
HW_device_template.py 2.31 KiB
Newer Older
# -*- coding: utf-8 -*-
#
Taya Snijder's avatar
Taya Snijder committed
# 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.

Taya Snijder's avatar
Taya Snijder committed
"""

"""

# PyTango imports
from tango.server import run
Taya Snijder's avatar
Taya Snijder committed
from tango import AttrWriteType
# Additional import

Taya Snijder's avatar
Taya Snijder committed
from src.attribute_wrapper import attribute_wrapper
from src.hardware_device import hardware_device

__all__ = ["HW_dev"]

class HW_dev(hardware_device):
Thomas Juerges's avatar
Thomas Juerges committed
    """
Taya Snijder's avatar
Taya Snijder committed
    This class is the minimal (read empty) implementation of a class using 'hardware_device'
    """
Thomas Juerges's avatar
Thomas Juerges committed

    # ----------
    # Attributes
    # ----------
    """
Taya Snijder's avatar
Taya Snijder committed
    attribute wrapper objects can be declared here. All attribute wrapper objects will get automatically put in a list (attr_list) for easy access
Taya Snijder's avatar
Taya Snijder committed
    example = attribute_wrapper(comms_annotation="this is an example", datatype=numpy.double, dims=(8, 2), access=AttrWriteType.READ_WRITE)
    ...
Taya Snijder's avatar
Taya Snijder committed
    """
Thomas Juerges's avatar
Thomas Juerges committed

    def always_executed_hook(self):
        """Method always executed before any TANGO command is executed."""
        pass

    def delete_device(self):
        """Hook to delete resources allocated in init_device.

Taya Snijder's avatar
Taya Snijder committed
        This method allows for any memory or other resources allocated in the
        init_device method to be released.  This method is called by the device
        destructor and by the device Init command (a Tango built-in).
        """
Thomas Juerges's avatar
Thomas Juerges committed
        self.debug_stream("Shutting down...")

        self.Off()
        self.debug_stream("Shut down.  Good bye.")

    # --------
    # overloaded functions
    # --------
    def fault(self):
        """ user code here. is called when the state is set to FAULT """
        pass

    def off(self):
        """ user code here. is called when the state is set to OFF """
        pass

    def on(self):
        """ user code here. is called when the state is set to ON """

        pass

    def standby(self):
        """ user code here. is called when the state is set to STANDBY """
        pass

    def initialise(self):
        """ user code here. is called when the sate is set to INIT """
        pass
# ----------
# Run server
# ----------
def main(args=None, **kwargs):
Thomas Juerges's avatar
Thomas Juerges committed
    """Main function of the hardware device module."""
    return run((HW_dev,), args=args, **kwargs)


if __name__ == '__main__':
Thomas Juerges's avatar
Thomas Juerges committed
    main()