From 4f6a7c872288fe2efcbdeae609f194b47e7addea Mon Sep 17 00:00:00 2001 From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl> Date: Tue, 31 Mar 2020 17:53:18 +0200 Subject: [PATCH] Forgot to add important files --- crossechoTangoDev/Crossecho.py | 144 +++++++++++++++++++++++++++++ crossechoTangoDev/requirements.txt | 2 + 2 files changed, 146 insertions(+) create mode 100644 crossechoTangoDev/Crossecho.py create mode 100644 crossechoTangoDev/requirements.txt diff --git a/crossechoTangoDev/Crossecho.py b/crossechoTangoDev/Crossecho.py new file mode 100644 index 000000000..4979adf7a --- /dev/null +++ b/crossechoTangoDev/Crossecho.py @@ -0,0 +1,144 @@ +# -*- coding: utf-8 -*- +# +# This file is part of the Crossecho project +# +# +# +# Distributed under the terms of the APACHE license. +# See LICENSE.txt for more info. + +""" LOFAR2.0 Station Software + +Implementation of a Tango device on top of an existing OPC-UA server in Python3. +""" + +# PyTango imports +import PyTango +from PyTango import DebugIt +from PyTango.server import run +from PyTango.server import Device, DeviceMeta +from PyTango.server import attribute, command, pipe +from PyTango.server import device_property +from PyTango import AttrQuality, DispLevel, DevState +from PyTango import AttrWriteType, PipeWriteType +# Additional import +# PROTECTED REGION ID(Crossecho.additionnal_import) ENABLED START # +# PROTECTED REGION END # // Crossecho.additionnal_import + +__all__ = ["Crossecho", "main"] + + +class Crossecho(Device): + """ + Implementation of a Tango device on top of an existing OPC-UA server in Python3. + """ + __metaclass__ = DeviceMeta + # PROTECTED REGION ID(Crossecho.class_variable) ENABLED START # + # PROTECTED REGION END # // Crossecho.class_variable + + # ----------------- + # Device Properties + # ----------------- + + OPC_Server_Name = device_property( + dtype='str', default_value="localhost" + ) + + OPC_Server_Port = device_property( + dtype='str', default_value="55555" + ) + + # ---------- + # Attributes + # ---------- + + RCU_modes = attribute( + dtype=('str',), + max_dim_x=1024, + ) + + crosslet_stat = attribute( + dtype=('double',), + max_dim_x=10240, + ) + + # ----- + # Pipes + # ----- + + xlt_stat = pipe( + label="xlt", + ) + + # --------------- + # General methods + # --------------- + + def init_device(self): + Device.init_device(self) + # PROTECTED REGION ID(Crossecho.init_device) ENABLED START # + # PROTECTED REGION END # // Crossecho.init_device + + def always_executed_hook(self): + # PROTECTED REGION ID(Crossecho.always_executed_hook) ENABLED START # + pass + # PROTECTED REGION END # // Crossecho.always_executed_hook + + def delete_device(self): + # PROTECTED REGION ID(Crossecho.delete_device) ENABLED START # + pass + # PROTECTED REGION END # // Crossecho.delete_device + + # ------------------ + # Attributes methods + # ------------------ + + def read_RCU_modes(self): + # PROTECTED REGION ID(Crossecho.RCU_modes_read) ENABLED START # + return [''] + # PROTECTED REGION END # // Crossecho.RCU_modes_read + + def read_crosslet_stat(self): + # PROTECTED REGION ID(Crossecho.crosslet_stat_read) ENABLED START # + return [0.0] + # PROTECTED REGION END # // Crossecho.crosslet_stat_read + + + # ------------- + # Pipes methods + # ------------- + + def read_xlt_stat(self): + # PROTECTED REGION ID(Crossecho.xlt_stat_read) ENABLED START # + return dict(x=0,y=0) + # PROTECTED REGION END # // Crossecho.xlt_stat_read + + # -------- + # Commands + # -------- + + @command( + ) + @DebugIt() + def record_cross(self): + # PROTECTED REGION ID(Crossecho.record_cross) ENABLED START # + pass + # PROTECTED REGION END # // Crossecho.record_cross + + def is_record_cross_allowed(self): + # PROTECTED REGION ID(Crossecho.is_record_cross_allowed) ENABLED START # + return self.get_state() not in [DevState.OFF,DevState.INIT,DevState.FAULT] + # PROTECTED REGION END # // Crossecho.is_record_cross_allowed + +# ---------- +# Run server +# ---------- + + +def main(args=None, **kwargs): + # PROTECTED REGION ID(Crossecho.main) ENABLED START # + return run((Crossecho,), args=args, **kwargs) + # PROTECTED REGION END # // Crossecho.main + +if __name__ == '__main__': + main() diff --git a/crossechoTangoDev/requirements.txt b/crossechoTangoDev/requirements.txt new file mode 100644 index 000000000..c89a9ef10 --- /dev/null +++ b/crossechoTangoDev/requirements.txt @@ -0,0 +1,2 @@ +numpy==1.18.1 +opcua==0.98.9 -- GitLab