{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "waiting-chance",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "moving-alexandria",
   "metadata": {},
   "outputs": [],
   "source": [
    "d=DeviceProxy(\"LTS/UNB2/1\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ranking-aluminum",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Device is now in on state\n"
     ]
    }
   ],
   "source": [
    "state = str(d.state())\n",
    "\n",
    "\n",
    "if state == \"OFF\" or state == \"FAULT\":\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": 8,
   "id": "0caa8146",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "version_R *L2SS-268-LR1_2_Read_hardware_status_of_UB2c_from_SDPHW [1007a5c5462b1aa3e8f81268f890f6c058413218]\n",
      "UNB2_Power_ON_OFF_RW [False False]\n",
      "UNB2_Front_Panel_LED_RW [0 0]\n",
      "UNB2_Front_Panel_LED_R [0 0]\n",
      "UNB2_mask_RW [False False]\n",
      "UNB2_I2C_bus_STATUS_R [False False]\n",
      "UNB2_EEPROM_Unique_ID_R [5947666 5947666]\n",
      "UNB2_DC_DC_48V_12V_VIN_R [29.18505859 29.18505859]\n",
      "UNB2_DC_DC_48V_12V_VOUT_R [12.00146484 11.98486328]\n",
      "UNB2_DC_DC_48V_12V_IOUT_R [3.625 3.625]\n",
      "UNB2_DC_DC_48V_12V_TEMP_R [37. 37.]\n",
      "UNB2_POL_QSFP_N01_VOUT_R [3.28686523 3.28686523]\n",
      "UNB2_POL_QSFP_N01_IOUT_R [1.55078125 1.55078125]\n",
      "UNB2_POL_QSFP_N01_TEMP_R [33.75 33.75]\n",
      "UNB2_POL_QSFP_N23_VOUT_R [3.28710938 3.28710938]\n",
      "UNB2_POL_QSFP_N23_IOUT_R [1.25195312 1.25195312]\n",
      "UNB2_POL_QSFP_N23_TEMP_R [40.625 40.625]\n",
      "UNB2_POL_SWITCH_1V2_VOUT_R [1.19970703 1.19970703]\n",
      "UNB2_POL_SWITCH_1V2_IOUT_R [1.73632812 1.73632812]\n",
      "UNB2_POL_SWITCH_1V2_TEMP_R [45.125 45.125]\n",
      "UNB2_POL_SWITCH_PHY_VOUT_R [1.00024414 1.00024414]\n",
      "UNB2_POL_SWITCH_PHY_IOUT_R [0.52050781 0.52050781]\n",
      "UNB2_POL_SWITCH_PHY_TEMP_R [46.1875 46.1875]\n",
      "UNB2_POL_CLOCK_VOUT_R [2.49951172 2.49951172]\n",
      "UNB2_POL_CLOCK_IOUT_R [0.94042969 0.94042969]\n",
      "UNB2_POL_CLOCK_TEMP_R [42.875 42.875]\n",
      "UNB2_FPGA_DDR4_SLOT_TEMP_R [[27.5  27.5  29.25 27.75 28.75 29.25 28.5  28.5 ]\n",
      " [27.5  27.5  29.25 27.75 28.75 29.25 28.5  28.5 ]]\n",
      "UNB2_FPGA_POL_CORE_IOUT_R [[5.921875   4.109375   3.76171875 3.55859375]\n",
      " [5.921875   4.1015625  3.76171875 3.55859375]]\n",
      "UNB2_FPGA_POL_CORE_TEMP_R [[30.84375 31.46875 32.4375  34.75   ]\n",
      " [30.84375 31.5     32.375   34.6875 ]]\n",
      "UNB2_FPGA_POL_ERAM_VOUT_R [[0.8996582  0.90014648 0.90014648 0.8996582 ]\n",
      " [0.8996582  0.8996582  0.90014648 0.8996582 ]]\n",
      "UNB2_FPGA_POL_ERAM_IOUT_R [[0.08764648 0.0880127  0.18725586 0.08703613]\n",
      " [0.02593994 0.0880127  0.18725586 0.08703613]]\n",
      "UNB2_FPGA_POL_ERAM_TEMP_R [[38.75   39.25   41.     41.4375]\n",
      " [38.75   39.25   41.     41.4375]]\n",
      "UNB2_FPGA_POL_RXGXB_VOUT_R [[0.90014648 0.89990234 0.90014648 0.90014648]\n",
      " [0.90014648 0.89990234 0.90014648 0.90014648]]\n",
      "UNB2_FPGA_POL_RXGXB_IOUT_R [[0.49755859 0.41113281 0.40234375 0.48876953]\n",
      " [0.49755859 0.41113281 0.40234375 0.48876953]]\n",
      "UNB2_FPGA_POL_RXGXB_TEMP_R [[34.75   38.0625 36.5    38.1875]\n",
      " [34.75   38.0625 36.5    38.1875]]\n",
      "UNB2_FPGA_POL_TXGXB_VOUT_R [[0.89990234 0.90014648 0.90014648 0.89990234]\n",
      " [0.89990234 0.90014648 0.90014648 0.89990234]]\n",
      "UNB2_FPGA_POL_TXGXB_IOUT_R [[0.17480469 0.12219238 0.06433105 0.13110352]\n",
      " [0.17480469 0.12219238 0.06433105 0.13110352]]\n",
      "UNB2_FPGA_POL_HGXB_VOUT_R [[1.80004883 1.79956055 1.79980469 1.79980469]\n",
      " [1.80004883 1.79956055 1.79980469 1.79980469]]\n",
      "UNB2_FPGA_POL_HGXB_IOUT_R [[0.67089844 0.76269531 0.80664062 0.7265625 ]\n",
      " [0.67089844 0.76269531 0.80664062 0.7265625 ]]\n",
      "UNB2_FPGA_POL_HGXB_TEMP_R [[40.375  41.8125 44.3125 40.625 ]\n",
      " [40.375  41.8125 44.3125 40.625 ]]\n",
      "UNB2_FPGA_POL_PGM_VOUT_R [[1.80029297 1.80004883 1.79931641 1.80029297]\n",
      " [1.80029297 1.80004883 1.79931641 1.80029297]]\n",
      "UNB2_FPGA_POL_PGM_IOUT_R [[0.13818359 0.17089844 0.31542969 0.10656738]\n",
      " [0.1550293  0.17089844 0.31542969 0.10656738]]\n",
      "UNB2_FPGA_POL_PGM_TEMP_R [[40.0625 42.1875 44.3125 40.3125]\n",
      " [40.0625 42.1875 44.3125 40.3125]]\n",
      "State <function __get_command_func.<locals>.f at 0x7f636d295510>\n",
      "Status <function __get_command_func.<locals>.f at 0x7f636d295510>\n"
     ]
    }
   ],
   "source": [
    "attr_names = d.get_attribute_list()\n",
    "\n",
    "\n",
    "for i in attr_names:\n",
    "    exec(\"value = print(i, d.{})\".format(i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "929965c2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Old values:\n",
      " [0 0]\n",
      "Values to be set:\n",
      " [1 3]\n",
      "Values set in RW:\n",
      " [1 3]\n",
      "Values read back after setting:\n",
      " [0 0]\n"
     ]
    }
   ],
   "source": [
    "#Test the LED CP\n",
    "led = d.UNB2_Front_Panel_LED_R\n",
    "print(\"Old values:\\n\",  led)\n",
    "led[0] = 1\n",
    "led[1] = 3\n",
    "print(\"Values to be set:\\n\", led)\n",
    "d.UNB2_Front_Panel_LED_RW = led\n",
    "print(\"Values set in RW:\\n\",d.UNB2_Front_Panel_LED_RW)\n",
    "print(\"Values read back after setting:\\n\",d.UNB2_Front_Panel_LED_R)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "6813164e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Old values:\n",
      " [False False]\n",
      "Values to be set:\n",
      " [False False]\n",
      "Values set in RW:\n",
      " [False False]\n"
     ]
    }
   ],
   "source": [
    "#Test the ON OFF CP\n",
    "onoff = d.UNB2_Power_ON_OFF_RW\n",
    "print(\"Old values:\\n\",  onoff)\n",
    "onoff[0] = False\n",
    "onoff[1] = False\n",
    "print(\"Values to be set:\\n\", onoff)\n",
    "d.UNB2_Power_ON_OFF_RW = onoff\n",
    "print(\"Values set in RW:\\n\",d.UNB2_Power_ON_OFF_RW)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "e9b32ec7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Old values:\n",
      " [ True  True]\n",
      "Values to be set:\n",
      " [False False]\n",
      "Values read back after setting:\n",
      " [False False]\n"
     ]
    }
   ],
   "source": [
    "#Test the MASK CP\n",
    "mask = d.UNB2_mask_RW\n",
    "print(\"Old values:\\n\",  mask)\n",
    "mask[0] = False\n",
    "mask[1] = False\n",
    "print(\"Values to be set:\\n\", mask)\n",
    "d.UNB2_mask_RW = mask\n",
    "print(\"Values read back after setting:\\n\",d.UNB2_mask_RW)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "transsexual-battle",
   "metadata": {},
   "outputs": [
    {
     "ename": "DevFailed",
     "evalue": "DevFailed[\nDevError[\n    desc = Read value for attribute FPGA_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/sdp/1, attribute FPGA_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/tmp/ipykernel_22/2885399456.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      1\u001b[0m values = [\n\u001b[0;32m----> 2\u001b[0;31m     \u001b[0;34m[\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mFPGA_mask_RW\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"FPGA_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[0m\u001b[1;32m      3\u001b[0m     \u001b[0;34m[\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mFPGA_scrap_R\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"FPGA_scrap_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[0mFPGA_scrap_RW\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"FPGA_scrap_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[0mFPGA_status_R\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"FPGA_status_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    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 = Read value for attribute FPGA_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/sdp/1, attribute FPGA_mask_RW\n  origin = DeviceProxy::read_attribute()\n  reason = API_AttributeFailed\nseverity = ERR]\n]"
     ]
    }
   ],
   "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": 19,
   "id": "b88868c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],\n",
       "       [1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],\n",
       "       [1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]],\n",
       "      dtype=float32)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wgswitches = d.FPGA_wg_enable_R\n",
    "print(\"Old values:\\n\",  wgswitches)\n",
    "wgswitches[9][0] = True\n",
    "wgswitches[10][0] = True\n",
    "print(\"Values to be set:\\n\", wgswitches)\n",
    "d.FPGA_wg_enable_RW =wgswitches\n",
    "time.sleep(7)\n",
    "print(\"Values read back after setting:\\n\",d.FPGA_wg_enable_R)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "8f3db8c7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[119.99817, 119.99817, 119.99817, 119.99817, 119.99817, 119.99817,\n",
       "        119.99817, 119.99817, 119.99817, 119.99817, 119.99817, 119.99817,\n",
       "        119.99817, 119.99817, 119.99817, 119.99817],\n",
       "       [119.99817, 119.99817, 119.99817, 119.99817, 119.99817, 119.99817,\n",
       "        119.99817, 119.99817, 119.99817, 119.99817, 119.99817, 119.99817,\n",
       "        119.99817, 119.99817, 119.99817, 119.99817],\n",
       "       [119.99817, 119.99817, 119.99817, 119.99817,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ],\n",
       "       [  0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ],\n",
       "       [  0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ],\n",
       "       [  0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ],\n",
       "       [  0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ],\n",
       "       [  0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ],\n",
       "       [  0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ],\n",
       "       [  0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ],\n",
       "       [  0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ],\n",
       "       [  0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ,   0.     ,   0.     ,\n",
       "          0.     ,   0.     ,   0.     ,   0.     ]], dtype=float32)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "phases = d.FPGA_wg_phase_R\n",
    "print(\"Old values:\\n\",  phases)\n",
    "phases[9][0] = 1.0334\n",
    "phases[9][1] = 20.15\n",
    "phases[10][0] = 130\n",
    "print(\"Values to be set:\\n\", phases)\n",
    "d.FPGA_wg_phase_RW = phases\n",
    "time.sleep(7)\n",
    "print(\"Values read back after setting:\\n\", d.FPGA_wg_phase_R)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e45b4874",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[29921878., 29921878., 29921878., 29921878., 29921878., 29921878.,\n",
       "        29921878., 29921878., 29921878., 29921878., 29921878., 29921878.,\n",
       "        29921878., 29921878., 29921878., 29921878.],\n",
       "       [29921878., 29921878., 29921878., 29921878., 29921878., 29921878.,\n",
       "        29921878., 29921878., 29921878., 29921878., 29921878., 29921878.,\n",
       "        29921878., 29921878., 29921878., 29921878.],\n",
       "       [29921878., 29921878., 29921878., 29921878.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.],\n",
       "       [       0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.],\n",
       "       [       0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.],\n",
       "       [       0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.],\n",
       "       [       0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.],\n",
       "       [       0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.],\n",
       "       [       0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.],\n",
       "       [       0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.],\n",
       "       [       0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.],\n",
       "       [       0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.,        0.,        0.,\n",
       "               0.,        0.,        0.,        0.]], dtype=float32)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "amplitudes = d.FPGA_wg_amplitude_R\n",
    "print(\"Old values:\\n\",  amplitudes)\n",
    "amplitudes[9][0] = 1.0\n",
    "amplitudes[9][1] = 1.99\n",
    "amplitudes[10][0] = 0.5\n",
    "print(\"Values to be set:\\n\", amplitudes)\n",
    "d.FPGA_wg_amplitude_RW = amplitudes\n",
    "time.sleep(7)\n",
    "print(\"Values read back after setting:\\n\", d.FPGA_wg_amplitude_R)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9b1bbd3e",
   "metadata": {},
   "outputs": [],
   "source": [
    "frequencies = d.FPGA_wg_frequency_R\n",
    "print(\"Old values:\\n\",  frequencies)\n",
    "frequencies[9][0] = 19000000\n",
    "frequencies[9][1] = 20000000\n",
    "frequencies[10][0] = 22000000\n",
    "print(\"Values to be set:\\n\", frequencies)\n",
    "d.FPGA_wg_frequency_RW = frequencies\n",
    "print(\"Values read back after setting:\\n\", d.FPGA_wg_frequency_R)"
   ]
  }
 ],
 "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
}