Skip to content
Snippets Groups Projects
Commit 59d47dcd authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-950: refine jupyter macro

parent df50363b
No related branches found
No related tags found
1 merge request!458Resolve L2SS-950 "Jupyter macros"
......@@ -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]
%% Cell type:code id:c0494f3f-9db5-44cf-b70b-66a4e4180e71 tags:
``` python
# load the macro
%store -r __start_devices
```
%% Cell type:code id:f54daaa7-848f-4a5d-b6c6-70630e3c9474 tags:
``` python
__start_devices
```
%% Output
RECV(stat/recv/1) is in state ON
SDP(stat/sdp/1) is in state ON
%% Cell type:code id:a018bfb3-1eaa-437c-8866-19266902e9d4 tags:
``` python
```
......
%% Cell type:code id:69bb10e4-133e-40da-aa35-70da4b07d919 tags:
``` python
# Start all devices
devices = [recv, sdp]
for device in devices:
if device.state() == DevState.FAULT:
device.Off()
if device.state() == DevState.OFF:
device.warm_boot()
if device.state() == DevState.INIT:
device.Standby()
if device.state() == DevState.STANDBY:
device.On()
print(f'{device} is in state {device.state()}')
try:
if device.state() == DevState.FAULT:
device.Off()
if device.state() == DevState.OFF:
device.warm_boot()
if device.state() == DevState.INIT:
device.Standby()
if device.state() == DevState.STANDBY:
device.On()
print(f'{device} is in state {device.state()}')
except ConnectionFailed as e:
print(f"{device} is in state DOWN: {e.args[0].desc}")
```
%% Cell type:code id:6cad779f-6c9a-44a3-bbc8-9017cfb0f903 tags:
``` python
# %macro -q <macro_name> <cell_number>
%macro -q __start_devices 1
```
%% Cell type:code id:fc8cc0eb-2dcd-4905-9fb6-7bdbaf5b4650 tags:
``` python
recv.off()
recv.state()
```
%% Cell type:code id:0905f4b9-918f-4207-99d9-c73900271493 tags:
``` python
__start_devices
```
%% Cell type:code id:846e6813-58c5-4f1d-a156-8e19c073b2bf tags:
``` python
recv.state()
```
%% Cell type:code id:4e3b628e-7283-4d8d-8fd9-188142c810d1 tags:
``` python
# store the macro
%store __start_devices
```
%% Cell type:code id:ea34b186-48f5-4220-9951-2b61df9efe97 tags:
``` python
# load the macro
%store -r __start_devices
```
%% Cell type:code id:a7bc9113-dc8c-40b9-9d03-0f9cf275a9e5 tags:
``` python
__start_devices
```
%% Cell type:code id:b3644931-84fb-44e8-871b-49c32c3f9ec6 tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment