diff --git a/CDB/LOFAR_ConfigDb.json b/CDB/LOFAR_ConfigDb.json index 0bb4ae996caa6c6400f9141b3ebe8ff4d780bef9..50953c051b21b94f83e29b96b33ac52f046b4f0d 100644 --- a/CDB/LOFAR_ConfigDb.json +++ b/CDB/LOFAR_ConfigDb.json @@ -17,84 +17,6 @@ "600000" ] }, - "HBA_element_beamformer_delays_R": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] - }, - "HBA_element_beamformer_delays_RW": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] - }, - "HBA_element_led_R": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] - }, - "HBA_element_led_RW": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] - }, - "HBA_element_pwr_R": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] - }, - "HBA_element_pwr_RW": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] - }, "RCU_ADC_CML_R": { "archive_period": [ "600000" @@ -282,6 +204,12 @@ "600000" ] }, + "RCU_monitor_rate": { + "rel_change": [ + "-1", + "1" + ] + }, "RCU_monitor_rate_RW": { "archive_period": [ "600000" @@ -295,11 +223,6 @@ "1.0" ] }, - "RCU_state_R": { - "archive_period": [ - "600000" - ] - }, "RCU_temperature_R": { "archive_period": [ "600000" @@ -333,19 +256,6 @@ "event_period": [ "0" ] - }, - "uC_ID_R": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] } }, "properties": { @@ -400,22 +310,6 @@ "rcu_temperature_r", "1000", "rcu_version_r", - "1000", - "hba_element_beamformer_delays_r", - "1000", - "hba_element_beamformer_delays_rw", - "1000", - "hba_element_led_r", - "1000", - "hba_element_led_rw", - "1000", - "hba_element_pwr_r", - "1000", - "hba_element_pwr_rw", - "1000", - "rcu_state_r", - "1000", - "uc_id_r", "1000" ] } @@ -532,130 +426,27 @@ ] }, "State": { - "archive_period": [ - "600000" + "event_period": [ + "60000" ] }, "Status": { - "archive_period": [ - "600000" - ] - }, - "fpga_mask_RW": { - "archive_period": [ - "600000" - ] - }, - "fpga_scrap_R": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] - }, - "fpga_scrap_RW": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] - }, - "fpga_status_R": { - "archive_period": [ - "600000" + "event_period": [ + "60000" ] }, "fpga_temp_R": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] - }, - "fpga_version_R": { - "archive_period": [ - "600000" - ] - }, - "fpga_weights_R": { - "archive_period": [ - "600000" - ], "archive_rel_change": [ "-1", "1" ], - "rel_change": [ - "-1", - "1" - ] - }, - "fpga_weights_RW": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" - ], - "rel_change": [ - "-1", - "1" - ] - }, - "tr_busy_R": { - "archive_period": [ - "600000" - ] - }, - "tr_reload_RW": { - "archive_period": [ - "600000" - ] - }, - "tr_tod_R": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-1", - "1" + "event_period": [ + "60000" ], "rel_change": [ "-1", "1" ] - }, - "tr_uptime_R": { - "archive_period": [ - "600000" - ], - "archive_rel_change": [ - "-3600", - "3600" - ], - "rel_change": [ - "-10", - "10" - ] } }, "properties": { @@ -671,31 +462,11 @@ "polled_attr": [ "fpga_temp_r", "1000", + "sdp_mask_rw", + "1000", "state", "1000", "status", - "1000", - "fpga_mask_rw", - "1000", - "fpga_scrap_r", - "1000", - "fpga_scrap_rw", - "1000", - "fpga_status_r", - "1000", - "fpga_version_r", - "1000", - "fpga_weights_r", - "1000", - "fpga_weights_rw", - "1000", - "tr_busy_r", - "1000", - "tr_reload_rw", - "1000", - "tr_tod_r", - "1000", - "tr_uptime_r", "1000" ] } diff --git a/CDB/device_ConfigDb.json b/CDB/device_ConfigDb.json new file mode 100644 index 0000000000000000000000000000000000000000..92331cd38297e3f014321c8565b1dca69f4a7572 --- /dev/null +++ b/CDB/device_ConfigDb.json @@ -0,0 +1,56 @@ +{ + "servers": { + "PCC": { + "1": { + "PCC": { + "LTS/PCC/1": { + "properties": { + "OPC_Server_Name": [ + "ltspi.astron.nl" + ] + } + } + } + } + }, + "SDP": { + "1": { + "SDP": { + "LTS/SDP/1": { + "properties": { + "OPC_Server_Name": [ + "DESPi2.astron.nl" + ] + } + } + } + } + }, + "example_device": { + "1": { + "example_device": { + "LTS/example_device/1": { + "attribute_properties": { + "Ant_mask_RW": { + "archive_period": [ + "600000" + ] + } + }, + "properties": { + "OPC_Server_Name": [ + "host.docker.internal" + ], + "OPC_Server_Port": [ + "4842" + ], + "OPC_Time_Out": [ + "5.0" + ] + } + } + } + } + } + } +} diff --git a/CDB/test_ConfigDb.json b/CDB/test_ConfigDb.json new file mode 100644 index 0000000000000000000000000000000000000000..af43e68f5eead7b164cb8772a83143f39856189e --- /dev/null +++ b/CDB/test_ConfigDb.json @@ -0,0 +1,56 @@ +{ + "servers": { + "PCC": { + "1": { + "PCC": { + "LTS/PCC/1": { + "properties": { + "OPC_Server_Name": [ + "ltspi.astron.nl" + ] + } + } + } + } + }, + "SDP": { + "1": { + "SDP": { + "LTS/SDP/1": { + "properties": { + "OPC_Server_Name": [ + "DESPi2.astron.nl" + ] + } + } + } + } + }, + "test_device": { + "1": { + "test_device": { + "LTS/test_device/1": { + "attribute_properties": { + "Ant_mask_RW": { + "archive_period": [ + "600000" + ] + } + }, + "properties": { + "OPC_Server_Name": [ + "host.docker.internal" + ], + "OPC_Server_Port": [ + "4842" + ], + "OPC_Time_Out": [ + "5.0" + ] + } + } + } + } + } + } +} diff --git a/PCC/LICENSE.txt b/PCC/LICENSE.txt deleted file mode 100644 index ae533fce6dc75595f91290511273c7ff62312f76..0000000000000000000000000000000000000000 --- a/PCC/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, -ASTRON Netherlands Institute for Radio Astronomy - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/PCC/MANIFEST.in b/PCC/MANIFEST.in deleted file mode 100644 index 251eebae288846436b6dc7b6022214cda5af98af..0000000000000000000000000000000000000000 --- a/PCC/MANIFEST.in +++ /dev/null @@ -1,9 +0,0 @@ -recursive-include PCC *.py -recursive-include test *.py -include *.rst -include PCC.xmi -include *.txt -graft docs - -global-exclude *.pyc -global-exclude *.pyo diff --git a/PCC/NOTICE b/PCC/NOTICE deleted file mode 100644 index 9c7867598e17de5d69b8c26656caa8316cd0a30f..0000000000000000000000000000000000000000 --- a/PCC/NOTICE +++ /dev/null @@ -1,8 +0,0 @@ -Citation Notice version 1.0 -This Citation Notice is part of the LOFAR software suite. -Parties that use ASTRON Software resulting in papers and/or publications are requested to -refer to the DOI(s) that correspond(s) to the version(s) of the ASTRON Software used: -<List of DOIs> -Parties that use ASTRON Software for purposes that do not result in publications (e.g. -commercial parties) are asked to inform ASTRON about their use of ASTRON Software, by -sending an email to including the DOIs mentioned above in the message. \ No newline at end of file diff --git a/PCC/PCC/README.md b/PCC/PCC/README.md deleted file mode 100644 index d7926f28a9a0660f25eb7824ed38af0fd41be25c..0000000000000000000000000000000000000000 --- a/PCC/PCC/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Device wrapper - -This code provides an attribute_wrapper class in place of attributes for tango devices. the attribute wrappers contain additional code -that moves a lot of the complexity and redundant code to the background. - -The only things required on the users part are to declare the attributes using the attribute_wrapper (see `example/example_device`), -declare what client the attribute has to use in the initialisation and provide support for the used clients. -To see how to add support for new clients, see `clients/README.md` - - -Requires numpy -```pip install numpy``` - -Requires opcua -```pip install opcua``` - -Requires pytango -```pip install pytango``` - - diff --git a/PCC/PCC/__init__.py b/PCC/PCC/__init__.py deleted file mode 100644 index f46dac89c5c6fb96b76b166b6d8c2be540b19e0d..0000000000000000000000000000000000000000 --- a/PCC/PCC/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- 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. - -"""PCC Device Server for LOFAR2.0 - -""" - -from . import release -from .PCC import PCC, main - -__version__ = release.version -__version_info__ = release.version_info -__author__ = release.author diff --git a/PCC/PCC/__main__.py b/PCC/PCC/__main__.py deleted file mode 100644 index 52b1fda83b2b1f2f8d9dbae05f114527555136ce..0000000000000000000000000000000000000000 --- a/PCC/PCC/__main__.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- 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. - -from PCC import main -main() diff --git a/PCC/PCC/clients/opcua_connection.py b/PCC/PCC/clients/opcua_connection.py deleted file mode 100644 index 35709f0b71cbde79db5cfe2daa5b992229989046..0000000000000000000000000000000000000000 --- a/PCC/PCC/clients/opcua_connection.py +++ /dev/null @@ -1,215 +0,0 @@ -from comms_client import * - - -__all__ = ["OPCUAConnection"] - -OPCua_to_numpy_dict = { - "VariantType.Boolean": numpy.bool_, - "VariantType.SByte": numpy.int8, - "VariantType.Byte": numpy.uint8, - "VariantType.Int16": numpy.int16, - "VariantType.UInt16": numpy.uint16, - "VariantType.Int32": numpy.int32, - "VariantType.UInt32": numpy.uint32, - "VariantType.Int64": numpy.int64, - "VariantType.UInt64": numpy.uint64, - "VariantType.DateTime": numpy.datetime_data, # is this the right type, does it even matter? - "VariantType.Float": numpy.float32, - "VariantType.Double": numpy.double, - "VariantType.String": numpy.str, - "VariantType.ByteString": numpy.uint8 # sequence of bytes, not a string -} - -numpy_to_OPCua_dict = { - "<class 'numpy.bool_'>": opcua.ua.VariantType.Boolean, - "<class 'numpy.int8'>": opcua.ua.VariantType.SByte, - "<class 'numpy.uint8'>": opcua.ua.VariantType.Byte, - "<class 'numpy.int16'>": opcua.ua.VariantType.Int16, - "<class 'numpy.uint16'>": opcua.ua.VariantType.UInt16, - "<class 'numpy.int32'>": opcua.ua.VariantType.Int32, - "<class 'numpy.uint32'>": opcua.ua.VariantType.UInt32, - "<class 'numpy.int64'>": opcua.ua.VariantType.Int64, - "<class 'numpy.uint64'>": opcua.ua.VariantType.UInt64, - "<class 'numpy.datetime_data'>": opcua.ua.VariantType.DateTime, # is this the right type, does it even matter? - "<class 'numpy.float32'>": opcua.ua.VariantType.Float, - "<class 'numpy.float64'>": opcua.ua.VariantType.Double, - "<class 'numpy.double'>": opcua.ua.VariantType.Double, - "<class 'numpy.str_'>": opcua.ua.VariantType.String, - "<class 'numpy.str'>": opcua.ua.VariantType.String, - "str": opcua.ua.VariantType.String -} - -# <class 'numpy.bool_'> - -class OPCUAConnection(CommClient): - """ - Connects to OPC-UA in the foreground or background, and sends HELLO - messages to keep a check on the connection. On connection failure, reconnects once. - """ - - def start(self): - super().start() - - def __init__(self, address, timeout, on_func, fault_func, streams, try_interval=2): - """ - Create the OPC ua client and connect() to it and get the object node - """ - super().__init__(on_func, fault_func, streams, try_interval) - - self.client = Client(address, timeout) - - # Explicitly connect - if not self.connect(): - # hardware or infra is down -- needs fixing first - fault_func() - return - - self.streams.debug_stream("Demo ||\t connection established") - - # determine namespace used - try: - self.name_space_index = self.client.get_namespace_index("http://lofar.eu") - except Exception as e: - self.streams.warn_stream("Cannot determine the OPC-UA name space index. Will try and use the default = 2.") - self.name_space_index = 2 - - self.obj = self.client.get_objects_node() - - def _servername(self): - return self.client.server_url.geturl() - - def connect(self): - """ - Try to connect to the client - """ - - try: - self.streams.debug_stream("Connecting to server %s", self._servername()) - self.client.connect() - self.connected = True - self.streams.debug_stream("Connected to server. Initialising.") - return True - except socket.error as e: - self.streams.error_stream("Could not connect to server %s: %s", self._servername(), e) - return False - - def disconnect(self): - """ - disconnect from the client - """ - self.connected = False # always force a reconnect, regardless of a successful disconnect - - try: - self.client.disconnect() - except Exception as e: - self.streams.error_stream("Disconnect from OPC-UA server %s failed: %s", self._servername(), e) - - def ping(self): - """ - ping the client to make sure the connection with the client is still functional. - """ - try: - self.client.send_hello() - except Exception as e: - raise Exception("Lost connection to server %s: %s", self._servername(), e) - - def _setup_annotation(self, annotation): - """ - This class's Implementation of the get_mapping function. returns the read and write functions - """ - - if isinstance(annotation, dict): - # check if required path inarg is present - if annotation.get('path') is None: - AssertionError("OPC-ua mapping requires a path argument in the annotation") - - path = annotation.get("path") # required - ua_Type = annotation.get("ua_type") # optional, if excluded must be a build in python type - elif isinstance(annotation, list): - path = annotation - else: - TypeError("OPC-ua mapping requires either a list or dict with the path") - return - - #TODO exceptions - - try: - node = self.obj.get_child(path) - except Exception as e: - self.streams.error_stream("Could not get node: %s on server %s: %s", path, self._servername(), e) - raise Exception("Could not get node: %s on server %s: %s", path, self._servername(), e) - - return node - - def setup_value_conversion(self, attribute): - """ - gives the client access to the attribute_wrapper object in order to access all data it could potentially need. - the OPC ua read/write functions require the dimensionality and the type to be known - """ - - dim_x = attribute.dim_x - dim_y = attribute.dim_y - ua_type = numpy_to_OPCua_dict[str(attribute.numpy_type)] # convert the numpy type to a corresponding UA type - - return dim_x, dim_y, ua_type - - def setup_attribute(self, annotation, attribute): - """ - MANDATORY function: is used by the attribute wrapper to get read/write functions. must return the read and write functions - """ - - # process the annotation - node = self._setup_annotation(annotation) - - # get all the necessary data to set up the read/write functions from the attribute_wrapper - dim_x, dim_y, ua_type = self.setup_value_conversion(attribute) - - # configure and return the read/write functions - prot_attr = ProtocolAttribute(node, dim_x, dim_y, ua_type) - - node_name = str(node.get_browse_name())[len("QualifiedName(2:"):] - self.streams.debug_stream("connected OPC ua node {} of type {} to attribute with dimensions: {} x {} ".format(str(node_name)[:len(node_name)-1], str(ua_type)[len("VariantType."):], dim_x, dim_y)) - - # return the read/write functions - return prot_attr.read_function, prot_attr.write_function - - - - -class ProtocolAttribute: - """ - This class provides a small wrapper for the OPC ua read/write functions in order to better organise the code - """ - - def __init__(self, node, dim_x, dim_y, ua_type): - self.node = node - self.dim_y = dim_y - self.dim_x = dim_x - self.ua_type = ua_type - - def read_function(self): - """ - Read_R function - """ - value = numpy.array(self.node.get_value()) - - if self.dim_y != 0: - value = numpy.array(numpy.split(value, indices_or_sections=self.dim_y)) - else: - value = numpy.array(value) - return value - - def write_function(self, value): - """ - write_RW function - """ - # set_data_value(opcua.ua.uatypes.Variant(value = value.tolist(), varianttype=opcua.ua.VariantType.Int32)) - - if self.dim_y != 0: - v = numpy.concatenate(value) - self.node.set_data_value(opcua.ua.uatypes.Variant(value=v.tolist(), varianttype=self.ua_type)) - - elif self.dim_x != 1: - self.node.set_data_value(opcua.ua.uatypes.Variant(value=value.tolist(), varianttype=self.ua_type)) - else: - self.node.set_data_value(opcua.ua.uatypes.Variant(value=value, varianttype=self.ua_type)) diff --git a/PCC/PCC/example/README.md b/PCC/PCC/example/README.md deleted file mode 100644 index d84d08646c3b88417269d864d2de4882e17337d0..0000000000000000000000000000000000000000 --- a/PCC/PCC/example/README.md +++ /dev/null @@ -1,6 +0,0 @@ -####This example provides a more minimal tango device. - -The tango device, named `example_device` provides a number of attribute wrappers named after their type -and dimensionality (E.g `float32_image_R`). - -These attributes make use of the `example_client`, a very minimal implementation of a comms_client. \ No newline at end of file diff --git a/PCC/PCC/example/example_device.py b/PCC/PCC/example/example_device.py deleted file mode 100644 index 35dba23e45425e5f4c6c30ef55ca99678a3a06ce..0000000000000000000000000000000000000000 --- a/PCC/PCC/example/example_device.py +++ /dev/null @@ -1,205 +0,0 @@ -# -*- 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. - -""" PCC Device Server for LOFAR2.0 - -""" - -# PyTango imports -from tango import DebugIt -from tango.server import run -from tango.server import Device -from tango.server import device_property -from tango import DevState -# Additional import - -from clients.example_client import example_client -from attribute_wrapper import * - -__all__ = ["example_device", "main"] - - -class example_device(Device): - client = 0 - name_space_index = 0 - obj = 0 - - # ----------------- - # Device Properties - # ----------------- - - OPC_Server_Name = device_property( - dtype='DevString', - mandatory=True - ) - - OPC_Server_Port = device_property( - dtype='DevULong', - mandatory=True - ) - - OPC_Time_Out = device_property( - dtype='DevDouble', - mandatory=True - ) - - # ---------- - # 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) - - int64_spectrum_R = attribute_wrapper(comms_annotation="numpy.int64 type read spectrum (len = 8)", datatype=numpy.int64, dims=(8,)) - str_spectrum_RW = attribute_wrapper(comms_annotation="numpy.str type read/write spectrum (len = 8)", datatype=numpy.str_, dims=(8,), access=AttrWriteType.READ_WRITE) - - 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) - - 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) - 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) - - attr_list = [ bool_scalar_R, bool_scalar_RW, int64_spectrum_R, str_spectrum_RW, double_image_R, double_image_RW, int32_scalar_R, - uint16_spectrum_RW, float32_image_R, uint8_image_RW] - - def setup_value_dict(self): - self.value_dict = {} - for i in self.attr_list: - self.value_dict[str(i)] = i.initial_value() - - def init_device(self): - """ Instantiates the device in the OFF state. """ - - # NOTE: Will delete_device first, if necessary - Device.init_device(self) - - self.set_state(DevState.OFF) - - def initialise(self): - """Initialises the attributes and properties of the PCC.""" - - self.set_state(DevState.INIT) - - - #set up the OPC ua client - self.example_client = example_client(self.Standby, self.Fault, self) - - - # NOTE: MANDATORY will contain all attribute values for this tango device instance - self.setup_value_dict() - - # map an access helper class - for i in self.attr_list: - i.set_comm_client(self.example_client) - - - self.example_client.start() - - 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. - - 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). - """ - self.debug_stream("Shutting down...") - - self.Off() - self.debug_stream("Shut down. Good bye.") - - # -------- - # Commands - # -------- - - @command() - @only_in_states([DevState.FAULT, DevState.OFF]) - @DebugIt() - def Initialise(self): - """ - Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. - - :return:None - """ - - self.initialise() - - @only_in_states([DevState.INIT]) - def Standby(self): - """ - Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. - - :return:None - """ - print("setting standby state") - self.set_state(DevState.STANDBY) - - @command() - @only_in_states([DevState.STANDBY]) - @DebugIt() - def On(self): - """ - Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. - - :return:None - """ - - self.set_state(DevState.ON) - - @command() - @DebugIt() - def Off(self): - """ - Command to ask for shutdown of this device. - - :return:None - """ - if self.get_state() == DevState.OFF: - # Already off. Don't complain. - return - - # Turn off - self.set_state(DevState.OFF) - - # Stop keep-alive - self.opcua_connection.stop() - - # Turn off again, in case of race conditions through reconnecting - self.set_state(DevState.OFF) - - @command() - @only_in_states([DevState.ON, DevState.INIT, DevState.STANDBY]) - @DebugIt() - def Fault(self): - """ - FAULT state is used to indicate our connection with the OPC-UA server is down. - - This device will try to reconnect once, and transition to the ON state on success. - - If reconnecting fails, the user needs to call Initialise() to retry to restart this device. - - :return:None - """ - self.set_state(DevState.FAULT) - - -# ---------- -# Run server -# ---------- -def main(args=None, **kwargs): - """Main function of the example module.""" - return run((example_device,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/PCC/PCC/example_device.py b/PCC/PCC/example_device.py deleted file mode 100644 index 6e1842f8d04b8ccaaae3b5c8ec5c9d87925a62e0..0000000000000000000000000000000000000000 --- a/PCC/PCC/example_device.py +++ /dev/null @@ -1,205 +0,0 @@ -# -*- 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. - -""" PCC Device Server for LOFAR2.0 - -""" - -# PyTango imports -from tango import DebugIt -from tango.server import run -from tango.server import Device -from tango.server import device_property -from tango import DevState -# Additional import - -from clients.example_client import example_client -from attribute_wrapper import * - -__all__ = ["example_device", "main"] - - -class example_device(Device): - client = 0 - name_space_index = 0 - obj = 0 - - # ----------------- - # Device Properties - # ----------------- - - OPC_Server_Name = device_property( - dtype='DevString', - mandatory=True - ) - - OPC_Server_Port = device_property( - dtype='DevULong', - mandatory=True - ) - - OPC_Time_Out = device_property( - dtype='DevDouble', - mandatory=True - ) - - # ---------- - # 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) - - int64_spectrum_R = attribute_wrapper(comms_annotation="numpy.int64 type read spectrum (len = 8)", datatype=numpy.int64, dims=(8,)) - str_spectrum_RW = attribute_wrapper(comms_annotation="numpy.str type read/write spectrum (len = 8)", datatype=numpy.str_, dims=(8,), access=AttrWriteType.READ_WRITE) - - 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) - - 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) - 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) - - attr_list = [ bool_scalar_R, bool_scalar_RW, int64_spectrum_R, str_spectrum_RW, double_image_R, double_image_RW, int32_scalar_R, - uint16_spectrum_RW, float32_image_R, uint8_image_RW] - - def setup_value_dict(self): - self.value_dict = {} - for i in self.attr_list: - self.value_dict[str(i)] = i.initial_value() - - def init_device(self): - """ Instantiates the device in the OFF state. """ - - # NOTE: Will delete_device first, if necessary - Device.init_device(self) - - self.set_state(DevState.OFF) - - def initialise(self): - """Initialises the attributes and properties of the PCC.""" - - self.set_state(DevState.INIT) - - - #set up the OPC ua client - self.example_client = example_client(self.Standby, self.Fault, self) - - - # NOTE: MANDATORY will contain all attribute values for this tango device instance - self.setup_value_dict() - - # map an access helper class - for i in self.attr_list: - i.set_comm_client(self.example_client) - - - self.example_client.start() - - 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. - - 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). - """ - self.debug_stream("Shutting down...") - - self.Off() - self.debug_stream("Shut down. Good bye.") - - # -------- - # Commands - # -------- - - @command() - @only_in_states([DevState.FAULT, DevState.OFF]) - @DebugIt() - def Initialise(self): - """ - Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. - - :return:None - """ - - self.initialise() - - @only_in_states([DevState.INIT]) - def Standby(self): - """ - Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. - - :return:None - """ - print("setting standby state") - self.set_state(DevState.STANDBY) - - @command() - @only_in_states([DevState.STANDBY]) - @DebugIt() - def On(self): - """ - Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. - - :return:None - """ - - self.set_state(DevState.ON) - - @command() - @DebugIt() - def Off(self): - """ - Command to ask for shutdown of this device. - - :return:None - """ - if self.get_state() == DevState.OFF: - # Already off. Don't complain. - return - - # Turn off - self.set_state(DevState.OFF) - - # Stop keep-alive - self.opcua_connection.stop() - - # Turn off again, in case of race conditions through reconnecting - self.set_state(DevState.OFF) - - @command() - @only_in_states([DevState.ON, DevState.INIT, DevState.STANDBY]) - @DebugIt() - def Fault(self): - """ - FAULT state is used to indicate our connection with the OPC-UA server is down. - - This device will try to reconnect once, and transition to the ON state on success. - - If reconnecting fails, the user needs to call Initialise() to retry to restart this device. - - :return:None - """ - self.set_state(DevState.FAULT) - - -# ---------- -# Run server -# ---------- -def main(args=None, **kwargs): - """Main function of the PCC module.""" - return run((example_device,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/PCC/PCC/release.py b/PCC/PCC/release.py deleted file mode 100644 index 5c73788786197b9f66c7b94dfb27cb747be6776d..0000000000000000000000000000000000000000 --- a/PCC/PCC/release.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- 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. - -"""Release information for Python Package""" - -name = """tangods-PCC""" -version = "1.0.0" -version_info = version.split(".") -description = """""" -author = "Thomas Juerges" -author_email = "jurges at astron.nl" -license = """APACHE""" -url = """https://git.astron.nl/lofar2.0/tango.git""" -copyright = """""" diff --git a/PCC/README.rst b/PCC/README.rst deleted file mode 100644 index 9d42e957e28bd5e452349ec56c00dab61a4def46..0000000000000000000000000000000000000000 --- a/PCC/README.rst +++ /dev/null @@ -1,25 +0,0 @@ -## PCC Device Server for LOFAR2.0 - - -## Requirement - -- PyTango >= 8.1.6 -- devicetest (for using tests) -- sphinx (for building sphinx documentation) - -## Installation - -Run python setup.py install - -If you want to build sphinx documentation, -run python setup.py build_sphinx - -If you want to pass the tests, -run python setup.py test - -## Usage - -Now you can start your device server in any -Terminal or console by calling it : - -PCC instance_name diff --git a/PCC/requirements.txt b/PCC/requirements.txt deleted file mode 100644 index 3b3b3b08bb560cfbe4fed2e7c7a0241f02f0af24..0000000000000000000000000000000000000000 --- a/PCC/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -opcua >= 0.98.9 diff --git a/PCC/setup.py b/PCC/setup.py deleted file mode 100644 index 0d197078aa73c4adfd461e86f94bdc5b90554629..0000000000000000000000000000000000000000 --- a/PCC/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# -*- 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. - -import os -import sys -from setuptools import setup - -setup_dir = os.path.dirname(os.path.abspath(__file__)) - -# make sure we use latest info from local code -sys.path.insert(0, setup_dir) - -readme_filename = os.path.join(setup_dir, 'README.rst') -with open(readme_filename) as file: - long_description = file.read() - -release_filename = os.path.join(setup_dir, 'PCC', 'release.py') -exec(open(release_filename).read()) - -pack = ['PCC'] - -setup(name=name, - version=version, - description='', - packages=pack, - include_package_data=True, - test_suite="test", - entry_points={'console_scripts':['PCC = PCC:main']}, - author='Thomas Juerges', - author_email='jurges at astron.nl', - license='APACHE', - long_description=long_description, - url='https://git.astron.nl/lofar2.0/tango.git', - platforms="Unix Like" - ) diff --git a/PCC/test/PCC_test.py b/PCC/test/PCC_test.py deleted file mode 100644 index 37b80b7e27125b85765da7f7b29e261f32eef1f6..0000000000000000000000000000000000000000 --- a/PCC/test/PCC_test.py +++ /dev/null @@ -1,89 +0,0 @@ -######################################################################################### -# -*- 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. -######################################################################################### -"""Contain the tests for the RCU-SCC Device Server for LOFAR2.0.""" - -# Path -import sys -import os -path = os.path.join(os.path.dirname(__file__), os.pardir) -sys.path.insert(0, os.path.abspath(path)) - -# Imports -import pytest -from mock import MagicMock - -from PyTango import DevState - -# PROTECTED REGION ID(PCC.test_additional_imports) ENABLED START # -# PROTECTED REGION END # // PCC.test_additional_imports - - -# Device test case -@pytest.mark.usefixtures("tango_context", "initialize_device") -# PROTECTED REGION ID(PCC.test_PCC_decorators) ENABLED START # -# PROTECTED REGION END # // PCC.test_PCC_decorators -class TestPCC(object): - """Test case for packet generation.""" - - properties = { - 'OPC_Server_Name': '', - 'OPC_Server_Port': '', - 'OPC_Time_Out': '', - } - - @classmethod - def mocking(cls): - """Mock external libraries.""" - # Example : Mock numpy - # cls.numpy = PCC.numpy = MagicMock() - # PROTECTED REGION ID(PCC.test_mocking) ENABLED START # - # PROTECTED REGION END # // PCC.test_mocking - - def test_properties(self, tango_context): - # Test the properties - # PROTECTED REGION ID(PCC.test_properties) ENABLED START # - # PROTECTED REGION END # // PCC.test_properties - pass - - # PROTECTED REGION ID(PCC.test_State_decorators) ENABLED START # - # PROTECTED REGION END # // PCC.test_State_decorators - def test_State(self, tango_context): - """Test for State""" - # PROTECTED REGION ID(PCC.test_State) ENABLED START # - assert tango_context.device.State() == DevState.UNKNOWN - # PROTECTED REGION END # // PCC.test_State - - # PROTECTED REGION ID(PCC.test_Status_decorators) ENABLED START # - # PROTECTED REGION END # // PCC.test_Status_decorators - def test_Status(self, tango_context): - """Test for Status""" - # PROTECTED REGION ID(PCC.test_Status) ENABLED START # - assert tango_context.device.Status() == "The device is in UNKNOWN state." - # PROTECTED REGION END # // PCC.test_Status - - - # PROTECTED REGION ID(PCC.test_time_offset_rw_decorators) ENABLED START # - # PROTECTED REGION END # // PCC.test_time_offset_rw_decorators - def test_time_offset_rw(self, tango_context): - """Test for time_offset_rw""" - # PROTECTED REGION ID(PCC.test_time_offset_rw) ENABLED START # - assert tango_context.device.time_offset_rw == 0 - # PROTECTED REGION END # // PCC.test_time_offset_rw - - # PROTECTED REGION ID(PCC.test_time_offset_r_decorators) ENABLED START # - # PROTECTED REGION END # // PCC.test_time_offset_r_decorators - def test_time_offset_r(self, tango_context): - """Test for time_offset_r""" - # PROTECTED REGION ID(PCC.test_time_offset_r) ENABLED START # - assert tango_context.device.time_offset_r == 0 - # PROTECTED REGION END # // PCC.test_time_offset_r - - diff --git a/PCC/test/__init__.py b/PCC/test/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/PCC/test/test-PCC.py b/PCC/test/test-PCC.py deleted file mode 100644 index d151a5d31203690883b24de7916470d8acc8a653..0000000000000000000000000000000000000000 --- a/PCC/test/test-PCC.py +++ /dev/null @@ -1,28 +0,0 @@ -#! /usr/bin/env python3 - -import opcua -from time import sleep - -port = 4840 -host = "10.87.2.8" - -client = opcua.Client("opc.tcp://{}:{}".format(host, port)) -client.connect() -obj = client.get_objects_node() -name_space_index = 2 -time_offset = obj.get_child("{}:time_offset".format(name_space_index)) -time_offset_R = time_offset.get_child("{}:time_offset_R".format(name_space_index)) -time_offset_RW = time_offset.get_child("{}:time_offset_RW".format(name_space_index)) -old_time_offset = time_offset_R.get_value() -target_time_offset = 1 -new_time_offset = old_time_offset + target_time_offset -time_offset_RW.set_value(new_time_offset) -sleep(1.0) -latest_time_offset = time_offset_R.get_value() -difference_time_offset = latest_time_offset - old_time_offset -if difference_time_offset != target_time_offset: - print("ERROR: Setting and reading back time_offset. old_time_offset = %d, new_time_offset = %d, latest_time_offset = %d, target_time_offset = %d, difference_time_offset = %d." % (old_time_offset, new_time_offset, latest_time_offset, target_time_offset, difference_time_offset)) -else: - print("SUCCESS: Setting and reading back time_offset.") -time_offset_RW.set_value(old_time_offset) -client.disconnect() diff --git a/SDP/LICENSE.txt b/SDP/LICENSE.txt deleted file mode 100644 index ae533fce6dc75595f91290511273c7ff62312f76..0000000000000000000000000000000000000000 --- a/SDP/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, -ASTRON Netherlands Institute for Radio Astronomy - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/SDP/MANIFEST.in b/SDP/MANIFEST.in deleted file mode 100644 index d9d9aaba41c43f633c9a02635e72b4eb1b791f50..0000000000000000000000000000000000000000 --- a/SDP/MANIFEST.in +++ /dev/null @@ -1,9 +0,0 @@ -recursive-include RCUSCC *.py -recursive-include test *.py -include *.rst -include RCUSCC.xmi -include *.txt -graft docs - -global-exclude *.pyc -global-exclude *.pyo diff --git a/SDP/NOTICE b/SDP/NOTICE deleted file mode 100644 index 9c7867598e17de5d69b8c26656caa8316cd0a30f..0000000000000000000000000000000000000000 --- a/SDP/NOTICE +++ /dev/null @@ -1,8 +0,0 @@ -Citation Notice version 1.0 -This Citation Notice is part of the LOFAR software suite. -Parties that use ASTRON Software resulting in papers and/or publications are requested to -refer to the DOI(s) that correspond(s) to the version(s) of the ASTRON Software used: -<List of DOIs> -Parties that use ASTRON Software for purposes that do not result in publications (e.g. -commercial parties) are asked to inform ASTRON about their use of ASTRON Software, by -sending an email to including the DOIs mentioned above in the message. \ No newline at end of file diff --git a/SDP/README.rst b/SDP/README.rst deleted file mode 100644 index aafea1e3022ae9546fd62e1a2b1474dfc1bbef6a..0000000000000000000000000000000000000000 --- a/SDP/README.rst +++ /dev/null @@ -1,25 +0,0 @@ -## SDP Device Server for LOFAR2.0 - - -## Requirement - -- PyTango >= 8.1.6 -- devicetest (for using tests) -- sphinx (for building sphinx documentation) - -## Installation - -Run python setup.py install - -If you want to build sphinx documentation, -run python setup.py build_sphinx - -If you want to pass the tests, -run python setup.py test - -## Usage - -Now you can start your device server in any -Terminal or console by calling it : - -SDP instance_name diff --git a/SDP/SDP/__init__.py b/SDP/SDP/__init__.py deleted file mode 100644 index cf68b03729a1a4d562556c9765b9e7389fd49b18..0000000000000000000000000000000000000000 --- a/SDP/SDP/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of the SDP project -# -# -# -# Distributed under the terms of the APACHE license. -# See LICENSE.txt for more info. - -"""SDP Device Server for LOFAR2.0 - -""" - -from . import release -from .SDP import SDP, main - -__version__ = release.version -__version_info__ = release.version_info -__author__ = release.author diff --git a/SDP/SDP/__main__.py b/SDP/SDP/__main__.py deleted file mode 100644 index 5ef0710c551b94138cfbe4b1c762af830dae9a62..0000000000000000000000000000000000000000 --- a/SDP/SDP/__main__.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of the SDP project -# -# -# -# Distributed under the terms of the APACHE license. -# See LICENSE.txt for more info. - -from SDP import main -main() diff --git a/SDP/SDP/attribute_wrapper.py b/SDP/SDP/attribute_wrapper.py deleted file mode 100644 index ff1937c17dbb377dc6a0f9737d6b64379294d5b8..0000000000000000000000000000000000000000 --- a/SDP/SDP/attribute_wrapper.py +++ /dev/null @@ -1,153 +0,0 @@ -from tango.server import attribute, command -from tango import DebugIt -from tango import AttrWriteType - -import numpy - -from wrappers import only_in_states, only_when_on, fault_on_error - - -def swap_dims_tuple(dims): - """ - arrays are inconsistent between tango and numpy. - This function exists to swap around the tuple containing the dimension data - """ - if len(dims) == 2: - return tuple((dims[1], dims[0])) - else: - return dims - - - -class attribute_wrapper(attribute): - """ - Wraps all the attributes in a wrapper class to manage most of the redundant code behind the scenes - """ - - def __init__(self, comms_annotation=None, datatype=None, dims=1, **kwargs): - """ - wraps around the tango Attribute class. Provides an easier interface for 1d or 2d arrays. Also provides a way to abstract - managing the communications interface. - """ - - # ensure the type is a numpy array - if "numpy" not in str(datatype) and type(datatype) != str: - raise TypeError("Attribute needs to be a Tango-supported numpy or str type, but has type \"%s\"" % (datatype,)) - - - - self.comms_annotation = comms_annotation # store data that can be used by the comms interface. not used by the wrapper itself - self.numpy_type = datatype # tango changes our attribute to their representation (E.g numpy.int64 becomes "DevLong64") - - wrap_RW = kwargs.get("access", AttrWriteType.READ) - - self.init_value = kwargs.get("init_value", None) # if not None, gets used as default value - - max_dim_y = 0 - - # tango doesn't recognise numpy.str_, for consistencies sake we convert it here and hide this from the top level - # NOTE: discuss, idk if this is an important detail somewhere else - if datatype is numpy.str_: - datatype = str - - # check if not scalar - if isinstance(dims, tuple): - - # fill the array with initial values - # self.value = numpy.zeros(swap_dims_tuple(dims), dtype=datatype) - # self.value = numpy.full(swap_dims_tuple(dims), datatype(0), dtype=data_type) - - # get first dimension - max_dim_x = dims[0] - - # single dimension/spectrum requires the datatype to be wrapped in a tuple - datatype = (datatype,) - - if len(dims) == 2: - # get second dimension - max_dim_y = dims[1] - # wrap the datatype tuple in another tuple for 2d arrays/images - datatype = (datatype,) - else: - # scalar, just set the single dimension - max_dim_x = 1 - - - if wrap_RW == AttrWriteType.READ_WRITE: - """ if the attribute is of READ_WRITE type, assign the RW and write function to it""" - - @only_when_on - @fault_on_error - def read_RW(device): - # print("read_RW {}, {}x{}, {}, {}".format(me.name, me.dim_x, me.dim_y, me.attr_type, me.value)) - """ - read_RW returns the value that was last written to the attribute - """ - try: - return device.value_dict[str(self)] - except: - print() - - @only_when_on - @fault_on_error - def write_RW(device, value): - """ - _write_RW writes a value to this attribute - """ - self.write_function(value) - device.value_dict[str(self)] = value - - self.fget = read_RW - self.fset = write_RW - - - else: - """ if the attribute is of READ type, assign the read function to it""" - - @only_when_on - @fault_on_error - def read_R(device): - """ - _read_R reads the attribute value, stores it and returns it" - """ - device.value_dict[str(self)] = self.read_function() - return device.value_dict[str(self)] - - self.fget = read_R - - super().__init__(dtype=datatype, max_dim_y=max_dim_y, max_dim_x=max_dim_x, **kwargs) - - return - - def initial_value(self): - """ - returns a numpy array filled with zeroes fit to the size of the attribute. Or if init_value is not the default None, return that value - """ - if self.init_value is not None: - return self.init_value - - if self.dim_y > 1: - dims = (self.dim_x, self.dim_y) - else: - dims = (self.dim_x,) - - # x and y are swapped for numpy and Tango. to maintain tango conventions, x and y are swapped for numpy - value = numpy.zeros(swap_dims_tuple(dims), dtype=self.numpy_type) - return value - - def set_comm_client(self, client): - """ - takes a communications client as input arguments This client should be of a class containing a "get_mapping" function - and return a read and write function that the wrapper will use to get/set data. - """ - try: - self.read_function, self.write_function = client.setup_attribute(self.comms_annotation, self) - except: - def pass_func(value=None): - pass - print("setting comm_client failed. using pass function instead") - - self.read_function = pass_func - self.write_function = pass_func - - diff --git a/SDP/SDP/comms_client.py b/SDP/SDP/comms_client.py deleted file mode 100644 index 544df539d972cff9da37ac6a2dce00db27d76796..0000000000000000000000000000000000000000 --- a/SDP/SDP/comms_client.py +++ /dev/null @@ -1,114 +0,0 @@ -from threading import Thread -import socket -import time -import numpy - -import opcua -from opcua import Client - -from tango import DevState - - -class CommClient(Thread): - """ - The ProtocolHandler class is the generic interface class between the tango attribute_wrapper and the outside world - """ - - def __init__(self, standby_func, fault_func, streams, try_interval=2): - """ - - """ - self.standby_func = standby_func - self.fault_func = fault_func - self.try_interval = try_interval - self.streams = streams - self.stopping = False - self.connected = False - - super().__init__(daemon=True) - - def connect(self): - """ - Function used to connect to the client. - """ - self.connected = True - return True - - def disconnect(self): - """ - Function used to connect to the client. - """ - self.connected = False - - def run(self): - - # Explicitly connect - if not self.connect(): - # hardware or infra is down -- needs fixing first - self.fault_func() - return - - self.standby_func() - - self.stopping = False - while not self.stopping: - # keep trying to connect - print("connected check") - if not self.connected: - print("not connected, try to connect") - if self.connect(): - print("connected now, call on_func") - self.standby_func() - else: - # we retry only once, to catch exotic network issues. if the infra or hardware is down, - # our device cannot help, and must be reinitialised after the infra or hardware is fixed. - self.fault_func() - return - - # keep checking if the connection is still alive - try: - while not self.stopping: - self.ping() - time.sleep(self.try_interval) - except Exception as e: - self.streams.error_stream("Fault condition in communication detected.", e) - - # technically, we may not have dropped the connection, but encounter a different error. so explicitly disconnect. - self.disconnect() - - # signal that we're disconnected - self.fault_func() - - def ping(self): - pass - - def stop(self): - """ - Stop connecting & disconnect. Can take a few seconds for the timeouts to hit. - """ - - if not self.ident: - # have not yet been started, so nothing to do - return - - self.stopping = True - self.join() - - self.disconnect() - - def setup_attribute(self, annotation, attribute): - ''' - This function is responsible for providing the attribute_wrapper with a read/write function - How this is done is implementation specific. - The setup-attribute has access to the comms_annotation provided to the attribute wrapper to pass along to the comms client - as well as a reference to the attribute itself. - - Examples: - - File system: get_mapping returns functions that read/write a fixed - number of bytes at a fixed location in a file. (SEEK) - - OPC-UA: traverse the OPC-UA tree until the node is found. - Then return the read/write functions for that node which automatically - convert values between Python and OPC-UA. - ''' - AssertionError("the setup_attribute must be implemented and provide return a valid read/write function for the attribute") - diff --git a/SDP/SDP/hardware_device.py b/SDP/SDP/hardware_device.py deleted file mode 100644 index 6b665055cf35387ea3be4eebfb12f8928cfc6e4e..0000000000000000000000000000000000000000 --- a/SDP/SDP/hardware_device.py +++ /dev/null @@ -1,175 +0,0 @@ -# -*- 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. - -""" PCC Device Server for LOFAR2.0 - -""" - -# PyTango imports -from tango import DebugIt -from tango.server import run -from tango.server import Device -from tango.server import device_property -from tango import DevState -# Additional import - -from clients.opcua_connection import OPCUAConnection -from attribute_wrapper import * - - -__all__ = ["hardware_device"] - -class hardware_device(Device): - """ - - **Properties:** - - States are as follows: - INIT = Device is initialising. - STANDBY = Device is initialised, but pends external configuration and an explicit turning on, - ON = Device is fully configured, functional, controls the hardware, and is possibly actively running, - FAULT = Device detected an unrecoverable error, and is thus malfunctional, - OFF = Device is turned off, drops connection to the hardware, - - The following state transitions are implemented: - boot -> OFF: Triggered by tango. Device will be instantiated, - OFF -> INIT: Triggered by device. Device will initialise (connect to hardware, other devices), - INIT -> STANDBY: Triggered by device. Device is initialised, and is ready for additional configuration by the user, - STANDBY -> ON: Triggered by user. Device reports to be functional, - * -> FAULT: Triggered by device. Device has degraded to malfunctional, for example because the connection to the hardware is lost, - * -> FAULT: Triggered by user. Emulate a forced malfunction for integration testing purposes, - * -> OFF: Triggered by user. Device is turned off. Triggered by the Off() command, - FAULT -> INIT: Triggered by user. Device is reinitialised to recover from an error, - - The user triggers their transitions by the commands reflecting the target state (Initialise(), On(), Fault()). - """ - - @classmethod - def attr_list(cls): - """ Return a list of all the attribute_wrapper members of this class. """ - return [v for k, v in cls.__dict__.items() if type(v) == attribute_wrapper] - - def init_device(self): - """ Instantiates the device in the OFF state. """ - - # NOTE: Will delete_device first, if necessary - Device.init_device(self) - - self.set_state(DevState.OFF) - - - 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. - - 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). - """ - self.debug_stream("Shutting down...") - - self.Off() - self.debug_stream("Shut down. Good bye.") - - # -------- - # Commands - # -------- - - @command() - @only_in_states([DevState.FAULT, DevState.OFF]) - @DebugIt() - def Initialise(self): - """ - Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. - - :return:None - """ - self.set_state(DevState.INIT) - self.initialise() - - # if self.get_state() == DevState.STANDBY: - # # Already STANDBY. Don't complain. - # return - # self.set_state(DevState.STANDBY) - - @only_in_states([DevState.INIT]) - def Standby(self): - """ - Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. - - :return:None - """ - - self.standby() - self.set_state(DevState.STANDBY) - - @command() - @only_in_states([DevState.STANDBY]) - @DebugIt() - def On(self): - """ - Command to ask for initialisation of this device. Can only be called in FAULT or OFF state. - - :return:None - """ - self.on() - self.set_state(DevState.ON) - - @command() - @DebugIt() - def Off(self): - """ - Command to ask for shutdown of this device. - - :return:None - """ - if self.get_state() == DevState.OFF: - # Already off. Don't complain. - return - - # Turn off - self.set_state(DevState.OFF) - - self.off() - - # Turn off again, in case of race conditions through reconnecting - self.set_state(DevState.OFF) - - @command() - @only_in_states([DevState.ON, DevState.INIT, DevState.STANDBY]) - @DebugIt() - def Fault(self): - """ - FAULT state is used to indicate our connection with the OPC-UA server is down. - - This device will try to reconnect once, and transition to the ON state on success. - - If reconnecting fails, the user needs to call Initialise() to retry to restart this device. - - :return:None - """ - self.fault() - self.set_state(DevState.FAULT) - - - # functions that can be overloaded - def fault(self): - pass - def off(self): - pass - def on(self): - pass - def standby(self): - pass - def initialise(self): - pass - diff --git a/SDP/SDP/main.py b/SDP/SDP/main.py deleted file mode 100644 index 6fae6c9e440b093c6d607cb53eb5509ec5b3fbe8..0000000000000000000000000000000000000000 --- a/SDP/SDP/main.py +++ /dev/null @@ -1,61 +0,0 @@ -from tango.server import run -from tango.server import Device -from tango.server import attribute, command -from tango import AttrWriteType - -import devices.PCC -devices.PCC.main() - -# from attribute_wrapper import * -# -# import numpy -# # -# # class TangoDevice(Device): -# # def init_device(self): -# # Device.init_device(self) -# # self._my_attribute = 0.0 -# # -# # @attribute(label="stuff", unit="stuff_unit", dtype="DevDouble", doc="blah blah blah") -# # def my_attribute(self): -# # """some stuff""" -# # return 123456.123456 -# # -# # @my_attribute.write -# # def my_attribute(self, set_point): -# # self._my_attribute = set_point -# -# -# test_obj1 = attribute_wrapper(dtype="DevLong64", label="test1", max_dim_x=32, max_dim_y=3, access=AttrWriteType.READ_WRITE) -# print(test_obj1._read_RW()) -# test_obj1._write_RW(numpy.full((32, 3), 1)) -# -# test_obj2 = attribute_wrapper(dtype="DevDouble", label="test2", max_dim_x=32, max_dim_y=1, access=AttrWriteType.READ_WRITE) -# print(test_obj2._read_R()) -# test_obj2._write_RW(numpy.full((32, 1), 1.0)) -# -# test_obj3 = attribute_wrapper(dtype="DevString", label="test3", max_dim_x=1, max_dim_y=1, access=AttrWriteType.READ_WRITE) -# print(test_obj3._read_RW()) -# test_obj3._write_RW(numpy.full((1, 1), "test")) -# -# -# print(test_obj1._read_RW()) -# print(test_obj2._read_RW()) -# print(test_obj3._read_RW()) -# -# -# # def decorator(func): -# # def wrapper(arg1, arg2): -# # print("the decorator caught: ", arg1, arg2) -# # func(arg1, arg2) -# # return wrapper -# # -# # @decorator -# # def test(a, b): -# # print("") -# -# device_list = [] -# -# device_list.append(attribute_wrapper()) -# -# -# diff --git a/SDP/SDP/release.py b/SDP/SDP/release.py deleted file mode 100644 index 74a9dd436a73d6acd8d9c7918c63dfc95b49ca09..0000000000000000000000000000000000000000 --- a/SDP/SDP/release.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of the SDP project -# -# -# -# Distributed under the terms of the APACHE license. -# See LICENSE.txt for more info. - -"""Release information for Python Package""" - -name = """tangods-sdp""" -version = "1.0.0" -version_info = version.split(".") -description = """""" -author = "Thomas Juerges" -author_email = "jurges at astron.nl" -license = """APACHE""" -url = """https://git.astron.nl/lofar2.0/tango.git""" -copyright = """""" diff --git a/SDP/SDP/wrappers.py b/SDP/SDP/wrappers.py deleted file mode 100644 index 9dbc45a68dc850b36bd30a0a5b8664d104b58e30..0000000000000000000000000000000000000000 --- a/SDP/SDP/wrappers.py +++ /dev/null @@ -1,53 +0,0 @@ -from tango import DevState, Except -from functools import wraps -import traceback - -__all__ = ["only_in_states", "only_when_on", "fault_on_error"] - -def only_in_states(allowed_states): - """ - Wrapper to call and return the wrapped function if the device is - in one of the given states. Otherwise a PyTango exception is thrown. - """ - def wrapper(func): - @wraps(func) - def state_check_wrapper(self, *args, **kwargs): - if self.get_state() in allowed_states: - return func(self, *args, **kwargs) - - self.warn_stream("Illegal command: Function %s can only be called in states %s. Current state: %s" % (func.__name__, allowed_states, self.get_state())) - Except.throw_exception("IllegalCommand", "Function can only be called in states %s. Current state: %s" % (allowed_states, self.get_state()), func.__name__) - - return state_check_wrapper - - return wrapper - -def only_when_on(func): - """ - Wrapper to call and return the wrapped function if the device is - in the ON state. Otherwise None is returned and nothing - will be called. - """ - @wraps(func) - def when_on_wrapper(self, *args, **kwargs): - if self.get_state() == DevState.ON: - return func(self, *args, **kwargs) - - return None - - return when_on_wrapper - -def fault_on_error(func): - """ - Wrapper to catch exceptions. Sets the device in a FAULT state if any occurs. - """ - @wraps(func) - def error_wrapper(self, *args, **kwargs): - try: - return func(self, *args, **kwargs) - except Exception as e: - self.error_stream("Function failed. Trace: %s", traceback.format_exc()) - self.Fault() - return None - - return error_wrapper diff --git a/SDP/requirements.txt b/SDP/requirements.txt deleted file mode 100644 index a0195dd42b98b0f3194e55e91cded17608ed6ee3..0000000000000000000000000000000000000000 --- a/SDP/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -opcua >= 0.98.9 -numpy diff --git a/SDP/setup.py b/SDP/setup.py deleted file mode 100644 index 8def2ec90e9cf446fc680fe7740f2c18aaa19975..0000000000000000000000000000000000000000 --- a/SDP/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# This file is part of the SDP project -# -# -# -# Distributed under the terms of the APACHE license. -# See LICENSE.txt for more info. - -import os -import sys -from setuptools import setup - -setup_dir = os.path.dirname(os.path.abspath(__file__)) - -# make sure we use latest info from local code -sys.path.insert(0, setup_dir) - -readme_filename = os.path.join(setup_dir, 'README.rst') -with open(readme_filename) as file: - long_description = file.read() - -release_filename = os.path.join(setup_dir, 'SDP', 'release.py') -exec(open(release_filename).read()) - -pack = ['SDP'] - -setup(name=name, - version=version, - description='', - packages=pack, - include_package_data=True, - test_suite="test", - entry_points={'console_scripts':['SDP = SDP:main']}, - author='Thomas Juerges', - author_email='jurges at astron.nl', - license='APACHE', - long_description=long_description, - url='https://git.astron.nl/lofar2.0/tango.git', - platforms="Unix Like" - ) diff --git a/devices/HW_device_implementation.py b/devices/HW_device_implementation.py new file mode 100644 index 0000000000000000000000000000000000000000..0c76b0c519d96e0491da7d1852f48afc0bb74752 --- /dev/null +++ b/devices/HW_device_implementation.py @@ -0,0 +1,89 @@ +# -*- 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. + +""" PCC Device Server for LOFAR2.0 + +""" + +# PyTango imports +from tango.server import run +# Additional import + +from src.hardware_device import * + + +__all__ = ["HW_dev"] + +class HW_dev(hardware_device): + """ + This class is the minimal (read empty) implementation of a class using 'hardware_device' + """ + + # ---------- + # Attributes + # ---------- + """ + attribute wrapper objects can be declared here. All attribute wrapper objects will get automatically put in a ist (attr_list) for easy access + + example = attribute_wrapper(comms_annotation="this is an example", datatype=numpy.double, dims=(8, 2), access=AttrWriteType.READ_WRITE) + ... + + """ + + 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. + + 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). + """ + 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): + """Main function of the PCC module.""" + return run((HW_dev,), args=args, **kwargs) + + +if __name__ == '__main__': + main() + diff --git a/SDP/SDP/LICENSE.txt b/devices/LICENSE.txt similarity index 100% rename from SDP/SDP/LICENSE.txt rename to devices/LICENSE.txt diff --git a/PCC/PCC/PCC.py b/devices/PCC.py similarity index 88% rename from PCC/PCC/PCC.py rename to devices/PCC.py index 660d12e712c3281a9b4d080ee9e2b1de6c545f16..a0cb16d4ac6b2bc50e06d5153f270366707b6104 100644 --- a/PCC/PCC/PCC.py +++ b/devices/PCC.py @@ -12,16 +12,13 @@ """ # PyTango imports -from tango import DebugIt from tango.server import run -from tango.server import Device from tango.server import device_property -from tango import DevState # Additional import from clients.opcua_connection import OPCUAConnection -from attribute_wrapper import * -from hardware_device import * +from src.attribute_wrapper import * +from src.hardware_device import * __all__ = ["PCC", "main"] @@ -89,6 +86,8 @@ class PCC(hardware_device): RCU_monitor_rate_RW = attribute_wrapper(comms_annotation=["2:PCC", "2:RCU_monitor_rate_RW"], datatype=numpy.float64, access=AttrWriteType.READ_WRITE) def setup_value_dict(self): + """ set the initial value for all the attribute wrapper objects""" + self.value_dict = {str(i): i.initial_value() for i in self.attr_list()} def always_executed_hook(self): @@ -110,41 +109,33 @@ class PCC(hardware_device): # -------- # 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 """ # Stop keep-alive self.opcua_connection.stop() - 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 state is set to STANDBY """ - """Initialises the attributes and properties of the PCC.""" - #set up the OPC ua client - self.OPCua_client = OPCUAConnection("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), self.OPC_Time_Out, self.Standby, self.Fault, self) + """Initialises the attributes, values and properties of the PCC.""" - # will contain all the values for this object + # will contain all the values for this device self.setup_value_dict() - # map an access helper class + #set up the OPC ua client + self.OPCua_client = OPCUAConnection("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), self.OPC_Time_Out, self.Standby, self.Fault, self) + + # map the attributes to the OPC ua comm client for i in self.attr_list(): i.set_comm_client(self.OPCua_client) self.OPCua_client.start() + # -------- + # Commands + # -------- + # ---------- # Run server # ---------- diff --git a/SDP/SDP/README.md b/devices/README.md similarity index 64% rename from SDP/SDP/README.md rename to devices/README.md index d7926f28a9a0660f25eb7824ed38af0fd41be25c..ec8659a855ced71f01cd419d1f1c7c919261b6e6 100644 --- a/SDP/SDP/README.md +++ b/devices/README.md @@ -3,10 +3,15 @@ This code provides an attribute_wrapper class in place of attributes for tango devices. the attribute wrappers contain additional code that moves a lot of the complexity and redundant code to the background. +The tango Device class is also abstracted further to a "hardware_device" class. This class wraps + The only things required on the users part are to declare the attributes using the attribute_wrapper (see `example/example_device`), declare what client the attribute has to use in the initialisation and provide support for the used clients. To see how to add support for new clients, see `clients/README.md` +In addition it also provides an abstraction to the tango device, specifically for hardware devices. Examples of hardware devices +can be found in SDP.py, PCC.py and test_device.py. as well as a completely empty template in HW_device_implementation.py + Requires numpy ```pip install numpy``` diff --git a/SDP/SDP/SDP.py b/devices/SDP.py similarity index 87% rename from SDP/SDP/SDP.py rename to devices/SDP.py index 0faa38a1ed1cc53061ca6c4773ee49924adfd584..ef991709f2c53fddf2aecc9ce6f6f13be2eb574c 100644 --- a/SDP/SDP/SDP.py +++ b/devices/SDP.py @@ -12,16 +12,13 @@ """ # PyTango imports -from tango import DebugIt from tango.server import run -from tango.server import Device from tango.server import device_property -from tango import DevState # Additional import from clients.opcua_connection import OPCUAConnection -from attribute_wrapper import * -from hardware_device import * +from src.attribute_wrapper import * +from src.hardware_device import * __all__ = ["SDP", "main"] @@ -98,25 +95,12 @@ class SDP(hardware_device): # -------- # 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 """ # Stop keep-alive self.opcua_connection.stop() - 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 """ """Initialises the attributes and properties of the PCC.""" @@ -133,6 +117,10 @@ class SDP(hardware_device): self.OPCua_client.start() + # -------- + # Commands + # -------- + # ---------- # Run server # ---------- diff --git a/PCC/PCC/clients/README.md b/devices/clients/README.md similarity index 100% rename from PCC/PCC/clients/README.md rename to devices/clients/README.md diff --git a/SDP/SDP/clients/opcua_connection.py b/devices/clients/opcua_connection.py similarity index 99% rename from SDP/SDP/clients/opcua_connection.py rename to devices/clients/opcua_connection.py index 35709f0b71cbde79db5cfe2daa5b992229989046..b8707022f8355e84a286368532b2cffeb162e0ca 100644 --- a/SDP/SDP/clients/opcua_connection.py +++ b/devices/clients/opcua_connection.py @@ -1,4 +1,4 @@ -from comms_client import * +from src.comms_client import * __all__ = ["OPCUAConnection"] diff --git a/PCC/PCC/clients/test_client.py b/devices/clients/test_client.py similarity index 96% rename from PCC/PCC/clients/test_client.py rename to devices/clients/test_client.py index 37ab2d32b6ede43477327204969d5778e01bc59d..090437441abd3cdaefee54b5fce63d35fd0ba1f2 100644 --- a/PCC/PCC/clients/test_client.py +++ b/devices/clients/test_client.py @@ -1,4 +1,4 @@ -from comms_client import * +from src.comms_client import * __all__ = ["example_client"] diff --git a/PCC/PCC/attribute_wrapper.py b/devices/src/attribute_wrapper.py similarity index 92% rename from PCC/PCC/attribute_wrapper.py rename to devices/src/attribute_wrapper.py index ff1937c17dbb377dc6a0f9737d6b64379294d5b8..f003df926801b207c7538fd52593a19d676c609f 100644 --- a/PCC/PCC/attribute_wrapper.py +++ b/devices/src/attribute_wrapper.py @@ -1,10 +1,9 @@ -from tango.server import attribute, command -from tango import DebugIt +from tango.server import attribute from tango import AttrWriteType import numpy -from wrappers import only_in_states, only_when_on, fault_on_error +from src.wrappers import only_when_on, fault_on_error def swap_dims_tuple(dims): @@ -24,7 +23,7 @@ class attribute_wrapper(attribute): Wraps all the attributes in a wrapper class to manage most of the redundant code behind the scenes """ - def __init__(self, comms_annotation=None, datatype=None, dims=1, **kwargs): + def __init__(self, comms_annotation=None, datatype=None, dims=(1,), **kwargs): """ wraps around the tango Attribute class. Provides an easier interface for 1d or 2d arrays. Also provides a way to abstract managing the communications interface. diff --git a/PCC/PCC/comms_client.py b/devices/src/comms_client.py similarity index 95% rename from PCC/PCC/comms_client.py rename to devices/src/comms_client.py index 544df539d972cff9da37ac6a2dce00db27d76796..b6eb284607e8aea8f64baaa63de5a77c18224f57 100644 --- a/PCC/PCC/comms_client.py +++ b/devices/src/comms_client.py @@ -97,7 +97,7 @@ class CommClient(Thread): self.disconnect() def setup_attribute(self, annotation, attribute): - ''' + """ This function is responsible for providing the attribute_wrapper with a read/write function How this is done is implementation specific. The setup-attribute has access to the comms_annotation provided to the attribute wrapper to pass along to the comms client @@ -109,6 +109,6 @@ class CommClient(Thread): - OPC-UA: traverse the OPC-UA tree until the node is found. Then return the read/write functions for that node which automatically convert values between Python and OPC-UA. - ''' + """ AssertionError("the setup_attribute must be implemented and provide return a valid read/write function for the attribute") diff --git a/PCC/PCC/hardware_device.py b/devices/src/hardware_device.py similarity index 91% rename from PCC/PCC/hardware_device.py rename to devices/src/hardware_device.py index 6b665055cf35387ea3be4eebfb12f8928cfc6e4e..68afa9b82bfb28bcb30d972f9519b96007f56c56 100644 --- a/PCC/PCC/hardware_device.py +++ b/devices/src/hardware_device.py @@ -12,19 +12,18 @@ """ # PyTango imports -from tango import DebugIt -from tango.server import run -from tango.server import Device -from tango.server import device_property -from tango import DevState +from tango.server import Device, command +from tango import DevState, DebugIt # Additional import -from clients.opcua_connection import OPCUAConnection -from attribute_wrapper import * +from src.attribute_wrapper import * __all__ = ["hardware_device"] +from src.wrappers import only_in_states + + class hardware_device(Device): """ @@ -63,23 +62,6 @@ class hardware_device(Device): self.set_state(DevState.OFF) - - 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. - - 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). - """ - self.debug_stream("Shutting down...") - - self.Off() - self.debug_stream("Shut down. Good bye.") - # -------- # Commands # -------- @@ -173,3 +155,18 @@ class hardware_device(Device): def initialise(self): pass + 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. + + 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). + """ + self.debug_stream("Shutting down...") + + self.Off() + self.debug_stream("Shut down. Good bye.") diff --git a/PCC/PCC/wrappers.py b/devices/src/wrappers.py similarity index 100% rename from PCC/PCC/wrappers.py rename to devices/src/wrappers.py diff --git a/devices/test_device.py b/devices/test_device.py new file mode 100644 index 0000000000000000000000000000000000000000..e38ff5b9a39646890a2dbe31767a7ec0f178ab5a --- /dev/null +++ b/devices/test_device.py @@ -0,0 +1,103 @@ +# -*- 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. + +""" PCC Device Server for LOFAR2.0 + +""" + +# PyTango imports +from tango.server import run +from tango.server import device_property +from tango import DevState +# Additional import + +from clients.test_client import example_client +from src.attribute_wrapper import * +from src.hardware_device import * + +__all__ = ["test_device", "main"] + + +class test_device(hardware_device): + + # ----------------- + # Device Properties + # ----------------- + + OPC_Server_Name = device_property( + dtype='DevString', + ) + + OPC_Server_Port = device_property( + dtype='DevULong', + ) + + OPC_Time_Out = device_property( + dtype='DevDouble', + ) + + # ---------- + # 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) + + int64_spectrum_R = attribute_wrapper(comms_annotation="numpy.int64 type read spectrum (len = 8)", datatype=numpy.int64, dims=(8,)) + str_spectrum_RW = attribute_wrapper(comms_annotation="numpy.str type read/write spectrum (len = 8)", datatype=numpy.str_, dims=(8,), access=AttrWriteType.READ_WRITE) + + 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) + + 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) + 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) + + tr_tod_R = attribute_wrapper(comms_annotation=["1:tr_tod_R"], datatype=numpy.uint64) + tr_uptime_R = attribute_wrapper(comms_annotation=["1:tr_uptime_R"], datatype=numpy.uint64) + + def setup_value_dict(self): + """ set the initial value for all the attribute wrapper objects""" + + self.value_dict = {str(i): i.initial_value() for i in self.attr_list()} + + # -------- + # overloaded functions + # -------- + def initialise(self): + """ user code here. is called when the sate is set to INIT """ + """Initialises the attributes and properties of the PCC.""" + + self.set_state(DevState.INIT) + + + #set up the OPC ua client + self.example_client = example_client(self.Standby, self.Fault, self) + + + # NOTE: MANDATORY will contain all attribute values for this tango device instance + self.setup_value_dict() + + # map an access helper class + for i in self.attr_list(): + i.set_comm_client(self.example_client) + + + self.example_client.start() + +# ---------- +# Run server +# ---------- +def main(args=None, **kwargs): + """Main function of the example module.""" + return run((test_device,), args=args, **kwargs) + + +if __name__ == '__main__': + main() diff --git a/jupyter-notebooks/.ipynb_checkpoints/PCC_notebook-checkpoint.ipynb b/jupyter-notebooks/.ipynb_checkpoints/PCC_notebook-checkpoint.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..78ff25505beb3948e19f8fa5427c9c3bb0aa9537 --- /dev/null +++ b/jupyter-notebooks/.ipynb_checkpoints/PCC_notebook-checkpoint.ipynb @@ -0,0 +1,562 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 7, + "id": "intense-seeker", + "metadata": {}, + "outputs": [], + "source": [ + "import time" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "solar-facility", + "metadata": {}, + "outputs": [], + "source": [ + "d=DeviceProxy(\"LTS/PCC/1\")" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "objective-netscape", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Device is now in on state\n" + ] + } + ], + "source": [ + "state = str(d.state())\n", + "\n", + "if state == \"OFF\":\n", + " d.initialise()\n", + " time.sleep(1)\n", + "state = str(d.state())\n", + "if state == \"STANDBY\":\n", + " d.on()\n", + "state = str(d.state())\n", + "if state == \"ON\":\n", + " print(\"Device is now in on state\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "portuguese-patrick", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🟦🟦🟦 RCU_mask_RW : [False False False False False False False False False False False False\n", + " False False False False False False False False False False False False\n", + " False False False False False False False False]\n", + "🟦🟦🟦 Ant_mask_RW : [[False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]]\n", + "🟦🟦🟦 RCU_attenuator_R : [[10 10 10]\n", + " [10 10 10]\n", + " [10 10 10]\n", + " [10 10 10]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]]\n", + "🟦🟦🟦 RCU_attenuator_RW : [[0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]]\n", + "🟦🟦🟦 RCU_band_R : [[3 3 3]\n", + " [3 3 3]\n", + " [3 3 3]\n", + " [3 3 3]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]]\n", + "🟦🟦🟦 RCU_band_RW : [[0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]]\n", + "🟦🟦🟦 RCU_temperature_R : [312.01573 310.93797 314.71013 313.09349 0. 0. 0.\n", + " 0. 0. 0. 0. 0. 0. 0.\n", + " 0. 0. 0. 0. 0. 0. 0.\n", + " 0. 0. 0. 0. 0. 0. 0.\n", + " 0. 0. 0. 0. ]\n", + "🟦🟦🟦 RCU_Pwr_dig_R : [1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", + "🟦🟦🟦 RCU_LED0_R : [2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", + "🟦🟦🟦 RCU_LED0_RW : [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", + "🟦🟦🟦 RCU_ADC_lock_R : [[129 129 129]\n", + " [129 129 129]\n", + " [129 129 129]\n", + " [129 129 129]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]]\n", + "🟦🟦🟦 RCU_ADC_SYNC_R : [[1 1 1]\n", + " [1 1 1]\n", + " [1 1 1]\n", + " [1 1 1]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]]\n", + "🟦🟦🟦 RCU_ADC_JESD_R : [[20 20 20]\n", + " [20 20 20]\n", + " [20 20 20]\n", + " [20 20 20]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]]\n", + "🟦🟦🟦 RCU_ADC_CML_R : [[7 7 7]\n", + " [7 7 7]\n", + " [7 7 7]\n", + " [7 7 7]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]]\n", + "🟦🟦🟦 RCU_OUT1_R : [[202 74 21]\n", + " [202 74 21]\n", + " [202 74 21]\n", + " [202 74 21]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]]\n", + "🟦🟦🟦 RCU_OUT2_R : [[202 191 23]\n", + " [202 191 23]\n", + " [202 191 23]\n", + " [202 191 23]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]]\n", + "🟦🟦🟦 RCU_ID_R : [6000635 5986246 5985389 6000221 0 0 0 0 0\n", + " 0 0 0 0 0 0 0 0 0\n", + " 0 0 0 0 0 0 0 0 0\n", + " 0 0 0 0 0]\n", + "🟦🟦🟦 RCU_version_R : ('RCU2L v0.3', 'RCU2L v0.4', 'RCU2H v0.2', 'RCU2L v0.1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ')\n", + "🟦🟦🟦 HBA_element_beamformer_delays_R : [[0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " ...\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]]\n", + "🟦🟦🟦 HBA_element_beamformer_delays_RW : [[0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " ...\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]]\n", + "🟦🟦🟦 HBA_element_pwr_R : [[0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " ...\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]]\n", + "🟦🟦🟦 HBA_element_pwr_RW : [[0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " ...\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]]\n", + "🟦🟦🟦 RCU_monitor_rate_RW : 0.0\n" + ] + } + ], + "source": [ + "\n", + "values = [[d.RCU_mask_RW, \"RCU_mask_RW\"],\n", + "[d.Ant_mask_RW,\"Ant_mask_RW\"],\n", + "[d.RCU_attenuator_R,\"RCU_attenuator_R\"],\n", + "[d.RCU_attenuator_RW,\"RCU_attenuator_RW\"],\n", + "[d.RCU_band_R,\"RCU_band_R\"],\n", + "[d.RCU_band_RW,\"RCU_band_RW\"],\n", + "[d.RCU_temperature_R,\"RCU_temperature_R\"],\n", + "[d.RCU_Pwr_dig_R,\"RCU_Pwr_dig_R\"],\n", + "[d.RCU_LED0_R,\"RCU_LED0_R\"],\n", + "[d.RCU_LED0_RW,\"RCU_LED0_RW\"],\n", + "[d.RCU_ADC_lock_R,\"RCU_ADC_lock_R\"],\n", + "[d.RCU_ADC_SYNC_R,\"RCU_ADC_SYNC_R\"],\n", + "[d.RCU_ADC_JESD_R,\"RCU_ADC_JESD_R\"],\n", + "[d.RCU_ADC_CML_R,\"RCU_ADC_CML_R\"],\n", + "[d.RCU_OUT1_R,\"RCU_OUT1_R\"],\n", + "[d.RCU_OUT2_R,\"RCU_OUT2_R\"],\n", + "[d.RCU_ID_R,\"RCU_ID_R\"],\n", + "[d.RCU_version_R,\"RCU_version_R\"],\n", + "[d.HBA_element_beamformer_delays_R,\"HBA_element_beamformer_delays_R\"],\n", + "[d.HBA_element_beamformer_delays_RW,\"HBA_element_beamformer_delays_RW\"],\n", + "[d.HBA_element_pwr_R,\"HBA_element_pwr_R\"],\n", + "[d.HBA_element_pwr_RW,\"HBA_element_pwr_RW\"],\n", + "[d.RCU_monitor_rate_RW,\"RCU_monitor_rate_RW\"]]\n", + "\n", + "\n", + "for i in values:\n", + " print(\"🟦🟦🟦\", i[1], \": \", i[0])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "animal-depression", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[False False False False False False False False False False False False\n", + " False False False False False False False False False False False False\n", + " False False False False False False False False]\n", + "current monitoring rate: 0.0, setting to 1.0\n", + "new monitoring rate is: 1.0\n" + ] + } + ], + "source": [ + "d.RCU_mask_RW = [False, False, False, False, False, False, False, False, False, False, False, False,\n", + " False, False, False, False, False, False, False, False, False, False, False, False,\n", + " False, False, False, False, False, False, False, False,]\n", + "time.sleep(1)\n", + "print(d.RCU_mask_RW)\n", + "\n", + "monitor_rate = d.RCU_monitor_rate_RW\n", + "print(\"current monitoring rate: {}, setting to {}\".format(monitor_rate, monitor_rate + 1))\n", + "d.RCU_monitor_rate_RW = monitor_rate + 1\n", + "time.sleep(2)\n", + "print(\"new monitoring rate is: {}\".format(d.RCU_monitor_rate_RW))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "maritime-qualification", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "painted-hampton", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "StationControl", + "language": "python", + "name": "stationcontrol" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/jupyter-notebooks/.ipynb_checkpoints/SDP_notebook-checkpoint.ipynb b/jupyter-notebooks/.ipynb_checkpoints/SDP_notebook-checkpoint.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..251c6cb059d484ebb0748a37b936242bfbea5b79 --- /dev/null +++ b/jupyter-notebooks/.ipynb_checkpoints/SDP_notebook-checkpoint.ipynb @@ -0,0 +1,560 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "waiting-chance", + "metadata": {}, + "outputs": [], + "source": [ + "import time" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "moving-alexandria", + "metadata": {}, + "outputs": [], + "source": [ + "d=DeviceProxy(\"LTS/PCC/1\")" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "ranking-aluminum", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Device is now in on state\n" + ] + } + ], + "source": [ + "state = str(d.state())\n", + "\n", + "if state == \"OFF\":\n", + " d.initialise()\n", + " time.sleep(1)\n", + "state = str(d.state())\n", + "if state == \"STANDBY\":\n", + " d.on()\n", + "state = str(d.state())\n", + "if state == \"ON\":\n", + " print(\"Device is now in on state\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "polished-confidence", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🟦🟦🟦 RCU_mask_RW : [False False False False False False False False False False False False\n", + " False False False False False False False False False False False False\n", + " False False False False False False False False]\n", + "🟦🟦🟦 Ant_mask_RW : [[False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]\n", + " [False False False]]\n", + "🟦🟦🟦 RCU_attenuator_R : [[10 10 10]\n", + " [10 10 10]\n", + " [10 10 10]\n", + " [10 10 10]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]]\n", + "🟦🟦🟦 RCU_attenuator_RW : [[0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]]\n", + "🟦🟦🟦 RCU_band_R : [[3 3 3]\n", + " [3 3 3]\n", + " [3 3 3]\n", + " [3 3 3]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]]\n", + "🟦🟦🟦 RCU_band_RW : [[0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]]\n", + "🟦🟦🟦 RCU_temperature_R : [314.17125 311.47685 315.51845 312.28517 0. 0. 0.\n", + " 0. 0. 0. 0. 0. 0. 0.\n", + " 0. 0. 0. 0. 0. 0. 0.\n", + " 0. 0. 0. 0. 0. 0. 0.\n", + " 0. 0. 0. 0. ]\n", + "🟦🟦🟦 RCU_Pwr_dig_R : [1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", + "🟦🟦🟦 RCU_LED0_R : [2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", + "🟦🟦🟦 RCU_LED0_RW : [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", + "🟦🟦🟦 RCU_ADC_lock_R : [[129 129 129]\n", + " [129 129 129]\n", + " [129 129 129]\n", + " [129 129 129]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]]\n", + "🟦🟦🟦 RCU_ADC_SYNC_R : [[1 1 1]\n", + " [1 1 1]\n", + " [1 1 1]\n", + " [1 1 1]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]]\n", + "🟦🟦🟦 RCU_ADC_JESD_R : [[20 20 20]\n", + " [20 20 20]\n", + " [20 20 20]\n", + " [20 20 20]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]]\n", + "🟦🟦🟦 RCU_ADC_CML_R : [[7 7 7]\n", + " [7 7 7]\n", + " [7 7 7]\n", + " [7 7 7]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]\n", + " [0 0 0]]\n", + "🟦🟦🟦 RCU_OUT1_R : [[202 74 21]\n", + " [202 74 21]\n", + " [202 74 21]\n", + " [202 74 21]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]]\n", + "🟦🟦🟦 RCU_OUT2_R : [[202 191 23]\n", + " [202 191 23]\n", + " [202 191 23]\n", + " [202 191 23]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]\n", + " [ 0 0 0]]\n", + "🟦🟦🟦 RCU_ID_R : [6000635 5986246 5985389 6000221 0 0 0 0 0\n", + " 0 0 0 0 0 0 0 0 0\n", + " 0 0 0 0 0 0 0 0 0\n", + " 0 0 0 0 0]\n", + "🟦🟦🟦 RCU_version_R : ('RCU2L v0.3', 'RCU2L v0.4', 'RCU2H v0.2', 'RCU2L v0.1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ')\n", + "🟦🟦🟦 HBA_element_beamformer_delays_R : [[0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " ...\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]]\n", + "🟦🟦🟦 HBA_element_beamformer_delays_RW : [[0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " ...\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]]\n", + "🟦🟦🟦 HBA_element_pwr_R : [[0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " ...\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]]\n", + "🟦🟦🟦 HBA_element_pwr_RW : [[0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " ...\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]\n", + " [0 0 0 ... 0 0 0]]\n", + "🟦🟦🟦 RCU_monitor_rate_RW : 0.0\n" + ] + } + ], + "source": [ + "values = [[d.RCU_mask_RW, \"RCU_mask_RW\"],\n", + "[d.Ant_mask_RW,\"Ant_mask_RW\"],\n", + "[d.RCU_attenuator_R,\"RCU_attenuator_R\"],\n", + "[d.RCU_attenuator_RW,\"RCU_attenuator_RW\"],\n", + "[d.RCU_band_R,\"RCU_band_R\"],\n", + "[d.RCU_band_RW,\"RCU_band_RW\"],\n", + "[d.RCU_temperature_R,\"RCU_temperature_R\"],\n", + "[d.RCU_Pwr_dig_R,\"RCU_Pwr_dig_R\"],\n", + "[d.RCU_LED0_R,\"RCU_LED0_R\"],\n", + "[d.RCU_LED0_RW,\"RCU_LED0_RW\"],\n", + "[d.RCU_ADC_lock_R,\"RCU_ADC_lock_R\"],\n", + "[d.RCU_ADC_SYNC_R,\"RCU_ADC_SYNC_R\"],\n", + "[d.RCU_ADC_JESD_R,\"RCU_ADC_JESD_R\"],\n", + "[d.RCU_ADC_CML_R,\"RCU_ADC_CML_R\"],\n", + "[d.RCU_OUT1_R,\"RCU_OUT1_R\"],\n", + "[d.RCU_OUT2_R,\"RCU_OUT2_R\"],\n", + "[d.RCU_ID_R,\"RCU_ID_R\"],\n", + "[d.RCU_version_R,\"RCU_version_R\"],\n", + "[d.HBA_element_beamformer_delays_R,\"HBA_element_beamformer_delays_R\"],\n", + "[d.HBA_element_beamformer_delays_RW,\"HBA_element_beamformer_delays_RW\"],\n", + "[d.HBA_element_pwr_R,\"HBA_element_pwr_R\"],\n", + "[d.HBA_element_pwr_RW,\"HBA_element_pwr_RW\"],\n", + "[d.RCU_monitor_rate_RW,\"RCU_monitor_rate_RW\"]]\n", + "\n", + "\n", + "for i in values:\n", + " print(\"🟦🟦🟦\", i[1], \": \", i[0])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "sporting-current", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3.0" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "d.RCU_mask_RW = [False, False, False, False, False, False, False, False, False, False, False, False,\n", + " False, False, False, False, False, False, False, False, False, False, False, False,\n", + " False, False, False, False, False, False, False, False,]\n", + "time.sleep(1)\n", + "print(d.RCU_mask_RW)\n", + "\n", + "monitor_rate = d.RCU_monitor_rate_RW\n", + "print(\"current monitoring rate: {}, setting to {}\".format(monitor_rate, monitor_rate + 1))\n", + "monitor_rate = monitor_rate + 1\n", + "\n", + "time.sleep(1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "sharing-mechanics", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ruled-tracy", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "StationControl", + "language": "python", + "name": "stationcontrol" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/jupyter-notebooks/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/jupyter-notebooks/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..a8a343a4f93bc27422945e4955afb69e032c7f72 --- /dev/null +++ b/jupyter-notebooks/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,86 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "id": "thermal-fiction", + "metadata": {}, + "outputs": [], + "source": [ + "d=DeviceProxy(\"LTS/PCC/1\")" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "adolescent-knowing", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "OFF\n" + ] + } + ], + "source": [ + "state = str(d.state())\n", + "\n", + "if state == \"OFF\":\n", + " d.initialise()\n", + "state = str(d.state())\n", + "if state == \"STANDBY\":\n", + " d.on()\n", + "if state == \"ON\":\n", + " print(\"Device is now in on state\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "supreme-killing", + "metadata": {}, + "outputs": [ + { + "ename": "DevFailed", + "evalue": "DevFailed[\nDevError[\n desc = Function can only be called in states [tango._tango.DevState.FAULT, tango._tango.DevState.OFF]. Current state: ON\n origin = Initialise\n reason = IllegalCommand\nseverity = ERR]\n\nDevError[\n desc = Failed to execute command_inout on device lts/pcc/1, command initialise\n origin = Connection::command_inout()\n reason = API_CommandFailed\nseverity = ERR]\n]", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mDevFailed\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m<ipython-input-7-ea00ec97fe2a>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minitialise\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mon\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py\u001b[0m in \u001b[0;36mf\u001b[0;34m(*args, **kwds)\u001b[0m\n\u001b[1;32m 273\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 274\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 275\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mdp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcommand_inout\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 276\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 277\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__doc__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdoc\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/green.py\u001b[0m in \u001b[0;36mgreener\u001b[0;34m(obj, *args, **kwargs)\u001b[0m\n\u001b[1;32m 193\u001b[0m \u001b[0mgreen_mode\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0maccess\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'green_mode'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 194\u001b[0m \u001b[0mexecutor\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_object_executor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgreen_mode\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 195\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mexecutor\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mwait\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mwait\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 196\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 197\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mgreener\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/green.py\u001b[0m in \u001b[0;36mrun\u001b[0;34m(self, fn, args, kwargs, wait, timeout)\u001b[0m\n\u001b[1;32m 107\u001b[0m \u001b[0;31m# Sychronous (no delegation)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 108\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masynchronous\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0min_executor_context\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 109\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 110\u001b[0m \u001b[0;31m# Asynchronous delegation\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[0maccessor\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdelegate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/connection.py\u001b[0m in \u001b[0;36m__Connection__command_inout\u001b[0;34m(self, name, *args, **kwds)\u001b[0m\n\u001b[1;32m 106\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m*\u001b[0m \u001b[0mparameter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 107\u001b[0m \"\"\"\n\u001b[0;32m--> 108\u001b[0;31m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mConnection\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcommand_inout_raw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 109\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mDeviceData\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 110\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/connection.py\u001b[0m in \u001b[0;36m__Connection__command_inout_raw\u001b[0;34m(self, cmd_name, cmd_param)\u001b[0m\n\u001b[1;32m 135\u001b[0m \"\"\"\n\u001b[1;32m 136\u001b[0m \u001b[0mparam\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m__get_command_inout_param\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcmd_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcmd_param\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 137\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__command_inout\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcmd_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparam\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 138\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 139\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDevFailed\u001b[0m: DevFailed[\nDevError[\n desc = Function can only be called in states [tango._tango.DevState.FAULT, tango._tango.DevState.OFF]. Current state: ON\n origin = Initialise\n reason = IllegalCommand\nseverity = ERR]\n\nDevError[\n desc = Failed to execute command_inout on device lts/pcc/1, command initialise\n origin = Connection::command_inout()\n reason = API_CommandFailed\nseverity = ERR]\n]" + ] + } + ], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "StationControl", + "language": "python", + "name": "stationcontrol" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/jupyter-notebooks/.ipynb_checkpoints/test_device-checkpoint.ipynb b/jupyter-notebooks/.ipynb_checkpoints/test_device-checkpoint.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..93409ad97b1a8ec40a768698729ec68cf5169b22 --- /dev/null +++ b/jupyter-notebooks/.ipynb_checkpoints/test_device-checkpoint.ipynb @@ -0,0 +1,231 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 26, + "id": "waiting-chance", + "metadata": {}, + "outputs": [], + "source": [ + "import time\n", + "import numpy" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "moving-alexandria", + "metadata": {}, + "outputs": [], + "source": [ + "d=DeviceProxy(\"LTS/test_device/1\")" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "ranking-aluminum", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Device is now in on state\n" + ] + } + ], + "source": [ + "state = str(d.state())\n", + "\n", + "if state == \"OFF\":\n", + " d.initialise()\n", + " time.sleep(1)\n", + "state = str(d.state())\n", + "if state == \"STANDBY\":\n", + " d.on()\n", + "state = str(d.state())\n", + "if state == \"ON\":\n", + " print(\"Device is now in on state\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "beneficial-evidence", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "bool_scalar_R [False]\n", + "bool_scalar_RW [False]\n", + "int64_spectrum_R [0 0 0 0 0 0 0 0]\n", + "str_spectrum_RW ('', '', '', '', '', '', '', '')\n", + "double_image_R [[0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]]\n", + "double_image_RW [[0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0.]]\n", + "int32_scalar_R [0]\n", + "uint16_spectrum_RW [0 0 0 0 0 0 0 0]\n", + "float32_image_R [[0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0.]]\n", + "uint8_image_RW [[0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]]\n", + "tr_tod_R [0]\n", + "tr_uptime_R [0]\n", + "State <function __get_command_func.<locals>.f at 0x7f1c88a29e18>\n", + "Status <function __get_command_func.<locals>.f at 0x7f1c88a5abf8>\n" + ] + } + ], + "source": [ + "attr_names = d.get_attribute_list()\n", + "\n", + "for i in attr_names:\n", + " exec(\"value = print(i, d.{})\".format(i))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "polished-confidence", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🟦🟦🟦 bool_scalar_R : [False]\n", + "🟦🟦🟦 bool_scalar_RW : [False]\n", + "🟦🟦🟦 int64_spectrum_R : [0 0 0 0 0 0 0 0]\n", + "🟦🟦🟦 str_spectrum_RW : ('', '', '', '', '', '', '', '')\n", + "🟦🟦🟦 double_image_R : [[0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]]\n", + "🟦🟦🟦 double_image_RW : [[0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0.]]\n", + "🟦🟦🟦 int32_scalar_R : [0]\n", + "🟦🟦🟦 uint16_spectrum_RW : [0 0 0 0 0 0 0 0]\n", + "🟦🟦🟦 float32_image_R : [[0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0.]]\n", + "🟦🟦🟦 uint8_image_RW : [[0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]]\n", + "🟦🟦🟦 tr_tod_R : [0]\n", + "🟦🟦🟦 tr_uptime_R : [0]\n" + ] + } + ], + "source": [ + "values = [[d.bool_scalar_R, \"bool_scalar_R\"],\n", + "[d.bool_scalar_RW,\"bool_scalar_RW\"],\n", + "[d.int64_spectrum_R,\"int64_spectrum_R\"],\n", + "[d.str_spectrum_RW,\"str_spectrum_RW\"],\n", + "[d.double_image_R,\"double_image_R\"],\n", + "[d.double_image_RW,\"double_image_RW\"],\n", + "[d.int32_scalar_R,\"int32_scalar_R\"],\n", + "[d.uint16_spectrum_RW,\"uint16_spectrum_RW\"],\n", + "[d.float32_image_R,\"float32_image_R\"],\n", + "[d.uint8_image_RW,\"uint8_image_RW\"],\n", + "[d.tr_tod_R,\"tr_tod_R\"],\n", + "[d.tr_uptime_R,\"tr_uptime_R\"]]\n", + "\n", + "\n", + "for i in values:\n", + " print(\"🟦🟦🟦\", i[1], \": \", i[0])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "sporting-current", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3.0" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "d.RCU_mask_RW = [False, False, False, False, False, False, False, False, False, False, False, False,\n", + " False, False, False, False, False, False, False, False, False, False, False, False,\n", + " False, False, False, False, False, False, False, False,]\n", + "time.sleep(1)\n", + "print(d.RCU_mask_RW)\n", + "\n", + "monitor_rate = d.RCU_monitor_rate_RW\n", + "print(\"current monitoring rate: {}, setting to {}\".format(monitor_rate, monitor_rate + 1))\n", + "monitor_rate = monitor_rate + 1\n", + "\n", + "time.sleep(1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "sharing-mechanics", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ruled-tracy", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "StationControl", + "language": "python", + "name": "stationcontrol" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/jupyter-notebooks/PCC_notebook.ipynb b/jupyter-notebooks/PCC_notebook.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..f0dd0f9bedae6261c0524b03898491b72eeac1b2 --- /dev/null +++ b/jupyter-notebooks/PCC_notebook.ipynb @@ -0,0 +1,173 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "funded-deputy", + "metadata": {}, + "outputs": [], + "source": [ + "import time" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "bridal-mumbai", + "metadata": {}, + "outputs": [], + "source": [ + "d=DeviceProxy(\"LTS/PCC/1\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "subjective-conference", + "metadata": {}, + "outputs": [], + "source": [ + "state = str(d.state())\n", + "\n", + "if state == \"OFF\":\n", + " d.initialise()\n", + " time.sleep(1)\n", + "state = str(d.state())\n", + "if state == \"STANDBY\":\n", + " d.on()\n", + "state = str(d.state())\n", + "if state == \"ON\":\n", + " print(\"Device is now in on state\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "liable-thesaurus", + "metadata": {}, + "outputs": [ + { + "ename": "DevFailed", + "evalue": "DevFailed[\nDevError[\n desc = Read value for attribute RCU_mask_RW has not been updated\n origin = Device_3Impl::read_attributes_no_except\n reason = API_AttrValueNotSet\nseverity = ERR]\n\nDevError[\n desc = Failed to read_attribute on device lts/pcc/1, attribute RCU_mask_RW\n origin = DeviceProxy::read_attribute()\n reason = API_AttributeFailed\nseverity = ERR]\n]", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mDevFailed\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m<ipython-input-4-aafae2adcd98>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m values = [[d.RCU_mask_RW, \"RCU_mask_RW\"],\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mAnt_mask_RW\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"Ant_mask_RW\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRCU_attenuator_R\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"RCU_attenuator_R\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRCU_attenuator_RW\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"RCU_attenuator_RW\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRCU_band_R\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"RCU_band_R\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py\u001b[0m in \u001b[0;36m__DeviceProxy__getattr\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 342\u001b[0m \u001b[0mattr_info\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__get_attr_cache\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname_l\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 343\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mattr_info\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 344\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m__get_attribute_value\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mattr_info\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 345\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 346\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py\u001b[0m in \u001b[0;36m__get_attribute_value\u001b[0;34m(self, attr_info, name)\u001b[0m\n\u001b[1;32m 281\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__get_attribute_value\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mattr_info\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 282\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0menum_class\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mattr_info\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 283\u001b[0;31m \u001b[0mattr_value\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 284\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0menum_class\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 285\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0menum_class\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mattr_value\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/green.py\u001b[0m in \u001b[0;36mgreener\u001b[0;34m(obj, *args, **kwargs)\u001b[0m\n\u001b[1;32m 193\u001b[0m \u001b[0mgreen_mode\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0maccess\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'green_mode'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 194\u001b[0m \u001b[0mexecutor\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_object_executor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgreen_mode\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 195\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mexecutor\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mwait\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mwait\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 196\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 197\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mgreener\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/green.py\u001b[0m in \u001b[0;36mrun\u001b[0;34m(self, fn, args, kwargs, wait, timeout)\u001b[0m\n\u001b[1;32m 107\u001b[0m \u001b[0;31m# Sychronous (no delegation)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 108\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masynchronous\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0min_executor_context\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 109\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 110\u001b[0m \u001b[0;31m# Asynchronous delegation\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[0maccessor\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdelegate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py\u001b[0m in \u001b[0;36m__DeviceProxy__read_attribute\u001b[0;34m(self, value, extract_as)\u001b[0m\n\u001b[1;32m 439\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 440\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__DeviceProxy__read_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mextract_as\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mExtractAs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mNumpy\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 441\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m__check_read_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_read_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mextract_as\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 442\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 443\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py\u001b[0m in \u001b[0;36m__check_read_attribute\u001b[0;34m(dev_attr)\u001b[0m\n\u001b[1;32m 155\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__check_read_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdev_attr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 156\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdev_attr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhas_failed\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 157\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mDevFailed\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mdev_attr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_err_stack\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 158\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mdev_attr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 159\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDevFailed\u001b[0m: DevFailed[\nDevError[\n desc = Read value for attribute RCU_mask_RW has not been updated\n origin = Device_3Impl::read_attributes_no_except\n reason = API_AttrValueNotSet\nseverity = ERR]\n\nDevError[\n desc = Failed to read_attribute on device lts/pcc/1, attribute RCU_mask_RW\n origin = DeviceProxy::read_attribute()\n reason = API_AttributeFailed\nseverity = ERR]\n]" + ] + } + ], + "source": [ + "\n", + "values = [[d.RCU_mask_RW, \"RCU_mask_RW\"],\n", + "[d.Ant_mask_RW,\"Ant_mask_RW\"],\n", + "[d.RCU_attenuator_R,\"RCU_attenuator_R\"],\n", + "[d.RCU_attenuator_RW,\"RCU_attenuator_RW\"],\n", + "[d.RCU_band_R,\"RCU_band_R\"],\n", + "[d.RCU_band_RW,\"RCU_band_RW\"],\n", + "[d.RCU_temperature_R,\"RCU_temperature_R\"],\n", + "[d.RCU_Pwr_dig_R,\"RCU_Pwr_dig_R\"],\n", + "[d.RCU_LED0_R,\"RCU_LED0_R\"],\n", + "[d.RCU_LED0_RW,\"RCU_LED0_RW\"],\n", + "[d.RCU_ADC_lock_R,\"RCU_ADC_lock_R\"],\n", + "[d.RCU_ADC_SYNC_R,\"RCU_ADC_SYNC_R\"],\n", + "[d.RCU_ADC_JESD_R,\"RCU_ADC_JESD_R\"],\n", + "[d.RCU_ADC_CML_R,\"RCU_ADC_CML_R\"],\n", + "[d.RCU_OUT1_R,\"RCU_OUT1_R\"],\n", + "[d.RCU_OUT2_R,\"RCU_OUT2_R\"],\n", + "[d.RCU_ID_R,\"RCU_ID_R\"],\n", + "[d.RCU_version_R,\"RCU_version_R\"],\n", + "[d.HBA_element_beamformer_delays_R,\"HBA_element_beamformer_delays_R\"],\n", + "[d.HBA_element_beamformer_delays_RW,\"HBA_element_beamformer_delays_RW\"],\n", + "[d.HBA_element_pwr_R,\"HBA_element_pwr_R\"],\n", + "[d.HBA_element_pwr_RW,\"HBA_element_pwr_RW\"],\n", + "[d.RCU_monitor_rate_RW,\"RCU_monitor_rate_RW\"]]\n", + "\n", + "\n", + "for i in values:\n", + " print(\"🟦🟦🟦\", i[1], \": \", i[0])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "charitable-subject", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[False False False False False False False False False False False False\n", + " False False False False False False False False False False False False\n", + " False False False False False False False False]\n", + "current monitoring rate: 0.0, setting to 1.0\n", + "new monitoring rate is: 1.0\n" + ] + } + ], + "source": [ + "d.RCU_mask_RW = [False, False, False, False, False, False, False, False, False, False, False, False,\n", + " False, False, False, False, False, False, False, False, False, False, False, False,\n", + " False, False, False, False, False, False, False, False,]\n", + "time.sleep(1)\n", + "print(d.RCU_mask_RW)\n", + "\n", + "monitor_rate = d.RCU_monitor_rate_RW\n", + "print(\"current monitoring rate: {}, setting to {}\".format(monitor_rate, monitor_rate + 1))\n", + "d.RCU_monitor_rate_RW = monitor_rate + 1\n", + "time.sleep(2)\n", + "print(\"new monitoring rate is: {}\".format(d.RCU_monitor_rate_RW))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "impressive-request", + "metadata": {}, + "outputs": [], + "source": [ + "attr_names = d.get_attribute_list()\n", + "\n", + "for i in attr_names:\n", + " exec(\"value = print(i, d.{})\".format(i))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "conditional-scale", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "StationControl", + "language": "python", + "name": "stationcontrol" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/jupyter-notebooks/SDP_notebook.ipynb b/jupyter-notebooks/SDP_notebook.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..0845262a8dcb366d94a9ae6098d3e912569b4a27 --- /dev/null +++ b/jupyter-notebooks/SDP_notebook.ipynb @@ -0,0 +1,132 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 6, + "id": "waiting-chance", + "metadata": {}, + "outputs": [], + "source": [ + "import time" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "moving-alexandria", + "metadata": {}, + "outputs": [], + "source": [ + "d=DeviceProxy(\"LTS/SDP/1\")" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "ranking-aluminum", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "warning, expected device to be in on state, is: FAULT\n" + ] + } + ], + "source": [ + "state = str(d.state())\n", + "\n", + "if state == \"OFF\":\n", + " d.initialise()\n", + " time.sleep(1)\n", + "state = str(d.state())\n", + "if state == \"STANDBY\":\n", + " d.on()\n", + "state = str(d.state())\n", + "if state == \"ON\":\n", + " print(\"Device is now in on state\")\n", + "else:\n", + " print(\"warning, expected device to be in on state, is: \", state)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "transsexual-battle", + "metadata": {}, + "outputs": [], + "source": [ + "values = [\n", + " [d.fpga_mask_RW, \"fpga_mask_RW\"],\n", + " [d.fpga_scrap_R, \"fpga_scrap_R\"],\n", + " [d.fpga_scrap_RW, \"fpga_scrap_RW\"],\n", + " [d.fpga_status_R, \"fpga_status_R\"],\n", + " [d.fpga_temp_R, \"fpga_temp_R\"],\n", + " [d.fpga_version_R, \"fpga_version_R\"],\n", + " [d.fpga_weights_R, \"fpga_weights_R\"],\n", + " [d.fpga_weights_RW, \"fpga_weights_RW\"],\n", + " [d.tr_busy_R, \"tr_busy_R\"],\n", + " [d.tr_reload_RW, \"tr_reload_RW\"],\n", + " # [d.tr_tod_R, \"tr_tod_R\"],\n", + " # [d.tr_uptime_R, \"tr_uptime_R\"]\n", + "]\n", + "\n", + "for i in values:\n", + " print(\"🟦🟦🟦\", i[1], \": \", i[0])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "eligible-times", + "metadata": {}, + "outputs": [ + { + "ename": "DevFailed", + "evalue": "DevFailed[\nDevError[\n desc = TypeError: Expecting a numeric type, but it is not. If you use a numpy type instead of python core types, then it must exactly match (ex: numpy.int32 for PyTango.DevLong)\n \n origin = Traceback (most recent call last):\n File \"/usr/local/lib/python3.7/dist-packages/tango/server.py\", line 138, in read_attr\n set_complex_value(attr, ret)\n File \"/usr/local/lib/python3.7/dist-packages/tango/server.py\", line 115, in set_complex_value\n attr.set_value(value)\nTypeError: Expecting a numeric type, but it is not. If you use a numpy type instead of python core types, then it must exactly match (ex: numpy.int32 for PyTango.DevLong)\n\n reason = PyDs_PythonError\nseverity = ERR]\n\nDevError[\n desc = Failed to read_attribute on device lts/sdp/1, attribute tr_tod_R\n origin = DeviceProxy::read_attribute()\n reason = API_AttributeFailed\nseverity = ERR]\n]", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mDevFailed\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m<ipython-input-5-e44d5c52394a>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtr_tod_R\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py\u001b[0m in \u001b[0;36m__DeviceProxy__getattr\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 319\u001b[0m \u001b[0mattr_info\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__get_attr_cache\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname_l\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 320\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mattr_info\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 321\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m__get_attribute_value\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mattr_info\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 322\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 323\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mname_l\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__get_pipe_cache\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py\u001b[0m in \u001b[0;36m__get_attribute_value\u001b[0;34m(self, attr_info, name)\u001b[0m\n\u001b[1;32m 281\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__get_attribute_value\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mattr_info\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 282\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0menum_class\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mattr_info\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 283\u001b[0;31m \u001b[0mattr_value\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 284\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0menum_class\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 285\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0menum_class\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mattr_value\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/green.py\u001b[0m in \u001b[0;36mgreener\u001b[0;34m(obj, *args, **kwargs)\u001b[0m\n\u001b[1;32m 193\u001b[0m \u001b[0mgreen_mode\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0maccess\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'green_mode'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 194\u001b[0m \u001b[0mexecutor\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_object_executor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgreen_mode\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 195\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mexecutor\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mwait\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mwait\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 196\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 197\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mgreener\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/green.py\u001b[0m in \u001b[0;36mrun\u001b[0;34m(self, fn, args, kwargs, wait, timeout)\u001b[0m\n\u001b[1;32m 107\u001b[0m \u001b[0;31m# Sychronous (no delegation)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 108\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masynchronous\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0min_executor_context\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 109\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 110\u001b[0m \u001b[0;31m# Asynchronous delegation\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[0maccessor\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdelegate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py\u001b[0m in \u001b[0;36m__DeviceProxy__read_attribute\u001b[0;34m(self, value, extract_as)\u001b[0m\n\u001b[1;32m 439\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 440\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__DeviceProxy__read_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mextract_as\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mExtractAs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mNumpy\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 441\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m__check_read_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_read_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mextract_as\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 442\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 443\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py\u001b[0m in \u001b[0;36m__check_read_attribute\u001b[0;34m(dev_attr)\u001b[0m\n\u001b[1;32m 155\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__check_read_attribute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdev_attr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 156\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdev_attr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhas_failed\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 157\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mDevFailed\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mdev_attr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_err_stack\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 158\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mdev_attr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 159\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDevFailed\u001b[0m: DevFailed[\nDevError[\n desc = TypeError: Expecting a numeric type, but it is not. If you use a numpy type instead of python core types, then it must exactly match (ex: numpy.int32 for PyTango.DevLong)\n \n origin = Traceback (most recent call last):\n File \"/usr/local/lib/python3.7/dist-packages/tango/server.py\", line 138, in read_attr\n set_complex_value(attr, ret)\n File \"/usr/local/lib/python3.7/dist-packages/tango/server.py\", line 115, in set_complex_value\n attr.set_value(value)\nTypeError: Expecting a numeric type, but it is not. If you use a numpy type instead of python core types, then it must exactly match (ex: numpy.int32 for PyTango.DevLong)\n\n reason = PyDs_PythonError\nseverity = ERR]\n\nDevError[\n desc = Failed to read_attribute on device lts/sdp/1, attribute tr_tod_R\n origin = DeviceProxy::read_attribute()\n reason = API_AttributeFailed\nseverity = ERR]\n]" + ] + } + ], + "source": [ + "attr_names = d.get_attribute_list()\n", + "\n", + "for i in attr_names:\n", + " exec(\"value = print(i, d.{})\".format(i))\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "StationControl", + "language": "python", + "name": "stationcontrol" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/jupyter-notebooks/test_device.ipynb b/jupyter-notebooks/test_device.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..66d3a5f1057cb9051dce52325fb4fc73fb9d7005 --- /dev/null +++ b/jupyter-notebooks/test_device.ipynb @@ -0,0 +1,171 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 26, + "id": "waiting-chance", + "metadata": {}, + "outputs": [], + "source": [ + "import time\n", + "import numpy" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "moving-alexandria", + "metadata": {}, + "outputs": [], + "source": [ + "d=DeviceProxy(\"LTS/test_device/1\")" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "ranking-aluminum", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Device is now in on state\n" + ] + } + ], + "source": [ + "state = str(d.state())\n", + "\n", + "if state == \"OFF\":\n", + " d.initialise()\n", + " time.sleep(1)\n", + "state = str(d.state())\n", + "if state == \"STANDBY\":\n", + " d.on()\n", + "state = str(d.state())\n", + "if state == \"ON\":\n", + " print(\"Device is now in on state\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "beneficial-evidence", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "bool_scalar_R [False]\n", + "bool_scalar_RW [False]\n", + "int64_spectrum_R [0 0 0 0 0 0 0 0]\n", + "str_spectrum_RW ('', '', '', '', '', '', '', '')\n", + "double_image_R [[0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]]\n", + "double_image_RW [[0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0.]]\n", + "int32_scalar_R [0]\n", + "uint16_spectrum_RW [0 0 0 0 0 0 0 0]\n", + "float32_image_R [[0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0.]]\n", + "uint8_image_RW [[0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]\n", + " [0 0]]\n", + "tr_tod_R [0]\n", + "tr_uptime_R [0]\n", + "State <function __get_command_func.<locals>.f at 0x7f1c88a29e18>\n", + "Status <function __get_command_func.<locals>.f at 0x7f1c88a5abf8>\n" + ] + } + ], + "source": [ + "attr_names = d.get_attribute_list()\n", + "\n", + "for i in attr_names:\n", + " exec(\"value = print(i, d.{})\".format(i))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "sporting-current", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3.0" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "d.RCU_mask_RW = [False, False, False, False, False, False, False, False, False, False, False, False,\n", + " False, False, False, False, False, False, False, False, False, False, False, False,\n", + " False, False, False, False, False, False, False, False,]\n", + "time.sleep(1)\n", + "print(d.RCU_mask_RW)\n", + "\n", + "monitor_rate = d.RCU_monitor_rate_RW\n", + "print(\"current monitoring rate: {}, setting to {}\".format(monitor_rate, monitor_rate + 1))\n", + "monitor_rate = monitor_rate + 1\n", + "\n", + "time.sleep(1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "sharing-mechanics", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ruled-tracy", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "StationControl", + "language": "python", + "name": "stationcontrol" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}