diff --git a/devices/clients/attribute_wrapper.py b/devices/clients/attribute_wrapper.py index e55a662142cb89f62775fb7ac2189c063593df37..2b887a254287276a2ede2f85bc490520d0c0bcb7 100644 --- a/devices/clients/attribute_wrapper.py +++ b/devices/clients/attribute_wrapper.py @@ -154,7 +154,7 @@ class attribute_wrapper(attribute): try: self.read_function, self.write_function = client.setup_attribute(self.comms_annotation, self) except Exception as e: - raise Exception("Exception while setting %s attribute with annotation: '%s'", client.__class__.__name__, self.comms_annotation) from e + raise Exception(f"Exception while setting {client.__class__.__name__} attribute with annotation: '{self.comms_annotation}'") from e async def async_set_comm_client(self, client): """ @@ -163,7 +163,7 @@ class attribute_wrapper(attribute): try: self.read_function, self.write_function = await client.setup_attribute(self.comms_annotation, self) except Exception as e: - raise Exception("Exception while setting %s attribute with annotation: '%s'", client.__class__.__name__, self.comms_annotation) from e + raise Exception(f"Exception while setting {client.__class__.__name__} attribute with annotation: '{self.comms_annotation}'") from e def set_pass_func(self): def pass_func(value=None): diff --git a/jupyter-notebooks/test_device.ipynb b/jupyter-notebooks/test_device.ipynb index 7701f520937bcaf88b09f624c8b9e3a4ee752c85..d8cf2b2bcdf8034e5ca0bc398a65ab5853720fe9 100644 --- a/jupyter-notebooks/test_device.ipynb +++ b/jupyter-notebooks/test_device.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 61, + "execution_count": 37, "id": "waiting-chance", "metadata": {}, "outputs": [], @@ -13,17 +13,17 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 38, "id": "moving-alexandria", "metadata": {}, "outputs": [], "source": [ - "d=DeviceProxy(\"LTS/SST/1\")" + "d=DeviceProxy(\"LTS/UNB2/1\")" ] }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 39, "id": "ranking-aluminum", "metadata": {}, "outputs": [ @@ -46,12 +46,14 @@ " d.on()\n", "state = str(d.state())\n", "if state == \"ON\":\n", - " print(\"Device is now in on state\")\n" + " print(\"Device is now in on state\")\n", + "else:\n", + " print(f\"Device is now in {state} state\")" ] }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 40, "id": "beneficial-evidence", "metadata": {}, "outputs": [ @@ -59,36 +61,112 @@ "name": "stdout", "output_type": "stream", "text": [ - "packet_count_R [55]\n", - "last_packet_timestamp_R [1623249385]\n", - "queue_percentage_used_R [0.]\n", - "State <function __get_command_func.<locals>.f at 0x7fcb205fd0d0>\n", - "Status <function __get_command_func.<locals>.f at 0x7fcb205fd0d0>\n" + "['version_R', 'opcua_missing_attributes_R', 'UNB2TR_translator_busy_R', 'UNB2_DC_DC_48V_12V_IOUT_R', 'UNB2_DC_DC_48V_12V_TEMP_R', 'UNB2_DC_DC_48V_12V_VIN_R', 'UNB2_DC_DC_48V_12V_VOUT_R', 'UNB2_EEPROM_Serial_Number_R', 'UNB2_EEPROM_Unique_ID_R', 'UNB2_FPGA_DDR4_SLOT_TEMP_R', 'UNB2_FPGA_POL_CORE_IOUT_R', 'UNB2_FPGA_POL_CORE_TEMP_R', 'UNB2_FPGA_POL_CORE_VOUT_R', 'UNB2_FPGA_POL_ERAM_IOUT_R', 'UNB2_FPGA_POL_ERAM_TEMP_R', 'UNB2_FPGA_POL_ERAM_VOUT_R', 'UNB2_FPGA_POL_HGXB_IOUT_R', 'UNB2_FPGA_POL_HGXB_TEMP_R', 'UNB2_FPGA_POL_HGXB_VOUT_R', 'UNB2_FPGA_POL_PGM_IOUT_R', 'UNB2_FPGA_POL_PGM_TEMP_R', 'UNB2_FPGA_POL_PGM_VOUT_R', 'UNB2_FPGA_POL_RXGXB_IOUT_R', 'UNB2_FPGA_POL_RXGXB_TEMP_R', 'UNB2_FPGA_POL_RXGXB_VOUT_R', 'UNB2_FPGA_POL_TXGXB_IOUT_R', 'UNB2_FPGA_POL_TXGXB_TEMP_R', 'UNB2_FPGA_POL_TXGXB_VOUT_R', 'UNB2_FPGA_QSFP_CAGE_LOS_R', 'UNB2_FPGA_QSFP_CAGE_TEMP_R', 'UNB2_Front_Panel_LED_R', 'UNB2_Front_Panel_LED_RW', 'UNB2_I2C_bus_DDR4_error_R', 'UNB2_I2C_bus_error_R', 'UNB2_I2C_bus_FPGA_PS_error_R', 'UNB2_I2C_bus_PS_error_R', 'UNB2_I2C_bus_QSFP_error_R', 'UNB2_mask_RW', 'UNB2_POL_CLOCK_IOUT_R', 'UNB2_POL_CLOCK_TEMP_R', 'UNB2_POL_CLOCK_VOUT_R', 'UNB2_POL_QSFP_N01_IOUT_R', 'UNB2_POL_QSFP_N01_TEMP_R', 'UNB2_POL_QSFP_N01_VOUT_R', 'UNB2_POL_QSFP_N23_IOUT_R', 'UNB2_POL_QSFP_N23_TEMP_R', 'UNB2_POL_QSFP_N23_VOUT_R', 'UNB2_POL_SWITCH_1V2_IOUT_R', 'UNB2_POL_SWITCH_1V2_TEMP_R', 'UNB2_POL_SWITCH_1V2_VOUT_R', 'UNB2_POL_SWITCH_PHY_IOUT_R', 'UNB2_POL_SWITCH_PHY_TEMP_R', 'UNB2_POL_SWITCH_PHY_VOUT_R', 'UNB2_PWR_off_R', 'UNB2_PWR_off_RW', 'State', 'Status']\n", + "\r\n", + "Attributes:\n", + ">>>\t version_R\n", + ">>>\t opcua_missing_attributes_R\n", + ">>>\t UNB2TR_translator_busy_R\n", + ">>>\t UNB2_DC_DC_48V_12V_IOUT_R\n", + ">>>\t UNB2_DC_DC_48V_12V_TEMP_R\n", + ">>>\t UNB2_DC_DC_48V_12V_VIN_R\n", + ">>>\t UNB2_DC_DC_48V_12V_VOUT_R\n", + ">>>\t UNB2_EEPROM_Serial_Number_R\n", + ">>>\t UNB2_EEPROM_Unique_ID_R\n", + ">>>\t UNB2_FPGA_DDR4_SLOT_TEMP_R\n", + ">>>\t UNB2_FPGA_POL_CORE_IOUT_R\n", + ">>>\t UNB2_FPGA_POL_CORE_TEMP_R\n", + ">>>\t UNB2_FPGA_POL_CORE_VOUT_R\n", + ">>>\t UNB2_FPGA_POL_ERAM_IOUT_R\n", + ">>>\t UNB2_FPGA_POL_ERAM_TEMP_R\n", + ">>>\t UNB2_FPGA_POL_ERAM_VOUT_R\n", + ">>>\t UNB2_FPGA_POL_HGXB_IOUT_R\n", + ">>>\t UNB2_FPGA_POL_HGXB_TEMP_R\n", + ">>>\t UNB2_FPGA_POL_HGXB_VOUT_R\n", + ">>>\t UNB2_FPGA_POL_PGM_IOUT_R\n", + ">>>\t UNB2_FPGA_POL_PGM_TEMP_R\n", + ">>>\t UNB2_FPGA_POL_PGM_VOUT_R\n", + ">>>\t UNB2_FPGA_POL_RXGXB_IOUT_R\n", + ">>>\t UNB2_FPGA_POL_RXGXB_TEMP_R\n", + ">>>\t UNB2_FPGA_POL_RXGXB_VOUT_R\n", + ">>>\t UNB2_FPGA_POL_TXGXB_IOUT_R\n", + ">>>\t UNB2_FPGA_POL_TXGXB_TEMP_R\n", + ">>>\t UNB2_FPGA_POL_TXGXB_VOUT_R\n", + ">>>\t UNB2_FPGA_QSFP_CAGE_LOS_R\n", + ">>>\t UNB2_FPGA_QSFP_CAGE_TEMP_R\n", + ">>>\t UNB2_Front_Panel_LED_R\n", + ">>>\t UNB2_Front_Panel_LED_RW\n", + ">>>\t UNB2_I2C_bus_DDR4_error_R\n", + ">>>\t UNB2_I2C_bus_error_R\n", + ">>>\t UNB2_I2C_bus_FPGA_PS_error_R\n", + ">>>\t UNB2_I2C_bus_PS_error_R\n", + ">>>\t UNB2_I2C_bus_QSFP_error_R\n", + ">>>\t UNB2_mask_RW\n", + ">>>\t UNB2_POL_CLOCK_IOUT_R\n", + ">>>\t UNB2_POL_CLOCK_TEMP_R\n", + ">>>\t UNB2_POL_CLOCK_VOUT_R\n", + ">>>\t UNB2_POL_QSFP_N01_IOUT_R\n", + ">>>\t UNB2_POL_QSFP_N01_TEMP_R\n", + ">>>\t UNB2_POL_QSFP_N01_VOUT_R\n", + ">>>\t UNB2_POL_QSFP_N23_IOUT_R\n", + ">>>\t UNB2_POL_QSFP_N23_TEMP_R\n", + ">>>\t UNB2_POL_QSFP_N23_VOUT_R\n", + ">>>\t UNB2_POL_SWITCH_1V2_IOUT_R\n", + ">>>\t UNB2_POL_SWITCH_1V2_TEMP_R\n", + ">>>\t UNB2_POL_SWITCH_1V2_VOUT_R\n", + ">>>\t UNB2_POL_SWITCH_PHY_IOUT_R\n", + ">>>\t UNB2_POL_SWITCH_PHY_TEMP_R\n", + ">>>\t UNB2_POL_SWITCH_PHY_VOUT_R\n", + ">>>\t UNB2_PWR_off_R\n", + ">>>\t UNB2_PWR_off_RW\n", + ">>>\t State\n", + ">>>\t Status\n", + "Missing Attributes: \n", + " ('2:UNB2TR_translator_busy_R', '2:UNB2_EEPROM_Serial_Number_R', '2:UNB2_I2C_bus_DDR4_error_R', '2:UNB2_I2C_bus_error_R', '2:UNB2_I2C_bus_FPGA_PS_error_R', '2:UNB2_I2C_bus_PS_error_R', '2:UNB2_I2C_bus_QSFP_error_R', '2:UNB2_PWR_off_R', '2:UNB2_PWR_off_RW')\n" ] } ], "source": [ "attr_names = d.get_attribute_list()\n", + "print(attr_names)\n", "\n", + "print(\"\\r\\nAttributes:\")\n", "for i in attr_names:\n", - " exec(\"value = print(i, d.{})\".format(i))\n" + " print(\">>>\\t\",i)\n", + " #exec(\"value = print(i, d.{})\".format(i))\n", + "print(\"Missing Attributes: \\n\", d.opcua_missing_attributes_R)" ] }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 20, "id": "sporting-current", "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "3.0" - ] - }, - "execution_count": 39, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "[False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n" + ] + }, + { + "ename": "AttributeError", + "evalue": "RCU_monitor_rate_RW", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mConnectionFailed\u001b[0m Traceback (most recent call last)", + "\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 326\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--> 327\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__refresh_cmd_cache\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 328\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\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__refresh_cmd_cache\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 241\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__DeviceProxy__refresh_cmd_cache\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\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--> 242\u001b[0;31m \u001b[0mcmd_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcommand_list_query\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 243\u001b[0m \u001b[0mcmd_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;31mConnectionFailed\u001b[0m: DevFailed[\nDevError[\n desc = Device lts/sst/1 is not exported (hint: try starting the device server)\n origin = DeviceProxy::get_corba_name()\n reason = API_DeviceNotExported\nseverity = ERR]\n]", + "\nThe above exception was the direct cause of the following exception:\n", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/tmp/ipykernel_22/1020840340.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRCU_mask_RW\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0mmonitor_rate\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRCU_monitor_rate_RW\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"current monitoring rate: {}, setting to {}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmonitor_rate\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmonitor_rate\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m1\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 9\u001b[0m \u001b[0mmonitor_rate\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmonitor_rate\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m1\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 353\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_pipe\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[1;32m 354\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 355\u001b[0;31m \u001b[0msix\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mraise_from\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mAttributeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcause\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 356\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 357\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/six.py\u001b[0m in \u001b[0;36mraise_from\u001b[0;34m(value, from_value)\u001b[0m\n", + "\u001b[0;31mAttributeError\u001b[0m: RCU_monitor_rate_RW" + ] } ], "source": [