Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reset ion pumps #141

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
237 changes: 237 additions & 0 deletions bin/sirius-script-reset-ipumps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
#!/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-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 = [
'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',
'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',
]


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:
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_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=timeout):
print('timeout in {}'.format(pv.pvname))
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)

# 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)