From e37679dc7b9ea9256e8acbf931f7c115404376be Mon Sep 17 00:00:00 2001
From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl>
Date: Tue, 31 Mar 2020 17:52:29 +0200
Subject: [PATCH] Update Crossecho Tango example

---
 crossechoTangoDev/Crossecho.xmi          |  50 ++++++++++--
 crossechoTangoDev/Crossecho/Crossecho.py | 100 -----------------------
 crossechoTangoDev/Crossecho/__init__.py  |  20 -----
 crossechoTangoDev/Crossecho/__main__.py  |  11 ---
 crossechoTangoDev/Crossecho/release.py   |  20 -----
 crossechoTangoDev/test/Crossecho_test.py |   8 +-
 6 files changed, 52 insertions(+), 157 deletions(-)
 delete mode 100644 crossechoTangoDev/Crossecho/Crossecho.py
 delete mode 100644 crossechoTangoDev/Crossecho/__init__.py
 delete mode 100644 crossechoTangoDev/Crossecho/__main__.py
 delete mode 100644 crossechoTangoDev/Crossecho/release.py

diff --git a/crossechoTangoDev/Crossecho.xmi b/crossechoTangoDev/Crossecho.xmi
index 552163651..663665f22 100644
--- a/crossechoTangoDev/Crossecho.xmi
+++ b/crossechoTangoDev/Crossecho.xmi
@@ -1,10 +1,20 @@
 <?xml version="1.0" encoding="ASCII"?>
 <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
   <classes name="Crossecho" pogoRevision="9.6">
-    <description description="Implementation of a Tango device on top of an existing OPC-UA server in Python3." title="LOFAR2.0 Station Software" sourcePath="/hosthome/workspace.astron/extern/Tango/tango-workshop/crossechoTangoDev" language="PythonHL" filestogenerate="XMI   file,Code files,Python Package,Protected Regions" license="APACHE" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false">
+    <description description="Implementation of a Tango device on top of an existing OPC-UA server in Python3." title="LOFAR2.0 Station Software" sourcePath="/home/tango/tango-workshop/crossechoTangoDev" language="PythonHL" filestogenerate="XMI   file,Code files,Protected Regions" license="APACHE" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
       <inheritances classname="Device_Impl" sourcePath=""/>
       <identification contact="at astron.nl - jurges" author="jurges" emailDomain="astron.nl" classFamily="OtherInstruments" siteSpecific="" platform="Unix Like" bus="Not Applicable" manufacturer="none" reference=""/>
     </description>
+    <deviceProperties name="OPC_Server_Name" description="">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <DefaultPropValue>localhost</DefaultPropValue>
+    </deviceProperties>
+    <deviceProperties name="OPC_Server_Port" description="">
+      <type xsi:type="pogoDsl:StringType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <DefaultPropValue>55555</DefaultPropValue>
+    </deviceProperties>
     <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
       <argin description="none">
         <type xsi:type="pogoDsl:VoidType"/>
@@ -25,21 +35,51 @@
     </commands>
     <commands name="record_cross" description="" execMethod="record_cross" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
       <argin description="">
-        <type xsi:type="pogoDsl:EncodedType"/>
+        <type xsi:type="pogoDsl:VoidType"/>
       </argin>
       <argout description="">
-        <type xsi:type="pogoDsl:EncodedType"/>
+        <type xsi:type="pogoDsl:VoidType"/>
       </argout>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <excludedStates>OFF</excludedStates>
+      <excludedStates>INIT</excludedStates>
+      <excludedStates>FAULT</excludedStates>
     </commands>
-    <attributes name="crosslet_stat" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="15000" maxX="" maxY="" allocReadMember="true" isDynamic="false">
-      <dataType xsi:type="pogoDsl:EncodedType"/>
+    <attributes name="RCU_modes" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="1024" maxY="" allocReadMember="true" isDynamic="false">
+      <dataType xsi:type="pogoDsl:StringType"/>
+      <changeEvent fire="false" libCheckCriteria="false"/>
+      <archiveEvent fire="false" libCheckCriteria="false"/>
+      <dataReadyEvent fire="false" libCheckCriteria="true"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
+    </attributes>
+    <attributes name="crosslet_stat" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="10240" maxY="" allocReadMember="true" isDynamic="false">
+      <dataType xsi:type="pogoDsl:DoubleType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
       <dataReadyEvent fire="false" libCheckCriteria="true"/>
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
       <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
+    <pipes name="xlt_stat" description="" label="xlt" rwType="READ" displayLevel="OPERATOR"/>
+    <states name="ON" description="">
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </states>
+    <states name="OFF" description="">
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </states>
+    <states name="INIT" description="">
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </states>
+    <states name="FAULT" description="">
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </states>
+    <states name="ALARM" description="">
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </states>
+    <states name="STANDBY" description="">
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </states>
     <preferences docHome="./doc_html" makefileHome="/usr/local/share/pogo/preferences"/>
   </classes>
 </pogoDsl:PogoSystem>
diff --git a/crossechoTangoDev/Crossecho/Crossecho.py b/crossechoTangoDev/Crossecho/Crossecho.py
deleted file mode 100644
index 01a16e039..000000000
--- a/crossechoTangoDev/Crossecho/Crossecho.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# -*- 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
-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
-
-    # ----------
-    # Attributes
-    # ----------
-
-    crosslet_stat = attribute(
-        dtype='bytearray',
-    )
-
-    # ---------------
-    # 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_crosslet_stat(self):
-        # PROTECTED REGION ID(Crossecho.crosslet_stat_read) ENABLED START #
-        return ['', '']
-        # PROTECTED REGION END #    //  Crossecho.crosslet_stat_read
-
-
-    # --------
-    # Commands
-    # --------
-
-    @command(
-    dtype_in='bytearray', 
-    dtype_out='bytearray', 
-    )
-    @DebugIt()
-    def record_cross(self, argin):
-        # PROTECTED REGION ID(Crossecho.record_cross) ENABLED START #
-        return "", ""
-        # PROTECTED REGION END #    //  Crossecho.record_cross
-
-# ----------
-# 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/Crossecho/__init__.py b/crossechoTangoDev/Crossecho/__init__.py
deleted file mode 100644
index c97b40c68..000000000
--- a/crossechoTangoDev/Crossecho/__init__.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- 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.
-"""
-
-from . import release
-from .Crossecho import Crossecho, main
-
-__version__ = release.version
-__version_info__ = release.version_info
-__author__ = release.author
diff --git a/crossechoTangoDev/Crossecho/__main__.py b/crossechoTangoDev/Crossecho/__main__.py
deleted file mode 100644
index e0468aeb0..000000000
--- a/crossechoTangoDev/Crossecho/__main__.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- 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.
-
-from Crossecho import main
-main()
diff --git a/crossechoTangoDev/Crossecho/release.py b/crossechoTangoDev/Crossecho/release.py
deleted file mode 100644
index 5e579e20c..000000000
--- a/crossechoTangoDev/Crossecho/release.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- 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.
-
-"""Release information for Python Package"""
-
-name = """tangods-crossecho"""
-version = "1.0.0"
-version_info = version.split(".")
-description = """Implementation of a Tango device on top of an existing OPC-UA server in Python3."""
-author = "jurges"
-author_email = "jurges at astron.nl"
-license = """APACHE"""
-url = """www.tango-controls.org"""
-copyright = """"""
diff --git a/crossechoTangoDev/test/Crossecho_test.py b/crossechoTangoDev/test/Crossecho_test.py
index a2372ddf2..3adc49113 100644
--- a/crossechoTangoDev/test/Crossecho_test.py
+++ b/crossechoTangoDev/test/Crossecho_test.py
@@ -39,7 +39,7 @@ class CrossechoDeviceTestCase(DeviceTestCase):
     # PROTECTED REGION ID(Crossecho.test_additionnal_import) ENABLED START #
     # PROTECTED REGION END #    //  Crossecho.test_additionnal_import
     device = Crossecho
-    properties = {
+    properties = {'OPC_Server_Name': 'localhost', 'OPC_Server_Port': '55555', 
                   }
     empty = None  # Should be []
 
@@ -75,6 +75,12 @@ class CrossechoDeviceTestCase(DeviceTestCase):
         self.device.record_cross([""])
         # PROTECTED REGION END #    //  Crossecho.test_record_cross
 
+    def test_RCU_modes(self):
+        """Test for RCU_modes"""
+        # PROTECTED REGION ID(Crossecho.test_RCU_modes) ENABLED START #
+        self.device.RCU_modes
+        # PROTECTED REGION END #    //  Crossecho.test_RCU_modes
+
     def test_crosslet_stat(self):
         """Test for crosslet_stat"""
         # PROTECTED REGION ID(Crossecho.test_crosslet_stat) ENABLED START #
-- 
GitLab