Skip to content
Snippets Groups Projects
test_device.py 3.15 KiB
Newer Older
# -*- coding: utf-8 -*-
#
# This file is part of the PCC project
#
#
#
# Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info.

Taya Snijder's avatar
Taya Snijder committed
""" test Device Server
"""

# PyTango imports
from tango.server import run
from tango.server import device_property
from tango import DevState
# Additional import

Taya Snijder's avatar
Taya Snijder committed
from clients.test_client import test_client
Jan David Mol's avatar
Jan David Mol committed
from util.attribute_wrapper import *
from util.hardware_device import *

__all__ = ["test_device", "main"]


class test_device(hardware_device):
Thomas Juerges's avatar
Thomas Juerges committed
    # -----------------
    # Device Properties
    # -----------------
Thomas Juerges's avatar
Thomas Juerges committed
    OPC_Server_Name = device_property(
        dtype='DevString',
    )
Thomas Juerges's avatar
Thomas Juerges committed
    OPC_Server_Port = device_property(
        dtype='DevULong',
    )
Thomas Juerges's avatar
Thomas Juerges committed
    OPC_Time_Out = device_property(
        dtype='DevDouble',
    )
Thomas Juerges's avatar
Thomas Juerges committed
    # ----------
    # Attributes
    # ----------
    bool_scalar_R = attribute_wrapper(comms_annotation="numpy.bool_ type read scalar", datatype=numpy.bool_)
    bool_scalar_RW = attribute_wrapper(comms_annotation="numpy.bool_ type read/write scalar", datatype=numpy.bool_, access=AttrWriteType.READ_WRITE)
    int32_spectrum_R = attribute_wrapper(comms_annotation="numpy.int32 type read spectrum (len = 8)", datatype=numpy.int32, dims=(8,))
    int32_spectrum_RW = attribute_wrapper(comms_annotation="numpy.int32 type read spectrum (len = 8)", datatype=numpy.int32, dims=(8,),
                                          access=AttrWriteType.READ_WRITE)
Thomas Juerges's avatar
Thomas Juerges committed
    double_image_R = attribute_wrapper(comms_annotation="numpy.double type read image (dims = 2x8)", datatype=numpy.double, dims=(2, 8))
    double_image_RW = attribute_wrapper(comms_annotation="numpy.double type read/write image (dims = 8x2)", datatype=numpy.double, dims=(8, 2),
                                        access=AttrWriteType.READ_WRITE)
Thomas Juerges's avatar
Thomas Juerges committed
    int32_scalar_R = attribute_wrapper(comms_annotation="numpy.int32 type read scalar", datatype=numpy.int32)
    uint16_spectrum_RW = attribute_wrapper(comms_annotation="numpy.uint16 type read/write spectrum (len = 8)", datatype=numpy.uint16, dims=(8,),
                                           access=AttrWriteType.READ_WRITE)
Thomas Juerges's avatar
Thomas Juerges committed
    float32_image_R = attribute_wrapper(comms_annotation="numpy.float32 type read image (dims = 8x2)", datatype=numpy.float32, dims=(8, 2))
    uint8_image_RW = attribute_wrapper(comms_annotation="numpy.uint8 type read/write image (dims = 2x8)", datatype=numpy.uint8, dims=(2, 8),
                                       access=AttrWriteType.READ_WRITE)
Thomas Juerges's avatar
Thomas Juerges committed
    # --------
    # overloaded functions
    # --------
    def configure_for_initialise(self):
Thomas Juerges's avatar
Thomas Juerges committed
        """ user code here. is called when the sate is set to INIT """
        """Initialises the attributes and properties of the PCC."""
Thomas Juerges's avatar
Thomas Juerges committed
        self.set_state(DevState.INIT)
Taya Snijder's avatar
Taya Snijder committed
        # set up the test client
Taya Snijder's avatar
Taya Snijder committed
        self.test_client = test_client(self.Fault, self)
Thomas Juerges's avatar
Thomas Juerges committed
        # map an access helper class
        for i in self.attr_list():
Taya Snijder's avatar
Taya Snijder committed
            i.set_comm_client(self.test_client)
Taya Snijder's avatar
Taya Snijder committed
        self.test_client.start()


# ----------
# Run server
# ----------
def main(args=None, **kwargs):
Thomas Juerges's avatar
Thomas Juerges committed
    """Main function of the example module."""
    return run((test_device,), args=args, **kwargs)


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