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
tango-ds
DeviceClasses
Acquisition
2D
AGIPD
Commits
3ec2d6b5
Commit
3ec2d6b5
authored
Feb 16, 2016
by
Yuelong Yu
Browse files
delete file
parent
571af523
Changes
1
Hide whitespace changes
Inline
Side-by-side
agipd/AcquisitionThread.cpp
deleted
100644 → 0
View file @
571af523
#include
"NXFileSavingBuilder.h"
#include
"AcquisitionThread.h"
namespace
AGIPD_ns
{
NXFileSavingBuilder_ns
::
NXWriter
objNXWriter
;
NXFileSavingBuilder_ns
::
AGIPDBuilder
objAGIPDBuilder
;
AcquisitionThread
::
AcquisitionThread
(
AGIPD
*
_objAGIPD
,
AGIPDInterface
*
_objDet
,
omni_mutex
&
_mutexAcq
)
:
omni_thread
(),
Tango
::
LogAdapter
(
_objAGIPD
),
m_objAGIPD
(
_objAGIPD
),
m_objDet
(
_objDet
),
m_mutexAcq
(
_mutexAcq
),
m_bFirstFrame
(
true
)
,
m_lStartFrame
(
-
1
)
{
start_undetached
();
}
AcquisitionThread
::~
AcquisitionThread
()
{
}
void
*
AcquisitionThread
::
run_undetached
(
void
*
ptr
)
{
DEBUG_STREAM
<<
"The AcquisitonThread Starts..."
<<
endl
;
while
(
1
)
{
usleep
(
100
);
{
omni_mutex_lock
l
(
m_mutexAcq
);
if
(
m_objAGIPD
->
m_bSysExit
)
break
;
//if starts acquisition
if
(
m_objAGIPD
->
m_bStartAcq
)
AcquisitionStart
();
else
if
(
m_objAGIPD
->
m_bStopAcq
)
// acquisition stops
AcquisitionStop
();
else
if
(
m_objAGIPD
->
m_bAcquiringData
)
//acquiring data from detector
AcquiringData
();
}
}
omni_thread
::
exit
();
}
void
AcquisitionThread
::
AcquisitionStart
()
{
m_objAGIPD
->
SetState
(
Tango
::
MOVING
);
m_objAGIPD
->
m_bStartAcq
=
false
;
m_objAGIPD
->
m_bAcquiringData
=
true
;
m_lFrameNo
=
-
2
;
m_lAcquiredImgs
=
0
;
m_bFirstFrame
=
true
;
m_lStartFrame
=
-
1
;
*
(
m_objAGIPD
->
attr_LatestImageNumber_read
)
=
0
;
*
(
m_objAGIPD
->
attr_TotalLossFrames_read
)
=
0
;
if
(
*
(
m_objAGIPD
->
attr_SaveAllImages_read
))
{
string
strFileDir
=
m_objAGIPD
->
DevStringToString
(
*
(
m_objAGIPD
->
attr_SaveFilePath_read
));
string
strFileName
=
m_objAGIPD
->
DevStringToString
(
*
(
m_objAGIPD
->
attr_SaveFileName_read
));
string
strFile
=
strFileDir
+
"/"
+
strFileName
;
objNXWriter
.
SetBuilder
(
&
objAGIPDBuilder
);
objNXWriter
.
FileConfig
(
strFile
,
1
,
m_objAGIPD
->
m_nSizeY
,
m_objAGIPD
->
m_nSizeX
,
m_objAGIPD
->
m_shDepth
,
*
(
m_objAGIPD
->
attr_ChunkSize_read
)
//chunk size
,
*
(
m_objAGIPD
->
attr_CompressionEnabled_read
)
//compression enable
,
*
(
m_objAGIPD
->
attr_CompressorShuffle_read
)
//compression shuffle
,
*
(
m_objAGIPD
->
attr_CompressionRate_read
)
//compression level
,
*
(
m_objAGIPD
->
attr_FileSplitEnabled_read
)
//file splitting
,
*
(
m_objAGIPD
->
attr_FileSizeLimit_read
)
*
1024
//file limit size GigaBytes*1024=MegaBytes
,
*
(
m_objAGIPD
->
attr_FilePostfix_read
)
//postfix
);
// objNXWriter.FileConfig(strFile
// ,1
// ,m_objAGIPD->m_nSizeY
// ,m_objAGIPD->m_nSizeX
// ,m_objAGIPD->m_shDepth
// ,1 //chunk size
// ,true //compression enable
// ,true //compression shuffle
// ,2 //compression level
// ,false //file splitting
// ,0 //file limit size
// ,*(m_objAGIPD->attr_FilePostfix_read) //postfix
// );
objNXWriter
.
CreateFile
();
objNXWriter
.
CreateGroup
(
"entry"
,
"NXentry"
);
objNXWriter
.
CreateGroup
(
"/entry/instrument"
,
"NXinstrument"
);
objNXWriter
.
CreateGroup
(
"/entry/instrument/detector"
,
"NXdetector"
);
objNXWriter
.
CreateField
(
"data"
);
DumpSettings
();
}
m_objDet
->
StartImaging
();
}
void
AcquisitionThread
::
AcquisitionStop
()
{
m_objDet
->
StopImaging
();
m_objAGIPD
->
m_bStopAcq
=
false
;
m_objAGIPD
->
m_bAcquiringData
=
false
;
if
(
*
(
m_objAGIPD
->
attr_SaveAllImages_read
))
{
if
(
m_lAcquiredImgs
!=
0
)
{
(
*
(
m_objAGIPD
->
attr_FileStartNum_read
))
++
;
m_objAGIPD
->
UpdateFileName
();
}
else
cout
<<
"no image inside"
<<
endl
;
objNXWriter
.
CloseFile
();
}
m_bFirstFrame
=
true
;
m_lStartFrame
=
-
1
;
m_lAcquiredImgs
=
0
;
m_lFrameNo
=
-
2
;
m_objAGIPD
->
SetState
(
Tango
::
ON
);
}
void
AcquisitionThread
::
AcquiringData
()
{
long
lBufferImgs
=
m_objDet
->
GetQueuedImageNumbers
(
0
);
if
(
lBufferImgs
>
0
)
{
m_ptrShData
=
m_objDet
->
GetImageData
(
m_lFrameNo
,
m_shErrCode
);
if
(
m_ptrShData
!=
NULL
&&
m_lFrameNo
!=-
1
&&
m_shErrCode
!=-
1
)
{
if
(
m_bFirstFrame
)
{
m_lStartFrame
=
m_lFrameNo
;
m_bFirstFrame
=
false
;
}
m_lFrameNo
=
m_lFrameNo
-
m_lStartFrame
+
1
;
WriteData
(
m_ptrShData
,
m_lFrameNo
,
m_shErrCode
);
if
(
m_shErrCode
!=
0
)
//frame lost
(
*
(
m_objAGIPD
->
attr_TotalLossFrames_read
))
++
;
*
(
m_objAGIPD
->
attr_LatestImageNumber_read
)
=
m_lFrameNo
;
m_lAcquiredImgs
++
;
//cout<<"Data is right:"<<m_ptrShData<<";"<<m_lFrameNo<<";"<<m_shErrCode<<endl;
}
else
cout
<<
"Data is wrong:"
<<
m_ptrShData
<<
";"
<<
m_lFrameNo
<<
";"
<<
m_shErrCode
<<
endl
;
}
else
{
if
(
m_objAGIPD
->
m_bAcquiringData
==
true
&&
m_lAcquiredImgs
>=*
(
m_objAGIPD
->
attr_FrameNumbers_read
))
{
m_objAGIPD
->
m_bAcquiringData
=
false
;
m_objAGIPD
->
m_bStartAcq
=
false
;
m_objAGIPD
->
m_bStopAcq
=
true
;
cout
<<
"Acquisition Finished!!!"
<<
endl
;
cout
<<
"Already acquired images: "
<<
m_lAcquiredImgs
<<
endl
;
}
}
}
void
AcquisitionThread
::
WriteData
(
short
*
ptrShData
,
long
lFrame
,
short
shErrCode
)
{
//cout<<"Writting data:"<<m_ptrShData<<";"<<m_lFrameNo<<";"<<m_shErrCode<<endl;
//analog one
if
((
m_lFrameNo
%
2
)
!=
0
)
{
//in live mode
if
(
*
(
m_objAGIPD
->
attr_LiveMode_read
)
&&
((
m_lFrameNo
+
1
)
%
704
==
0
))
{
copy
(
ptrShData
,
ptrShData
+
(
m_objAGIPD
->
m_nImgSize
),
m_objAGIPD
->
attr_LiveDataAnalog_read
);
*
(
m_objAGIPD
->
attr_LiveFrameNoAnalog_read
)
=
m_lFrameNo
;
}
}
else
//digital one
{
if
(
*
(
m_objAGIPD
->
attr_LiveMode_read
)
&&
(
m_lFrameNo
%
704
==
0
))
{
copy
(
ptrShData
,
ptrShData
+
(
m_objAGIPD
->
m_nImgSize
),
m_objAGIPD
->
attr_LiveDataDigital_read
);
*
(
m_objAGIPD
->
attr_LiveFrameNoDigital_read
)
=
m_lFrameNo
;
}
}
//write data into disk
long
lFrameRemain
=
*
(
m_objAGIPD
->
attr_FrameNumbers_read
)
-
m_lAcquiredImgs
-
1
;
if
(
*
(
m_objAGIPD
->
attr_SaveAllImages_read
))
objNXWriter
.
WriteData
(
ptrShData
,
lFrame
,
shErrCode
,
lFrameRemain
);
}
void
AcquisitionThread
::
DumpSettings
()
{
//ADCLatency
objNXWriter
.
DumpAllAttributesFromTango
(
"adc_latency"
,
*
(
m_objAGIPD
->
attr_ADCLatency_read
),
""
,
false
);
//ADCTrigger
objNXWriter
.
DumpAllAttributesFromTango
(
"adc_trigger"
,
*
(
m_objAGIPD
->
attr_ADCTrigger_read
),
""
,
false
);
//ASICCS
objNXWriter
.
DumpAllAttributesFromTango
(
"asic_cs"
,
string
(
*
(
m_objAGIPD
->
attr_ASICCS_read
)),
false
);
//ASICPS
objNXWriter
.
DumpAllAttributesFromTango
(
"asic_ps"
,
string
(
*
(
m_objAGIPD
->
attr_ASICPS_read
)),
false
);
// //DELAY1
// objNXWriter.DumpAllAttributesFromTango("delay_1",*(m_objAGIPD->attr_Delay1_read),"",false);
// //DELAY2
// objNXWriter.DumpAllAttributesFromTango("delay_2",*(m_objAGIPD->attr_Delay2_read),"",false);
// //DELAY3
// objNXWriter.DumpAllAttributesFromTango("delay_3",*(m_objAGIPD->attr_Delay3_read),"",false);
// //DELAY4
// objNXWriter.DumpAllAttributesFromTango("delay_4",*(m_objAGIPD->attr_Delay4_read),"",false);
// //DELAY5
// objNXWriter.DumpAllAttributesFromTango("delay_5",*(m_objAGIPD->attr_Delay5_read),"",false);
// //DELAY6
// objNXWriter.DumpAllAttributesFromTango("delay_6",*(m_objAGIPD->attr_Delay6_read),"",false);
// //DELAY7
// objNXWriter.DumpAllAttributesFromTango("delay_7",*(m_objAGIPD->attr_Delay7_read),"",false);
// //DELAY8
// objNXWriter.DumpAllAttributesFromTango("delay_8",*(m_objAGIPD->attr_Delay8_read),"",false);
//IntegrationTime
objNXWriter
.
DumpAllAttributesFromTango
(
"integration_time"
,(
int
)(
*
(
m_objAGIPD
->
attr_IntegrationTime_read
)),
"clocks"
,
false
);
//SaveFilePath
objNXWriter
.
DumpAllAttributesFromTango
(
"save_file_path"
,
string
(
*
(
m_objAGIPD
->
attr_SaveFilePath_read
)),
false
);
//FrameNumbers
objNXWriter
.
DumpAllAttributesFromTango
(
"frame_numbers"
,(
int
)(
*
(
m_objAGIPD
->
attr_FrameNumbers_read
)),
""
,
false
);
//IntegrationOffset
objNXWriter
.
DumpAllAttributesFromTango
(
"integration_offset"
,
*
(
m_objAGIPD
->
attr_IntegrationOffset_read
),
"clocks"
,
false
);
//LiveMode
objNXWriter
.
DumpAllAttributesFromTango
(
"live_mode"
,
*
(
m_objAGIPD
->
attr_LiveMode_read
),
false
);
//PatternFile
objNXWriter
.
DumpAllAttributesFromTango
(
"pattern_file"
,
string
(
*
(
m_objAGIPD
->
attr_PatternFile_read
)),
false
);
//SaveAllImages
objNXWriter
.
DumpAllAttributesFromTango
(
"save_all_images"
,
*
(
m_objAGIPD
->
attr_SaveAllImages_read
),
false
);
//CompressionEnabled
objNXWriter
.
DumpAllAttributesFromTango
(
"compression_enabled"
,
*
(
m_objAGIPD
->
attr_CompressionEnabled_read
),
false
);
//CompressionShuffle
objNXWriter
.
DumpAllAttributesFromTango
(
"compressor_shuffle"
,
*
(
m_objAGIPD
->
attr_CompressorShuffle_read
),
false
);
//CompressionRate
objNXWriter
.
DumpAllAttributesFromTango
(
"compression_rate"
,(
int
)(
*
(
m_objAGIPD
->
attr_CompressionRate_read
)),
""
,
false
);
//FileSplitEnabled
objNXWriter
.
DumpAllAttributesFromTango
(
"file_split_enabled"
,
*
(
m_objAGIPD
->
attr_FileSplitEnabled_read
),
false
);
//FileSizeLimit
objNXWriter
.
DumpAllAttributesFromTango
(
"file_size_limit"
,(
int
)(
*
(
m_objAGIPD
->
attr_FileSizeLimit_read
)),
"GigaBytes"
,
false
);
//ChukSize
objNXWriter
.
DumpAllAttributesFromTango
(
"chunk_size"
,(
int
)(
*
(
m_objAGIPD
->
attr_ChunkSize_read
)),
""
,
false
);
//TotalLossFrames
objNXWriter
.
DumpAllAttributesFromTango
(
"total_loss_frames"
,(
int
)(
*
(
m_objAGIPD
->
attr_TotalLossFrames_read
)),
""
,
false
);
}
}
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