{ "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\nrequire([\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 '