Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LimaGroup
Lima-camera-eiger
Commits
101e2148
Commit
101e2148
authored
Dec 16, 2019
by
Alejandro Homs Puron
Committed by
operator for beamline
Dec 16, 2019
Browse files
Cache frequently-used Eiger acq. params; issue requests only when changed:
* EXPOSURE, FRAME_TIME, NIMAGES, NTRIGGER, TRIGGER_MODE
parent
31deb1d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/EigerCamera.h
View file @
101e2148
...
...
@@ -90,7 +90,7 @@ namespace lima
void
setTrigMode
(
TrigMode
mode
);
void
getTrigMode
(
TrigMode
&
mode
);
void
setExpTime
(
double
exp_time
);
void
setExpTime
(
double
exp_time
,
bool
force
=
false
);
void
getExpTime
(
double
&
exp_time
);
void
setLatTime
(
double
lat_time
);
...
...
@@ -161,19 +161,41 @@ namespace lima
friend
class
InitCallback
;
void
initialiseController
();
/// Used during plug-in initialization
void
_acquisition_finished
(
bool
);
template
<
typename
T
>
struct
Cache
{
T
val
;
Cache
()
=
default
;
Cache
(
T
v
)
:
val
(
v
)
{}
operator
T
&
()
{
return
val
;
}
Cache
&
operator
=
(
T
new_val
)
{
val
=
new_val
;
return
*
this
;
}
bool
changed
(
T
new_val
)
{
std
::
swap
(
val
,
new_val
);
return
(
val
!=
new_val
);
}
};
//-----------------------------------------------------------------------------
//- lima stuff
int
m_nb_frames
;
Cache
<
unsigned
int
>
m_nb_images
;
Cache
<
unsigned
int
>
m_nb_triggers
;
int
m_image_number
;
double
m_latency_time
;
TrigMode
m_trig_mode
;
Cache
<
TrigMode
>
m_trig_mode
;
//- camera stuff
ApiGeneration
m_api
;
std
::
string
m_detector_model
;
std
::
string
m_detector_type
;
unsigned
int
m_maxImageWidth
,
m_maxImageHeight
;
ImageType
m_detectorImageType
;
ImageType
m_detectorImageType
;
InternalStatus
m_initilize_state
;
InternalStatus
m_trigger_state
;
...
...
@@ -183,13 +205,13 @@ namespace lima
double
m_temperature
;
double
m_humidity
;
double
m_exp_time
;
Cache
<
double
>
m_exp_time
;
Cache
<
double
>
m_frame_time
;
double
m_readout_time
;
double
m_x_pixelsize
,
m_y_pixelsize
;
Cond
m_cond
;
std
::
string
m_detector_ip
;
double
m_min_frame_time
;
};
}
// namespace Eiger
}
// namespace lima
...
...
src/EigerCamera.cpp
View file @
101e2148
...
...
@@ -204,17 +204,16 @@ void Camera::prepareAcq()
if
(
m_trigger_state
!=
IDLE
)
EIGER_SYNC_CMD
(
Requests
::
DISARM
);
int
nb_frames
;
unsigned
nb_trigger
;
unsigned
nb_images
,
nb_triggers
;
switch
(
m_trig_mode
)
{
case
IntTrig
:
case
ExtTrigSingle
:
nb_
fram
es
=
m_nb_frames
,
nb_trigger
=
1
;
break
;
nb_
imag
es
=
m_nb_frames
,
nb_trigger
s
=
1
;
break
;
case
IntTrigMult
:
case
ExtTrigMult
:
case
ExtGate
:
nb_
fram
es
=
1
,
nb_trigger
=
m_nb_frames
;
break
;
nb_
imag
es
=
1
,
nb_trigger
s
=
m_nb_frames
;
break
;
default:
THROW_HW_ERROR
(
Error
)
<<
"Very weird can't be in this case"
;
}
...
...
@@ -230,26 +229,31 @@ void Camera::prepareAcq()
bool
parallel_sync_cmds
=
(
m_api
==
Eiger1
);
DEB_PARAM
()
<<
DEB_VAR1
(
frame_time
);
std
::
shared_ptr
<
Requests
::
Param
>
frame_time_req
=
m_requests
->
set_param
(
Requests
::
FRAME_TIME
,
frame_time
);
if
(
!
parallel_sync_cmds
)
frame_time_req
->
wait
();
std
::
shared_ptr
<
Requests
::
Param
>
nimages_req
=
m_requests
->
set_param
(
Requests
::
NIMAGES
,
nb_frames
);
if
(
!
parallel_sync_cmds
)
nimages_req
->
wait
();
std
::
shared_ptr
<
Requests
::
Param
>
ntrigger_req
=
m_requests
->
set_param
(
Requests
::
NTRIGGER
,
nb_trigger
);
if
(
!
parallel_sync_cmds
)
ntrigger_req
->
wait
();
try
{
DEB_PARAM
()
<<
DEB_VAR1
(
frame_time
);
std
::
shared_ptr
<
Requests
::
Param
>
frame_time_req
;
if
(
m_frame_time
.
changed
(
frame_time
))
{
frame_time_req
=
m_requests
->
set_param
(
Requests
::
FRAME_TIME
,
frame_time
);
if
(
!
parallel_sync_cmds
)
frame_time_req
->
wait
();
}
std
::
shared_ptr
<
Requests
::
Param
>
nimages_req
;
if
(
m_nb_images
.
changed
(
nb_images
))
{
nimages_req
=
m_requests
->
set_param
(
Requests
::
NIMAGES
,
nb_images
);
if
(
!
parallel_sync_cmds
)
nimages_req
->
wait
();
}
std
::
shared_ptr
<
Requests
::
Param
>
ntrigger_req
;
if
(
m_nb_triggers
.
changed
(
nb_triggers
))
{
ntrigger_req
=
m_requests
->
set_param
(
Requests
::
NTRIGGER
,
nb_triggers
);
if
(
!
parallel_sync_cmds
)
ntrigger_req
->
wait
();
}
if
(
parallel_sync_cmds
)
{
frame_time_req
->
wait
();
nimages_req
->
wait
();
ntrigger_req
->
wait
();
if
(
frame_time_req
)
frame_time_req
->
wait
();
if
(
nimages_req
)
nimages_req
->
wait
();
if
(
ntrigger_req
)
ntrigger_req
->
wait
();
}
}
catch
(
const
eigerapi
::
EigerException
&
e
)
...
...
@@ -427,9 +431,9 @@ void Camera::setTrigMode(TrigMode trig_mode) ///< [in] lima trigger mode to set
default:
THROW_HW_ERROR
(
NotSupported
)
<<
DEB_VAR1
(
trig_mode
);
}
EIGER_SYNC_SET_PARAM
(
Requests
::
TRIGGER_MODE
,
trig_
nam
e
)
;
m_trig_mode
=
trig_mode
;
if
(
m_trig_mode
.
changed
(
trig_
mod
e
)
)
EIGER_SYNC_SET_PARAM
(
Requests
::
TRIGGER_MODE
,
trig_name
)
;
}
...
...
@@ -448,13 +452,14 @@ void Camera::getTrigMode(TrigMode& mode) ///< [out] current trigger mode
//-----------------------------------------------------------------------------
/// Set the new exposure time
//-----------------------------------------------------------------------------
void
Camera
::
setExpTime
(
double
exp_time
)
///< [in] exposure time to set
void
Camera
::
setExpTime
(
double
exp_time
,
///< [in] exposure time to set
bool
force
)
{
DEB_MEMBER_FUNCT
();
DEB_PARAM
()
<<
DEB_VAR1
(
exp_time
);
EIGER_SYNC_SET_PARAM
(
Requests
::
EXPOSURE
,
exp_time
);
m_exp_time
=
exp_time
;
if
(
m_exp_time
.
changed
(
exp_time
)
||
force
)
EIGER_SYNC_SET_PARAM
(
Requests
::
EXPOSURE
,
exp_time
)
;
}
...
...
@@ -479,8 +484,9 @@ void Camera::setLatTime(double lat_time) ///< [in] latency time
DEB_MEMBER_FUNCT
();
DEB_PARAM
()
<<
DEB_VAR1
(
lat_time
);
bool
force_exp
=
(
lat_time
!=
m_latency_time
);
m_latency_time
=
lat_time
;
setExpTime
(
m_exp_time
);
setExpTime
(
m_exp_time
,
force_exp
);
}
...
...
@@ -685,9 +691,9 @@ void Camera::initialiseController()
synchro_list
.
push_back
(
m_requests
->
get_param
(
Requests
::
DETECTOR_NUMBER
,
m_detector_type
));
synchro_list
.
push_back
(
m_requests
->
get_param
(
Requests
::
EXPOSURE
,
m_exp_time
));
synchro_list
.
push_back
(
m_requests
->
get_param
(
Requests
::
NIMAGES
,
m_nb_images
));
unsigned
nb_trigger
;
synchro_list
.
push_back
(
m_requests
->
get_param
(
Requests
::
NTRIGGER
,
nb_trigger
));
synchro_list
.
push_back
(
m_requests
->
get_param
(
Requests
::
NTRIGGER
,
m_nb_triggers
));
std
::
shared_ptr
<
Requests
::
Param
>
frame_time_req
=
m_requests
->
get_param
(
Requests
::
FRAME_TIME
);
synchro_list
.
push_back
(
frame_time_req
);
...
...
@@ -716,9 +722,9 @@ void Camera::initialiseController()
//Trigger mode
if
(
trig_name
==
"ints"
)
m_trig_mode
=
nb_trigger
>
1
?
IntTrigMult
:
IntTrig
;
m_trig_mode
=
m_
nb_trigger
s
>
1
?
IntTrigMult
:
IntTrig
;
else
if
(
trig_name
==
"exts"
)
m_trig_mode
=
nb_trigger
>
1
?
ExtTrigMult
:
ExtTrigSingle
;
m_trig_mode
=
m_
nb_trigger
s
>
1
?
ExtTrigMult
:
ExtTrigSingle
;
else
if
(
trig_name
==
"exte"
)
m_trig_mode
=
ExtGate
;
else
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment