Skip to content
Snippets Groups Projects
Commit c157b7d3 authored by 29iduser's avatar 29iduser
Browse files

endstation init with BL iocs not running

parent 4c8faffe
No related branches found
No related tags found
No related merge requests found
......@@ -95,13 +95,11 @@ def ARPES_init(*userName,**kwargs):
folders_ARPES(user_name,**kwargs)
#logging
try:
if kwargs['set_folders']:
log_init('ARPES',user_name,_ARPES_log_dictionary,set_file=True)
else:
log_init('ARPES',user_name,_ARPES_log_dictionary,set_file=False)
except:
print_warning_message('log_init failed')
if kwargs['set_folders']:
log_init('ARPES',user_name,_ARPES_log_dictionary,set_file=True)
else:
log_init('ARPES',user_name,_ARPES_log_dictionary,set_file=False)
#EA
if EA.connected:
sleep(1)
......@@ -118,7 +116,7 @@ def ARPES_init(*userName,**kwargs):
global tey, ca15
tey = Keithley('c',1)
ca15 = Keithley('b',15)
#default scan settings
ARPES_default_scan_settings()
......
......@@ -154,7 +154,7 @@ class Beamline_Config:
self.folder = 'c'
self.prefix = 'ARPES_'
self.branch = 'c'
elif endstation_name == 'Kappa':
elif endstation_name == 'kappa':
self.folder = 'd'
self.prefix = 'Kappa_'
self.branch = 'd'
......@@ -162,7 +162,7 @@ class Beamline_Config:
self.folder = 'e'
self.branch = 'd'
else:
print('folder and prefix not set')
print_warning_message('BL_config: folder and prefix were not set')
elif mode == 'staff':
#overwrite folder for staff mode
......@@ -170,12 +170,12 @@ class Beamline_Config:
self.prefix = endstation_name+"_"
if endstation_name == 'ARPES':
self.branch = 'c'
elif endstation_name == 'Kappa':
elif endstation_name == 'kappa':
self.branch = 'd'
elif endstation_name == 'Octupole':
self.branch = 'd'
else:
print('folder and prefix not set')
print_warning_message('BL_config: folder and prefix were not set')
else:
message = 'Not a valid BL_mode choice\n'
message += 'BL_modes: '+BL_mode_list
......@@ -188,6 +188,6 @@ class Beamline_Config:
self.endstation_get = kwargs['endstation_get']
if kwargs['debug']:
print('BLconfig_init')
print('\nBL_config.init vars = ')
print(vars(self))
......@@ -99,13 +99,11 @@ def kappa_init(*userName,**kwargs):
folders_kappa(user_name,**kwargs)
#logging
try:
if kwargs['set_folders']:
log_init('kappa',user_name,_kappa_log_dictionary,set_file=True)
else:
log_init('kappa',user_name,_kappa_log_dictionary,set_file=False)
except:
print_warning_message('log_init failed')
if kwargs['set_folders']:
log_init('kappa',user_name,_kappa_log_dictionary,set_file=True)
else:
log_init('kappa',user_name,_kappa_log_dictionary,set_file=False)
#MPA
global mpa
......@@ -123,7 +121,8 @@ def kappa_init(*userName,**kwargs):
d3 = SRS("29idMZ0:scaler1.S3", '29idd:A2')
d4 = SRS("29idMZ0:scaler1.S4", '29idd:A3')
mesh = SRS("29idMZ0:scaler1.S14", '29idd:A4')
#default scan settings
kappa_default_scan_settings()
......
......@@ -2,7 +2,7 @@ from iexcode.instruments.IEX_BL_config import BLconfig_branch
import numpy as np
from time import sleep
from epics import caget, caput
from epics import caget, caput, PV
import iexcode.instruments.cfg as iex
from iexcode.instruments.userCalcs import userStringSeq_pvs, userStringSeq_clear
......@@ -83,16 +83,20 @@ class Keithley:
reads the current SRS and corresponding scaler values
verbose: prints current values True/False
"""
self.current = caget(self._pv+"read")
self.range = 'Autoscale' if caget(self._pv+"rangeAuto",as_string=True)=='On' else caget(self._pv+"range",as_string=True)
self.rate = caget(self._pv+"rate")
digital_filter = caget(self._pv+'digitalFilter',as_string=True)
self.filter_num = 1 if digital_filter == 'On' else caget(self._pv+'digitalFilterCount')
pv = PV(self._pv)
if pv.connected:
self.current = caget(self._pv+"read")
self.range = 'Autoscale' if caget(self._pv+"rangeAuto",as_string=True)=='On' else caget(self._pv+"range",as_string=True)
self.rate = caget(self._pv+"rate")
digital_filter = caget(self._pv+'digitalFilter',as_string=True)
self.filter_num = 1 if digital_filter == 'On' else caget(self._pv+'digitalFilterCount')
if verbose:
for key, value in vars(self).items():
if key[0] != '_':
print(key, ' = ', value)
if verbose:
for key, value in vars(self).items():
if key[0] != '_':
print(key, ' = ', value)
else:
print(self._pv+' is not connected')
def get(self,verbose=True):
"""
......
from os.path import join,isfile
import time
from epics import caget, caput
from epics import caget, caput, PV
from iexcode.instruments.utilities import today
from iexcode.instruments.utilities import today, print_warning_message
import iexcode.instruments.cfg as iex
## To do: make this work if User Folder doesn't already exist
......@@ -32,15 +32,21 @@ def log_update(d=None,**kwargs):
except:
print('No logfile written')
def log_filepath():
"""
get the filepath for the log file
"""
iex.BL.mda.filepath = filepath
return filepath
def log_name_set(file_name):
"""
change the name of the log file
"""
try:
iex.BL.mda.log.name_set(filename=file_name)
iex.BL.mda.filename = file_name
except:
print('No logfile name change')
print_warning_message('No logfile name change')
def log_init(endstation_name,user_name,log_dictionary,set_file=False):
"""
......@@ -73,8 +79,9 @@ class Logfile:
if set_file:
self.name_set()
print('\n log_filename = '+caget(self._name_pv(),as_string=True))
print('\tuse log_name_set to change')
print('\n logfile path = '+self.filepath)
print('\tuse log_name_set to change\n')
def _name_pv(self):
"""
......@@ -125,8 +132,12 @@ class Logfile:
Previously: logname
"""
return caget(self._name_pv())
pv = PV(self._name_pv())
if pv.connected:
name = caget(pv,as_string=True)
else:
name = "logfile.txt"
return name
def _fpath(self):
"""
......@@ -136,14 +147,9 @@ class Logfile:
Previously: logname, logname_generate
"""
user_folder = join(file_path,self.userName)
try:
filename = self.name_get()
fpath_with_subfolder = join(user_folder,filename)
except:
fpath_with_subfolder = "logfile.txt"
self.name_get()
print("Couldn't read log file path, using: "+fpath_with_subfolder)
filename = self.name_get()
fpath_with_subfolder = join(user_folder,filename)
return fpath_with_subfolder
......
......@@ -97,13 +97,10 @@ def Octupole_init(*userName,**kwargs):
print('user_name:',user_name)
#logging
try:
if kwargs['set_folders']:
log_init('Octupole',user_name,_Octupole_log_dictionary,set_file=True)
else:
log_init('Octupole',user_name,_Octupole_log_dictionary,set_file=False)
except:
print_warning_message('log_init failed')
if kwargs['set_folders']:
log_init('Octupole',user_name,_Octupole_log_dictionary,set_file=True)
else:
log_init('Octupole',user_name,_Octupole_log_dictionary,set_file=False)
#global detectors
global tey,tfy,pd,mesh,diag,kbh,kbv
......@@ -114,7 +111,7 @@ def Octupole_init(*userName,**kwargs):
tey = SRS("29ide:scaler1.S3", '29ide:SR570_4:')
tfy = Scaler("29ide:scaler1.S4")
pd = SRS("29ide:scaler1.S5", '29ide:SR570_5:')
#default scan settings
Octupole_default_scan_settings()
......
from epics import caget, caput
from epics import caget, caput, PV
############################################################
###################################################
......@@ -29,46 +29,53 @@ class SRS:
"""
set all PV to current SP values (what the screen shows in not necessarely what the PV are set to)
"""
pv=self._srs_pv+"init.PROC"
caput(pv,1)
pv=PV(self._srs_pv+"init.PROC")
if pv.connected:
caput(pv,1)
else:
print(self._srs_pv+" is not connected")
def get_all(self,verbose):
def get_all(self,verbose=False):
"""
reads the current SRS and corresponding scaler values
"""
self.scaler_value = caget(self._scaler_pv)
self.gain = float(caget(self._srs_pv+'sens_num.VAL',as_string=True))
self.current_unit = caget(self._srs_pv+'sens_unit.VAL',as_string=True)
self.invert = caget(self._srs_pv+'invert_on.VAL',as_string=True)
unit_sciNote = {'pA':1e-12, 'nA':1e-9, 'uA':1e-6, 'mA':1e-3}
pv=PV(self._scaler_pv)
if pv.connected:
self.scaler_value = caget(self._scaler_pv)
self.gain = float(caget(self._srs_pv+'sens_num.VAL',as_string=True))
self.current_unit = caget(self._srs_pv+'sens_unit.VAL',as_string=True)
self.invert = caget(self._srs_pv+'invert_on.VAL',as_string=True)
unit_sciNote = {'pA':1e-12, 'nA':1e-9, 'uA':1e-6, 'mA':1e-3}
self.offset_value=float(caget(self._srs_pv+"offset_num.VAL",as_string=True))
self.offset_unit=caget(self._srs_pv+"offset_unit.VAL",as_string=True)
self.offset_sign=caget(self._srs_pv+"offset_sign.VAL",as_string=True)
self.offset_factor=float(caget(self._srs_pv+"off_u_put.VAL",as_string=True))
current_Amp = self.scaler_value * self.gain * unit_sciNote[self.current_unit[:-2]]
baseline = self.offset_value * self.offset_factor * unit_sciNote[self.offset_unit]
self.offset_value=float(caget(self._srs_pv+"offset_num.VAL",as_string=True))
self.offset_unit=caget(self._srs_pv+"offset_unit.VAL",as_string=True)
self.offset_sign=caget(self._srs_pv+"offset_sign.VAL",as_string=True)
self.offset_factor=float(caget(self._srs_pv+"off_u_put.VAL",as_string=True))
current_Amp = self.scaler_value * self.gain * unit_sciNote[self.current_unit[:-2]]
baseline = self.offset_value * self.offset_factor * unit_sciNote[self.offset_unit]
if self.invert == 1:
current_Amp *= -1
if self.offset_sign == '+':
self.current_Amp = current_Amp + baseline
elif self.offset_sign == '-':
self.current_Amp = current_Amp - baseline
if self.invert == 1:
current_Amp *= -1
if self.offset_sign == '+':
self.current_Amp = current_Amp + baseline
elif self.offset_sign == '-':
self.current_Amp = current_Amp - baseline
self.filter_type=caget(self._srs_pv+'filter_type.VAL',as_string=True)
self.filter_low=caget(self._srs_pv+'low_freq.VAL',as_string=True)
self.filter_high=caget(self._srs_pv+'high_freq.VAL',as_string=True)
self.blank=caget(self._srs_pv+'blank_on.VAL',as_string=True)
self.bias_OnOff=caget(self._srs_pv+'bias_on.VAL',as_string=True)
self.bias_value=caget(self._srs_pv+'bias_put.VAL',as_string=True)
if verbose:
self.print_all(extended=True)
else:
print(self._scaler_pv+" is not connected")
self.filter_type=caget(self._srs_pv+'filter_type.VAL',as_string=True)
self.filter_low=caget(self._srs_pv+'low_freq.VAL',as_string=True)
self.filter_high=caget(self._srs_pv+'high_freq.VAL',as_string=True)
self.blank=caget(self._srs_pv+'blank_on.VAL',as_string=True)
self.bias_OnOff=caget(self._srs_pv+'bias_on.VAL',as_string=True)
self.bias_value=caget(self._srs_pv+'bias_put.VAL',as_string=True)
if verbose:
self.print_all(extended=True)
def get(self,verbose=True):
"""
returns the current in Amps with offset removed
......
......@@ -62,7 +62,12 @@ class Scaler:
"""
returns the current value
"""
val = caget(self.pv)
if verbose:
print(val)
pv = PV(self.pv)
if pv.connected:
val = caget(self.pv)
if verbose:
print(val)
else:
print(self.pv+" is not connected")
val = None
return val
# **IEX python - cheatsheet**
list iexcode function by file
vars(object) => lists all attributes and methods
<br>
---
<br>
# **Instruments**
# **Instrument files**
## **ARPES**
ARPES sepcific functions
......@@ -128,8 +128,8 @@ Cameras to enable/disable when switching between branches
## **IEX_BL_config**
used to access current beamline configuration, based on instance initialization not pv
Beamline_Config #class to carry all configuration info gets stored in BL
BLconfig_endstation_name() #gets or sets iex.BL.endstation_name
Beamline_Config #class to carry all configuration info gets stored in iex.BL
BLconfig_endstation_name() #gets or sets iex.BLendstation_name
BLconfig_folder() #gets or sets iex.BL.folder
BLconfig_branch() #gets or sets iex.BL.branch
BLconfig_xrays() #gets or sets iex.BL.xrays (True/False)
......@@ -194,7 +194,7 @@ Keithley specific functions
## **Logfile**
functions for writing logfile.txt, gets set by IEX_BL_config
functions for writing logfile.txt, gets set by IEX_BL_config (iex.mda.log)
log_print(comment) #print a comment in the logfile
log_update() #updates the logfile with the current info (used if script is aborted)
......@@ -231,7 +231,7 @@ motor class and common name functions
scaler_cts() #sets the scaler counter for the current endstation
## **scanRecord**
functions and class for handling the scanRecord
functions and class for handling the scanRecord (typically iex.BL.mda)
saveData_get_all() #returns dictions of fileSystem,subDir,scanNumber,baseName
mda_filepath() #gets the full filepath from the current mda setting
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment