Commit e30d66ae authored by Jose Tiago Macara Coutinho's avatar Jose Tiago Macara Coutinho Committed by blissadm_ID31@bibhelm
Browse files

SPEC config: add saving hook (called when experiment or sample changes)

parent 69f6b96d
......@@ -359,7 +359,8 @@ def bliss_dict_clear(dict) '{
#################################
def bliss_register_settings_class(class_name, \
dump_settings_macro, load_settings_macro) '{
dump_settings_macro, load_settings_macro, \
new_saving_macro) '{
local class_list mstr
if (bliss_settings_class_is_registered(class_name))
......@@ -370,6 +371,9 @@ def bliss_register_settings_class(class_name, \
BLISS["settings"]["class_list"] = class_list
BLISS[class_name]["dump_settings_macro"] = dump_settings_macro
BLISS[class_name]["load_settings_macro"] = load_settings_macro
if (new_saving_macro != 0) {
BLISS[class_name]["new_saving_macro"] = new_saving_macro
}
BLISS[class_name]["obj_list"] = bliss_list_string_init()
mstr = ""
......@@ -386,6 +390,15 @@ def bliss_register_settings_class(class_name, \
mstr = sprintf("%s }\n", mstr)
cdef("bliss_load_object_settings_code", mstr, class_name)
if (new_saving_macro != 0) {
mstr = ""
mstr = sprintf("%s if (class_name == \"%s\") {\n", mstr, class_name)
mstr = sprintf("%s %s(class_name, obj_name, experiment, sample)\n", \
mstr, new_saving_macro)
mstr = sprintf("%s }\n", mstr)
cdef("bliss_new_saving_object_code", mstr, class_name)
}
cdef("prompt_mac", "bliss_settings_prompt();\n", "bliss_settings")
}'
......@@ -398,12 +411,14 @@ def bliss_unregister_settings_class(class_name) '{
cdef("bliss_dump_object_settings_code", "", class_name, "delete")
cdef("bliss_load_object_settings_code", "", class_name, "delete")
cdef("bliss_new_saving_object_code", "", class_name, "delete")
class_list = BLISS["settings"]["class_list"]
class_list = bliss_list_string_del(class_list, class_name)
BLISS["settings"]["class_list"] = class_list
delete BLISS[class_name]["dump_settings_macro"]
delete BLISS[class_name]["load_settings_macro"]
delete BLISS[class_name]["new_saving_macro"]
delete BLISS[class_name]["obj_list"]
if (class_list == bliss_list_string_init())
......@@ -429,6 +444,20 @@ def bliss_settings_prompt() '{
}
}'
def bliss_update_saving(session, experiment, sample) '{
local nb_class class_arr[] class_name nb_obj obj_arr[] obj_name i j
nb_class = split(BLISS["settings"]["class_list"], class_arr)
for (i = 0; i < nb_class; i++) {
class_name = class_arr[i]
nb_obj = split(BLISS[class_name]["obj_list"], obj_arr)
for (j = 0; j < nb_obj; j++) {
obj_name = obj_arr[j]
bliss_new_saving_object(class_name, obj_name, experiment, sample)
}
}
}'
def bliss_update_settings_from_object(class_name, obj_name) '{
local obj_dict[] settings_dict[] key i
......@@ -489,6 +518,12 @@ def bliss_get_obj_settings_key(class_name, obj_name) '{
return sprintf("%s.%s", class_name, obj_name)
}'
cdef("bliss_new_saving_object_code", "\n", "bliss", 0x10)
def bliss_new_saving_object(class_name, obj_name, experiment, sample) '{
bliss_new_saving_object_code
}'
cdef("bliss_dump_object_settings_code", "\n", "bliss", 0x10)
def bliss_dump_object_settings(class_name, obj_name) '{
......
......@@ -27,7 +27,8 @@ def limasettingssetup '{
lima_class = lima_get_settings_class(lima_name)
bliss_register_settings_class(lima_class, "lima_dump_object_settings", \
"lima_load_object_settings")
"lima_load_object_settings", \
"lima_new_saving")
bliss_add_settings_object(lima_class, lima_name)
setup_tail("limasettings", lima_name)
}'
......@@ -197,6 +198,47 @@ def lima_load_object_settings(lima_class, lima_name, obj_settings) '{
}'
def lima_new_saving(lima_class, lima_name, experiment, sample) '{
local ccd_u label windows work_dir
local saving_directory saving_prefix saving_suffix
windows = 0
if (index(lima_name, "pco") == 1) {
label = "PCO"
windows = 1
}
else if (index(lima_name, "perkin") == 1) {
label = "PE"
windows = 1
}
else if (index(lima_name, "dexela") == 1) {
label = "DE"
}
else if (index(lima_name, "pilatus") == 1) {
label = "P3"
}
else if (index(lima_name, "mpx") == 1) {
label = "MPX"
}
else {
print "Unknown detector: lima directory not set"
return
}
saving_prefix = sample "_" label "_#n4_#p4"
saving_suffix = ".edf"
work_dir = session_get_working_dir()
saving_directory = work_dir "/" label
unix(sprintf("mkdir -p %s", saving_directory))
if (windows) {
saving_directory = sprintf("%s/%s", session_get_windows_working_dir(), label)
}
_limapar_set(lima_name, "saving_directory", saving_directory)
_limapar_set(lima_name, "saving_prefix", saving_prefix)
_limapar_set(lima_name, "saving_suffix", saving_suffix)
lima_dump_object_settings(lima_class, lima_name)
}'
def lima_ccd_unit(lima_name) '{
return LIMA_DEV[lima_name]["unit"]
}'
......
......@@ -45,6 +45,24 @@ def session_get_working_dir() '{
return sprintf("%s/%s", data_dir, SESSION[SPEC]["sample_id"])
}'
def session_get_windows_working_dir() '{
local local_dir exp_id exp_type dir_suffix
local_dir = session_get_working_dir()
exp_id = SESSION[SPEC]["experiment_id"]
exp_type = session_get_experiment_type(exp_id)
if (exp_type == "USR") {
sscanf(local_dir, "/data/visitor/%s", dir_suffix)
return sprintf("Z:/%s", dir_suffix)
}
else {
local dir_prefix
dir_prefix = sprintf("/data/%s/%%s", string_tolower(SPECBL))
sscanf(local_dir, dir_prefix, dir_suffix)
return sprintf("X:/%s", dir_suffix)
}
}'
def session_get_spec_file() '{
return sprintf("%s_%s.spec", SESSION[SPEC]["sample_id"], SPEC)
}'
......@@ -199,6 +217,7 @@ def newexperiment_worker(exp_id, samp_id) '{
SESSION[SPEC]["sample_id"] = samp_id
SESSION[SPEC]["scan_nb"] = 0
session_resetup()
bliss_update_saving(SPEC, exp_id, samp_id)
bliss_update_settings_from_object("session", SPEC)
}'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment