1110 lines
36 KiB
C++
1110 lines
36 KiB
C++
#include "RadionuclideMessage.h"
|
||
#include <QFile>
|
||
#include <QTextStream>
|
||
#include <QDebug>
|
||
#include <sstream>
|
||
|
||
#define SECOND 1
|
||
#define HOUR 3600
|
||
#define DAY (12*HOUR)
|
||
#define YEAR (365*DAY)
|
||
|
||
using namespace RadionuclideData;
|
||
|
||
RadionuclideMessage::RadionuclideMessage()
|
||
{
|
||
bIsValid = false;
|
||
analyse_data_type = InvalidData;
|
||
InitBlockFlagInfo();
|
||
}
|
||
|
||
RadionuclideMessage::~RadionuclideMessage()
|
||
{
|
||
}
|
||
|
||
const QVariant RadionuclideMessage::GetBlockData(QString& block_name)
|
||
{
|
||
if ( radionuclide_msg_data.contains(block_name) )
|
||
{
|
||
return radionuclide_msg_data[block_name];
|
||
}
|
||
return QVariant();
|
||
}
|
||
|
||
void RadionuclideMessage::ClearData()
|
||
{
|
||
bIsValid = false;
|
||
radionuclide_msg_data.clear();
|
||
AbstractSpectrumDataMessage::ClearData();
|
||
}
|
||
|
||
QVector<long> RadionuclideMessage::GetHistogramProjectedDataValue(
|
||
HistogramBlock &histogram, Qt::Orientation orientation)
|
||
{
|
||
QVector<long> projected_data_value;
|
||
QVector<long long> &counts = histogram.counts;
|
||
if (Qt::Vertical == orientation)
|
||
{
|
||
for (int i=0; i<histogram.g_channels; ++i)
|
||
{
|
||
long i_count = 0;
|
||
for (int j=0; j<histogram.b_channels; ++j)
|
||
{
|
||
i_count += counts[i*histogram.b_channels + j];
|
||
}
|
||
projected_data_value.append(i_count);
|
||
}
|
||
}
|
||
else if (Qt::Horizontal == orientation)
|
||
{
|
||
for (int j=0; j<histogram.b_channels; ++j)
|
||
{
|
||
long j_count = 0;
|
||
for (int i=0; i<histogram.g_channels; ++i)
|
||
{
|
||
j_count += counts[i*histogram.b_channels + j];
|
||
}
|
||
projected_data_value.append(j_count);
|
||
}
|
||
}
|
||
return projected_data_value;
|
||
}
|
||
|
||
|
||
bool RadionuclideMessage::AnalysePHD_Msg(QString &msg_string)
|
||
{
|
||
return AbstractSpectrumDataMessage::AnalyseMsg(msg_string);
|
||
}
|
||
|
||
bool RadionuclideMessage::AnalysePHD_File(QString phd_name)
|
||
{
|
||
return AbstractSpectrumDataMessage::AnalyseFile(phd_name);
|
||
}
|
||
|
||
bool RadionuclideMessage::IsValid()
|
||
{
|
||
return bIsValid;
|
||
}
|
||
|
||
AnalyseDataType RadionuclideMessage::GetAnalyseDataType()
|
||
{
|
||
return analyse_data_type;
|
||
}
|
||
|
||
void RadionuclideMessage::InitBlockFlagInfo()
|
||
{
|
||
block_flag.append(QLatin1String("#Header")); // [ 0 ]
|
||
block_flag.append(QLatin1String("#Comment")); // [ 1 ]
|
||
block_flag.append(QLatin1String("#Collection")); // [ 2 ]
|
||
block_flag.append(QLatin1String("#Acquisition")); // [ 3 ]
|
||
block_flag.append(QLatin1String("#Processing")); // [ 4 ]
|
||
block_flag.append(QLatin1String("#Sample")); // [ 5 ]
|
||
block_flag.append(QLatin1String("#g_Energy")); // [ 6 ]
|
||
block_flag.append(QLatin1String("#b_Energy")); // [ 7 ]
|
||
block_flag.append(QLatin1String("#g_Resolution")); // [ 8 ]
|
||
block_flag.append(QLatin1String("#b_Resolution")); // [ 9 ]
|
||
block_flag.append(QLatin1String("#g_Efficiency")); // [ 10 ]
|
||
block_flag.append(QLatin1String("#ROI_Limits")); // [ 11 ]
|
||
block_flag.append(QLatin1String("#b-gEfficiency")); // [ 12 ]
|
||
block_flag.append(QLatin1String("#TotalEff")); // [ 13 ]
|
||
block_flag.append(QLatin1String("#Ratios")); // [ 14 ]
|
||
block_flag.append(QLatin1String("#g_Spectrum")); // [ 15 ]
|
||
block_flag.append(QLatin1String("#b_Spectrum")); // [ 16 ]
|
||
block_flag.append(QLatin1String("#Histogram")); // [ 17 ]
|
||
block_flag.append(QLatin1String("#Calibration")); // [ 18 ]
|
||
block_flag.append(QLatin1String("#Certificate")); // [ 19 ]
|
||
block_flag.append(QLatin1String("STOP")); // [ STOP ]
|
||
block_flag.append(QLatin1String("BEGIN")); // [ BEGIN ]
|
||
block_flag.append(QLatin1String("#Spectrum")); // [ 22 ]
|
||
block_flag.append(QLatin1String("#GPS")); // [ 23 ]
|
||
block_flag.append(QLatin1String("#b_self_Attenuation")); // [ 24 ]
|
||
block_flag.append(QLatin1String("#b_Efficiency")); // [ 25 ]
|
||
}
|
||
|
||
bool RadionuclideMessage::AnalyseMessgeBody(QTextStream &content)
|
||
{
|
||
const MessageInfo& msg = AbstractSpectrumDataMessage::GetMessageInfo();
|
||
if ( QLatin1String("SAMPLEPHD") != msg.data_type &&
|
||
QLatin1String("SPHDF") != msg.data_type &&
|
||
QLatin1String("SPHDP") != msg.data_type &&
|
||
QLatin1String("GASBKPHD") != msg.data_type &&
|
||
QLatin1String("BLANKPHD") != msg.data_type &&
|
||
QLatin1String("DETBKPHD") != msg.data_type &&
|
||
QLatin1String("QCPHD") != msg.data_type &&
|
||
QLatin1String("CALIBPHD") != msg.data_type )
|
||
{
|
||
return bIsValid = false;
|
||
}
|
||
radionuclide_msg_data.insert(block_flag.at(21), QVariant::fromValue(msg));
|
||
bool bRet = true;
|
||
QString line = content.readLine();
|
||
do {
|
||
if ( 0==line.left(7).compare(block_flag.at(0)) && bRet)
|
||
{
|
||
bRet &= Analyse_Header_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(1)) && bRet)
|
||
{
|
||
bRet &= Analyse_Comment_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(2)) && bRet)
|
||
{
|
||
bRet &= Analyse_Collection_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(3)) && bRet)
|
||
{
|
||
bRet &= Analyse_Acquisition_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(4)) && bRet)
|
||
{
|
||
bRet &= Analyse_Processing_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(5)) && bRet)
|
||
{
|
||
bRet &= Analyse_Sample_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(6)) && bRet)
|
||
{
|
||
bRet &= Analyse_g_Energy_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(7)) && bRet)
|
||
{
|
||
bRet &= Analyse_b_Energy_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(8)) && bRet)
|
||
{
|
||
bRet &= Analyse_g_Resolution_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(9)) && bRet)
|
||
{
|
||
bRet &= Analyse_b_Resolution_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(10)) && bRet)
|
||
{
|
||
bRet &= Analyse_g_Efficiency_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(11)) && bRet)
|
||
{
|
||
bRet &= Analyse_ROI_Limits_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(12)) && bRet)
|
||
{
|
||
bRet &= Analyse_bg_Efficiency_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(13)) && bRet)
|
||
{
|
||
bRet &= Analyse_TotalEff_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(14)) && bRet)
|
||
{
|
||
bRet &= Analyse_Ratios_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(15)) && bRet )
|
||
{
|
||
bRet &= Analyse_g_Spectrum_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(22)) && bRet )
|
||
{
|
||
bRet &= Analyse_g_Spectrum_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(16)) && bRet)
|
||
{
|
||
bRet &= Analyse_b_Spectrum_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(17)) && bRet)
|
||
{
|
||
bRet &= Analyse_Histogram_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(18)) && bRet)
|
||
{
|
||
bRet &= Analyse_Calibration_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(19)) && bRet)
|
||
{
|
||
bRet &= Analyse_Certificate_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(23)) && bRet)
|
||
{
|
||
bRet &= Analyse_Gps_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(24)) && bRet)
|
||
{
|
||
bRet &= Analyse_b_self_Attenuation_Block(content, line);
|
||
}
|
||
else if ( 0==line.compare(block_flag.at(25)) && bRet)
|
||
{
|
||
bRet &= Analyse_b_Efficiency_Block(content, line);
|
||
}
|
||
else
|
||
{ // 数据错误,数据有效
|
||
bIsValid = false;
|
||
radionuclide_msg_data.clear();
|
||
bRet = bIsValid;
|
||
break;
|
||
}
|
||
|
||
QString temp_line = line.simplified();
|
||
if (0==temp_line.compare(block_flag.at(20)) && bRet )
|
||
{
|
||
bIsValid = true; //检测到“STOP line”,消息完整,数据有效
|
||
break;
|
||
}
|
||
else if (content.atEnd() || !bRet)
|
||
{
|
||
bIsValid = false;
|
||
radionuclide_msg_data.clear();
|
||
bRet = bIsValid;
|
||
break;
|
||
}
|
||
}
|
||
while( bRet );
|
||
|
||
return bRet;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Header_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
HeaderBlock Header;
|
||
QString &line = nextBlock;
|
||
Header.designator = line.mid(8);
|
||
content >> Header.site_code >> Header.detector_code >> Header.system_type >> Header.sample_geometry >> Header.spectrum_quantity;
|
||
content >> Header.sample_ref_id;
|
||
content.readLine();
|
||
|
||
m_system_type = Header.system_type;
|
||
const MessageInfo& msg = AbstractSpectrumDataMessage::GetMessageInfo();
|
||
if ( msg.verify_srid )
|
||
{
|
||
bool bRet = Verity_SampleReferenceId( Header.sample_ref_id );
|
||
if (!bRet) return bRet;
|
||
}
|
||
if (QString("P") == Header.system_type || QString("G") == Header.system_type)
|
||
{
|
||
analyse_data_type = GammaAnalyseData;
|
||
}
|
||
else if (QString("B") == Header.system_type)
|
||
{
|
||
analyse_data_type = BetaGammaAnalyseData;
|
||
}
|
||
QString temp_line = content.readLine();
|
||
QStringList temp_str_list;
|
||
QTextStream temp_line_stream(&temp_line);
|
||
for (;!temp_line_stream.atEnd();)
|
||
{
|
||
QString temp;
|
||
temp_line_stream >> temp;
|
||
temp_str_list.append(temp);
|
||
}
|
||
|
||
for (int i=0, j = 0; i<temp_str_list.count(); ++i)
|
||
{
|
||
QString str_item = temp_str_list.at(i);
|
||
if ( str_item==QString("0") || str_item.isEmpty() )
|
||
{
|
||
// pass
|
||
}
|
||
else if ( temp_str_list.at(i).count()<26 )
|
||
{
|
||
str_item += " " + temp_str_list.at(i+1);
|
||
++i;
|
||
}
|
||
|
||
if (0==j)
|
||
{
|
||
Header.measurement_id = str_item;
|
||
}
|
||
else if (1==j)
|
||
{
|
||
Header.detector_bk_measurement_id = str_item;
|
||
}
|
||
else if (2==j)
|
||
{
|
||
Header.gas_bk_measurement_id = str_item;
|
||
}
|
||
++j;
|
||
}
|
||
|
||
content >> Header.transmit_date >> Header.transmit_time;
|
||
radionuclide_msg_data.insert(block_flag.at(0), QVariant::fromValue(Header));
|
||
|
||
content >> nextBlock;
|
||
content.readLine(); //该处的读取行内容操作仅将文件光标移至下一行开头
|
||
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Comment_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
CommentBlock comment;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while ( !block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
if ( !nextBlock.isEmpty() )
|
||
{
|
||
comment.append(nextBlock + QLatin1String("\n"));
|
||
}
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
}
|
||
radionuclide_msg_data.insert(block_flag.at(1), QVariant::fromValue(comment));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Collection_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
CollectionBlock Collection;
|
||
content >> Collection.collection_start_date >> Collection.collection_start_time >> Collection.collection_stop_date \
|
||
>> Collection.collection_stop_time >> Collection.air_volume;
|
||
radionuclide_msg_data.insert(block_flag.at(2), QVariant::fromValue(Collection));
|
||
|
||
content >> nextBlock;
|
||
//change add by caoanqi 2015-12-03
|
||
content.readLine();
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Acquisition_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
AcquisitionBlock Acquisition;
|
||
content >> Acquisition.acquisition_start_date >> Acquisition.acquisition_start_time \
|
||
>> Acquisition.acquisition_real_time >> Acquisition.acquisition_live_time;
|
||
radionuclide_msg_data.insert(block_flag.at(3), QVariant::fromValue(Acquisition));
|
||
|
||
content >> nextBlock;
|
||
content.readLine();
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Processing_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
ProcessingBlock Processing;
|
||
content >> Processing.sample_volume_of_Xe >> Processing.uncertainty_1;
|
||
content >> Processing.Xe_collection_yield >> Processing.uncertainty_2;
|
||
content >> Processing.archive_bottle_id;
|
||
radionuclide_msg_data.insert(block_flag.at(4), QVariant::fromValue(Processing));
|
||
|
||
content >> nextBlock;
|
||
content.readLine();
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Sample_Block(QTextStream &content, QString &nextBlock)
|
||
{
|
||
SampleBlock Sample;
|
||
content >> Sample.dimension_1 >> Sample.dimension_2;
|
||
radionuclide_msg_data.insert(block_flag.at(5), QVariant::fromValue(Sample));
|
||
|
||
content >> nextBlock;
|
||
content.readLine();
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_g_Energy_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
G_EnergyBlock g_Energy;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
double g_energy, centroid_channel, uncertainty;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> g_energy >> centroid_channel >> uncertainty;
|
||
|
||
g_Energy.g_energy << g_energy;
|
||
g_Energy.centroid_channel << centroid_channel;
|
||
g_Energy.uncertainty << uncertainty;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
g_Energy.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(6), QVariant::fromValue(g_Energy));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_b_Energy_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
B_EnergyBlock b_Energy;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
QString decay_mode;
|
||
double electron_energy, channel, uncertainty;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> electron_energy >> decay_mode >> channel >> uncertainty;
|
||
|
||
b_Energy.electron_energy << electron_energy;
|
||
b_Energy.decay_mode << decay_mode;
|
||
b_Energy.channel << channel;
|
||
b_Energy.uncertainty << uncertainty;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
b_Energy.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(7), QVariant::fromValue(b_Energy));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_g_Resolution_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
G_ResolutionBlock g_Resolution;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
double g_energy, FWHM, uncertainty;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> g_energy >> FWHM >> uncertainty;
|
||
|
||
g_Resolution.g_energy << g_energy;
|
||
g_Resolution.FWHM << FWHM;
|
||
g_Resolution.uncertainty << uncertainty;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
g_Resolution.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(8), QVariant::fromValue(g_Resolution));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_b_Resolution_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
B_ResolutionBlock b_Resolution;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
double electron_energy, FWHM, uncertainty;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> electron_energy >> FWHM >> uncertainty;
|
||
|
||
b_Resolution.electron_energy << electron_energy;
|
||
b_Resolution.FWHM << FWHM;
|
||
b_Resolution.uncertainty << uncertainty;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
b_Resolution.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(9), QVariant::fromValue(b_Resolution));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_g_Efficiency_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
if(m_system_type == 'C')
|
||
{
|
||
n_G_EfficiencyBlock g_eff;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
double g_energy, efficiency, uncertainty;
|
||
QString name;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> name >> g_energy >> efficiency >> uncertainty;
|
||
g_eff.dev_name.push_back(name);
|
||
g_eff.g_energy << g_energy;
|
||
g_eff.efficiency << efficiency;
|
||
g_eff.uncertainty << uncertainty;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
g_eff.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(10), QVariant::fromValue(g_eff));
|
||
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
G_EfficiencyBlock g_Efficiency;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
double g_energy, efficiency, uncertainty;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> g_energy >> efficiency >> uncertainty;
|
||
|
||
g_Efficiency.g_energy << g_energy;
|
||
g_Efficiency.efficiency << efficiency;
|
||
g_Efficiency.uncertainty << uncertainty;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
g_Efficiency.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(10), QVariant::fromValue(g_Efficiency));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_ROI_Limits_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
ROI_LimitsBlock ROI_Limits;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
QString ROI_number;
|
||
double POI_B_x1, POI_B_x2, POI_G_y1, POI_G_y2;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> ROI_number >> POI_B_x1 >> POI_B_x2 >> POI_G_y1 >> POI_G_y2;
|
||
|
||
ROI_Limits.ROI_number << ROI_number;
|
||
ROI_Limits.POI_B_x1 << POI_B_x1;
|
||
ROI_Limits.POI_B_x2 << POI_B_x2;
|
||
ROI_Limits.POI_G_y1 << POI_G_y1;
|
||
ROI_Limits.POI_G_y2 << POI_G_y2;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
ROI_Limits.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(11), QVariant::fromValue(ROI_Limits));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_bg_Efficiency_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
BG_EfficiencyBlock bg_Efficiency;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
QString nuclide_name, ROI_number;
|
||
double bg_efficiency, uncertainty;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> nuclide_name >> ROI_number >> bg_efficiency >> uncertainty;
|
||
|
||
bg_Efficiency.nuclide_name << nuclide_name;
|
||
bg_Efficiency.ROI_number << ROI_number;
|
||
bg_Efficiency.bg_efficiency << bg_efficiency;
|
||
bg_Efficiency.uncertainty << uncertainty;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
bg_Efficiency.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(12), QVariant::fromValue(bg_Efficiency));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_TotalEff_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
TotaleffBlock Totaleff;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
double g_energy, total_efficiency, uncertainty;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> g_energy >> total_efficiency >> uncertainty;
|
||
|
||
Totaleff.g_energy << g_energy;
|
||
Totaleff.total_efficiency << total_efficiency;
|
||
Totaleff.uncertainty << uncertainty;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
Totaleff.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(13), QVariant::fromValue(Totaleff));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Ratios_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
RatiosBlock Ratios;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
QString ratio_id, ROI_num_highter_G_energy_ROI, ROI_num_lower_G_energy_ROI;
|
||
double count_ratio, count_ratio_uncertainty;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> ratio_id >> ROI_num_highter_G_energy_ROI >> ROI_num_lower_G_energy_ROI \
|
||
>> count_ratio >> count_ratio_uncertainty;
|
||
|
||
Ratios.ratio_id << ratio_id;
|
||
Ratios.ROI_num_highter_G_energy_ROI << ROI_num_highter_G_energy_ROI;
|
||
Ratios.ROI_num_lower_G_energy_ROI << ROI_num_lower_G_energy_ROI;
|
||
Ratios.count_ratio << count_ratio;
|
||
Ratios.count_ratio_uncertainty << count_ratio_uncertainty;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
Ratios.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(14), QVariant::fromValue(Ratios));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_g_Spectrum_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
G_SpectrumBlock g_Spectrum;
|
||
content >> g_Spectrum.num_g_channel >> g_Spectrum.g_energy_span;
|
||
content.readLine();
|
||
|
||
bool beginFlag=true;
|
||
long temp=0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
QTextStream line_content(&nextBlock);
|
||
if(beginFlag)
|
||
{
|
||
line_content >> g_Spectrum.begin_channel;
|
||
beginFlag = false;
|
||
}
|
||
else
|
||
{
|
||
line_content >> temp;
|
||
}
|
||
for (; !line_content.atEnd();)
|
||
{
|
||
line_content >> temp;
|
||
if (line_content.status()==QTextStream::Ok)
|
||
{
|
||
g_Spectrum.counts << temp;
|
||
}
|
||
else if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
}
|
||
g_Spectrum.num_g_channel = g_Spectrum.counts.count();
|
||
|
||
#if 0
|
||
long temp=0;
|
||
long row_channel_span = g_Spectrum.num_g_channel / 5;
|
||
for (long row=0; row<row_channel_span; ++row)
|
||
{
|
||
content >> temp;
|
||
for (int column=0; column<5; ++column)
|
||
{
|
||
content >> temp;
|
||
g_Spectrum.counts << temp;
|
||
}
|
||
}
|
||
content >> temp;
|
||
long channel_remainder = g_Spectrum.num_g_channel % 5;
|
||
for (long i=0; i<channel_remainder; ++i)
|
||
{
|
||
content >> temp;
|
||
g_Spectrum.counts << temp;
|
||
}
|
||
content >> nextBlock;
|
||
content.readLine();
|
||
#endif
|
||
|
||
radionuclide_msg_data.insert(block_flag.at(15), QVariant::fromValue(g_Spectrum));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_b_Spectrum_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
B_SpectrumBlock b_Spectrum;
|
||
content >> b_Spectrum.num_b_channel >> b_Spectrum.b_energy_span;
|
||
content.readLine();
|
||
|
||
long temp=0;
|
||
bool beginFlag=true;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
QTextStream line_content(&nextBlock);
|
||
if(beginFlag)
|
||
{
|
||
line_content >> b_Spectrum.begin_channel;
|
||
beginFlag = false;
|
||
}
|
||
else
|
||
{
|
||
line_content >> temp;
|
||
}
|
||
for (; !line_content.atEnd();)
|
||
{
|
||
line_content >> temp;
|
||
if (line_content.status()==QTextStream::Ok)
|
||
{
|
||
b_Spectrum.counts << temp;
|
||
}
|
||
else if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
}
|
||
b_Spectrum.num_b_channel = b_Spectrum.counts.count();
|
||
|
||
#if 0
|
||
long temp;
|
||
long row_channel_span = b_Spectrum.num_b_channel / 5;
|
||
for (long row=0; row<row_channel_span; ++row)
|
||
{
|
||
content >> temp;
|
||
for (int column=0; column<5; ++column)
|
||
{
|
||
content >> temp;
|
||
b_Spectrum.counts << temp;
|
||
}
|
||
}
|
||
content >> temp;
|
||
long channel_remainder = b_Spectrum.num_b_channel % 5;
|
||
for (long i=0; i<channel_remainder; ++i)
|
||
{
|
||
content >> temp;
|
||
b_Spectrum.counts << temp;
|
||
}
|
||
content >> nextBlock;
|
||
content.readLine();
|
||
#endif
|
||
|
||
radionuclide_msg_data.insert(block_flag.at(16), QVariant::fromValue(b_Spectrum));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Histogram_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
HistogramBlock Histogram;
|
||
//change by cao 2015-12-3
|
||
// content >> Histogram.b_channels >> Histogram.g_channels >> Histogram.b_energy_span >> Histogram.g_energy_span;
|
||
content >> Histogram.b_channels >> Histogram.g_channels >> Histogram.g_energy_span >> Histogram.b_energy_span;
|
||
content.readLine();
|
||
|
||
long temp=0, row=0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
QTextStream line_content(&nextBlock);
|
||
for (; !line_content.atEnd();)
|
||
{
|
||
line_content >> temp;
|
||
if (line_content.status()==QTextStream::Ok)
|
||
{
|
||
Histogram.counts << temp;
|
||
}
|
||
else if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
++ row;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
}
|
||
Histogram.g_channels = row;
|
||
if(row == 0)
|
||
{
|
||
Histogram.b_channels = 0;
|
||
}
|
||
else
|
||
{
|
||
Histogram.b_channels = Histogram.counts.count()/row;
|
||
}
|
||
|
||
#if 0
|
||
long& row_size = Histogram.b_channels;
|
||
long& column_size = Histogram.g_channels;
|
||
for (long row=0; row<row_size; ++row)
|
||
{
|
||
for (long column=0; column<column_size; ++column)
|
||
{
|
||
long temp;
|
||
content >> temp;
|
||
Histogram.counts << temp;
|
||
}
|
||
}
|
||
|
||
content >> nextBlock;
|
||
content.readLine();
|
||
#endif
|
||
|
||
radionuclide_msg_data.insert(block_flag.at(17), QVariant::fromValue(Histogram));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Calibration_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
CalibrationBlock Calibration;
|
||
content >> Calibration.date_calibration >> Calibration.time_calibration;
|
||
radionuclide_msg_data.insert(block_flag.at(18), QVariant::fromValue(Calibration));
|
||
|
||
content >> nextBlock;
|
||
content.readLine();
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Certificate_Block(QTextStream& content, QString& nextBlock)
|
||
{
|
||
CertificateBlock Certificate;
|
||
|
||
QString temp_line = content.readLine();
|
||
QTextStream temp_line_stream(&temp_line);
|
||
temp_line_stream >> Certificate.total_source_activity >> Certificate.assay_date >> Certificate.assay_time >> Certificate.units_activity;
|
||
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
if (nextBlock.simplified().isEmpty())
|
||
{
|
||
nextBlock = content.readLine();
|
||
continue;
|
||
}
|
||
QString nuclide_name, half_life_time;
|
||
QString time_unit, electron_decay_mode;
|
||
double activity_nuclide_time_assay, uncertainty, g_energy, g_intensity, maximum_energy, intensity_b_particle;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> nuclide_name >> half_life_time >> time_unit >> activity_nuclide_time_assay \
|
||
>> uncertainty >> g_energy >> g_intensity >> electron_decay_mode \
|
||
>> maximum_energy >> intensity_b_particle ;
|
||
|
||
Certificate.nuclide_name << nuclide_name;
|
||
Certificate.half_life_time << half_life_time;
|
||
Certificate.time_unit << time_unit;
|
||
Certificate.activity_nuclide_time_assay << activity_nuclide_time_assay;
|
||
Certificate.uncertainty << uncertainty;
|
||
Certificate.g_energy << g_energy;
|
||
Certificate.g_intensity << g_intensity;
|
||
Certificate.electron_decay_mode << electron_decay_mode;
|
||
Certificate.maximum_energy << maximum_energy;
|
||
Certificate.intensity_b_particle << intensity_b_particle;
|
||
|
||
/* 时间转换办法,暂时使用, 将来启用时,需修改“CertificateBlock”结构
|
||
if (time_unit == QLatin1String("Y"))
|
||
{
|
||
float time = half_life_time.toFloat();
|
||
Certificate.half_life_time << qulonglong(time*YEAR);
|
||
}
|
||
else if (time_unit == QLatin1String("D"))
|
||
{
|
||
float time = half_life_time.toFloat();
|
||
Certificate.half_life_time << qulonglong(time*DAY);
|
||
}
|
||
else if (time_unit == QLatin1String("H"))
|
||
{
|
||
float time = half_life_time.toFloat();
|
||
Certificate.half_life_time << qulonglong(time*HOUR);
|
||
}
|
||
else if (time_unit == QLatin1String("S"))
|
||
{
|
||
Certificate.half_life_time << half_life_time.toULongLong();;
|
||
}
|
||
*/
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
Certificate.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(19), QVariant::fromValue(Certificate));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_Gps_Block(QTextStream &content, QString &nextBlock)
|
||
{
|
||
GpsBlock gps;
|
||
content >> gps.lon >> gps.lat;
|
||
radionuclide_msg_data.insert(block_flag.at(23), QVariant::fromValue(gps));
|
||
|
||
content >> nextBlock;
|
||
content.readLine();
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_b_self_Attenuation_Block(QTextStream &content, QString &nextBlock)
|
||
{
|
||
BSelfAttenuationBlock bsel;
|
||
|
||
QString buffer;
|
||
|
||
buffer = content.readLine();
|
||
while(buffer.at(0) != '#')
|
||
{
|
||
std::stringstream ss(buffer.toStdString());
|
||
std::string name;
|
||
std::array<double, 3> data1, data2;
|
||
ss >> name;
|
||
for(int i = 0; i < 3; i++)
|
||
{
|
||
ss >> data1[i];
|
||
}
|
||
|
||
for(int i = 0; i < 3; i++)
|
||
{
|
||
ss >> data2[i];
|
||
}
|
||
bsel.devNames.push_back(QString::fromStdString(name));
|
||
bsel.xenon.push_back(data1);
|
||
bsel.nitrogen.push_back(data2);
|
||
|
||
buffer = content.readLine();
|
||
};
|
||
|
||
radionuclide_msg_data.insert(block_flag.at(24), QVariant::fromValue(bsel));
|
||
|
||
nextBlock = buffer;
|
||
// content.readLine();
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Analyse_b_Efficiency_Block(QTextStream &content, QString &nextBlock)
|
||
{
|
||
NBG_EfficiencyBlock bg_Efficiency;
|
||
int row_count = 0;
|
||
nextBlock = content.readLine();
|
||
QString temp_line = nextBlock.simplified();
|
||
while (!block_flag.contains(temp_line) && !content.atEnd())
|
||
{
|
||
QString nuclide_name;
|
||
double bg_efficiency, uncertainty;
|
||
QTextStream line_content(&nextBlock);
|
||
line_content >> nuclide_name >> bg_efficiency >> uncertainty;
|
||
|
||
bg_Efficiency.nuclide_name << nuclide_name;
|
||
bg_Efficiency.bg_efficiency << bg_efficiency;
|
||
bg_Efficiency.uncertainty << uncertainty;
|
||
|
||
++ row_count;
|
||
nextBlock = content.readLine();
|
||
temp_line = nextBlock.simplified();
|
||
|
||
if (line_content.status()==QTextStream::ReadCorruptData)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
bg_Efficiency.record_count = row_count;
|
||
radionuclide_msg_data.insert(block_flag.at(25), QVariant::fromValue(bg_Efficiency));
|
||
return (content.status()==QTextStream::Ok)?true:false;
|
||
}
|
||
|
||
bool RadionuclideMessage::Verity_SampleReferenceId(QString srid)
|
||
{
|
||
bool bRet = true;
|
||
int srid_len = srid.length();
|
||
if ( 14==srid_len || 15==srid_len )
|
||
{
|
||
if ( QLatin1String("00G")==srid.right(3) ||
|
||
QLatin1String("00X")==srid.right(3) ) //GASBKPHD
|
||
{
|
||
AbstractSpectrumDataMessage::SetMsgDataType( QLatin1String("GASBKPHD") );
|
||
}
|
||
else if ( QLatin1String("00000000")==srid.mid(2,8) ) //BLANKPHD
|
||
{
|
||
AbstractSpectrumDataMessage::SetMsgDataType( QLatin1String("BLANKPHD") );
|
||
}
|
||
else if ( QLatin1String("11111111")==srid.mid(2,8) ) //DETBKPHD
|
||
{
|
||
AbstractSpectrumDataMessage::SetMsgDataType( QLatin1String("DETBKPHD") );
|
||
}
|
||
else if ( QLatin1String("77777777")==srid.mid(2,8) ) //Special IMS Samples
|
||
{
|
||
AbstractSpectrumDataMessage::SetMsgDataType( QLatin1String("SAMPLEPHD") );
|
||
}
|
||
else if ( QLatin1String("88888888")==srid.mid(2,8) ) //QCPHD
|
||
{
|
||
AbstractSpectrumDataMessage::SetMsgDataType( QLatin1String("QCPHD") );
|
||
}
|
||
else if ( QLatin1String("99999999")==srid.mid(2,8) ) //CALIBPHD
|
||
{
|
||
AbstractSpectrumDataMessage::SetMsgDataType( QLatin1String("CALIBPHD") );
|
||
}
|
||
else //SAMPLEPHD
|
||
{
|
||
AbstractSpectrumDataMessage::SetMsgDataType( QLatin1String("SAMPLEPHD") );
|
||
}
|
||
}
|
||
else
|
||
{
|
||
bRet &= false;
|
||
}
|
||
return bRet;
|
||
}
|