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-slsdetector
Commits
7695a1e7
Commit
7695a1e7
authored
Feb 09, 2021
by
Alejandro Homs Puron
Committed by
operator for beamline
Feb 18, 2021
Browse files
Jungfrau: add DoubleBuffer to GainADCImgProc, read does not copy data
parent
70c62230
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/SlsDetectorJungfrau.h
View file @
7695a1e7
...
...
@@ -24,6 +24,7 @@
#define __SLS_DETECTOR_JUNGFRAU_H
#include
"SlsDetectorCamera.h"
#include
"SlsDetectorDoubleBuffer.h"
#include
"processlib/SinkTask.h"
...
...
@@ -85,7 +86,7 @@ class Jungfrau : public Model
void
setImgProcConfig
(
std
::
string
config
);
void
getImgProcConfig
(
std
::
string
&
config
);
void
readGainADCMaps
(
Data
&
gain_map
,
Data
&
adc_map
);
void
readGainADCMaps
(
Data
&
gain_map
,
Data
&
adc_map
,
FrameType
&
frame
);
virtual
bool
isXferActive
();
...
...
@@ -210,6 +211,21 @@ class Jungfrau : public Model
memset
(
d
.
data
(),
0
,
d
.
size
());
}
static
void
makeDataRef
(
Data
&
src
,
Data
&
ref
,
Buffer
::
Callback
*
cb
)
{
ref
.
type
=
src
.
type
;
ref
.
dimensions
=
src
.
dimensions
;
ref
.
frameNumber
=
src
.
frameNumber
;
ref
.
timestamp
=
src
.
timestamp
;
ref
.
header
=
src
.
header
;
Buffer
*
b
=
new
Buffer
;
b
->
owner
=
Buffer
::
MAPPED
;
b
->
callback
=
cb
;
b
->
data
=
src
.
data
();
ref
.
setBuffer
(
b
);
b
->
unref
();
}
protected:
friend
class
Jungfrau
;
Jungfrau
*
m_jungfrau
;
...
...
@@ -228,38 +244,84 @@ class Jungfrau : public Model
DEB_CLASS_NAMESPC
(
DebModCamera
,
"Jungfrau::GainADCMapImgProc"
,
"SlsDetector"
);
public:
GainADCMapImgProc
(
Jungfrau
*
jungfrau
);
virtual
void
updateImageSize
(
Size
size
,
bool
raw
);
virtual
void
prepareAcq
();
virtual
void
processFrame
(
Data
&
data
);
void
readGainADCMaps
(
Data
&
gain_map
,
Data
&
adc_map
,
FrameType
&
frame
);
private:
struct
MapData
{
Data
gain_map
;
Data
adc_map
;
Mutex
mutex
;
AutoMutex
lock
()
{
return
mutex
;
}
MapData
()
{
gain_map
.
type
=
Data
::
UINT8
;
adc_map
.
type
=
Data
::
UINT16
;
}
void
updateSize
(
Size
size
)
{
AutoMutex
l
=
lock
();
updateDataSize
(
gain_map
,
size
);
updateDataSize
(
adc_map
,
size
);
};
void
clear
()
{
AutoMutex
l
=
lock
();
clearData
(
gain_map
);
clearData
(
adc_map
);
}
};
GainADCMapImgProc
(
Jungfrau
*
jungfrau
);
typedef
DoubleBuffer
<
MapData
>
DBuffer
;
class
ReaderHelper
:
public
Buffer
::
Callback
{
DEB_CLASS_NAMESPC
(
DebModCamera
,
"Jungfrau::"
"GainADCMapImgProc::ReaderHelper"
,
"SlsDetector"
);
public:
void
addRead
(
DBuffer
&
b
,
Data
&
gain_map
,
Data
&
adc_map
,
FrameType
frame
)
{
DEB_MEMBER_FUNCT
();
if
(
m_reader
)
THROW_HW_ERROR
(
Error
)
<<
"A reader is already active"
;
m_reader
=
new
Reader
(
b
,
frame
);
MapData
&
m
=
m_reader
->
getBuffer
();
DEB_TRACE
()
<<
DEB_VAR1
(
&
m
);
makeDataRef
(
m
.
gain_map
,
gain_map
,
this
);
++
m_count
;
makeDataRef
(
m
.
adc_map
,
adc_map
,
this
);
++
m_count
;
DEB_TRACE
()
<<
DEB_VAR1
(
m_count
);
frame
=
m_reader
->
getCounter
();
}
virtual
void
updateImageSize
(
Size
size
,
bool
raw
);
virtual
void
prepareAcq
();
virtual
void
processFrame
(
Data
&
data
);
protected:
virtual
void
destroy
(
void
*
buffer
)
{
DEB_MEMBER_FUNCT
();
DEB_PARAM
()
<<
DEB_VAR1
(
m_count
);
if
((
m_count
==
0
)
||
!
m_reader
)
DEB_ERROR
()
<<
DEB_VAR1
(
m_count
);
MapData
&
m
=
m_reader
->
getBuffer
();
if
((
buffer
!=
m
.
gain_map
.
data
())
&&
(
buffer
!=
m
.
adc_map
.
data
()))
THROW_HW_ERROR
(
Error
)
<<
"Bad buffer"
;
if
(
--
m_count
==
0
)
m_reader
=
NULL
;
}
private:
friend
class
Jungfrau
;
MapData
m_data
;
private:
typedef
DoubleBufferReader
<
MapData
>
Reader
;
AutoPtr
<
Reader
>
m_reader
;
int
m_count
{
0
};
};
DBuffer
m_buffer
;
AutoPtr
<
ReaderHelper
>
m_reader
;
};
void
addImgProc
(
ImgProcBase
*
img_proc
);
...
...
sip/SlsDetectorJungfrau.sip
View file @
7695a1e7
...
...
@@ -75,7 +75,8 @@ class Jungfrau : public SlsDetector::Model
void setImgProcConfig(std::string config);
void getImgProcConfig(std::string &config /Out/);
void readGainADCMaps(Data& gain_map /Out/, Data& adc_map /Out/);
void readGainADCMaps(Data& gain_map /Out/, Data& adc_map /Out/,
unsigned long& frame /In,Out/);
virtual bool isXferActive();
...
...
src/SlsDetectorJungfrau.cpp
View file @
7695a1e7
...
...
@@ -254,7 +254,7 @@ void Jungfrau::ImgProcBase::prepareAcq()
*/
Jungfrau
::
GainADCMapImgProc
::
GainADCMapImgProc
(
Jungfrau
*
jungfrau
)
:
ImgProcBase
(
jungfrau
,
"gain_adc_map"
)
:
ImgProcBase
(
jungfrau
,
"gain_adc_map"
)
,
m_reader
(
new
ReaderHelper
)
{
DEB_CONSTRUCTOR
();
}
...
...
@@ -262,27 +262,32 @@ Jungfrau::GainADCMapImgProc::GainADCMapImgProc(Jungfrau *jungfrau)
void
Jungfrau
::
GainADCMapImgProc
::
updateImageSize
(
Size
size
,
bool
raw
)
{
DEB_MEMBER_FUNCT
();
DEB_
ALWAYS
()
<<
DEB_VAR3
(
m_name
,
size
,
raw
);
DEB_
PARAM
()
<<
DEB_VAR3
(
m_name
,
size
,
raw
);
ImgProcBase
::
updateImageSize
(
size
,
raw
);
m_data
.
updateSize
(
size
);
for
(
auto
&
d
:
m_buffer
)
d
.
updateSize
(
size
);
}
void
Jungfrau
::
GainADCMapImgProc
::
prepareAcq
()
{
DEB_MEMBER_FUNCT
();
ImgProcBase
::
prepareAcq
();
m_data
.
clear
();
for
(
auto
&
d
:
m_buffer
)
d
.
clear
();
m_buffer
.
reset
();
}
void
Jungfrau
::
GainADCMapImgProc
::
processFrame
(
Data
&
data
)
{
DEB_MEMBER_FUNCT
();
long
frame
=
data
.
frameNumber
;
DEB_
ALWAYS
()
<<
DEB_VAR1
(
frame
);
DEB_
PARAM
()
<<
DEB_VAR1
(
frame
);
MapData
&
m
=
m_data
;
AutoMutex
l
=
m
.
lock
();
DoubleBufferWriter
<
MapData
>
w
(
m_buffer
);
MapData
&
m
=
w
.
getBuffer
();
DEB_TRACE
()
<<
DEB_VAR1
(
&
m
);
unsigned
short
*
src
;
{
src
=
(
unsigned
short
*
)
data
.
data
();
...
...
@@ -298,8 +303,17 @@ void Jungfrau::GainADCMapImgProc::processFrame(Data& data)
*
dst
++
=
*
src
++
&
0x3fff
;
m
.
adc_map
.
frameNumber
=
frame
;
}
w
.
setCounter
(
frame
);
}
void
Jungfrau
::
GainADCMapImgProc
::
readGainADCMaps
(
Data
&
gain_map
,
Data
&
adc_map
,
FrameType
&
frame
)
{
DEB_MEMBER_FUNCT
();
DEB_PARAM
()
<<
DEB_VAR1
(
frame
);
m_reader
->
addRead
(
m_buffer
,
gain_map
,
adc_map
,
frame
);
DEB_RETURN
()
<<
DEB_VAR3
(
gain_map
,
adc_map
,
frame
);
}
/*
* Jungfrau detector class
...
...
@@ -667,6 +681,10 @@ void Jungfrau::prepareAcq()
ThreadList
::
iterator
tit
,
tend
=
m_thread_list
.
end
();
for
(
tit
=
m_thread_list
.
begin
();
tit
!=
tend
;
++
tit
)
(
*
tit
)
->
prepareAcq
();
ImgProcList
::
iterator
pit
,
pend
=
m_img_proc_list
.
end
();
for
(
pit
=
m_img_proc_list
.
begin
();
pit
!=
pend
;
++
pit
)
(
*
pit
)
->
prepareAcq
();
}
void
Jungfrau
::
startAcq
()
...
...
@@ -827,7 +845,7 @@ void Jungfrau::getImgProcConfig(std::string &config)
DEB_RETURN
()
<<
DEB_VAR1
(
config
);
}
void
Jungfrau
::
readGainADCMaps
(
Data
&
gain_map
,
Data
&
adc_map
)
void
Jungfrau
::
readGainADCMaps
(
Data
&
gain_map
,
Data
&
adc_map
,
FrameType
&
frame
)
{
DEB_MEMBER_FUNCT
();
ImgProcList
::
iterator
it
,
end
=
m_img_proc_list
.
end
();
...
...
@@ -838,9 +856,6 @@ void Jungfrau::readGainADCMaps(Data& gain_map, Data& adc_map)
if
(
it
==
end
)
THROW_HW_ERROR
(
Error
)
<<
"ImgProc gain_adc_map not found"
;
GainADCMapImgProc
*
img_proc
=
static_cast
<
GainADCMapImgProc
*>
(
*
it
);
GainADCMapImgProc
::
MapData
&
m
=
img_proc
->
m_data
;
AutoMutex
l
=
m
.
lock
();
gain_map
=
m
.
gain_map
.
copy
();
adc_map
=
m
.
adc_map
.
copy
();
img_proc
->
readGainADCMaps
(
gain_map
,
adc_map
,
frame
);
}
tango/SlsDetector.py
View file @
7695a1e7
...
...
@@ -512,13 +512,15 @@ class SlsDetector(PyTango.Device_4Impl):
@
Core
.
DEB_MEMBER_FUNCT
def
read_jungfrau_gain_map
(
self
,
attr
):
jungfrau
=
_SlsDetectorJungfrau
gain_data
,
adc_data
=
jungfrau
.
readGainADCMaps
()
gain_data
,
adc_data
,
frame
=
jungfrau
.
readGainADCMaps
(
-
1
)
deb
.
Always
(
"frame=%s"
%
frame
)
attr
.
set_value
(
gain_data
.
buffer
)
@
Core
.
DEB_MEMBER_FUNCT
def
read_jungfrau_adc_map
(
self
,
attr
):
jungfrau
=
_SlsDetectorJungfrau
gain_data
,
adc_data
=
jungfrau
.
readGainADCMaps
()
gain_data
,
adc_data
,
frame
=
jungfrau
.
readGainADCMaps
(
-
1
)
deb
.
Always
(
"frame=%s"
%
frame
)
attr
.
set_value
(
adc_data
.
buffer
)
@
Core
.
DEB_MEMBER_FUNCT
...
...
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