71 lines
2.3 KiB
Python
Executable File
71 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# *-----------------------------------------------------------------------*
|
|
# | |
|
|
# | Copyright (c) 2022 by Paul Scherrer Institute (http://www.psi.ch) |
|
|
# | Based on Zac great first implementation |
|
|
# | Author Thierry Zamofing (thierry.zamofing@psi.ch) |
|
|
# *-----------------------------------------------------------------------*
|
|
|
|
import logging
|
|
_log=logging.getLogger(__name__)
|
|
import epics
|
|
|
|
#from app_config import settings
|
|
#from app_utils import assert_motor_positions
|
|
|
|
class Backlight(object):
|
|
def __init__(self, prefix: str='SAR-EXPMX:MOT_BLGT',pos={'pos_in':-29000,'pos_out':0,'pos_diode':0}):
|
|
if prefix is None:
|
|
self._sim={'pos':'out'}
|
|
_log.info('simulated mode:{}'.format(self._sim))
|
|
return #simulated mode
|
|
self._mot = epics.Motor(prefix)
|
|
self._pos = pos
|
|
|
|
def is_pos(self,strPos):
|
|
try:
|
|
m=self._mot
|
|
except AttributeError:
|
|
_log.info('simulated mode:{}'.format(strPos))
|
|
return self._sim['pos']==strPos
|
|
m.refresh()
|
|
return abs(m.readback - self._pos['pos_'+strPos]) < 10
|
|
|
|
def move(self, strPos, wait=False):
|
|
try:
|
|
m=self._mot
|
|
except AttributeError:
|
|
_log.info('simulated mode:{}'.format(strPos))
|
|
self._sim['pos']=strPos
|
|
return
|
|
m=self._mot
|
|
_log.debug("backlight to {}".format(strPos))
|
|
target=self._pos['pos_'+strPos]
|
|
m.move(target, ignore_limits=True, wait=wait)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import time,os
|
|
import argparse
|
|
logging.basicConfig(level=logging.DEBUG,format='%(levelname)s:%(module)s:%(lineno)d:%(funcName)s:%(message)s ')
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('-m', '--mode', help='mode string with characters: "frgbka" for front,red,green,blue,back,all')
|
|
parser.add_argument("-t", "--test", help="test sequence", action="store_true")
|
|
|
|
args = parser.parse_args()
|
|
os.environ['EPICS_CA_ADDR_LIST']='129.129.244.255 sf-saresc-cagw.psi.ch:5062 sf-saresc-cagw.psi.ch:5066'
|
|
_log.info('Arguments:{}'.format(args.__dict__))
|
|
|
|
bl = Backlight()
|
|
if args.test:
|
|
bl.move('in')
|
|
time.sleep(2)
|
|
bl.move('out')
|
|
time.sleep(2)
|
|
bl.move('in')
|
|
time.sleep(2)
|
|
bl.move('out')
|
|
time.sleep(2)
|