From 7e905fa722dacbdd925c6a4d315bf2391eddb584 Mon Sep 17 00:00:00 2001 From: stedif <stefano.difrischia@inaf.it> Date: Thu, 13 Oct 2022 10:23:27 +0200 Subject: [PATCH] L2SS-950-create-macros --- jupyter-notebooks/load_macro.ipynb | 63 ++++++++++++++ jupyter-notebooks/macros.ipynb | 129 +++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 jupyter-notebooks/load_macro.ipynb create mode 100644 jupyter-notebooks/macros.ipynb diff --git a/jupyter-notebooks/load_macro.ipynb b/jupyter-notebooks/load_macro.ipynb new file mode 100644 index 000000000..d7348001f --- /dev/null +++ b/jupyter-notebooks/load_macro.ipynb @@ -0,0 +1,63 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "c0494f3f-9db5-44cf-b70b-66a4e4180e71", + "metadata": {}, + "outputs": [], + "source": [ + "# load the macro\n", + "%store -r __start_devices" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "f54daaa7-848f-4a5d-b6c6-70630e3c9474", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "RECV(stat/recv/1) is in state ON\n", + "SDP(stat/sdp/1) is in state ON\n" + ] + } + ], + "source": [ + "__start_devices" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a018bfb3-1eaa-437c-8866-19266902e9d4", + "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 +} diff --git a/jupyter-notebooks/macros.ipynb b/jupyter-notebooks/macros.ipynb new file mode 100644 index 000000000..cdbe6af56 --- /dev/null +++ b/jupyter-notebooks/macros.ipynb @@ -0,0 +1,129 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "69bb10e4-133e-40da-aa35-70da4b07d919", + "metadata": {}, + "outputs": [], + "source": [ + "# Start all devices\n", + "devices = [recv, sdp]\n", + "for device in devices:\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", + " \n", + " print(f'{device} is in state {device.state()}')" + ] + }, + { + "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 +} -- GitLab