diff --git a/docker-compose/jupyter/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py b/docker-compose/jupyter/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py index 350ecb1e87f4829ddd60698831bbf75d941782a9..527f1ee25ebfd8acb420d5433b44541c8a705656 100644 --- a/docker-compose/jupyter/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py +++ b/docker-compose/jupyter/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py @@ -10,6 +10,7 @@ xst = DeviceProxy("STAT/XST/1") unb2 = DeviceProxy("STAT/UNB2/1") boot = DeviceProxy("STAT/Boot/1") tilebeam = DeviceProxy("STAT/TileBeam/1") +pcon = DeviceProxy("STAT/PCON/1") psoc = DeviceProxy("STAT/PSOC/1") beamlet = DeviceProxy("STAT/Beamlet/1") digitalbeam = DeviceProxy("STAT/DigitalBeam/1") @@ -18,4 +19,4 @@ docker = DeviceProxy("STAT/Docker/1") temperaturemanager = DeviceProxy("STAT/TemperatureManager/1") # Put them in a list in case one wants to iterate -devices = [apsct, ccd, apspu, recv, sdp, bst, sst, xst, unb2, boot, tilebeam, beamlet, digitalbeam, antennafield, temperaturemanager, docker] +devices = [apsct, ccd, apspu, recv, sdp, bst, sst, xst, unb2, boot, tilebeam, beamlet, digitalbeam, antennafield, temperaturemanager, docker, pcon, psoc] diff --git a/docker-compose/jupyterlab/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py b/docker-compose/jupyterlab/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py index 350ecb1e87f4829ddd60698831bbf75d941782a9..527f1ee25ebfd8acb420d5433b44541c8a705656 100644 --- a/docker-compose/jupyterlab/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py +++ b/docker-compose/jupyterlab/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py @@ -10,6 +10,7 @@ xst = DeviceProxy("STAT/XST/1") unb2 = DeviceProxy("STAT/UNB2/1") boot = DeviceProxy("STAT/Boot/1") tilebeam = DeviceProxy("STAT/TileBeam/1") +pcon = DeviceProxy("STAT/PCON/1") psoc = DeviceProxy("STAT/PSOC/1") beamlet = DeviceProxy("STAT/Beamlet/1") digitalbeam = DeviceProxy("STAT/DigitalBeam/1") @@ -18,4 +19,4 @@ docker = DeviceProxy("STAT/Docker/1") temperaturemanager = DeviceProxy("STAT/TemperatureManager/1") # Put them in a list in case one wants to iterate -devices = [apsct, ccd, apspu, recv, sdp, bst, sst, xst, unb2, boot, tilebeam, beamlet, digitalbeam, antennafield, temperaturemanager, docker] +devices = [apsct, ccd, apspu, recv, sdp, bst, sst, xst, unb2, boot, tilebeam, beamlet, digitalbeam, antennafield, temperaturemanager, docker, pcon, psoc] diff --git a/jupyter-notebooks/load_macro.ipynb b/jupyter-notebooks/load_macro.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..52d2aea466575549a0fa00dbd1d29c281808f8e0 --- /dev/null +++ b/jupyter-notebooks/load_macro.ipynb @@ -0,0 +1,46 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "c0494f3f-9db5-44cf-b70b-66a4e4180e71", + "metadata": {}, + "outputs": [], + "source": [ + "# load the macro\n", + "%store -r __start_devices" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f54daaa7-848f-4a5d-b6c6-70630e3c9474", + "metadata": {}, + "outputs": [], + "source": [ + "__start_devices" + ] + } + ], + "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/macros.ipynb b/jupyter-notebooks/macros.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..3d4bf0befb4fd41602fec427fd30dece01030579 --- /dev/null +++ b/jupyter-notebooks/macros.ipynb @@ -0,0 +1,130 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "69bb10e4-133e-40da-aa35-70da4b07d919", + "metadata": {}, + "outputs": [], + "source": [ + "# Start all devices\n", + "for device in devices:\n", + " try:\n", + " if device.state() == DevState.FAULT:\n", + " device.Off()\n", + " if device.state() == DevState.OFF:\n", + " device.warm_boot()\n", + " if device.state() == DevState.INIT:\n", + " device.Standby()\n", + " if device.state() == DevState.STANDBY:\n", + " device.On() \n", + " print(f'{device} is in state {device.state()}')\n", + " except ConnectionFailed as e:\n", + " print(f\"{device} is in state DOWN: {e.args[0].desc}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6cad779f-6c9a-44a3-bbc8-9017cfb0f903", + "metadata": {}, + "outputs": [], + "source": [ + "# %macro -q <macro_name> <cell_number>\n", + "%macro -q __start_devices 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fc8cc0eb-2dcd-4905-9fb6-7bdbaf5b4650", + "metadata": {}, + "outputs": [], + "source": [ + "recv.off()\n", + "recv.state()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0905f4b9-918f-4207-99d9-c73900271493", + "metadata": {}, + "outputs": [], + "source": [ + "__start_devices" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "846e6813-58c5-4f1d-a156-8e19c073b2bf", + "metadata": {}, + "outputs": [], + "source": [ + "recv.state()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4e3b628e-7283-4d8d-8fd9-188142c810d1", + "metadata": {}, + "outputs": [], + "source": [ + "# store the macro\n", + "%store __start_devices " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ea34b186-48f5-4220-9951-2b61df9efe97", + "metadata": {}, + "outputs": [], + "source": [ + "# load the macro\n", + "%store -r __start_devices" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a7bc9113-dc8c-40b9-9d03-0f9cf275a9e5", + "metadata": {}, + "outputs": [], + "source": [ + "__start_devices" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b3644931-84fb-44e8-871b-49c32c3f9ec6", + "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 +}