05_2022
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#print "Detectors Check"
|
||||
|
||||
|
||||
|
||||
"""
|
||||
for name, info in DETECTORS.items():
|
||||
path = info["path"]
|
||||
try:
|
||||
@@ -12,5 +12,22 @@ for name, info in DETECTORS.items():
|
||||
info["enabled"] = False
|
||||
#print " error"
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def check_dev(name):
|
||||
info = DETECTORS[name]
|
||||
path = info["path"]
|
||||
try:
|
||||
caget_str(path)
|
||||
info["enabled"] = True
|
||||
return name + " ok"
|
||||
except:
|
||||
info["enabled"] = False
|
||||
return name + " error"
|
||||
|
||||
functions = []
|
||||
for name, info in DETECTORS.items():
|
||||
functions.append((check_dev,(name,)))
|
||||
parallelize(*functions)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
def on_change_data_path(path):
|
||||
if path is not None:
|
||||
print "Data path: " + str(path)
|
||||
raw_data_folder = path + "/raw_data"
|
||||
os.makedirs(raw_data_folder)
|
||||
#with open(raw_data_folder + "/test.txt", "w") as f:
|
||||
# f.write("Success")
|
||||
for name, info in DETECTORS.items():
|
||||
log(name + " enabled = " + str(info["enabled"]))
|
||||
if info["enabled"]:
|
||||
channel_path = info["path"]
|
||||
caput_str(channel_path, raw_data_folder + "/" + name)
|
||||
|
||||
def check_detector(name, raw_data_folder):
|
||||
info = DETECTORS[name]
|
||||
dev_path = raw_data_folder + "/" + name
|
||||
channel_path = info["path"]
|
||||
try:
|
||||
caget_str(channel_path)
|
||||
print "OK: ", name
|
||||
info["enabled"] = True
|
||||
channel_path = info["path"]
|
||||
caput_str(channel_path, dev_path)
|
||||
return name + " ok"
|
||||
except:
|
||||
print "ERROR: ", name
|
||||
info["enabled"] = False
|
||||
return name + " error"
|
||||
finally:
|
||||
log(name + " enabled = " + str(info["enabled"])+ " folder = " + str(dev_path))
|
||||
|
||||
def check_detectors(raw_data_folder, timeout = 0.5):
|
||||
functions = []
|
||||
for name, info in DETECTORS.items():
|
||||
functions.append((check_detector,(name,raw_data_folder)))
|
||||
r = fork(*functions)
|
||||
|
||||
chrono = Chrono()
|
||||
while True:
|
||||
if not False in [f.isDone() for f in r]:
|
||||
break
|
||||
if timeout >0:
|
||||
if chrono.isTimeout(int(timeout*1000)):
|
||||
break
|
||||
time.sleep(0.01)
|
||||
|
||||
|
||||
r = check_detectors("/sls/X05LA/Data1/x05laop/2022_04/20220411/")
|
||||
log("QUit", False)
|
||||
+58
-4
@@ -22,7 +22,8 @@ crlogic_config["class"] = "ch.psi.pshell.crlogic.CrlogicScan"
|
||||
run("CPython/wrapper")
|
||||
|
||||
DETECTORS={ \
|
||||
'Eiger4m': {"path":"X05LA-ES1-EIGER1:cam1:FilePath", "enabled": False}, \
|
||||
'Eiger4m/scan': {"path":"X05LA-ES1-EIGER1:cam1:FilePath", "enabled": False}, \
|
||||
'FalconX/scan': {"path":"X05LA-SITORO:HDF1:FilePath", "enabled": False}, \
|
||||
'XRayEye': {"path":"X05LA-ES2-GIGE01:TIFF1:FilePath", "enabled": False} \
|
||||
}
|
||||
|
||||
@@ -62,19 +63,60 @@ def on_command_started(info):
|
||||
|
||||
def on_command_finished(info):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
def check_detector_raw_data_folder(name, raw_data_folder):
|
||||
info = DETECTORS[name]
|
||||
dev_path = raw_data_folder + "/" + name
|
||||
channel_path = info["path"]
|
||||
try:
|
||||
caget_str(channel_path)
|
||||
info["enabled"] = True
|
||||
channel_path = info["path"]
|
||||
caput_str(channel_path, dev_path)
|
||||
return name + " ok"
|
||||
except:
|
||||
info["enabled"] = False
|
||||
return name + " error"
|
||||
finally:
|
||||
log(name + " enabled = " + str(info["enabled"])+ " folder = " + str(dev_path))
|
||||
|
||||
_detector_check_futures = None
|
||||
|
||||
def check_detectors_raw_data_folders(raw_data_folder, timeout = 0.5):
|
||||
global _detector_check_futures
|
||||
if _detector_check_futures is not None:
|
||||
join(_detector_check_futures)
|
||||
|
||||
functions = []
|
||||
for name, info in DETECTORS.items():
|
||||
functions.append((check_detector_raw_data_folder,(name,raw_data_folder)))
|
||||
_detector_check_futures = fork(*functions)
|
||||
|
||||
chrono = Chrono()
|
||||
while True:
|
||||
if not False in [f.isDone() for f in _detector_check_futures]:
|
||||
break
|
||||
if timeout >0:
|
||||
if chrono.isTimeout(int(timeout*1000)):
|
||||
break
|
||||
time.sleep(0.01)
|
||||
|
||||
def on_change_data_path(path):
|
||||
if path is not None:
|
||||
print "Data path: " + str(path)
|
||||
raw_data_folder = path + "/raw_data"
|
||||
os.makedirs(raw_data_folder)
|
||||
#with open(raw_data_folder + "/test.txt", "w") as f:
|
||||
# f.write("Success")
|
||||
|
||||
"""
|
||||
for name, info in DETECTORS.items():
|
||||
log(name + " enabled = " + str(info["enabled"]))
|
||||
if info["enabled"]:
|
||||
channel_path = info["path"]
|
||||
caput_str(channel_path, raw_data_folder + "/" + name)
|
||||
"""
|
||||
check_detectors_raw_data_folders(raw_data_folder)
|
||||
|
||||
|
||||
def on_session_started(id):
|
||||
@@ -82,3 +124,15 @@ def on_session_started(id):
|
||||
|
||||
def on_session_finished(id):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# System utiomities
|
||||
###################################################################################################
|
||||
|
||||
def memory():
|
||||
import java.lang.Runtime as Runtime
|
||||
r=Runtime.getRuntime()
|
||||
print "Used: ", r.totalMemory()
|
||||
print "Max : ", r.maxMemory()
|
||||
@@ -0,0 +1 @@
|
||||
[ [ [ false, "/sls/X05LA/Data1/x05laop/2021_08/20210825/noXRD_XRF_otf_8400eV_200ms_XY_F8Bte5_zoom1.xml", "", "Resume", "Disabled" ], [ false, "/sls/X05LA/Data1/x05laop/2021_08/20210825/noXRD_XRF_otf_8400eV_200ms_XY_F8Bte5_zoom2.xml", "", "Resume", "Disabled" ], [ false, "/sls/X05LA/Data1/x05laop/2021_08/20210825/noXRD_XRF_otf_8400eV_200ms_XY_F8Bte5_zoom2.xml", "", "Resume", "Disabled" ], [ true, "/sls/X05LA/Data1/x05laop/2021_08/20210825/noXRD_XRF_otf_8400eV_200ms_XY_F2BteSti_zoom1.xml", "", "Resume", "Success" ], [ true, "/sls/X05LA/Data1/x05laop/2021_08/20210825/noXRD_XRF_otf_8400eV_200ms_XY_F2BteSti_zoom2.xml", "", "Resume", "Success" ], [ true, "/sls/X05LA/Data1/x05laop/2021_08/20210825/noXRD_XRF_otf_8400eV_200ms_XY_F2BteSti_zoom4.xml", "", "Resume", "Success" ], [ true, "/sls/X05LA/Data1/x05laop/2021_08/20210825/noXRD_XRF_otf_8400eV_200ms_XY_F2BteSti_zoom3.xml", "", "Resume", "Success" ] ] ]
|
||||
Reference in New Issue
Block a user