Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DetectorSoftware
libagipdrecv
Commits
17d745d6
Commit
17d745d6
authored
Sep 06, 2018
by
Yuelong Yu
Browse files
updated NXWrapper and implemented receiver task
parent
f1caaba1
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/NXWrapper.h
View file @
17d745d6
...
...
@@ -119,7 +119,6 @@ namespace NexusNS
{
return
FILE_ERROR
;
}
}
int
OpenFile
(
string
strFileName
)
...
...
@@ -185,16 +184,48 @@ namespace NexusNS
* @param : data type
* @param : x
* @param : y
* @param : depth of data
* @param : cache size
* @param : use build-in compressor or not. true: use build-in compressor
* @param : compression is enabled or not. true: enabled. false: disabled
* @param : compressor shuffle
* @param : compression ratio
* @param : file splitting
* @param : maximum file limit size
* @param : postfix of file. h5 or nxs
* @param : error code
* 0: OK
*/
int
FileConfig
(
string
strFileName
,
int
nX
,
int
nY
,
string
strFilePostfix
=
string
(
"nxs"
))
int
FileConfig
(
string
strFileName
,
bool
bOverwrite
,
int
nDataType
,
int
nX
,
int
nY
,
int
nDepth
,
int
nCacheSize
,
bool
bBuildInCompressor
,
bool
bCompressionEnabled
,
bool
bCompressionShuffleEnabled
,
unsigned
short
usCompressionRate
,
bool
bSplitEnabled
,
int
nFileSizeLimit
,
string
strFilePostfix
=
string
(
"nxs"
))
{
m_strFileName
=
strFileName
;
m_nCacheSize
=
nCacheSize
;
m_nDataDepth
=
nDepth
;
m_nDataType
=
nDataType
;
m_nX
=
nX
;
m_nY
=
nY
;
m_nSize
=
nX
*
nY
;
m_bSplitting
=
bSplitEnabled
;
m_bOverwrite
=
bOverwrite
;
m_nLimitSize
=
nFileSizeLimit
;
m_strFilePostfix
=
strFilePostfix
;
m_bBuildInCompressor
=
bBuildInCompressor
;
m_bCompression
=
bCompressionEnabled
;
m_bCompressorShuffle
=
bCompressionShuffleEnabled
;
m_ushCompressionRate
=
usCompressionRate
;
m_strFileName
=
strFileName
+
"."
+
strFilePostfix
;
return
0
;
...
...
@@ -202,10 +233,9 @@ namespace NexusNS
void
PreAcq
(
string
strDataFieldPath
,
string
strFrameFieldPath
,
string
strErrField
)
{
cout
<<
"m_nX:"
<<
m_nX
<<
"m_nY:"
<<
m_nY
<<
endl
;
//cout<<"m_nX:"<<m_nX<<"m_nY:"<<m_nY<<endl;
//m_nIdx = nIndex;
ResetIndex
();
m_objDataSelection
=
dataspace
::
Hyperslab
({{
0
,
0
,
0
},
{
1
,
static_cast
<
unsigned
int
>
(
m_nX
),
static_cast
<
unsigned
int
>
(
m_nY
)}});
m_objFrameSelection
=
dataspace
::
Hyperslab
({{
0
,
0
},{
1
,
1
}});
...
...
@@ -231,6 +261,16 @@ namespace NexusNS
m_nxDataField
=
objDataFieldList
[
0
];
m_nxFrameField
=
objFrameFieldList
[
0
];
m_nxErrField
=
objErrFieldList
[
0
];
m_nIdx
=
m_nxFrameField
.
dataspace
().
size
();
if
(
m_nIdx
==
1
)
{
m_nxDataField
.
extent
(
0
,
1
);
m_nIdx
-=
2
;
//
}
else
m_nIdx
-=
1
;
}
/**
...
...
@@ -255,26 +295,15 @@ namespace NexusNS
template
<
typename
T
>
int
Write2DData
(
vector
<
T
>&
vData
,
int
nFrameNo
,
short
shErr
)
{
cout
<<
"write 2d data"
<<
endl
;
//
cout<<"write 2d data"<<endl;
try
{
++
m_nIdx
;
if
(
m_nIdx
!=
0
)
{
m_nxFrameField
.
extent
(
0
,
1
);
m_objFrameSelection
.
offset
(
0
,
m_nIdx
);
m_nxErrField
.
extent
(
0
,
1
);
m_objErrSelection
.
offset
(
0
,
m_nIdx
);
}
SetCorrectPos
();
m_nxFrameField
.
write
(
nFrameNo
,
m_objFrameSelection
);
m_nxErrField
.
write
(
shErr
,
m_objErrSelection
);
m_nxDataField
.
extent
(
0
,
1
);
m_objDataSelection
.
offset
(
0
,
m_nIdx
);
m_nxDataField
.
write
(
vData
,
m_objDataSelection
);
m_nxDataField
.
write
(
vData
,
m_objDataSelection
);
return
NO_ERROR
;
}
...
...
@@ -303,21 +332,10 @@ namespace NexusNS
{
try
{
++
m_nIdx
;
if
(
m_nIdx
!=
0
)
{
m_nxFrameField
.
extent
(
0
,
1
);
m_objFrameSelection
.
offset
(
0
,
m_nIdx
);
m_nxErrField
.
extent
(
0
,
1
);
m_objErrSelection
.
offset
(
0
,
m_nIdx
);
}
SetCorrectPos
();
m_nxFrameField
.
write
(
nFrameNo
,
m_objFrameSelection
);
m_nxErrField
.
write
(
shErr
,
m_objErrSelection
);
m_nxDataField
.
extent
(
0
,
1
);
m_objDataSelection
.
offset
(
0
,
m_nIdx
);
//H5DOwrite_chunk
long
long
unsigned
int
nOffset
[
3
]
=
{
static_cast
<
long
long
unsigned
int
>
(
m_nIdx
),
...
...
@@ -363,6 +381,23 @@ namespace NexusNS
void
ResetIndex
()
{
m_nIdx
=
-
1
;
}
void
SetCorrectPos
()
{
//cout<<"m_nIdx"<<m_nIdx<<endl;
++
m_nIdx
;
if
(
m_nIdx
!=
0
)
{
m_nxFrameField
.
extent
(
0
,
1
);
m_nxErrField
.
extent
(
0
,
1
);
m_nxDataField
.
extent
(
0
,
1
);
}
m_objFrameSelection
.
offset
(
0
,
m_nIdx
);
m_objErrSelection
.
offset
(
0
,
m_nIdx
);
m_objDataSelection
.
offset
(
0
,
m_nIdx
);
}
void
DisplayError
(
string
strFunc
,
string
strMsg
,
int
nRet
)
...
...
src/ReceiverTask.cpp
View file @
17d745d6
...
...
@@ -68,6 +68,11 @@ namespace FSDataRecvNS
int16
&
error_code
)
{
LOG_TRACE
(
__FUNCTION__
);
boost
::
unique_lock
<
boost
::
mutex
>
lock
(
m_bstSync
);
std
::
copy
(
m_img_data
.
begin
(),
m_img_data
.
end
(),
img_data
.
get
());
frame_number
=
m_current_frame_number
;
error_code
=
0
;
//not used for live images
lock
.
unlock
();
}
void
ReceiverTask
::
DoTaskAction
()
...
...
@@ -86,6 +91,9 @@ namespace FSDataRecvNS
{
m_udpconn
->
ClearDataInSocket
();
m_bstCond
.
wait
(
lock
);
m_received_imgs
=
0
;
m_packets_collected
=
0
;
}
if
(
m_fExit
)
...
...
@@ -108,8 +116,17 @@ namespace FSDataRecvNS
void
ReceiverTask
::
BuildImage
(
packet_struct
const
&
packet_data
)
{
LOG_TRACE
(
__FUNCTION__
);
memcpy
(
&
m_img_data
[
m_packets_collected
]
*
4096
,
packet_data
.
data
,
4096
*
sizeof
(
uint16_t
));
++
m_packets_collected
;
if
(
m_packets_collected
==
16
)
// one image is finished
{
++
m_received_imgs
;
m_current_frame_number
=
m_received_imgs
;
m_mempool16bit
->
WriteOneImage
(
m_img_data
,
m_received_imgs
,
0
);
}
++
m_received_imgs
;
}
}
src/ReceiverTask.h
View file @
17d745d6
...
...
@@ -43,7 +43,7 @@ namespace FSDataRecvNS
// uint16_t roundRobin;
// uint8_t detectortype;
// uint8_t headerVersion;
//
uint16_t data[BUFFER_LENGTH];
uint16_t
data
[
BUFFER_LENGTH
];
};
#pragma pack(pop)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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