Skip to content

Commit

Permalink
Merge pull request #103 from klauer/add_interface
Browse files Browse the repository at this point in the history
ENH: Add pcdsdevices interface support
  • Loading branch information
klauer authored Sep 30, 2020
2 parents 67e819f + d544f16 commit 6b7a127
Show file tree
Hide file tree
Showing 15 changed files with 534 additions and 405 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
ignore = E226,E741,W504
exclude = .git,__pycache__
max-line-length = 115
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: no-commit-to-branch
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-ast
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-xml
- id: check-yaml
exclude: '^(conda-recipe/meta.yaml)$'
- id: debug-statements

- repo: https://gitlab.com/pycqa/flake8.git
rev: 3.8.3
hooks:
- id: flake8

- repo: https://github.com/timothycrosley/isort
rev: 5.5.3
hooks:
- id: isort
22 changes: 13 additions & 9 deletions hxrsnd/aerotech.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
import os

import numpy as np
from ophyd import Component as Cmp, FormattedComponent as FrmCmp
from ophyd.utils import LimitError
from ophyd import Component as Cmp
from ophyd import FormattedComponent as FrmCmp
from ophyd.signal import EpicsSignal, EpicsSignalRO, Signal
from ophyd.status import wait as status_wait
from ophyd.utils import LimitError

from .sndmotor import SndEpicsMotor
from .exceptions import (BadN2Pressure, MotorDisabled, MotorFaulted,
MotorStopped)
from .pneumatic import PressureSwitch
from .sndmotor import SndEpicsMotor
from .utils import absolute_submodule_path, as_list, stop_on_keyboardinterrupt
from .exceptions import MotorDisabled, MotorFaulted, MotorStopped, BadN2Pressure

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -283,7 +285,8 @@ def mv(self, position, wait=True, print_move=True,
if wait:
logger.info("Move completed for '{0}'.".format(self.desc))
else:
logger.info("Move command sent to '{0}'.".format(self.desc))
logger.info(
"Move command sent to '{0}'.".format(self.desc))
return status

# Catch all the common motor exceptions
Expand Down Expand Up @@ -613,7 +616,8 @@ def expert_screen(self, print_msg=True):
print_msg : bool, optional
Prints that the screen is being launched.
"""
path = absolute_submodule_path("hxrsnd/screens/motor_expert_screens.sh")
path = absolute_submodule_path(
"hxrsnd/screens/motor_expert_screens.sh")
if print_msg:
logger.info("Launching expert screen.")
os.system("{0} {1} {2} &".format(path, self.prefix, "aerotech"))
Expand Down Expand Up @@ -653,12 +657,12 @@ def status(self, status="", offset=0, print_status=True, newline=False,
status += "{0}Faulted: {1:>20}\n".format(" "*(offset+2),
str(self.faulted))
status += "{0}State: {1:>22}\n".format(" "*(offset+2),
str(self.state))
str(self.state))
status += "{0}Position: {1:>19}\n".format(" "*(offset+2),
np.round(self.wm(), 6))
status += "{0}Dial: {1:>23}\n".format(" "*(offset+2),
np.round(self.dial.get(),
6))
np.round(self.dial.get(),
6))
status += "{0}Limits: {1:>21}\n".format(
" "*(offset+2), str((int(self.low_limit),
int(self.high_limit))))
Expand Down
39 changes: 32 additions & 7 deletions hxrsnd/attocube.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"""
Attocube devices
"""
import os
import logging
import os

import numpy as np
from ophyd import PositionerBase
from ophyd import Component as Cmp
from ophyd.utils import LimitError
from ophyd import PositionerBase
from ophyd.signal import EpicsSignal, EpicsSignalRO
from ophyd.status import wait as status_wait
from ophyd.utils import LimitError

from .sndmotor import SndMotor
from .snddevice import SndDevice
from .exceptions import MotorDisabled, MotorError, MotorFaulted
from .snddevice import SndDevice
from .sndmotor import SndMotor
from .utils import absolute_submodule_path, as_list

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -48,6 +48,31 @@ class EccBase(SndMotor, PositionerBase):
"""
ECC Motor Class
"""
tab_component_names = True
tab_whitelist = [
'check_status',
# 'check_value',
'connected',
'disable',
'egu',
'enable',
'enabled',
'error',
'expert_screen',
'high_limit',
'limits',
'low_limit',
'move',
'mv',
'position',
'reference',
'referenced',
'reset',
'set_limits',
'status',
'stop',
]

# position
user_readback = Cmp(EpicsSignalRO, ":POSITION", auto_monitor=True)
user_setpoint = Cmp(EpicsSignal, ":CMD:TARGET")
Expand Down Expand Up @@ -361,7 +386,6 @@ def mv(self, position, print_move=True, wait=None,
logger.warning("Cannot move - motor {0} is currently faulted. Try "
"running 'motor.clear()'.".format(self.desc))


def check_status(self, position=None):
"""
Checks the status of the motor to make sure it is ready to move. Checks
Expand Down Expand Up @@ -456,7 +480,8 @@ def expert_screen(self, print_msg=True):
Prints that the screen is being launched.
"""
# Get the absolute path to the screen
path = absolute_submodule_path("hxrsnd/screens/motor_expert_screens.sh")
path = absolute_submodule_path(
"hxrsnd/screens/motor_expert_screens.sh")
if print_msg:
logger.info("Launching expert screen.")
os.system("{0} {1} {2} &".format(path, self.prefix, "attocube"))
Expand Down
Loading

0 comments on commit 6b7a127

Please sign in to comment.