From cf76482f0a0fdabc3eb4940022c0e8aba029e8e6 Mon Sep 17 00:00:00 2001 From: Sirius Date: Sun, 23 Oct 2022 01:33:41 -0300 Subject: [PATCH 1/6] Add init script for reseting ion pumps --- .gitignore | 72 ++++++++++++++++++++++++++++++ bin/sirius-script-reset-ipumps.py | 73 +++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 .gitignore create mode 100755 bin/sirius-script-reset-ipumps.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bae0964 --- /dev/null +++ b/.gitignore @@ -0,0 +1,72 @@ +*~ + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# ipython notebooks + +siriuspy/siriuspy/pwrsupply/tests/.ipynb_checkpoints/ + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +.pytest_cache/ +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# Doxygen documentation +doc/doxygen/html/ +doc/doxygen/documentation.html + +# PyBuilder +target/ +.vscode + +# FTP configuration file +.ftpconfig diff --git a/bin/sirius-script-reset-ipumps.py b/bin/sirius-script-reset-ipumps.py new file mode 100755 index 0000000..e44a3f2 --- /dev/null +++ b/bin/sirius-script-reset-ipumps.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python-sirius + +import time +import epics + +CONTROLLERS = { + 'SI-RA01:VA-SIPC-06': + ['SI-01SAFE:VA-SIP150-MD', + 'SI-01C2FE:VA-SIP150-MD', + 'SI-0102BCFE:VA-SIP150-MD', + 'SR-RA01:VA-SIPC-06:C4'], + 'SI-RA02:VA-SIPC-05': + ['SI-02C4:VA-SIP20-BG', + 'SI-03M1:VA-SIP20-BG', + 'SI-02SBFE:VA-SIP150-MD', + 'SI-02BCFE:VA-SIP150-MD', + ], + 'SI-RA03:VA-SIPC-05': + ['SI-03SPFE:VA-SIP150-MD', + 'SI-03C2FE:VA-SIP150-MD', + 'SI-03BCFE:VA-SIP150-MD', + 'SI-RA03:VA-SIPC-05:C4', + ], +} + + +ION_PUMPS = [ + 'SI-01BCFE:VA-SIP150-MD', + 'SI-02BCFE:VA-SIP150-MD', + 'SI-03BCFE:VA-SIP150-MD', + 'SI-04BCFE:VA-SIP150-MD', + 'SI-05BCFE:VA-SIP150-MD', + 'SI-06BCFE:VA-SIP150-MD', + 'SI-07BCFE:VA-SIP150-MD', + 'SI-08BCFE:VA-SIP150-MD', + 'SI-09BCFE:VA-SIP150-MD', + 'SI-10BCFE:VA-SIP150-MD', + 'SI-11BCFE:VA-SIP150-MD', + 'SI-12BCFE:VA-SIP150-MD', + 'SI-13BCFE:VA-SIP150-MD', + 'SI-14BCFE:VA-SIP150-MD', + 'SI-15BCFE:VA-SIP150-MD', + 'SI-16BCFE:VA-SIP150-MD', + 'SI-17BCFE:VA-SIP150-MD', + 'SI-18BCFE:VA-SIP150-MD', + 'SI-19BCFE:VA-SIP150-MD', + 'SI-20BCFE:VA-SIP150-MD', + ] + + + +def check_currents(pvs, threshold=0): + while True: + print('checking all ion pumps...') + for ion_pump, pv in pvs.items(): + if pv.value < threshold: + print('ion pump {} has current below threshold!'.format(ion_pump)) + time.sleep(0.2) + +def create_ion_pumps_currents_pvs(ion_pumps): + pvs = {ion_pump:epics.PV(ion_pump + ':Current-Mon') for ion_pump in ion_pumps} + for pv in pvs.values(): + if not pv.wait_for_connection(timeout=10): + print('timeout in {}'.format(pv.pvname)) + return pvs + + +pvs = create_ion_pumps_currents_pvs(ION_PUMPS) +check_currents(pvs, threshold=2e-7) + + + + From dc8eb6d1284cf32f0f1d398a5aac3e099a40b56f Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 23 Oct 2022 01:37:32 -0300 Subject: [PATCH 2/6] test --- bin/sirius-script-reset-ipumps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/sirius-script-reset-ipumps.py b/bin/sirius-script-reset-ipumps.py index e44a3f2..40ed32d 100755 --- a/bin/sirius-script-reset-ipumps.py +++ b/bin/sirius-script-reset-ipumps.py @@ -20,7 +20,7 @@ 'SI-03C2FE:VA-SIP150-MD', 'SI-03BCFE:VA-SIP150-MD', 'SI-RA03:VA-SIPC-05:C4', - ], + ], } From f12d8ef64571a526204353bbe00ee33de847666b Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 23 Oct 2022 04:02:48 -0300 Subject: [PATCH 3/6] Completadas as listas CONTROLLERS e ION_PUMPS --- bin/sirius-script-reset-ipumps.py | 137 ++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/bin/sirius-script-reset-ipumps.py b/bin/sirius-script-reset-ipumps.py index 40ed32d..c331610 100755 --- a/bin/sirius-script-reset-ipumps.py +++ b/bin/sirius-script-reset-ipumps.py @@ -21,6 +21,113 @@ 'SI-03BCFE:VA-SIP150-MD', 'SI-RA03:VA-SIPC-05:C4', ], + + 'SI-RA05:VA-SIPC-05': + ['SI-05SAFE:VA-SIP150-MD', + 'SI-05C2FE:VA-SIP150-MD', + 'SI-05BCFE:VA-SIP150-MD', + 'SI-RA05:VA-SIPC-05:C4', + ], + + 'SI-RA06:VA-SIPC-04': + ['SI-06C4:VA-SIP20-BG', + 'SI-07M1:VA-SIP20-BG', + 'SI-06SBFE:VA-SIP150-MD', + 'SI-06BCFE:VA-SIP150-MD', + ], + + 'SI-RA07:VA-SIPC-05': + ['SI-07SPFE:VA-SIP150-MD', + 'SI-07C2FE:VA-SIP150-MD', + 'SI-07BCFE:VA-SIP150-MD', + 'SR-RA07:VA-SIPC-05:C4', + ], + + 'SI-RA09:VA-SIPC-05': + ['SI-09SAFE:VA-SIP150-MD', + 'SI-09C2FE:VA-SIP150-MD', + 'SI-09BCFE:VA-SIP150-MD', + 'SR-RA09:VA-SIPC-05:C4', + ], + + 'SI-RA10:VA-SIPC-04': + ['SI-10C4:VA-SIP20-BG', + 'SI-11M1:VA-SIP20-BG', + 'SI-10SBFE:VA-SIP150-MD', + 'SI-10BCFE:VA-SIP150-MD', + ], + + 'SI-RA11:VA-SIPC-05': + ['SI-11SPFE:VA-SIP150-MD', + 'SI-11C2FE:VA-SIP150-MD', + 'SI-11BCFE:VA-SIP150-MD', + 'SR-RA11:VA-SIPC-05:C4', + ], + + 'SI-RA12:VA-SIPC-04': + ['SI-12C4:VA-SIP20-BG', + 'SI-13M1:VA-SIP20-BG', + 'SI-12SBFE:VA-SIP150-MD', + 'SI-12BCFE:VA-SIP150-MD', + ], + + 'SI-RA13:VA-SIPC-05': + ['SI-13SAFE:VA-SIP150-MD', + 'SI-13C2FE:VA-SIP150-MD', + 'SI-13BCFE:VA-SIP150-MD', + 'SR-RA13:VA-SIPC-05:C4', + ], + + 'SI-RA14:VA-SIPC-04': + ['SI-14C4:VA-SIP20-BG', + 'SI-15M1:VA-SIP20-BG', + 'SI-14SBFE:VA-SIP150-MD', + 'SI-14BCFE:VA-SIP150-MD', + ], + + 'SI-RA15:VA-SIPC-05': + ['SI-15SPFE:VA-SIP150-MD', + 'SI-15C2FE:VA-SIP150-MD', + 'SI-15BCFE:VA-SIP150-MD', + 'SR-RA15:VA-SIPC-05:C4', + ], + + 'SI-RA16:VA-SIPC-04': + ['SI-16C4:VA-SIP20-BG', + 'SI-17M1:VA-SIP20-BG', + 'SI-16SBFE:VA-SIP150-MD', + 'SI-16BCFE:VA-SIP150-MD', + ], + + 'SI-RA17:VA-SIPC-05': + ['SI-17SAFE:VA-SIP150-MD', + 'SI-17C2FE:VA-SIP150-MD', + 'SI-17BCFE:VA-SIP150-MD', + 'SR-RA17:VA-SIPC-05:C4', + ], + + 'SI-RA18:VA-SIPC-04': + ['SI-18C4:VA-SIP20-BG', + 'SI-19M1:VA-SIP20-BG', + 'SI-18SBFE:VA-SIP150-MD', + 'SI-18BCFE:VA-SIP150-MD', + ], + + 'SI-RA19:VA-SIPC-05': + ['SI-19SPFE:VA-SIP150-MD', + 'SI-19C2FE:VA-SIP150-MD', + 'SI-19BCFE:VA-SIP150-MD', + 'SR-RA19:VA-SIPC-05:C4', + ], + + 'SI-RA20:VA-SIPC-06': + ['SI-20C4:VA-SIP20-BG', + 'SI-01M1:VA-SIP20-BG', + 'SI-20SBFE:VA-SIP150-MD', + 'SI-20BCFE:VA-SIP150-MD', + ], + + } @@ -45,6 +152,36 @@ 'SI-18BCFE:VA-SIP150-MD', 'SI-19BCFE:VA-SIP150-MD', 'SI-20BCFE:VA-SIP150-MD', + 'SI-01C2FE:VA-SIP150-MD', + 'SI-03C2FE:VA-SIP150-MD', + 'SI-05C2FE:VA-SIP150-MD', + 'SI-07C2FE:VA-SIP150-MD', + 'SI-09C2FE:VA-SIP150-MD', + 'SI-11C2FE:VA-SIP150-MD', + 'SI-13C2FE:VA-SIP150-MD', + 'SI-15C2FE:VA-SIP150-MD', + 'SI-17C2FE:VA-SIP150-MD', + 'SI-19C2FE:VA-SIP150-MD', + 'SI-02SBFE:VA-SIP150-MD', + 'SI-04SBFE:VA-SIP150-MD', + 'SI-06SBFE:VA-SIP150-MD', + 'SI-08SBFE:VA-SIP150-MD', + 'SI-10SBFE:VA-SIP150-MD', + 'SI-12SBFE:VA-SIP150-MD', + 'SI-14SBFE:VA-SIP150-MD', + 'SI-16SBFE:VA-SIP150-MD', + 'SI-18SBFE:VA-SIP150-MD', + 'SI-20SBFE:VA-SIP150-MD', + 'SI-01SAFE:VA-SIP150-MD', + 'SI-05SAFE:VA-SIP150-MD', + 'SI-09SAFE:VA-SIP150-MD', + 'SI-13SAFE:VA-SIP150-MD', + 'SI-17SAFE:VA-SIP150-MD', + 'SI-03SPFE:VA-SIP150-MD', + 'SI-07SPFE:VA-SIP150-MD', + 'SI-11SPFE:VA-SIP150-MD', + 'SI-15SPFE:VA-SIP150-MD', + 'SI-19SPFE:VA-SIP150-MD', ] From b613b356d4ff5f4b8e823fc038f350881a8ae22a Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 26 Oct 2022 02:01:02 -0300 Subject: [PATCH 4/6] Complete CONTROLLER dict --- bin/sirius-script-reset-ipumps.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/bin/sirius-script-reset-ipumps.py b/bin/sirius-script-reset-ipumps.py index c331610..386b965 100755 --- a/bin/sirius-script-reset-ipumps.py +++ b/bin/sirius-script-reset-ipumps.py @@ -7,14 +7,17 @@ 'SI-RA01:VA-SIPC-06': ['SI-01SAFE:VA-SIP150-MD', 'SI-01C2FE:VA-SIP150-MD', - 'SI-0102BCFE:VA-SIP150-MD', - 'SR-RA01:VA-SIPC-06:C4'], + 'SI-01BCFE:VA-SIP150-MD', + 'SR-RA01:VA-SIPC-06:C4', + ], + 'SI-RA02:VA-SIPC-05': ['SI-02C4:VA-SIP20-BG', 'SI-03M1:VA-SIP20-BG', 'SI-02SBFE:VA-SIP150-MD', 'SI-02BCFE:VA-SIP150-MD', ], + 'SI-RA03:VA-SIPC-05': ['SI-03SPFE:VA-SIP150-MD', 'SI-03C2FE:VA-SIP150-MD', @@ -22,6 +25,13 @@ 'SI-RA03:VA-SIPC-05:C4', ], + 'SI-RA04:VA-SIPC-04': + ['SI-04C4:VA-SIP20-BG', + 'SI-05M1:VA-SIP20-BG', + 'SI-04SBFE:VA-SIP150-MD', + 'SI-04BCFE:VA-SIP150-MD', + ], + 'SI-RA05:VA-SIPC-05': ['SI-05SAFE:VA-SIP150-MD', 'SI-05C2FE:VA-SIP150-MD', @@ -43,6 +53,13 @@ 'SR-RA07:VA-SIPC-05:C4', ], + 'SI-RA08:VA-SIPC-04': + ['SI-08C4:VA-SIP20-BG', + 'SI-09M1:VA-SIP20-BG', + 'SI-08SBFE:VA-SIP150-MD', + 'SI-08BCFE:VA-SIP150-MD', + ], + 'SI-RA09:VA-SIPC-05': ['SI-09SAFE:VA-SIP150-MD', 'SI-09C2FE:VA-SIP150-MD', From 7e877611bf2c510a1bd8fa0a4d32a484731b999b Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 26 Oct 2022 02:27:07 -0300 Subject: [PATCH 5/6] add ion pump to controller conversion --- bin/sirius-script-reset-ipumps.py | 58 ++++++++++++++++--------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/bin/sirius-script-reset-ipumps.py b/bin/sirius-script-reset-ipumps.py index 386b965..c1da849 100755 --- a/bin/sirius-script-reset-ipumps.py +++ b/bin/sirius-script-reset-ipumps.py @@ -2,7 +2,8 @@ import time import epics - + + CONTROLLERS = { 'SI-RA01:VA-SIPC-06': ['SI-01SAFE:VA-SIP150-MD', @@ -10,142 +11,121 @@ 'SI-01BCFE:VA-SIP150-MD', 'SR-RA01:VA-SIPC-06:C4', ], - 'SI-RA02:VA-SIPC-05': ['SI-02C4:VA-SIP20-BG', 'SI-03M1:VA-SIP20-BG', 'SI-02SBFE:VA-SIP150-MD', 'SI-02BCFE:VA-SIP150-MD', ], - 'SI-RA03:VA-SIPC-05': ['SI-03SPFE:VA-SIP150-MD', 'SI-03C2FE:VA-SIP150-MD', 'SI-03BCFE:VA-SIP150-MD', 'SI-RA03:VA-SIPC-05:C4', ], - 'SI-RA04:VA-SIPC-04': ['SI-04C4:VA-SIP20-BG', 'SI-05M1:VA-SIP20-BG', 'SI-04SBFE:VA-SIP150-MD', 'SI-04BCFE:VA-SIP150-MD', ], - 'SI-RA05:VA-SIPC-05': ['SI-05SAFE:VA-SIP150-MD', 'SI-05C2FE:VA-SIP150-MD', 'SI-05BCFE:VA-SIP150-MD', 'SI-RA05:VA-SIPC-05:C4', ], - 'SI-RA06:VA-SIPC-04': ['SI-06C4:VA-SIP20-BG', 'SI-07M1:VA-SIP20-BG', 'SI-06SBFE:VA-SIP150-MD', 'SI-06BCFE:VA-SIP150-MD', ], - 'SI-RA07:VA-SIPC-05': ['SI-07SPFE:VA-SIP150-MD', 'SI-07C2FE:VA-SIP150-MD', 'SI-07BCFE:VA-SIP150-MD', 'SR-RA07:VA-SIPC-05:C4', ], - 'SI-RA08:VA-SIPC-04': ['SI-08C4:VA-SIP20-BG', 'SI-09M1:VA-SIP20-BG', 'SI-08SBFE:VA-SIP150-MD', 'SI-08BCFE:VA-SIP150-MD', ], - 'SI-RA09:VA-SIPC-05': ['SI-09SAFE:VA-SIP150-MD', 'SI-09C2FE:VA-SIP150-MD', 'SI-09BCFE:VA-SIP150-MD', 'SR-RA09:VA-SIPC-05:C4', ], - 'SI-RA10:VA-SIPC-04': ['SI-10C4:VA-SIP20-BG', 'SI-11M1:VA-SIP20-BG', 'SI-10SBFE:VA-SIP150-MD', 'SI-10BCFE:VA-SIP150-MD', ], - 'SI-RA11:VA-SIPC-05': ['SI-11SPFE:VA-SIP150-MD', 'SI-11C2FE:VA-SIP150-MD', 'SI-11BCFE:VA-SIP150-MD', 'SR-RA11:VA-SIPC-05:C4', ], - 'SI-RA12:VA-SIPC-04': ['SI-12C4:VA-SIP20-BG', 'SI-13M1:VA-SIP20-BG', 'SI-12SBFE:VA-SIP150-MD', 'SI-12BCFE:VA-SIP150-MD', ], - 'SI-RA13:VA-SIPC-05': ['SI-13SAFE:VA-SIP150-MD', 'SI-13C2FE:VA-SIP150-MD', 'SI-13BCFE:VA-SIP150-MD', 'SR-RA13:VA-SIPC-05:C4', ], - 'SI-RA14:VA-SIPC-04': ['SI-14C4:VA-SIP20-BG', 'SI-15M1:VA-SIP20-BG', 'SI-14SBFE:VA-SIP150-MD', 'SI-14BCFE:VA-SIP150-MD', ], - 'SI-RA15:VA-SIPC-05': ['SI-15SPFE:VA-SIP150-MD', 'SI-15C2FE:VA-SIP150-MD', 'SI-15BCFE:VA-SIP150-MD', 'SR-RA15:VA-SIPC-05:C4', ], - 'SI-RA16:VA-SIPC-04': ['SI-16C4:VA-SIP20-BG', 'SI-17M1:VA-SIP20-BG', 'SI-16SBFE:VA-SIP150-MD', 'SI-16BCFE:VA-SIP150-MD', ], - 'SI-RA17:VA-SIPC-05': ['SI-17SAFE:VA-SIP150-MD', 'SI-17C2FE:VA-SIP150-MD', 'SI-17BCFE:VA-SIP150-MD', 'SR-RA17:VA-SIPC-05:C4', ], - 'SI-RA18:VA-SIPC-04': ['SI-18C4:VA-SIP20-BG', 'SI-19M1:VA-SIP20-BG', 'SI-18SBFE:VA-SIP150-MD', 'SI-18BCFE:VA-SIP150-MD', ], - 'SI-RA19:VA-SIPC-05': ['SI-19SPFE:VA-SIP150-MD', 'SI-19C2FE:VA-SIP150-MD', 'SI-19BCFE:VA-SIP150-MD', 'SR-RA19:VA-SIPC-05:C4', ], - 'SI-RA20:VA-SIPC-06': ['SI-20C4:VA-SIP20-BG', 'SI-01M1:VA-SIP20-BG', 'SI-20SBFE:VA-SIP150-MD', 'SI-20BCFE:VA-SIP150-MD', ], - - -} + } ION_PUMPS = [ @@ -202,6 +182,13 @@ ] +def conv_ipump_2_controller(ion_pump): + """.""" + for controller, channels in CONTROLLERS.items(): + if ion_pump in channels: + channel_idx = channels.index(ion_pump) + return controller, channel_idx + def check_currents(pvs, threshold=0): while True: @@ -210,18 +197,33 @@ def check_currents(pvs, threshold=0): if pv.value < threshold: print('ion pump {} has current below threshold!'.format(ion_pump)) time.sleep(0.2) - -def create_ion_pumps_currents_pvs(ion_pumps): + + +def create_controllers_steps_pvs(controllers, timeout=10): + pvs = {controller:epics.PV(controller + ':Step-SP') for controller in controllers} + for pv in pvs.values(): + if not pv.wait_for_connection(timeout=timeout): + print('timeout in {}'.format(pv.pvname)) + return pvs + +def create_ion_pumps_currents_pvs(ion_pumps, timeout=10): pvs = {ion_pump:epics.PV(ion_pump + ':Current-Mon') for ion_pump in ion_pumps} for pv in pvs.values(): - if not pv.wait_for_connection(timeout=10): + if not pv.wait_for_connection(timeout=timeout): print('timeout in {}'.format(pv.pvname)) return pvs -pvs = create_ion_pumps_currents_pvs(ION_PUMPS) -check_currents(pvs, threshold=2e-7) +# pvs = create_ion_pumps_currents_pvs(ION_PUMPS) +# check_currents(pvs, threshold=2e-7) +# controller_name = 'SI-RA01:VA-SIPC-06' +# ion_pumps = CONTROLLERS[controller_name] +# print(ion_pumps) +controller_name, channel_idx = conv_ipump_2_controller(ION_PUMPS[0]) +pvs = create_controllers_steps_pvs(CONTROLLERS) +pv = pvs[controller_name] +print(pv.value) From b8bdabbf712755b62b6401c91dbd29b815a0a1fb Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 26 Oct 2022 02:46:16 -0300 Subject: [PATCH 6/6] add ion pump voltage target function --- bin/sirius-script-reset-ipumps.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/sirius-script-reset-ipumps.py b/bin/sirius-script-reset-ipumps.py index c1da849..109215e 100755 --- a/bin/sirius-script-reset-ipumps.py +++ b/bin/sirius-script-reset-ipumps.py @@ -214,6 +214,14 @@ def create_ion_pumps_currents_pvs(ion_pumps, timeout=10): return pvs +def create_ion_pumps_voltage_target_pvs(ion_pumps, timeout=10): + pvs = {ion_pump:epics.PV(ion_pump + ':VoltageTarget-SP') for ion_pump in ion_pumps} + for pv in pvs.values(): + if not pv.wait_for_connection(timeout=timeout): + print('timeout in {}'.format(pv.pvname)) + return pvs + + # pvs = create_ion_pumps_currents_pvs(ION_PUMPS) # check_currents(pvs, threshold=2e-7)