#!/usr/local/lcls/package/python/current/bin/python

from __future__ import print_function
import epics
import time

# Author: N. Balakrishnan
# Created: 11/2/2017
# Modified: 
#
# Usage: ./enableXLEAP.py [OPTION]
# Description: Enables XLEAP motors
XLEAP = '''
WIGG:LTU1:849:USMotor
WIGG:LTU1:849:DSMotor
'''.strip().split()

# Turning on XLEAP
for prefix in XLEAP:
    enable_pv = ''.join((prefix, '.CNEN'))
    if epics.caget(enable_pv):
        print(prefix, 'is', epics.caget(enable_pv, as_string=True))    
    else:
        print(prefix, 'is disabled. Turning it on...')
        epics.caput('{}'.format(enable_pv), 1)
        time.sleep(1)
        print(prefix, 'is', epics.caget(enable_pv, as_string=True))

