{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# QCoDeS Example with Oxford Triton" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/*\r\n", " * Qcodes Jupyter/IPython widgets\r\n", " */\r\n", "require([\r\n", " 'nbextensions/widgets/widgets/js/widget',\r\n", " 'nbextensions/widgets/widgets/js/manager'\r\n", "], function (widget, manager) {\r\n", "\r\n", " var UpdateView = widget.DOMWidgetView.extend({\r\n", " render: function() {\r\n", " window.MYWIDGET = this;\r\n", " this._interval = 0;\r\n", " this.update();\r\n", " },\r\n", " update: function() {\r\n", " this.display(this.model.get('_message'));\r\n", " this.setInterval();\r\n", " },\r\n", " display: function(message) {\r\n", " /*\r\n", " * display method: override this for custom display logic\r\n", " */\r\n", " this.el.innerHTML = message;\r\n", " },\r\n", " remove: function() {\r\n", " clearInterval(this._updater);\r\n", " },\r\n", " setInterval: function(newInterval) {\r\n", " var me = this;\r\n", " if(newInterval===undefined) newInterval = me.model.get('interval');\r\n", " if(newInterval===me._interval) return;\r\n", "\r\n", " me._interval = newInterval;\r\n", "\r\n", " if(me._updater) clearInterval(me._updater);\r\n", "\r\n", " if(me._interval) {\r\n", " me._updater = setInterval(function() {\r\n", " me.send({myupdate: true});\r\n", " if(!me.model.comm_live) {\r\n", " console.log('missing comm, canceling widget updates', me);\r\n", " clearInterval(me._updater);\r\n", " }\r\n", " }, me._interval * 1000);\r\n", " }\r\n", " }\r\n", " });\r\n", " manager.WidgetManager.register_widget_view('UpdateView', UpdateView);\r\n", "\r\n", " var HiddenUpdateView = UpdateView.extend({\r\n", " display: function(message) {\r\n", " this.$el.hide();\r\n", " }\r\n", " });\r\n", " manager.WidgetManager.register_widget_view('HiddenUpdateView', HiddenUpdateView);\r\n", "\r\n", " var SubprocessView = UpdateView.extend({\r\n", " render: function() {\r\n", " var me = window.SPVIEW = this;\r\n", " me._interval = 0;\r\n", " me._minimize = '';\r\n", " me._restore = '';\r\n", "\r\n", " // in case there is already an outputView present,\r\n", " // like from before restarting the kernel\r\n", " $('.qcodes-output-view').not(me.$el).remove();\r\n", "\r\n", " me.$el\r\n", " .addClass('qcodes-output-view')\r\n", " .attr('qcodes-state', 'docked')\r\n", " .html(\r\n", " '
' +\r\n", " '' +\r\n", " '' +\r\n", " '' +\r\n", " '' +\r\n", " '' +\r\n", " '' +\r\n", " '
' +\r\n", " '
'\r\n",
       "                );\r\n",
       "\r\n",
       "            me.clearButton = me.$el.find('.qcodes-clear-output');\r\n",
       "            me.minButton = me.$el.find('.qcodes-minimize');\r\n",
       "            me.outputArea = me.$el.find('pre');\r\n",
       "            me.subprocessList = me.$el.find('span');\r\n",
       "            me.abortButton = me.$el.find('.qcodes-abort-loop');\r\n",
       "\r\n",
       "            me.clearButton.click(function() {\r\n",
       "                me.outputArea.html('');\r\n",
       "                me.clearButton.addClass('disabled');\r\n",
       "            });\r\n",
       "\r\n",
       "            me.abortButton.click(function() {\r\n",
       "                me.send({abort: true});\r\n",
       "            });\r\n",
       "\r\n",
       "            me.$el.find('.js-state').click(function() {\r\n",
       "                var oldState = me.$el.attr('qcodes-state'),\r\n",
       "                    state = this.className.substr(this.className.indexOf('qcodes'))\r\n",
       "                        .split('-')[1].split(' ')[0];\r\n",
       "\r\n",
       "                // not sure why I can't pop it out of the widgetarea in render, but it seems that\r\n",
       "                // some other bit of code resets the parent after render if I do it there.\r\n",
       "                // To be safe, just do it on every state click.\r\n",
       "                me.$el.appendTo('body');\r\n",
       "\r\n",
       "                if(oldState === 'floated') {\r\n",
       "                    me.$el.draggable('destroy').css({left:'', top: ''});\r\n",
       "                }\r\n",
       "\r\n",
       "                me.$el.attr('qcodes-state', state);\r\n",
       "\r\n",
       "                if(state === 'floated') {\r\n",
       "                    me.$el.draggable().css({\r\n",
       "                        left: window.innerWidth - me.$el.width() - 15,\r\n",
       "                        top: window.innerHeight - me.$el.height() - 10\r\n",
       "                    });\r\n",
       "                }\r\n",
       "            });\r\n",
       "\r\n",
       "            $(window).resize(function() {\r\n",
       "                if(me.$el.attr('qcodes-state') === 'floated') {\r\n",
       "                    var position = me.$el.position(),\r\n",
       "                        minVis = 20,\r\n",
       "                        maxLeft = window.innerWidth - minVis,\r\n",
       "                        maxTop = window.innerHeight - minVis;\r\n",
       "\r\n",
       "                    if(position.left > maxLeft) me.$el.css('left', maxLeft);\r\n",
       "                    if(position.top > maxTop) me.$el.css('top', maxTop);\r\n",
       "                }\r\n",
       "            });\r\n",
       "\r\n",
       "            me.update();\r\n",
       "        },\r\n",
       "\r\n",
       "        display: function(message) {\r\n",
       "            if(message) {\r\n",
       "                var initialScroll = this.outputArea.scrollTop();\r\n",
       "                this.outputArea.scrollTop(this.outputArea.prop('scrollHeight'));\r\n",
       "                var scrollBottom = this.outputArea.scrollTop();\r\n",
       "\r\n",
       "                if(this.$el.attr('qcodes-state') === 'minimized') {\r\n",
       "                    this.$el.find('.qcodes-docked').click();\r\n",
       "                    // always scroll to the bottom if we're restoring\r\n",
       "                    // because of a new message\r\n",
       "                    initialScroll = scrollBottom;\r\n",
       "                }\r\n",
       "\r\n",
       "                this.outputArea.append(message);\r\n",
       "                this.clearButton.removeClass('disabled');\r\n",
       "\r\n",
       "                // if we were scrolled to the bottom initially, make sure\r\n",
       "                // we stay that way.\r\n",
       "                this.outputArea.scrollTop(initialScroll === scrollBottom ?\r\n",
       "                    this.outputArea.prop('scrollHeight') : initialScroll);\r\n",
       "            }\r\n",
       "\r\n",
       "            var processes = this.model.get('_processes') || 'No subprocesses';\r\n",
       "            this.abortButton.toggleClass('disabled', processes.indexOf('Measurement')===-1);\r\n",
       "            this.subprocessList.text(processes);\r\n",
       "        }\r\n",
       "    });\r\n",
       "    manager.WidgetManager.register_widget_view('SubprocessView', SubprocessView);\r\n",
       "});\r\n"
      ],
      "text/plain": [
       ""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       ""
      ],
      "text/plain": [
       ""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib nbagg\n",
    "import matplotlib.pyplot as plt\n",
    "import time\n",
    "import numpy as np\n",
    "import qcodes as qc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13:21:17\n",
      "23.3481\n",
      "23.3481\n",
      "Idle\n",
      "OK\n"
     ]
    }
   ],
   "source": [
    "import qcodes.instrument_drivers.oxford.triton as triton\n",
    "\n",
    "\n",
    "triton = triton.Triton(name = 'Triton 1', address='127.0.0.1', port=33576, tmpfile='Triton1_thermometry.reg')\n",
    "# triton._get_temp_channels('thermometry.reg')\n",
    "# print(triton.chan_alias)\n",
    "\n",
    "print(triton.time.get())\n",
    "print(triton.T5.get())\n",
    "print(triton.MC.get())\n",
    "# for name,param in triton.parameters.items():\n",
    "#     print(name,param.get())\n",
    "print(triton.action.get())\n",
    "print(triton.status.get())\n",
    "# triton.close()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "triton.get_idn()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "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.9"
  },
  "nbsphinx": {
   "execute": "never"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}