Commit 58307af8 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by blissadm_ID31@bibhelm
Browse files

SPEC config: first version of Lima/CCD settings management

parent 2e29475a
......@@ -103,8 +103,8 @@ SPEC_SETUP_LIMA_CAMERA_TEMPLATE = """\
##########################
# Lima {type} {name!r}
#########################
ccdresetup {unit}
limaccdsetup {name} {unit} {limaccds}
limasettingssetup {name}
{limaset}"""
SPEC_SETUP_LIMA_TEMPLATE = """\
......@@ -329,7 +329,7 @@ class Generator(object):
self.__tango_bliss_servers[session_name] = tango_bliss
setup = SPEC_SETUP_BLISS_TEMPLATE.format(name=session_name)
self.__spec_setup.append(setup)
self.__spec_setup.insert(0, setup)
self.__spec_macros.add('bliss.mac')
return tango_bliss
......@@ -859,6 +859,7 @@ class Generator(object):
self.__spec_macros.add('lima/limacore.mac')
self.__spec_macros.add('lima/limatools.mac')
self.__spec_macros.add('lima/limaroi.mac')
self.__spec_macros.add('blisslima.mac')
cam_macro = LIMA_CAMERA_MACROS.get(camera_type)
if cam_macro:
self.__spec_macros.add(cam_macro)
......
......@@ -339,7 +339,7 @@ def bliss_dict_clear(dict) '{
def bliss_register_settings_class(class_name, \
dump_settings_macro, load_settings_macro) '{
local class_list
local class_list mstr
if (bliss_settings_class_is_registered(class_name))
return
......
......@@ -6,7 +6,7 @@ need bliss
# <lima-name>
def limasettingssetup '{
local lima_name lima_class
local lima_name lima_class first_time
if (!BLISS["device"])
blisssetup
......@@ -17,7 +17,13 @@ def limasettingssetup '{
exit
}
lima_class = lima_get_setting_class(lima_name)
first_time = !bliss_settings_class_is_registered("lima.common")
if (first_time) {
# TODO: Add global lima settings: CCD_U, NO_CCDS
}
lima_class = lima_get_settings_class(lima_name)
bliss_register_settings_class(lima_class, "lima_dump_object_settings", \
"lima_load_object_settings")
bliss_add_settings_object(lima_class, lima_name)
......@@ -37,27 +43,333 @@ def lima_get_settings_class(lima_name) '{
}'
def lima_dump_object_settings(lima_class, lima_name) '{
local obj_settings[]
local ccd_u obj_settings[] has_roi cbeg rbeg cend rend width height set_str
ccd_u = lima_ccd_unit(lima_name)
obj_settings["active_on_ct"] = CCD_ON[ccd_u]
set_str = sprintf("%s,%s", CCD_BIN[ccd_u]["col_bin"], \
CCD_BIN[ccd_u]["row_bin"])
obj_settings["image_bin"] = set_str
CCD_FLIP[ccd_u]["col_flip"] = _limapar_get(lima_name, "image_flip", 0)
CCD_FLIP[ccd_u]["row_flip"] = _limapar_get(lima_name, "image_flip", 1)
set_str = sprintf("%s,%s", CCD_FLIP[ccd_u]["col_flip"], \
CCD_FLIP[ccd_u]["row_flip"])
obj_settings["image_flip"] = set_str
width = image_par(ccd_u, "cols") / CCD_BIN[ccd_u]["col_bin"]
height = image_par(ccd_u, "rows") / CCD_BIN[ccd_u]["row_bin"]
cbeg = CCD_ROI[ccd_u]["col_beg"]
cend = CCD_ROI[ccd_u]["col_end"]
rbeg = CCD_ROI[ccd_u]["row_beg"]
rend = CCD_ROI[ccd_u]["row_end"]
has_roi = (ROI_ACTIVE[ccd_u] && !((cbeg == 0) && (cend == width - 1) && \
(rbeg == 0) && (rend == height - 1)))
if (has_roi) {
width = cend + 1 - cbeg
height = rend + 1 - rbeg
} else {
cbeg = rbeg = 0
}
set_str = sprintf("%s,%s,%s,%s", cbeg, rbeg, width, height)
obj_settings["image_roi"] = set_str
if (CCD_TRIG[ccd_u] == 0) {
set_str = "INTERNAL_TRIGGER"
} else if (CCD_TRIG[ccd_u] == 1) {
set_str = CCD_SOFT_PRESET[ccd_u] ? "EXTERNAL_TRIGGER" : \
"EXTERNAL_GATE"
} else {
set_str = "EXTERNAL_TRIGGER_MULTI"
}
obj_settings["acq_trigger_mode"] = set_str
set_str = CCDREAD_MODE[ccd_u] ? "NEVER" : "ALWAYS"
obj_settings["spec_read_mode"] = set_str
if (CCDSAVE[ccd_u] == 0) {
set_str = "MANUAL"
} else if (CCDSAVE_MODE[ccd_u] == 0) {
set_str = "SPEC"
} else if (CCDSAVE_MODE[ccd_u] == 1) {
set_str = "DSERVER"
} else if (CCDSAVE_MODE[ccd_u] == 2) {
set_str = "SPEC_CONCAT"
} else if (CCDSAVE_MODE[ccd_u] == 3) {
set_str = "DSERVER_CONCAT"
} else if (CCDSAVE_MODE[ccd_u] == 4) {
set_str = "DSERVER_AUTO_FRAME"
}
obj_settings["spec_saving_mode"] = set_str
obj_settings["saving_mode"] = _limapar_get(lima_name, "saving_mode")
CCD_DIR[ccd_u] = _limapar_get(lima_name, "saving_directory")
CCD_PREFIX[ccd_u] = _limapar_get(lima_name, "saving_prefix")
CCD_SUFFIX[ccd_u] = _limapar_get(lima_name, "saving_suffix")
CCD_N[ccd_u] = _limapar_get(lima_name, "saving_next_number")
obj_settings["saving_directory"] = CCD_DIR[ccd_u]
obj_settings["saving_prefix"] = CCD_PREFIX[ccd_u]
obj_settings["saving_suffix"] = CCD_SUFFIX[ccd_u]
obj_settings["saving_next_number"] = CCD_N[ccd_u]
set_str = _limapar_get(lima_name, "saving_overwrite_policy")
obj_settings["saving_overwrite_policy"] = set_str
obj_settings["spec_roi_cnt_act"] = CCD_INTEG[ccd_u]
if (CCD_NORM[ccd_u] == 0) {
set_str = "INTEGRATE"
} else if (CCD_NORM[ccd_u] == 1) {
set_str = "AVERAGE"
} else if (CCD_NORM[ccd_u] == 2) {
set_str = "AVERAGE_STD_DEV"
}
obj_settings["spec_roi_cnt_mode"] = set_str
obj_settings["spec_roi_cnt_mne1"] = CCD_MNE[ccd_u]
obj_settings["spec_roi_cnt_mne2"] = CCD_MNE2[ccd_u]
cbeg = CCD_CNTROI[ccd_u]["col_beg"]
cend = CCD_CNTROI[ccd_u]["col_end"]
rbeg = CCD_CNTROI[ccd_u]["row_beg"]
rend = CCD_CNTROI[ccd_u]["row_end"]
has_roi = (CCD_CNTROI[ccd_u]["active"] && \
!((cbeg == 0) && (cend == width - 1) && \
(rbeg == 0) && (rend == height - 1)))
if (has_roi) {
width = cend + 1 - cbeg
height = rend + 1 - rbeg
} else {
cbeg = rbeg = 0
}
set_str = sprintf("%s,%s,%s,%s", cbeg, rbeg, width, height)
obj_settings["spec_roi_cnt_region"] = set_str
obj_settings["spec_save_counters"] = CCD_SAVE_COUNTERS
set_str = CCD_EXT_HEADER ? MY_EXT_HEADER : ""
obj_settings["external_header"] = set_str
if (CCD_GUI[ccd_u]["on"] == 0) {
set_str = "NONE"
} else if (CCD_GUI[ccd_u]["guiconf"] == 0) {
set_str = "ONZE"
} else if (CCD_GUI[ccd_u]["guiconf"] == 1) {
set_str = "OXIDIS"
}
obj_settings["online_gui"] = set_str
return obj_settings
}'
def lima_load_object_settings(lima_class, lima_name, settings_dict) '{
local req_defaults i
req_defaults = bliss_is_default_settings(settings_dict)
if (req_defaults)
lima_load_default_settings()
if (!req_defaults) {
def lima_load_object_settings(lima_class, lima_name, obj_settings) '{
local _ccd_u
}
_ccd_u = lima_ccd_unit(lima_name)
_ccd_globals
global CCD_FLIP
_ccd_cdef()
if (bliss_is_default_settings(obj_settings))
lima_load_default_settings(lima_name)
else
lima_load_ext_settings(lima_name, obj_settings)
lima_resetup(lima_name)
}'
def lima_ccd_unit(lima_name) '{
return LIMA_DEV[lima_name]["unit"]
}'
def lima_load_default_settings(lima_name) '{
local ccd_u
ccd_u = lima_ccd_unit(lima_name)
lima_resetup()
CCD_DEPTH[ccd_u] = image_par(ccd_u, "bytes_pixel")
CCD_ON[ccd_u] = 1
CCD_BIN[ccd_u]["col_bin"] = 1
CCD_BIN[ccd_u]["row_bin"] = 1
CCD_FLIP[ccd_u]["col_flip"] = 0
CCD_FLIP[ccd_u]["row_flip"] = 0
ROI_ACTIVE[ccd_u] = 0
CCD_ROI[ccd_u]["col_beg"] = 0
CCD_ROI[ccd_u]["col_end"] = image_par(ccd_u, "cols") - 1
CCD_ROI[ccd_u]["row_beg"] = 0
CCD_ROI[ccd_u]["row_end"] = image_par(ccd_u, "rows") - 1
CCD_TRIG[ccd_u] = 0
CCD_PRESET[ccd_u] = 0
CCD_SOFT_PRESET[ccd_u] = 1
CCD_ADD_TIME[ccd_u] = 0
CCD_SOFT_INIT[ccd_u] = 0
CCDREAD_MODE[ccd_u] = 0
CCDSAVE[ccd_u] = 0
CCDSAVE_MODE[ccd_u] = 0
CCD_DIR[ccd_u] = ""
CCD_PREFIX[ccd_u] = ""
CCD_SUFFIX[ccd_u] = ".edf"
CCD_N[ccd_u] = 0
CCD_INTEG[ccd_u] = 0
CCD_NORM[ccd_u] = 0
CCD_MNE[ccd_u] = ""
CCD_MNE2[ccd_u] = ""
CCD_CNTROI[ccd_u]["active"] = 0
CCD_CNTROI[ccd_u]["col_beg"] = 0
CCD_CNTROI[ccd_u]["col_end"] = image_par(ccd_u, "cols") - 1
CCD_CNTROI[ccd_u]["row_beg"] = 0
CCD_CNTROI[ccd_u]["row_end"] = image_par(ccd_u, "rows") - 1
CCD_SAVE_COUNTERS = 0
CCD_EXT_HEADER = 0
MY_EXT_HEADER = ""
CCD_GUI[ccd_u]["on"] = 0
CCD_GUI[ccd_u]["guiconf"] = 1
}'
def lima_load_default_settings() '{
def lima_load_ext_settings(lima_name, obj_settings) '{
local ccd_u has_roi cbeg rbeg cend rend width height set_str sarr[]
ccd_u = lima_ccd_unit(lima_name)
CCD_ON[ccd_u] = obj_settings["active_on_ct"]
split(obj_settings["image_bin"], sarr, ",")
CCD_BIN[ccd_u]["col_bin"] = int(sarr[0])
CCD_BIN[ccd_u]["row_bin"] = int(sarr[1])
split(obj_settings["image_flip"], sarr, ",")
CCD_FLIP[ccd_u]["col_flip"] = int(sarr[0])
CCD_FLIP[ccd_u]["row_flip"] = int(sarr[1])
width = image_par(ccd_u, "cols") / CCD_BIN[ccd_u]["col_bin"]
height = image_par(ccd_u, "rows") / CCD_BIN[ccd_u]["row_bin"]
split(obj_settings["image_roi"], sarr, ",")
cbeg = int(sarr[0])
rbeg = int(sarr[1])
cend = int(sarr[0]) + int(sarr[2]) - 1
rend = int(sarr[1]) + int(sarr[3]) - 1
CCD_ROI[ccd_u]["col_beg"] = cbeg
CCD_ROI[ccd_u]["col_end"] = cend
CCD_ROI[ccd_u]["row_beg"] = rbeg
CCD_ROI[ccd_u]["row_end"] = rend
ROI_ACTIVE[ccd_u] = !((cbeg == 0) && (cend == width - 1) && \
(rbeg == 0) && (rend == height - 1))
width = cend - cbeg + 1
height = rend - rbeg + 1
set_str = obj_settings["acq_trigger_mode"]
if (set_str == "INTERNAL_TRIGGER") {
CCD_TRIG[ccd_u] = 0
} else if (set_str == "EXTERNAL_TRIGGER") {
CCD_TRIG[ccd_u] = 1
CCD_SOFT_PRESET[ccd_u] = 1
} else if (set_str == "EXTERNAL_GATE") {
CCD_TRIG[ccd_u] = 1
CCD_SOFT_PRESET[ccd_u] = 0
} else if (set_str == "EXTERNAL_TRIGGER_MULTI") {
CCD_TRIG[ccd_u] = 2
CCD_SOFT_PRESET[ccd_u] = 1
}
set_str = obj_settings["spec_read_mode"]
CCDREAD_MODE[ccd_u] = (set_str == "NEVER")
set_str = obj_settings["spec_saving_mode"]
if (set_str == "MANUAL") {
CCDSAVE[ccd_u] = 0
} else if (set_str == "SPEC") {
CCDSAVE_MODE[ccd_u] = 0
} else if (set_str == "DSERVER") {
CCDSAVE_MODE[ccd_u] = 1
} else if (set_str == "SPEC_CONCAT") {
CCDSAVE_MODE[ccd_u] = 2
} else if (set_str == "DSERVER_CONCAT") {
CCDSAVE_MODE[ccd_u] = 3
} else if (set_str = "DSERVER_AUTO_FRAME") {
CCDSAVE_MODE[ccd_u] = 4
}
_limapar_set(lima_name, "saving_mode", obj_settings["saving_mode"])
CCD_DIR[ccd_u] = obj_settings["saving_directory"]
CCD_PREFIX[ccd_u] = obj_settings["saving_prefix"]
CCD_SUFFIX[ccd_u] = obj_settings["saving_suffix"]
CCD_N[ccd_u] = obj_settings["saving_next_number"]
set_str = obj_settings["saving_overwrite_policy"]
_limapar_set(lima_name, "saving_overwrite_policy", set_str)
CCD_INTEG[ccd_u] = obj_settings["spec_roi_cnt_act"]
set_str = obj_settings["spec_roi_cnt_mode"]
if (set_str == "INTEGRATE") {
CCD_NORM[ccd_u] = 0
} else if (set_str == "AVERAGE") {
CCD_NORM[ccd_u] = 1
} else if (set_str == "AVERAGE_STD_DEV") {
CCD_NORM[ccd_u] = 2
}
CCD_MNE[ccd_u] = obj_settings["spec_roi_cnt_mne1"]
CCD_MNE2[ccd_u] = obj_settings["spec_roi_cnt_mne2"]
split(obj_settings["spec_roi_cnt_region"], sarr, ",")
cbeg = int(sarr[0])
rbeg = int(sarr[1])
cend = int(sarr[0]) + int(sarr[2]) - 1
rend = int(sarr[1]) + int(sarr[3]) - 1
CCD_CNTROI[ccd_u]["col_beg"] = cbeg
CCD_CNTROI[ccd_u]["col_end"] = cend
CCD_CNTROI[ccd_u]["row_beg"] = rbeg
CCD_CNTROI[ccd_u]["row_end"] = rend
CCD_CNTROI[ccd_u]["active"] = !((cbeg == 0) && (cend == width - 1) && \
(rbeg == 0) && (rend == height - 1))
CCD_SAVE_COUNTERS = obj_settings["spec_save_counters"]
MY_EXT_HEADER = obj_settings["external_header"]
CCD_EXT_HEADER = (MY_EXT_HEADER == "")
set_str = obj_settings["online_gui"]
if (set_str == "NONE") {
CCD_GUI[ccd_u]["on"] = 0
} else if (set_str == "ONZE") {
CCD_GUI[ccd_u]["on"] = 1
CCD_GUI[ccd_u]["guiconf"] = 0
} else if (set_str == "OXIDIS") {
CCD_GUI[ccd_u]["on"] = 1
CCD_GUI[ccd_u]["guiconf"] = 1
}
}'
def lima_resetup() '{
def lima_resetup(lima_name) '{
local ccd_u gui_on gui_conf
ccd_u = lima_ccd_unit(lima_name)
ccdresetup ccd_u
_limapar_set(lima_name, "image_flip", CCD_FLIP[ccd_u]["col_flip"], 0)
_limapar_set(lima_name, "image_flip", CCD_FLIP[ccd_u]["row_flip"], 1)
_limapar_set(lima_name, "saving_directory", CCD_DIR[ccd_u])
_limapar_set(lima_name, "saving_prefix", CCD_PREFIX[ccd_u])
_limapar_set(lima_name, "saving_suffix", CCD_SUFFIX[ccd_u])
_limapar_set(lima_name, "saving_next_number", CCD_N[ccd_u])
ccd_u = CCD_U
gui_on = CCD_GUI[CCD_U]["on"]
gui_conf = CCD_GUI[CCD_U]["guiconf"]
ccdgui gui_on gui_conf
CCD_U = ccd_u
}'
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