Initial commit on main branch

This commit is contained in:
wanglong 2024-06-04 15:27:02 +08:00
commit 2434b2a176
39 changed files with 11594 additions and 0 deletions

View File

@ -0,0 +1,330 @@
#include "AbstractSpectrumDataMessage.h"
#include <QFile>
AbstractSpectrumDataMessage::AbstractSpectrumDataMessage()
{
msg_items.append( "MSG_TYPE" ); // [0]
msg_items.append( "MSG_ID" ); // [1]
msg_items.append( "REF_ID" ); // [2]
msg_items.append( "PROD_ID" ); // [3]
msg_items.append( "DATA_TYPE" ); // [4]
data_types.append( "SAMPLEPHD" ); // [0]
data_types.append( "SPHDF" ); // [1]
data_types.append( "SPHDP" ); // [2]
data_types.append( "GASBKPHD" ); // [3]
data_types.append( "BLANKPHD" ); // [4]
data_types.append( "DETBKPHD" ); // [5]
data_types.append( "QCPHD" ); // [6]
data_types.append( "CALIBPHD" ); // [7]
data_types.append( "MET" ); // [8]
data_types.append( "RMSSOH" ); // [9]
data_types.append( "ALERT_FLOW" ); // [10]
data_types.append( "ALERT_SYSTEM" ); // [11]
data_types.append( "ALERT_TEMP" ); // [12]
data_types.append( "ALERT_UPS" ); // [13]
msg.verify_srid = false;
}
AbstractSpectrumDataMessage::~AbstractSpectrumDataMessage()
{
}
QString AbstractSpectrumDataMessage::GetSpectrumDataTypeFromFile(QString data_file)
{
QString ret_string;
QFile file(data_file);
if ( file.open(QIODevice::ReadOnly | QIODevice::Text) )
{
QTextStream content(&file);
if (!content.atEnd())
{
if ( AnalyseMessgeInfo(content, true) )
{
ret_string = msg.data_type;
if ( QLatin1String("SPHDP")==ret_string || QLatin1String("SPHDF")==ret_string )
{
ret_string = QLatin1String("SAMPLEPHD");
msg.data_type = ret_string;
}
}
}
}
file.close();
return ret_string;
}
QString AbstractSpectrumDataMessage::GetSpectrumDataTypeFromMessage(QString data_msg)
{
QString ret_string;
QTextStream content(&data_msg, QIODevice::ReadOnly);
if (!content.atEnd())
{
if ( AnalyseMessgeInfo(content, true) )
{
ret_string = msg.msg_type;
if ( QLatin1String("SPHDP")==ret_string && QLatin1String("SPHDF")==ret_string )
{
ret_string = QLatin1String("SAMPLEPHD");
}
}
}
return ret_string;
}
bool AbstractSpectrumDataMessage::AnalyseFile(QString file_name)
{
bool bRet = true;
QFile file(file_name);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
return bRet &= false;
}
QTextStream content(&file);
if (content.atEnd())
{
file.close();
return bRet &= false;
}
bRet &= AnalyseMessgeInfo(content);
/*
if (bRet)
{
bRet &= AnalyseMessgeBody(content);
}
*/
file.close();
/*
if ( bRet && msg.verify_srid )
{
ChangeOriginalFile(file_name);
}
*/
return bRet;
}
bool AbstractSpectrumDataMessage::AnalyseMsg(QString &msg_string)
{
bool bRet = true;
QTextStream content(&msg_string, QIODevice::ReadOnly);
if (content.atEnd())
{
return bRet &= false;
}
bRet &= AnalyseMessgeInfo(content);
/*
if (bRet)
{
bRet &= AnalyseMessgeBody(content);
}
*/
return bRet;
}
const MessageInfo &AbstractSpectrumDataMessage::GetMessageInfo()
{
return msg;
}
void AbstractSpectrumDataMessage::ClearData()
{
msg.data_type.clear();
msg.msg_id.clear();
msg.msg_type.clear();
msg.verify_srid = false;
}
bool AbstractSpectrumDataMessage::AnalyseMessgeInfo(QTextStream &content, bool only_analyse_msg)
{
bool bRet = true;
QString item_text = content.readLine();
if ( 0!=item_text.left(5).compare(QLatin1String("BEGIN")) &&
0!=item_text.mid(6).compare(QLatin1String("IMS2.0")) )
{
bRet &= false; //消息头的协议标示不对,消息无效
return bRet;
}
QString line = content.readLine();
while (bRet)
{
QTextStream line_stream(&line);
line_stream >> item_text;
if ( 0==item_text.compare(msg_items.at(0)) && bRet ) //MSG_TYPE
{
line_stream >> msg.msg_type;
if ( msg.msg_type!=(QLatin1String("DATA")) )
{
bRet &= false; //消息类型不是指定的“DATA”类型消息过滤
break;
}
line = content.readLine();
}
else if ( 0==item_text.compare(msg_items.at(1)) && bRet ) //MSG_ID
{
for (int i=0; !line_stream.atEnd(); ++i)
{
if ( 0==i )
{
line_stream >> msg.msg_id;
}
else if (1==i)
{
line_stream >> msg.msg_src_code;
}
}
line = content.readLine();
}
else if ( 0==item_text.compare(msg_items.at(2)) && bRet ) //REF_ID
{
QString ref_id_after = line_stream.readLine();
QTextStream ref_id_after_stream(&ref_id_after);
for (int i=0; !ref_id_after_stream.atEnd(); ++i)
{
QString temp;
ref_id_after_stream >> temp;
if (0==i)
{
msg.ref_id_str = temp;
}
else if (1==i)
{
msg.ref_src_code = temp;
}
else if (2==i)
{
msg.seq_num = temp;
}
else if (3==i)
{
msg.tot_num = temp;
}
}
msg.verify_srid = true;
line = content.readLine();
}
else if ( 0==item_text.compare(msg_items.at(3)) && bRet ) //PROD_ID
{
line_stream >> msg.product_id >> msg.delivery_id;
msg.verify_srid = true;
line = content.readLine();
}
else if ( 0==item_text.compare(msg_items.at(4)) && bRet ) //DATA_TYPE
{
line_stream >> msg.data_type;
if ( data_types.contains(msg.data_type) && bRet )
{
if ( !only_analyse_msg )
{
bRet &= AnalyseMessgeBody(content);
}
return bRet;
}
else
{
line = content.readLine();
QTextStream data_line_stream(&line);
data_line_stream >> item_text;
while (!msg_items.contains(item_text) && !content.atEnd())
{
line = content.readLine();
QTextStream line_stream(&line);
line_stream >> item_text;
}
msg.verify_srid = true;
}
}
else
{
//bRet = false;
// bRet不置为false表示针对消息头的有效检查持宽容态度允许跟文件协议有能接受的出入
break;
}
if ( content.atEnd() || (content.status()!=QTextStream::Ok) )
{
bRet = false;
ClearData();
break;
}
}
return bRet;
}
void AbstractSpectrumDataMessage::SetMsgDataType(QString data_type)
{
msg.data_type = data_type;
}
void AbstractSpectrumDataMessage::ChangeOriginalFile(QString file_name)
{
QFile file(file_name);
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QString temp_file_name = file_name + QLatin1String(".temp");
QFile temp_file(temp_file_name);
if (!temp_file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QString error = file.errorString();
return;
}
QTextStream in(&file);
QTextStream out(&temp_file);
bool bInBody = true;
QString line = in.readLine();
while ( !in.atEnd() && (in.status()==QTextStream::Ok) )
{
QString item_text;
QTextStream line_stream(&line);
line_stream >> item_text;
if ( 0==item_text.compare(msg_items.at(4)) && bInBody ) //DATA_TYPE
{
QString data_type;
line_stream >> data_type;
if ( data_types.contains(data_type) && bInBody )
{
bInBody = false;
}
else
{
line = in.readLine();
QTextStream data_line_stream(&line);
data_line_stream >> item_text;
while (!msg_items.contains(item_text) && !in.atEnd())
{
line = in.readLine();
QTextStream line_stream(&line);
line_stream >> item_text;
}
}
}
else if ( 0==item_text.compare(msg_items.at(2)) && bInBody ) //REF_ID
{
line = in.readLine();
}
else if ( 0==item_text.compare(msg_items.at(3)) && bInBody ) //PROD_ID
{
line = in.readLine();
}
else
{
out << line << "\n";
line = in.readLine();
}
}
temp_file.close();
file.close();
QFile::remove(file_name);
QFile::rename(temp_file_name, file_name);
}
}

View File

@ -0,0 +1,35 @@
#ifndef ABSTRACTSPECTRUMDATAMESSAGE_H
#define ABSTRACTSPECTRUMDATAMESSAGE_H
#include "DataManager_Define.h"
#include <QTextStream>
#include <QVariantMap>
class AbstractSpectrumDataMessage
{
public:
explicit AbstractSpectrumDataMessage();
~AbstractSpectrumDataMessage();
QString GetSpectrumDataTypeFromFile(QString data_file);
QString GetSpectrumDataTypeFromMessage(QString data_msg);
bool AnalyseFile(QString file_name);
bool AnalyseMsg(QString &msg_string);
virtual bool IsValid(){return false;}
virtual const MessageInfo& GetMessageInfo();
virtual void ClearData();
protected:
virtual bool AnalyseMessgeInfo(QTextStream& content, bool only_analyse_msg=false);
virtual bool AnalyseMessgeBody(QTextStream& content){ Q_UNUSED(content);return false;}
void SetMsgDataType(QString data_type);
void ChangeOriginalFile(QString file_name);
private:
MessageInfo msg;
QStringList msg_items;
QStringList data_types;
};
#endif // ABSTRACTSPECTRUMDATAMESSAGE_H

86
AlertMessage.cpp Normal file
View File

@ -0,0 +1,86 @@
#include "AlertMessage.h"
#include <QFile>
using namespace AlertData;
AlertMessage::AlertMessage()
{
}
AlertMessage::~AlertMessage()
{
}
bool AlertMessage::IsValid()
{
return bIsValid;
}
const AlertsInfo& AlertMessage::GetAlertsInfo()
{
return alerts_info;
}
void AlertMessage::ClearData()
{
bIsValid = false;
alerts_info.station_code.clear();
alerts_info.alert_type.clear();
alerts_info.date.clear();
alerts_info.time.clear();
alerts_info.desc.clear();
AbstractSpectrumDataMessage::ClearData();
}
bool AlertMessage::AnalyseMessgeBody(QTextStream &content)
{
const MessageInfo& msg = AbstractSpectrumDataMessage::GetMessageInfo();
if ( QLatin1String("ALERT_FLOW") != msg.data_type &&
QLatin1String("ALERT_SYSTEM") != msg.data_type &&
QLatin1String("ALERT_TEMP") != msg.data_type &&
QLatin1String("ALERT_UPS") != msg.data_type )
{
return bIsValid = false;
}
content >> alerts_info.station_code >> alerts_info.alert_type >> alerts_info.date >> alerts_info.time;
do
{
QString line = content.readLine();
if ( 0==line.compare(QLatin1String("STOP")) )
{
bIsValid = true; //检测到“STOP line”消息完整数据有效
break;
}
else if (content.atEnd())
{
bIsValid = false;
alerts_info.alert_type.clear();
alerts_info.date.clear();
alerts_info.desc.clear();
alerts_info.station_code.clear();
alerts_info.time.clear();
break;
}
else
{
// QString desc_row = QLatin1String("\n") + line;
QString desc_row;
if(alerts_info.desc.isEmpty())
{
desc_row = line;
}
else
{
desc_row = QLatin1String("\n") + line;
}
alerts_info.desc.append(desc_row);
}
}
while( !content.atEnd() );
return bIsValid;
}

26
AlertMessage.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef ALERTMESSAGE_H
#define ALERTMESSAGE_H
#include "AbstractSpectrumDataMessage.h"
#include "DataManager_Define.h"
#include <QTextStream>
class AlertMessage : public AbstractSpectrumDataMessage
{
public:
explicit AlertMessage();
~AlertMessage();
virtual bool IsValid();
const AlertData::AlertsInfo& GetAlertsInfo();
virtual void ClearData();
private:
bool AnalyseMessgeBody(QTextStream& content);
private:
bool bIsValid;
AlertData::AlertsInfo alerts_info;
};
#endif // ALERTMESSAGE_H

1528
BgWork.cpp Normal file

File diff suppressed because it is too large Load Diff

126
BgWork.h Normal file
View File

@ -0,0 +1,126 @@
#ifndef PACKAGING_H
#define PACKAGING_H
////////////////////////////////////////////////////////////////////////
// 类说明此类为b_g谱业务逻辑
//
// 注意事项1、ExtractSROIcts 用到2次拟合算法 请注意
//
////////////////////////////////////////////////////////////////////////
#include <QVector>
#include <QString>
#include "BgWorkDef.h"
class CBgWork
{
public:
CBgWork();
CBgWork(BgFileI& _fileHanle);
~CBgWork();
//log拆分而来错误日志
static QString BgAnlyseError(const BgErrorType& _error);
void SetBgFile(BgFileI& _fileHanle);
/////////////////////////////////////////////////////////////////////
// 函数说明:重新设置要分析的文件名
// _fileHanle
// 返回值void
//////////////////////////////////////////////////////////////////////
void RenameAnalyseFile(BgFileI& _fileHanle);
/////////////////////////////////////////////////////////////////////
// 函数说明:界面交互分析
// 函数参数b_e_calb能刻度计数方程系数
// g_e_cal: g能刻度计数方程系数
// 返回值void
//////////////////////////////////////////////////////////////////////
bool MutialAnalyse(BgCalibratePara& _BgCalPara);
////////////////////////////////////////////////////////////////////
// 函数说明:自动分析
// 函数参数void
// 返回值void
//////////////////////////////////////////////////////////////////////
bool AutoAnalyse();
/////////////////////////////////////////////////////////////////////
// 函数说明GetAllValue 获取所有分析结果
// 函数参数void
// 返回值: 分析的所有结构 详解请看结构
//////////////////////////////////////////////////////////////////////
BgAllGenerate GetAllValue();
/////////////////////////////////////////////////////////////////////
// 函数说明GetUIValue 获取与界面相关的结果
// 函数参数void
// 返回值: 分析的所有结构 详解请看结构
//////////////////////////////////////////////////////////////////////
BgUINeed GetUIValue();
/////////////////////////////////////////////////////////////////////
// 函数说明GetLastError 返回计算标示
// 函数参数void
// 返回值: 分析的所有结构 详解请看结构
//////////////////////////////////////////////////////////////////////
BgErrorType GetLastError();
BgSample GetSampleUseData();
BgGas GetGasUseData();
BgDetbgr GetDetbgrUseData();
/////////////////////////////////////////////////////////////////////
// 函数说明CaculateXeActivity 计算符合外推 核素活动值
// 函数参数: _watch_x:拟合观察点x; _watch_y拟合观察点y;_lamadaXe:Xe参数;_acqRealTime:生存时间;,QVector<double> &_fittingPara:拟合系数返回_fittingType:拟合方式
// 返回值: 分析的所有结构 详解请看结构
//////////////////////////////////////////////////////////////////////
static double CaculateXeActivity(QVector<double>&_watch_x,QVector<double>&_watch_y,const double& _lamadaXe,const double& _acqRealTime,QVector<double> &_fittingPara,int _fittingType=_default);
static bool GetFittingPara(QVector<double>& _watch_x,QVector<double> &_watch_y,FitType _fittype,QVector<double> &_fittingPara);
static bool GetFittingData(QVector<double>& _watch,FitType _fittype,QVector<double> &_fittingPara,QVector<int> &_rData);
static bool GetFittingData(QVector<double>& _watch,FitType _fittype,QVector<double> &_fittingPara,QVector<double> &_rData);
static bool GetFileFittingPara(QVector<double>& _watch_x,QVector<double> &_watch_y,QVector<double> &_fittingPara);
static bool GetFileFittingData(QVector<double>& _watch,QVector<double> &_fittingPara,QVector<int> &_rData);
static bool GetFileFittingData(QVector<double>& _watch,QVector<double> &_fittingPara,QVector<double> &_rData);
static QString GetFittingDescriptionByType(int _type);
static QString GetFittingEquation(int _type);
// 根据不同的拟合方法计算边界值, 默认2次拟合 可以继承书写新的拟合
virtual bool CalcBgBoundary(BgROILimit& _roi_limit,BgEC& _b_g_e_c,BgCalibratePara& _BgCalPara,BgBoundary& _output);
protected:
// 根据不同的拟合方法计算边界值, 默认2次拟合 可以继承书写新的拟合
virtual bool CalcBgBoundary(BgROILimit& _roi_limit,BgEC& _b_g_e_c,BgCalibratePara& _BgCalPara,BgBoundary& _output,BgFittingPara& _fittingPara);
private:
//初始化
bool SetPara(BgFileI& _fileHanle);
//处理流程
bool Analyse();
//获取样品谱感兴趣区计数
bool ExtractSROIcts();
//获取气体本底谱感兴趣区计数
bool ExtractGROIcts();
//获取探测器本底谱感兴趣区计数
bool ExtractDROIcts();
//样品谱扣除探测器本底谱计数
bool SDetuctDcts();
//气体本底谱扣除探测器本底谱计数
bool GDetuctDcts();
//获取净计数
bool ExtractNetCounts();
//日期差值计算
double SubtractTime(QString _begin,QString _end);
//计算感兴趣区浓度和不确定度
bool CalcRoiConUncer();
//计算同位素浓度和不确定度
bool CalcXeConUncer();
//MDC计算
bool MDC();
//所需数据
BgSample m_sampleData; //样品谱数据
BgGas m_gasData; //气体本底谱数据
BgDetbgr m_detbgrData; //探测器本地谱数据
BgAllGenerate m_allGenerate;
BgUINeed m_uiNeed;
BgSampleGenerate m_sampleGenerate; //样品谱生成数据
BgGasGenerate m_gasGenerate; //气体本底谱生成数据
BgDetbgrGenerate m_detbgrGenerate; //探测器本地谱生成数据
BgOtherGenerate m_otherGenerate; //生成的其他数据
const static double cst_fixed_volXe;
const static double cst_defvolXe; // Value substituted when Xe volume read as below 0.1 ml - warning issued.
static bool m_initAlgorithm;
BgCalibratePara m_bgCalPara;
BgFileI m_file;
bool m_flag_read_file;
BgErrorType m_lastError;
};
#endif

407
BgWorkDef.h Normal file
View File

@ -0,0 +1,407 @@
#ifndef B_G_WORK_DEFINE_H
#define B_G_WORK_DEFINE_H
#include "ProcessAlgorithmGlobalVar.h"
#include "RadionuclideMessage.h"
//错误类型结构
enum BgErrorType{
E_NONE //默认没有错误
,E_FILE_CONTEXT_SAMPLE_Acquisition //文件读取错误
,E_FILE_CONTEXT_SAMPLE_Collection //
,E_FILE_CONTEXT_SAMPLE_Ratios //
,E_FILE_CONTEXT_SAMPLE_g_Energy //
,E_FILE_CONTEXT_SAMPLE_b_Energy //
,E_FILE_CONTEXT_SAMPLE_ROI_Limits //
,E_FILE_CONTEXT_SAMPLE_bgEfficiency //
,E_FILE_CONTEXT_SAMPLE_Processing //
,E_FILE_CONTEXT_SAMPLE_Histogram //
,E_FILE_CONTEXT_GAS_Acquisition //
,E_FILE_CONTEXT_GAS_g_Energy //
,E_FILE_CONTEXT_GAS_b_Energy //
,E_FILE_CONTEXT_GAS_ROI_Limits //
,E_FILE_CONTEXT_GAS_Histogram //
,E_FILE_CONTEXT_GAS_Ratios //
,E_FILE_CONTEXT_DETA_Histogram //
,E_FILE_CONTEXT_DETA_Acquisition //
,E_FILE_CONTEXT_DETA_g_Energy //
,E_FILE_CONTEXT_DETA_b_Energy //
,E_FILE_CONTEXT_DETA_ROI_Limits //
,E_SAMPLE_ROI_CTS //样品谱感兴趣区计数错误
,E_GAS_ROI_CTS //气体本底谱感兴趣区计数错误
,E_DETA_ROI_CTS //探测器本体谱感兴趣区计数错误
,E_S_DETUCT_D_CTS //样品普扣除探测器本底谱计数错误
,E_G_DETUCT_D_CTS //气体本底谱扣除探测器本底谱计数错误
,E_NET_COUNTS //获取净计数错误
,E_ROI_CON_UNCER //获取感兴趣浓度和不平衡度错误
,E_XE_CON_UNCER //获取同位素浓度和不确定度错误
,E_MDC //MDC计算错误
};
//处理后数据结构
//文件传入参数
typedef struct tagBgFileI
{
RadionuclideMessage sample;
RadionuclideMessage gas;
RadionuclideMessage Detbgr;
}*pBgFileI,BgFileI;
//边界值
typedef struct tagBgBoundary
{
QVector<int> ROI_B_Boundary_start;
QVector<int> ROI_B_Boundary_stop;
QVector<int> ROI_G_Boundary_start;
QVector<int> ROI_G_Boundary_stop;
}*pBgBoundary,BgBoundary;
//MDC参数结构
typedef struct tagBgMDCPara
{
double MDC_Xe135; //MDC XE135
double MDC_Xe131m; //MDC XE131m
double MDC_Xe133m; //MDC XE133m
double MDC_Xe133; //MDC XE133
QVector<double> MDC;
QVector<double> MDC_CTS;
}*pBgMDCPara,BgMDCPara;
//LC参数结构
typedef struct tagBgLCPara
{
double LC_Xe135; //LC XE135
double LC_Xe131m; //LC XE131m
double LC_Xe133m; //LC XE133m
double LC_Xe133; //LC XE133
QVector<double> LC;
QVector<double> LC_CTS;
}*pBgLCPara,BgLCPara;
typedef struct tagBgXeConUncer
{
double Xe135_con; //135不浓度
double Xe135_uncer; //135不确定度
double Xe131m_con;
double Xe131m_uncer;
double Xe133m_con;
double Xe133m_uncer;
double Xe133_con;
double Xe133_uncer;
}*pBgXeConUncer,BgXeConUncer;
//其他数据
typedef struct tagBgOtherGenerate
{
QVector<double> ROI_net_coutns; //感兴趣区净计数
QVector<double> ROI_net_err;
QVector<double> ROI_con_uncer; //感兴趣区浓度和不确定度 [n..0]浓度 [n..1]不确定度
QVector<double> ROI_con_counts_factor; //感兴趣区浓度计数系数 [n..0]系数
global::XeType XeType;
BgLCPara LCPara;
BgMDCPara MDCPara;
BgXeConUncer XeConUncer;
}*pBgOtherGenerate,BgOtherGenerate;
//能道拟合处理后的数据
//交互处理参数
enum FitType{_default,liner,poly2,poly3,gauss};
typedef struct tagBgFittingHandleData
{
int b_fitting_type;
int g_fitting_type;
QVector<double> b_fitting_para;
QVector<double> g_fitting_para;
tagBgFittingHandleData()
{
b_fitting_type=poly2;
g_fitting_type=poly2;
}
}*pBgFittingHandleData,BgFittingHandleData;
typedef struct tagBgFittingPara
{
int b_fitting_type;
int g_fitting_type;
QVector<double> b_fitting_e_c;
QVector<double> g_fitting_e_c;
QVector<double> b_fitting_c_e;
QVector<double> g_fitting_c_e;
tagBgFittingPara()
{
b_fitting_type=poly2;
g_fitting_type=poly2;
}
}*pBgFittingPara,BgFittingPara;
//样品谱生成数据
typedef struct tagBgSmapleGenerate
{
BgBoundary s_boungdary;
QVector<double> s_roi_cts; //样品普感兴趣区计数
QVector<double> s_deduct_d_cts; //样品谱扣除探测器本底谱数据
BgFittingPara s_fittingPara; // 拟合后值
QString s_collection_time; //采集时间
}*pBgSampleGenerate,BgSampleGenerate;
//气体本地谱生成数据
typedef struct tagBgGasGenerate
{
BgBoundary g_boungdary;
QVector<double> g_roi_cts; //气体本底谱感兴趣区计数
QVector<double> g_deduct_d_cts; //气体本底谱扣除探测器本底谱数据
BgFittingPara g_fittingPara; // 拟合后值
}*pBgGasGenerate,BgGasGenerate;
//探测器本地谱生成数据
typedef struct tagBgDetbgrGenerate
{
BgBoundary d_boungdary;
QVector<double> d_roi_cts; //探测器本底谱感兴趣区计数
BgFittingPara d_fittingPara; // 拟合后值
}*pBgDetbgrGenerate,BgDetbgrGenerate;
//返回所有数据
typedef struct tagBgAllGenerate
{
BgGasGenerate BgGas;
BgSampleGenerate BgSample;
BgOtherGenerate BgOther;
BgDetbgrGenerate BgDetbgr;
bool bProcessed;
tagBgAllGenerate()
{
bProcessed = false;
}
}*pBgAllGenerate,BgAllGenerate;
//UI界面需要数据
typedef struct tagBgUINeed
{
BgMDCPara MDCPara;
BgXeConUncer XeConUncer;
// BgFittingHandleData fittingData;
}*pBgUINeed,BgUINeed;
//需处理数据结构
typedef struct tagBgCalibratePara
{
QVector<double> b_e_cal; //b 能刻度系数
QVector<double> g_e_cal; //g 能刻度系数
int b_e_cal_flag; //b 自计算刻度系数配置
int g_e_cal_flag; //g 自计算刻度系数配置
bool bApplyNewCalicSample; // 界面交互新刻度应用
bool bApplyNewCalicDetBg;
bool bApplyNewCalicGasBg;
bool bApplyNewCalicQc;
tagBgCalibratePara()
{
b_e_cal_flag = poly2;
g_e_cal_flag = poly2;
bApplyNewCalicSample = false;
bApplyNewCalicDetBg = false;
bApplyNewCalicGasBg = false;
bApplyNewCalicQc = false;
}
}*pBgCalibratePara, BgCalibratePara;
//能道数据
typedef struct tagBgEnergyChannel
{
QVector<double> energy; // g_Energy:g_energy or b_Energy:electron_energy kev 能量
QVector<double> channel; // g_Energy:centroid_channel or b_Energy channel 道
QVector<double> uncertainty; //不确定度 未使用
QVector<QString> mode; //类型 未使用
int record_count; //记录条数 未使用
tagBgEnergyChannel()
{
record_count=0;
}
}*pBgEnergyChannel,BgEnergyChannel;
//b g 能 道
typedef struct tagBgEC
{
BgEnergyChannel b_e_c;//b_Energy block
BgEnergyChannel g_e_c;//g_Energy block
}*pBgEC,BgEC;
//感应区限值结构
typedef struct tagBgROILimit
{
QVector<double> ROI_B_start_x1;// ROI B-rang start,x1(keV)
QVector<double> ROI_B_stop_x2; // ROI B_rang stop,x2(kev)
QVector<double> ROI_G_start_y1;// ROI G-rang start,y1(keV)
QVector<double> ROI_G_stop_y2; // ROI G_rang stop,y2(kev)
}*pBgROILimit,BgROILimit;
typedef struct tagBgHistogram
{
long b_channels; // β-channels
long g_channels; // γ-channels
QVector<long long> counts; // counts at channels
}*pBgHistorgram,BgHistogram;
//样品符合谱所需数据
typedef struct tagBgROIRatios
{
QVector<QString> ratio_id;
QVector<QString> ROI_num_highter_G_energy_ROI;
QVector<QString> ROI_num_lower_G_energy_ROI;
QVector<double> count_ratio;
QVector<double> count_ratio_uncertainty;
}*pBgRoiRatios,BgRoiRatios;
typedef struct tagBgEfficiencies
{
QVector<QString> nuclide_name; // nuclide name
QVector<QString> ROI_number; // ROI number
QVector<double> bg_efficiency; // β-γ coincidence efficiency (counts in ROI/β-γ pair emitted)
QVector<double> uncertainty;
}*pBgBgEfficiencies,BgBgEfficiencies;
typedef struct tagBgSample
{
BgROILimit s_limit; //样品谱限值
QString s_data_type; //样品数据类型
QVector<double> s_count_ratio; //样品谱比率计数
QVector<double> s_bg_efficiency; //样品谱能效感应区个数
QString s_collection_start_date; //样品谱采集开始日期 格式yyyy/MM/dd
QString s_collection_start_time; //样品普采集结束时间 格式hh:mm:ss.z
QString s_collection_stop_time; //样品谱采集结束日期 格式yyyy/MM/dd
QString s_collection_stop_date; //样品普采集结束时间 格式hh:mm:ss.z
QString s_acquisition_start_date; //acquisition start date (yyyy/MM/dd)
QString s_acquisition_start_time; //acquisition start time (hh:mm:ss.z)
double s_acquisition_real_time; //acquisition real time (s)
double s_acquisition_live_time; //acquisition live time (s)
double s_volume_of_Xe; //sample volume of Xe (cm 3 )
double s_xe_stable_volume; //total air volume sampled (standard cubic meters [scm])
double s_uncertainty; //uncertainty (cm 3 )
BgHistogram s_histogram; //Histogram Block
BgEC s_e_c; //能道
BgRoiRatios s_roi_ratio;
BgBgEfficiencies s_bg_efficiency_show;
}*pBgSample,BgSample;
//气体本底谱所需数据
typedef struct tagBgGas
{
BgROILimit g_limit; //气体本底谱限值
QString g_data_type; //气体本底谱数据类型
QVector<double> g_count_ratio; //气体本底谱比率计数
QString g_acquisition_start_date; //acquisition start date (yyyy/MM/dd)
QString g_acquisition_start_time; //acquisition start time (hh:mm:ss.z)
double g_acquisition_real_time; //acquisition real time (s)
double g_acquisition_live_time; //acquisition live time (s)
BgHistogram g_histogram; //Histogram Block
BgEC g_e_c; //能道
}*pBgGas,BgGas;
//探测器本底谱所需数据
typedef struct tagBgDetbgr
{
BgROILimit d_limit; //探测器本底谱限值
QString d_data_type; //探测体本底谱数据类型
double s_acquisition_live_time; //acquisition live time (s)
double d_acquisition_real_time; //acquisition live time (s)
BgHistogram d_histogram; //Histogram Block
BgEC d_e_c; //能道
}*pBgDetbgr,BgDetbgr;
//整合结构java调用所需
typedef struct tagBgSGD
{
//sample
//样品谱限值
QVector<double> s_ROI_B_start_x1;// ROI B-rang start,x1(keV)
QVector<double> s_ROI_B_stop_x2; // ROI B_rang stop,x2(kev)
QVector<double> s_ROI_G_start_y1;// ROI G-rang start,y1(keV)
QVector<double> s_ROI_G_stop_y2; // ROI G_rang stop,y2(kev)
QString s_data_type; //样品数据类型
QVector<double> s_count_ratio; //样品谱比率计数
QVector<double> s_bg_efficiency; //样品谱能效感应区个数
QString s_collection_start_date; //样品谱采集开始日期 格式yyyy/MM/dd
QString s_collection_start_time; //样品普采集结束时间 格式hh:mm:ss.z
QString s_collection_stop_time; //样品谱采集结束日期 格式yyyy/MM/dd
QString s_collection_stop_date; //样品普采集结束时间 格式hh:mm:ss.z
QString s_acquisition_start_date; //acquisition start date (yyyy/MM/dd)
QString s_acquisition_start_time; //acquisition start time (hh:mm:ss.z)
double s_acquisition_real_time; //acquisition real time (s)
double s_acquisition_live_time; //acquisition live time (s)
double s_volume_of_Xe; //sample volume of Xe (cm 3 )
double s_xe_stable_volume; //total air volume sampled (standard cubic meters [scm])
double s_uncertainty; //uncertainty (cm 3 )
//Histogram Block
long s_b_channels; // β-channels
long s_g_channels; // γ-channels
QVector<long> s_counts; // counts at channels
//BgEC s_e_c; //能道
//BgEnergyChannel b_e_c;//b_Energy block
QVector<double> s_b_energy; // g_Energy:g_energy or b_Energy:electron_energy kev 能量
QVector<double> s_b_channel; // g_Energy:centroid_channel or b_Energy channel 道
QVector<double> s_b_uncertainty; //不确定度 未使用
QVector<QString> s_b_mode; //类型 未使用
int s_b_record_count; //记录条数 未使用
//BgEnergyChannel g_e_c;//g_Energy block
QVector<double> s_g_energy; // g_Energy:g_energy or b_Energy:electron_energy kev 能量
QVector<double> s_g_channel; // g_Energy:centroid_channel or b_Energy channel 道
QVector<double> s_g_uncertainty; //不确定度 未使用
QVector<QString> s_g_mode; //类型 未使用
int s_g_record_count; //记录条数 未使用
//BgRoiRatios s_roi_ratio;
QVector<QString> ratio_id;
QVector<QString> ROI_num_highter_G_energy_ROI;
QVector<QString> ROI_num_lower_G_energy_ROI;
QVector<double> count_ratio;
QVector<double> count_ratio_uncertainty;
//BgBgEfficiencies s_bg_efficiency_show;
QVector<QString> nuclide_name; // nuclide name
QVector<QString> ROI_number; // ROI number
QVector<double> bg_efficiency; // β-γ coincidence efficiency (counts in ROI/β-γ pair emitted)
QVector<double> uncertainty;
//gas
//BgROILimit g_limit; //气体本底谱限值
QVector<double> g_ROI_B_start_x1;// ROI B-rang start,x1(keV)
QVector<double> g_ROI_B_stop_x2; // ROI B_rang stop,x2(kev)
QVector<double> g_ROI_G_start_y1;// ROI G-rang start,y1(keV)
QVector<double> g_ROI_G_stop_y2; // ROI G_rang stop,y2(kev)
QString g_data_type; //气体本底谱数据类型
QVector<double> g_count_ratio; //气体本底谱比率计数
QString g_acquisition_start_date; //acquisition start date (yyyy/MM/dd)
QString g_acquisition_start_time; //acquisition start time (hh:mm:ss.z)
double g_acquisition_real_time; //acquisition real time (s)
double g_acquisition_live_time; //acquisition live time (s)
//BgHistogram g_histogram; //Histogram Block
long g_b_channels; // β-channels
long g_g_channels; // γ-channels
QVector<long> g_counts; // counts at channels
//BgEC g_e_c; //能道
//BgEnergyChannel b_e_c;//b_Energy block
QVector<double> g_b_energy; // g_Energy:g_energy or b_Energy:electron_energy kev 能量
QVector<double> g_b_channel; // g_Energy:centroid_channel or b_Energy channel 道
QVector<double> g_b_uncertainty; //不确定度 未使用
QVector<QString> g_b_mode; //类型 未使用
int g_b_record_count; //记录条数 未使用
//BgEnergyChannel g_e_c;//g_Energy block
QVector<double> g_g_energy; // g_Energy:g_energy or b_Energy:electron_energy kev 能量
QVector<double> g_g_channel; // g_Energy:centroid_channel or b_Energy channel 道
QVector<double> g_g_uncertainty; //不确定度 未使用
QVector<QString> g_g_mode; //类型 未使用
int g_g_record_count = 0; //记录条数 未使用
//Detbgr
//BgROILimit d_limit; //探测器本底谱限值
QVector<double> d_ROI_B_start_x1;// ROI B-rang start,x1(keV)
QVector<double> d_ROI_B_stop_x2; // ROI B_rang stop,x2(kev)
QVector<double> d_ROI_G_start_y1;// ROI G-rang start,y1(keV)
QVector<double> d_ROI_G_stop_y2; // ROI G_rang stop,y2(kev)
QString d_data_type; //探测体本底谱数据类型
double d_acquisition_live_time; //acquisition live time (s)
double d_acquisition_real_time; //acquisition live time (s)
//BgHistogram d_histogram; //Histogram Block
long d_b_channels; // β-channels
long d_g_channels; // γ-channels
QVector<long> d_counts; // counts at channels
//BgEC d_e_c; //能道
//BgEnergyChannel b_e_c;//b_Energy block
QVector<double> d_b_energy; // g_Energy:g_energy or b_Energy:electron_energy kev 能量
QVector<double> d_b_channel; // g_Energy:centroid_channel or b_Energy channel 道
QVector<double> d_b_uncertainty; //不确定度 未使用
QVector<QString> d_b_mode; //类型 未使用
int d_b_record_count; //记录条数 未使用
//BgEnergyChannel g_e_c;//g_Energy block
QVector<double> d_g_energy; // g_Energy:g_energy or b_Energy:electron_energy kev 能量
QVector<double> d_g_channel; // g_Energy:centroid_channel or b_Energy channel 道
QVector<double> d_g_uncertainty; //不确定度 未使用
QVector<QString> d_g_mode; //类型 未使用
int d_g_record_count; //记录条数 未使用
}*pBgSGD,BgSGD;
#endif

217
CplusToJava.cpp Normal file
View File

@ -0,0 +1,217 @@
#include "CplusToJava.h"
#include <QStringList>
jobjectArray CplusToJava::GetjobjectArray(JNIEnv* env, jclass jcls, jobject jstruct, std::string var)
{
// 获取成员变量var的值
jfieldID fieldIDlist = env->GetFieldID(jcls, var.c_str(), "Ljava/util/List;");
jobject listObject = env->GetObjectField(jstruct, fieldIDlist);
jclass listClass = env->FindClass("java/util/List");
jmethodID toArrayMethodID = env->GetMethodID(listClass, "toArray", "()[Ljava/lang/Object;");
jobjectArray listValue = (jobjectArray)env->CallObjectMethod(listObject, toArrayMethodID);
return listValue;
}
jobjectArray CplusToJava::QVectorD2jobjectArray(QVector<double> vec, JNIEnv* env)
{
jint arraySize = vec.size();
jclass doubleClass = env->FindClass("java/lang/Double");
jobjectArray array = env->NewObjectArray(arraySize, doubleClass, NULL);
jmethodID constructorID = env->GetMethodID(doubleClass, "<init>", "(D)V");
for (int i = 0; i < arraySize; i++) {
jobject doubleObject = env->NewObject(doubleClass, constructorID, vec[i]);
env->SetObjectArrayElement(array, i, doubleObject);
}
return array;
}
jobjectArray CplusToJava::QVectorQS2jobjectArray(QVector<QString> vec, JNIEnv* env)
{
jint arraySize = vec.size();
jclass stringClass = env->FindClass("java/lang/String");
jobjectArray array = env->NewObjectArray(arraySize, stringClass, NULL);
jmethodID constructorID = env->GetMethodID(stringClass, "<init>", "(Ljava/lang/String;)V");
for (int i = 0; i < arraySize; i++) {
jstring tempstr = env->NewStringUTF(vec[i].toStdString().c_str());
jobject stringObject = env->NewObject(stringClass, constructorID, tempstr);
env->SetObjectArrayElement(array, i, stringObject);
}
return array;
}
jobjectArray CplusToJava::QVectorL2jobjectArray(QVector<long> vec, JNIEnv* env)
{
jint arraySize = vec.size();
jclass longClass = env->FindClass("java/lang/Long");
jobjectArray array = env->NewObjectArray(arraySize, longClass, NULL);
jmethodID constructorID = env->GetMethodID(longClass, "<init>", "(J)V");
for (int i = 0; i < arraySize; i++) {
jobject longObject = env->NewObject(longClass, constructorID, vec[i]);
env->SetObjectArrayElement(array, i, longObject);
}
return array;
}
jobjectArray CplusToJava::QVectorLL2jobjectArray(QVector<long long> vec, JNIEnv* env)
{
jint arraySize = vec.size();
jclass longClass = env->FindClass("java/lang/Long");
jobjectArray array = env->NewObjectArray(arraySize, longClass, NULL);
jmethodID constructorID = env->GetMethodID(longClass, "<init>", "(J)V");
for (int i = 0; i < arraySize; i++) {
jobject longObject = env->NewObject(longClass, constructorID, vec[i]);
env->SetObjectArrayElement(array, i, longObject);
}
return array;
}
jobjectArray CplusToJava::QVectorI2jobjectArray(QVector<int> vec, JNIEnv* env)
{
jint arraySize = vec.size();
jclass intClass = env->FindClass("java/lang/Integer");
jobjectArray array = env->NewObjectArray(arraySize, intClass, NULL);
jmethodID constructorID = env->GetMethodID(intClass, "<init>", "(I)V");
for (int i = 0; i < arraySize; i++) {
jobject intObject = env->NewObject(intClass, constructorID, vec[i]);
env->SetObjectArrayElement(array, i, intObject);
}
return array;
}
jobjectArray CplusToJava::QVectorS2jobjectArray(QVector<short> vec, JNIEnv* env)
{
jint arraySize = vec.size();
jclass intClass = env->FindClass("java/lang/Short");
jobjectArray array = env->NewObjectArray(arraySize, intClass, NULL);
jmethodID constructorID = env->GetMethodID(intClass, "<init>", "(S)V");
for (int i = 0; i < arraySize; i++) {
jobject intObject = env->NewObject(intClass, constructorID, vec[i]);
env->SetObjectArrayElement(array, i, intObject);
}
return array;
}
jobject CplusToJava::Createjobject(JNIEnv* env, jint esize, jobjectArray array)
{
jobject arrayList = env->NewObject(env->FindClass("java/util/ArrayList"), env->GetMethodID(env->FindClass("java/util/ArrayList"), "<init>", "()V"));
jmethodID addMethodID = env->GetMethodID(env->FindClass("java/util/ArrayList"), "add", "(Ljava/lang/Object;)Z");
for (int i = 0; i < esize; i++) {
jobject element = env->GetObjectArrayElement(array, i);
env->CallBooleanMethod(arrayList, addMethodID, element);
}
return arrayList;
}
jobjectArray CplusToJava::jobject2jobjectArray(JNIEnv* env, jobject array)
{
jclass listClass = env->FindClass("java/util/List");
jmethodID toArrayMethodID = env->GetMethodID(listClass, "toArray", "()[Ljava/lang/Object;");
jobjectArray listValue = (jobjectArray)env->CallObjectMethod(array, toArrayMethodID);
return listValue;
}
QVector<double> CplusToJava::jobjectArray2QVectorD(JNIEnv* env, jobjectArray listValue)
{
// 处理数组元素
jsize arrayLen = env->GetArrayLength(listValue);
QVector<double> results;
for (int i = 0; i < arrayLen; i++) {
jobject element = env->GetObjectArrayElement(listValue, i);
jdouble value = env->CallDoubleMethod(element, env->GetMethodID(env->FindClass("java/lang/Double"), "doubleValue", "()D"));
results.push_back(value);
}
return results;
}
QString CplusToJava::jstring2QString(JNIEnv* env, jstring jstr)
{
const char* str = env->GetStringUTFChars(jstr, NULL);
std::string filename(str);
QString qstr = QString::fromStdString(filename);
// 释放字符串内存
env->ReleaseStringUTFChars(jstr, str);
return qstr;
}
QString CplusToJava::getStructString(JNIEnv* env,jclass jcls,jobject jstruct, const char* name)
{
jfieldID fieldIDname = env->GetFieldID(jcls, name, SIG_STRING);
jstring nameValue = (jstring)env->GetObjectField(jstruct, fieldIDname);
const char* aStr = env->GetStringUTFChars(nameValue, NULL);
QString result(aStr);
return result;
}
double CplusToJava::DoubleLimit(const QString& _data)
{
double rData = _data.toDouble();
QString first = _data;
QStringList lstTemp = _data.split('.');
if (lstTemp.size() > 1)
{
first = lstTemp.at(0);
// return rData;
}
if (first.size() > 3)
{
QString temp = QLatin1String("-");
for (int pos = 1; pos < first.size(); pos++)
{
temp.append('9');
}
if (temp == first)
{
return -999;
}
}
return rData;
}
double CplusToJava::DoubleLimit(const double& _data)
{
QString limit = QString::number(_data, 'f');
double rData = DoubleLimit(limit);
return rData;
}
QVector<QString> CplusToJava::DoubleLimit(QVector<QString>& data)
{
for (int pos = 0; pos < data.size(); pos++)
{
data[pos] = QString::number(DoubleLimit(data.at(pos)), 'f');
}
return data;
}
QVector<QString> CplusToJava::DoubleLimit(QVector<double> _data)
{
QVector<QString> rdata;
for (int pos = 0; pos < _data.size(); pos++)
{
rdata << QString::number(DoubleLimit(_data.at(pos)), 'f');
}
return rdata;
}
QString CplusToJava::GetSqlBy(const QVector<QString>& _data, bool bSFlag)
{
QString rData;
for (int pos = 0; pos < _data.size(); pos++)
{
if (bSFlag)
{
rData += QLatin1String("'");
rData += _data.at(pos);
rData += QLatin1String("'");
}
else
{
rData += _data.at(pos);
}
if (pos != _data.size() - 1)
{
rData += QLatin1String(",");
}
}
return rData;
}

388
CplusToJava.h Normal file
View File

@ -0,0 +1,388 @@
#pragma once
#include "jni.h"
#include <QVector>
//变量名与java中sig对应
#define SIG_STRING "Ljava/lang/String;"
#define SIG_LIST "Ljava/util/List;"
#define SIG_DOUBLE "D"
#define SIG_INT "I"
#define SIG_LONG "J"
#define SIG_SHORT "S"
#define SIG_BOOL "Z"
enum BindType { BIND_NONE, BIND_STRING, BIND_CHAR, BIND_DOUBLE, BIND_INT };
typedef struct _Read_Result_
{
/* Infomations */
jstring msg_type;
jstring msg_id;
jstring data_type;
/* Header Black */
jstring designator; // designator
jstring site_code; // site code
jstring detector_code; // detector code
jstring system_type; // system type: P for particulate; B for gas with 3-D β - γ coincidence detection; and
// G for all other gas systems (high-resolu-tion γ-spectrometry or 2-D β-γ coinci-dence detection)
jstring sample_geometry; // sample geometry
jstring spectrum_quantity; // spectrum qualifier: preliminary ( PREL )or full ( FULL)
jstring sample_ref_id; // sample reference identification
jstring measurement_id; // measurement identification
jstring detector_bk_measurement_id; // detector background measurement identification
jstring gas_bk_measurement_id; // gas background measurement identification (memory effect)
jstring transmit_date; // transmit date (yyyy / mm / dd)
jstring transmit_time; // transmit time (hh : mm : ss . s)
/* Comment Block */
jstring comment;
/* Sample Block */
jdouble dimension_1;
jdouble dimension_2;
/* Acquisition Block */
jstring acquisition_start_date; // acquisition start date (yyyy / mm / dd)
jstring acquisition_start_time; // acquisition start time (hh : mm : ss . s)
jdouble acquisition_real_time; // acquisition real time (s)
jdouble acquisition_live_time; // acquisition live time (s)
/* Collection Block */
jstring collection_start_date; // collection start date (yyyy / mm / dd)
jstring collection_start_time; // collection start time (hh : mm : ss . s)
jstring collection_stop_date; // collection stop date (yyyy / mm / dd)
jstring collection_stop_time; // collection stop time (hh : mm : ss . s)
jdouble air_volume; // total air volume sampled (standard cubic meters [scm])
/* Processing Block */
jdouble sample_volume_of_Xe; // sample volume of Xe (cm 3 )
jdouble uncertainty_1; // uncertainty (cm 3 )
jdouble Xe_collection_yield; // Xe collection yield (Xe gas in sample/total Xe gas sampled)
jdouble uncertainty_2; // uncertainty (Xe gas in sample/total Xe gas sampled)
jstring archive_bottle_id; // archive bottle identification
/* Calibration Block */
jstring date_calibration; // date of last calibration (yyyy / mm / dd)
jstring time_calibration; // time of last calibration (hh : mm : ss)
/* g_Energy Block */
jobjectArray g_energy; // γ -energy (keV)
jobjectArray g_centroid_channel; // centroid channel
jobjectArray g_uncertainty; // uncertainty (channels)
jint g_record_count;
/* b_Energy Block */
jobjectArray b_electron_energy; // electron energy (keV)
jobjectArray b_decay_mode; // decay mode descriptor: B for β-particle, C for conversion electron (CE)
jobjectArray b_channel; // maximum channel of β-particle distribution or centroid channel of CE (channels)
jobjectArray b_uncertainty; // uncertainty (channels)
jint b_record_count;
/* g_Resolution Block */
jobjectArray g_r_energy; // γ -energy (keV)
jobjectArray g_r_FWHM; // FWHM (keV)
jobjectArray g_r_uncertainty; // uncertainty (keV)
jint g_r_record_count;
/* b_Resolution Block */
jobjectArray b_r_electron_energy; // electron energy (keV)
jobjectArray b_r_FWHM; // FWHM (keV)
jobjectArray b_r_uncertainty; // uncertainty (keV)
jint b_r_record_count;
/* g_Efficiency Block */
jobjectArray g_e_energy; // γ -energy (keV)
jobjectArray g_e_efficiency; // efficiency (counts in peak/photon emitted)
jobjectArray g_e_uncertainty; // uncertainty (counts in peak/photon emitted)
jint g_e_record_count;
/* ROI_Limits Block */
jobjectArray ROI_number; // ROI number
jobjectArray POI_B_x1; // 2-D ROI β-range start, x 1 (keV)
jobjectArray POI_B_x2; // 2-D ROI β-range stop, x 2 (keV)
jobjectArray POI_G_y1; // 2-D ROI γ-range start, y 1 (keV)
jobjectArray POI_G_y2; // 2-D ROI γ-range stop, y 2 (keV)
jint roi_record_count;
/* b-gEfficiency Block */
jobjectArray bg_nuclide_name; // nuclide name
jobjectArray bg_ROI_number; // ROI number
jobjectArray bg_efficiency; // β-γ coincidence efficiency (counts in ROI/β-γ pair emitted)
jobjectArray bg_uncertainty; // uncertainty (counts in ROI/β-γ pair emitted)
jint bg_record_count;
/* Ratios Block */
jobjectArray ratio_id; // ratio identifier
jobjectArray ROI_num_highter_G_energy_ROI; // ROI number for the higher γ -energy ROI
jobjectArray ROI_num_lower_G_energy_ROI; // ROI number for the lower γ -energy ROI
jobjectArray count_ratio; // Q_DECLARE_METATYPE(RMSSOHData::HeaderBlock)count ratio(counts in higher γ -energy ROI/counts in lower γ -energy ROI)
jobjectArray count_ratio_uncertainty; // count ratio uncertainty (percent)
jint ratio_record_count;
/* g_Spectrum Block */
jlong num_g_channel; // number of γ channels
jlong g_energy_span; // γ-energy span (keV)
jlong g_begin_channel; // begin of channels
jobjectArray g_counts; // count at channel
/* b_Spectrum Block */
jlong num_b_channel; // number of β -channels
jlong b_energy_span; // β -energy span (keV)
jlong b_begin_channel; // begin of channels
jobjectArray b_counts; // counts at channels
/* Histogram Block */
jlong b_channels; // β-channels
jlong g_channels; // γ-channels
jlong b_h_energy_span; // β-energy span
jlong g_h_energy_span; // γ-energy span
jobjectArray h_counts; // counts at channels
/* Certificate Block */
jdouble total_source_activity = 0; // total source activity (Bq)
jstring assay_date; // assay date (yyyy / mm / dd)
jstring assay_time; // assay time (hh : mm : ss)
jstring units_activity; // units of activity: “B,” “b” for Bq or “[blank]”; if nothing, then “B” is assigned
jobjectArray nuclide_name; // nuclide name
jobjectArray half_life_time; // half-life in seconds, hours, days, or years
jobjectArray time_unit; // time unit(Y, D, H, S)
jobjectArray activity_nuclide_time_assay; // activity of nuclide at time of assay
jobjectArray uncertainty; // uncertainty (%)
jobjectArray cer_g_energy; // γ-energy (keV)
jobjectArray g_intensity; // γ-intensity (percent)
jobjectArray electron_decay_mode; // electron decay mode descriptor: B for β particle or C for conversion electron (CE), 0 for none (that is, γ-only source)
jobjectArray maximum_energy; // maximum β-particle energy or CE energy (keV)
jobjectArray intensity_b_particle; // intensity of β-particle (percent)
jint record_count = 0;
/* Totaleff Block */
jobjectArray t_g_energy; // γ-energy (keV)
jobjectArray total_efficiency; // total efficiency (counts/photon emitted)
jobjectArray t_uncertainty; // uncertainty (counts/photon emitted)
jint t_record_count;
}ReadResult;
typedef struct _Generate_Result_
{
//BgGasGenerate BgGas;
jobjectArray g_ROI_B_Boundary_start;
jobjectArray g_ROI_B_Boundary_stop;
jobjectArray g_ROI_G_Boundary_start;
jobjectArray g_ROI_G_Boundary_stop;
jobjectArray g_roi_cts; //气体本底谱感兴趣区计数
jobjectArray g_deduct_d_cts; //气体本底谱扣除探测器本底谱数据
jint g_b_fitting_type;
jint g_g_fitting_type;
jobjectArray g_b_fitting_e_c;
jobjectArray g_g_fitting_e_c;
jobjectArray g_b_fitting_c_e;
jobjectArray g_g_fitting_c_e;
//BgSampleGenerate BgSample;
//BgBoundary s_boungdary;
jobjectArray s_ROI_B_Boundary_start;
jobjectArray s_ROI_B_Boundary_stop;
jobjectArray s_ROI_G_Boundary_start;
jobjectArray s_ROI_G_Boundary_stop;
jobjectArray s_roi_cts; //样品普感兴趣区计数
jobjectArray s_deduct_d_cts; //样品谱扣除探测器本底谱数据
jint s_b_fitting_type;
jint s_g_fitting_type;
jobjectArray s_b_fitting_e_c;
jobjectArray s_g_fitting_e_c;
jobjectArray s_b_fitting_c_e;
jobjectArray s_g_fitting_c_e;
jstring s_collection_time; //采集时间
//BgOtherGenerate BgOther;
jobjectArray ROI_net_coutns; //感兴趣区净计数
jobjectArray ROI_net_err;
jobjectArray ROI_con_uncer; //感兴趣区浓度和不确定度 [n..0]浓度 [n..1]不确定度
jobjectArray ROI_con_counts_factor; //感兴趣区浓度计数系数 [n..0]系数
//enum XeType{both,_131m,_133m,none};
jstring XeType;
jdouble LC_Xe135; //LC XE135
jdouble LC_Xe131m; //LC XE131m
jdouble LC_Xe133m; //LC XE133m
jdouble LC_Xe133; //LC XE133
jobjectArray LC;
jobjectArray LC_CTS;
jdouble MDC_Xe135; //MDC XE135
jdouble MDC_Xe131m; //MDC XE131m
jdouble MDC_Xe133m; //MDC XE133m
jdouble MDC_Xe133; //MDC XE133
jobjectArray MDC;
jobjectArray MDC_CTS;
jdouble Xe135_con; //135不浓度
jdouble Xe135_uncer; //135不确定度
jdouble Xe131m_con;
jdouble Xe131m_uncer;
jdouble Xe133m_con;
jdouble Xe133m_uncer;
jdouble Xe133_con;
jdouble Xe133_uncer;
jobjectArray ROI_B_Boundary_start;
jobjectArray ROI_B_Boundary_stop;
jobjectArray ROI_G_Boundary_start;
jobjectArray ROI_G_Boundary_stop;
jobjectArray d_roi_cts; //探测器本底谱感兴趣区计数
// 拟合后值
jint b_fitting_type;
jint g_fitting_type;
jobjectArray b_fitting_e_c;
jobjectArray g_fitting_e_c;
jobjectArray b_fitting_c_e;
jobjectArray g_fitting_c_e;
//BgDetbgrGenerate BgDetbgr;
jobjectArray d_ROI_B_Boundary_start;
jobjectArray d_ROI_B_Boundary_stop;
jobjectArray d_ROI_G_Boundary_start;
jobjectArray d_ROI_G_Boundary_stop;
jobjectArray d_d_roi_cts; //探测器本底谱感兴趣区计数
jint d_b_fitting_type;
jint d_g_fitting_type;
jobjectArray d_b_fitting_e_c;
jobjectArray d_g_fitting_e_c;
jobjectArray d_b_fitting_c_e;
jobjectArray d_g_fitting_c_e;
}GenerateResult;
typedef struct _SOHFile_Result_
{
/* Header block */
jstring station_code; // station code
jstring detector_code; // detector code or NA if 1) there is more than one detector or 2) data are from the sam-pling site of a split station
jstring start_date; // SOH data sampling period start date (yyyy/mm/dd)
jstring start_time; // SOH data sampling period start time (hh:mm:ss)
jstring designator; // designator
jstring end_date; // SOH data sampling period end date (yyyy/mm/dd)
jstring end_time; // SOH data sampling period end time (hh:mm:ss)
jstring transmit_date; // transmit date (yyyy/mm/dd)
jstring transmit_time; // transmit time (hh:mm:ss)
/* Air Sampler Flow block */
jobjectArray average_flow_rate; // average flow rate (standard cubic metersper hour (scm/h))
jobjectArray flow_rate_standard_deviation; // flow rate standard deviation (scm/h)
jobjectArray af_start_date; // SOH data sampling interval start date (yyyy/mm/dd)
jobjectArray af_start_time; // SOH data sampling interval start time (hh:mm:ss)
jobjectArray af_interval_duration; // SOH data sampling interval duration (s)
jint af_record_count;
/* Air Sampler Env block */
jobjectArray temperature; // average air temperature after filter (°C)
jobjectArray pressure; // average static air pressure after filter (hPa)
jobjectArray ae_date; // date (yyyy/mm/dd)
jobjectArray ae_time; // time (hh:mm:ss)
jobjectArray ae_interval_duration; // SOH data sampling interval duration (s)
jint ae_record_count;
/* Det Env block */
jobjectArray room_temperature; // average room temperature (°C)
jobjectArray detector_shield_status; // detector shield status (OPEN or CLOSED)
jobjectArray humidity; // average room humidity (in percent relative humidity)
jobjectArray d_voltage; // detector high voltage (V)
jobjectArray crystal_temperature; // average crystal temperature (°C)
jobjectArray electric_cooler_status; // electric cooler status (ON or OFF)
jobjectArray fill_fraction; // liquid nitrogen fill-fraction
jobjectArray leakage; // detector leakage current (nanoamperes [nA])
jobjectArray d_date; // date (yyyy/mm/dd)
jobjectArray d_time; // time (hh:mm:ss)
jobjectArray d_interval_duration; // SOH data sampling interval duration (s)
jint d_record_count;
/* NIMBIN block */
jobjectArray flag; // +/-
jobjectArray n_voltage; // average NIMBIN voltage (V)
jobjectArray n_date; // date (yyyy/mm/dd)
jobjectArray n_time; // time (hh:mm:ss)
jobjectArray n_interval_duration; // SOH data sampling interval duration (s)
jint n_record_count;
/* Power Supply block */
jobjectArray MAIN; // MAIN (for MAIN power supply)
jobjectArray main_power_status; // status of main power supply (ON/OFF)
jobjectArray AUX; // AUX (for AUXiliary power supply)
jobjectArray aux_power_status; // status of auxiliary power supply (ON/OFF)
jobjectArray UPS; // UPS (for Uninterrupted Power Supply)
jobjectArray ups_status; // status of uninterruptedly power supply (ON/ OFF)
jobjectArray p_date; // date (yyyy/mm/dd)
jobjectArray p_time; // time (hh:mm:ss)
jobjectArray p_interval_duration; // SOH data sampling interval duration (s)
jint p_record_count;
/* Equip Status block */
jobjectArray C_value; // status of sampling system (ON/OFF) or the SRID of the sample being collected
jobjectArray P_value; // status of sample preparation, processing, or decay (ON/OFF) or the SRID of the sample being processed or decayed
jobjectArray A_value; // status of detector system (ON/OFF) or the SRID of the sample being counted
jobjectArray e_date; // date (yyyy/mm/dd)
jobjectArray e_time; // time (hh:mm:ss)
jobjectArray e_interval_duration; // SOH data sampling interval duration (s)
jint e_record_count;
/* Tamper Env block */
jobjectArray tamper_sensor_name; // tamper sensor name
jobjectArray tamper_sensor_status; // tamper sensor status (OPEN or CLOSED)
jobjectArray t_date; // date (yyyy/mm/dd)
jobjectArray t_time; // time (hh:mm:ss)
jobjectArray t_interval_duration; // SOH data sampling interval duration (s)
jint t_record_count;
/* Process Sensors block */
jobjectArray sensor_type; // sensor type (TEMP, PRESSURE,PROCESSFLOW, VOLTAGE, COUN-TRATES, DEWPOINT, CO2VOLUME)
jobjectArray sensor_name; // tamper sensor status (OPEN or CLOSED)
jobjectArray sensor_reading; // sensor reading (TEMP in °C, PRESSURE in Pa, PROCESSFLOW in m3/h, VOLT-AGE in V, COUNTRATE in counts/s, DEWPOINT in °C, CO2VOLUME in cm3)
jobjectArray ps_date; // date (yyyy/mm/dd)
jobjectArray ps_time; // time (hh:mm:ss)
jobjectArray ps_duration; // SOH duration (s)
jint ps_record_count;
/* Chromatogram block */
jstring srid; // the SRID of the sample being counted
jobjectArray interval_number; // interval number (starts at 1)
jobjectArray interval_start_channel; // interval start channel
jobjectArray c_duration; // duration between chromatogram readings (in seconds [s])
jint interval_record_count;
jlong total_number; // total number of chromatogram readings
jobjectArray detector_response; // detector response
}SOHFileResult;
class CplusToJava
{
public:
static jobjectArray GetjobjectArray(JNIEnv* env, jclass jcls, jobject jstruct, std::string var);
//将QVector<double>转换为jobjectArray
static jobjectArray QVectorD2jobjectArray(QVector<double> vec, JNIEnv* env);
//将QVector<QString>转换为jobjectArray
static jobjectArray QVectorQS2jobjectArray(QVector<QString> vec, JNIEnv* env);
//将QVector<long>转换为jobjectArray
static jobjectArray QVectorL2jobjectArray(QVector<long> vec, JNIEnv* env);
//将QVector<long>转换为jobjectArray
static jobjectArray QVectorLL2jobjectArray(QVector<long long> vec, JNIEnv* env);
//将QVector<int>转换为jobjectArray
static jobjectArray QVectorI2jobjectArray(QVector<int> vec, JNIEnv* env);
//将QVector<short>转换为jobjectArray
static jobjectArray QVectorS2jobjectArray(QVector<short> vec, JNIEnv* env);
//生成jobject
static jobject Createjobject(JNIEnv* env, jint esize, jobjectArray array);
//jobject转换为jobjectArray
static jobjectArray jobject2jobjectArray(JNIEnv* env, jobject array);
//将jobjectArray转换为QVector<double>
static QVector<double> jobjectArray2QVectorD(JNIEnv* env, jobjectArray listValue);
//将jstring转换为QString
static QString jstring2QString(JNIEnv* env, jstring jstr);
//结构体获取
static QString getStructString(JNIEnv* env, jclass jcls, jobject jstruct, const char* name);
//-999判断
static double DoubleLimit(const double& _data);
static double DoubleLimit(const QString& _data);
static QVector<QString> DoubleLimit(QVector<QString>& data);
static QVector<QString> DoubleLimit(QVector<double> _data);
static QString GetSqlBy(const QVector<QString>& _data, bool bSFlag);
};

707
DataManager_Define.h Normal file
View File

@ -0,0 +1,707 @@
#ifndef DATA_MANAGE_DEFINE_H
#define DATA_MANAGE_DEFINE_H
#include <qglobal.h>
#include <QVector>
#include <QMetaType>
#include <QString>
#define DATE_FORMAT QLatin1String("yyyy/MM/dd")
#define TIME_FORMAT QLatin1String("hh:mm:ss.z")
#define DATATIME_FORMAT QLatin1String("yyyy/MM/dd hh:mm:ss.z")
#define DATATIME_FORMAT_NOSPACE QLatin1String("yyyy/MM/ddhh:mm:ss.z")
#define DATATIME_FORMAT_SECONDS QLatin1String("yyyy/MM/ddhh:mm:ss")
#define DATATIME_FORMAT_SPACE_SECONDS QLatin1String("yyyy/MM/dd hh:mm:ss")
#define ORDER_HEADER QLatin1String("#Header")
#define ORDER_COMMENT QLatin1String("#Comment")
#define ORDER_COLLECTION QLatin1String("#Collection")
#define ORDER_ACQUISITION QLatin1String("#Acquisition")
#define ORDER_PROCESSING QLatin1String("#Processing")
#define ORDER_SAMPLE QLatin1String("#Sample")
#define ORDER_G_ENERGY QLatin1String("#g_Energy")
#define ORDER_B_ENERGY QLatin1String("#b_Energy")
#define ORDER_G_RESOLUTION QLatin1String("#g_Resolution")
#define ORDER_B_RESOLUTION QLatin1String("#b_Resolution")
#define ORDER_G_EFFICIENCY QLatin1String("#g_Efficiency")
#define ORDER_ROI_LIMITS QLatin1String("#ROI_Limits")
#define ORDER_B_GEFFICIENCY QLatin1String("#b-gEfficiency")
#define ORDER_TOTALEFF QLatin1String("#TotalEff")
#define ORDER_RATIOS QLatin1String("#Ratios")
#define ORDER_G_SPECTRUM QLatin1String("#g_Spectrum")
#define ORDER_B_SPECTRUM QLatin1String("#b_Spectrum")
#define ORDER_HISTOGRAM QLatin1String("#Histogram")
#define ORDER_CALIBRATION QLatin1String("#Calibration")
#define ORDER_CERTIFICATE QLatin1String("#Certificate")
#define ORDER_STOP QLatin1String("STOP")
#define ORDER_BEGIN QLatin1String("BEGIN")
#define DATATYPE_QCPHD QLatin1String("QCPHD")
#define DATATYPE_DETBKPHD QLatin1String("DETBKPHD")
#define DATATYPE_SAMPLEPHD QLatin1String("SAMPLEPHD")
#define DATATYPE_GASBKPHD QLatin1String("GASBKPHD")
#define DATETYPE_SOH QLatin1String("RMSSOH")
#define DATETYPE_MET QLatin1String("MET")
#define DATETYPE_ALERT_FLOW QLatin1String("ALERT_FLOW")
#define DATETYPE_ALERT_SYSTEM QLatin1String("ALERT_SYSTEM")
#define DATETYPE_ALERT_TEMP QLatin1String("ALERT_TEMP")
#define DATETYPE_ALERT_UPS QLatin1String("ALERT_UPS")
#define SYSTEMTYPE_P QLatin1String("P") //P for particulate;
#define SYSTEMTYPE_B QLatin1String("B") //B for gaswith 3-D β - γ coincidence detection
#define SYSTEMTYPE_G QLatin1String("G") //G for all other gas systems (high-resolu-tion γ-spectrometry or 2-D β-γ coinci-dence detection)
#define FILE_SAMPLE_NAME_FORMAT QLatin1String("[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}(_S.PHD)$")
#define FILE_ALL_NAME_FORMAT QLatin1String("[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}(_G.PHD|_Q.PHD|_S.PHD|_D.PHD)$")
#define DEFAULT_DATA_PATH QLatin1String("DefaultData")
#define CFG_FILE_PATH tr("./cfg/")
#define CFG_FILE_NAME tr("filecfg.ini")
#define CFG_DELETE_FILE_NAME tr("filedelete.ini")
#define GROUP_DELETE_FILE tr("file")
#define KEY_DELETE_FILE tr("time")
//#define VALUE_DELETE_FILE tr("")
#define GROUP_CFG_FILE tr("FILE_NAME")
#define KEY_BG_AUTO_PROCESS tr("AUTO_DATA_PROCESS")
#define VALUE_BG_AUTO_PROCESS_FILE_NAME tr("auto_data_process.ini")
#define GROUP_BG_THREAD tr("THREAD")
#define KEY_GROUP_BG_THREAD_LIMIT tr("NUMBER")
#define VALUE_GROUP_BG_THREAD_LIMIT tr("2")
#define GROUP_BG_AUTO_ACQUIR tr("GET")
#define KEY_BG_AUTO_FILE_SOURCE_PATH tr("DETECT_FILE_PATH")
#define VALUE_BG_AUTO_FILE_SOURCE_PATH tr("./datatest/filesource/")
//#define GROUP_BG_AUTO_ACQUIR tr("acquire")
//#define KEY_BG_AUTO_FILE_MAIL_SAVE_PATH tr("FILEMAILSAVEPATH")
//#define VALUE_BG_AUTO_FILE_MAIL_SAVE_PATH tr("./datatest/mailload/")
//#define KEY_BG_AUTO_ACUIRE_MAILTIMEOUT tr("MAILDETECTTIMEOUT")
//#define VALUE_BG_AUTO_ACUIRE_MAILTIMEOUT tr("3")
#define KEY_BG_AUTO_ACUIRE_FILETIMEOUT tr("DETECT_FILE_INTERVAL_TIME")
#define VALUE_BG_AUTO_ACUIRE_FILETIMEOUT tr("600")
#define GROUP_BG_AUTO_LOG tr("LOG")
#define KEY_BG_AUTO_LOG_PATH tr("PATH")
#define VALUE_BG_AUTO_LOG_PATH tr("./datatest/log")
#define GROUP_BG_AUTO_DEAL tr("DEAL")
#define KEY_BG_AUTO_DEAL_TIMEOUT tr("UN_DEAL_SEARCH_FILE_TIMEOUT")
#define VALUE_BG_AUTO_DEAL_TIMEOUT tr("43200")
#define KEY_BG_AUTO_DEAL_ID_TIMEOUT tr("UN_DEAL_SEARCH_ID_TIMEOUT")
#define VALUE_BG_AUTO_DEAL_ID_TIMEOUT tr("43200")
#define KEY_BG_AUTO_DEAL_TIMEDETECT tr("UN_DEAL_FILE_DETECT_TIME")
#define VALUE_BG_AUTO_DEAL_TIMEDETECT tr("1800")
#define KEY_BG_AUTO_STATISTICS_TIME tr("STATISTICS_TIME")
#define VALUE_BG_AUTO_STATISTICS_TIME tr("24")
#define KEY_BG_AUTO_DELETE_FILE_INTERVAL_TIMEE tr("DELETE_FILE_INTERVAL_TIME")
#define VALUE_BG_AUTO_SDELETE_FILE_INTERVAL_TIME tr("30")
#define KEY_BG_AUTO_FILE_SAVE_PATH tr("FILE_SAVE_PATH")
#define VALUE_BG_AUTO_FILE_SAVE_PATH tr("./datatest/savefile/")
#define KEY_BG_AUTO_DETAGAS_DEFAULT_PATH tr("DETA_GAS_DEFAULT_PATH")
#define VALUE_BG_AUTO_DETAGAS_DEFAULT_PATH tr("./defaultdata/detagas/")
#define KEY_BG_AUTO_DEAL_NODEALFILEPATH tr("UN_DEAL_FILE_PATH")
#define VALUE_BG_AUTO_DEAL_NODEALFILEPATH tr("./datatest/undeal/")
#define KEY_DATABASE_FIEL_PATH tr("DATA_BASE")
#define VALUE_DATABASE_FIEL_PATH tr("data_base.ini")
#define GROUP_DATABASE tr("DATA_BASE")
#define KEY_DATABASE_TYPE tr("TYPE")
#define VALUE_DATABASE_TYPE tr("MYSQL")
#define GROUP_DATABASE_MYSQL tr("MYSQL")
#define GROUP_DATABASE_ORACLE tr("ORACLE")
#define KEY_DATABASE_HOSTNAME tr("HOSTNAME")
#define VALUE_DATABASE_HOSTNAME tr("192.168.0.101")
#define KEY_DATABASE_DATABASENAME tr("DATA_BASE_NAME")
#define VALUE_DATABASE_DATABASENAME tr("configuration")
#define KEY_DATABASE_USERNAME tr("USERNAME")
#define VALUE_DATABASE_USERNAME tr("root")
#define KEY_DATABASE_PASSWORD tr("PASSWORD")
#define VALUE_DATABASE_PASSWORD tr("123456")
#define KEY_DATABASE_PORT tr("PORT")
#define VALUE_DATABASE_PORT tr("3306")
#define VALUE_DATABAS_ORACLE_HOSTNAME tr("192.168.0.119")
#define VALUE_DATABASE_ORACLE_DATABASENAME tr("orcl")
#define VALUE_DATABASE_ORACLE_USERNAME tr("configuration")
#define VALUE_DATABASE_ORACLE_PASSWORD tr("123456")
#define VALUE_DATABASE_ORACLE_PORT tr("1521")
#define KEY_EMAIL_FIEL_PATH tr("EMAIL")
#define VALUE_EMAIL_FIEL_PATH tr("email.ini")
#define GROUP_EMAIL_SEND tr("SEND")
#define KEY_EMAIL_SEND_USER tr("USER")
#define VALUE_EMAIL_SEND_USER tr("xuhai_cpp@sina.com")
#define KEY_EMAIL_SEND_PASSWD tr("PASSWD")
#define VALUE_EMAIL_SEND_PASSWD tr("abc123456")
#define KEY_EMAIL_SEND_SERVER tr("SERVER")
#define VALUE_EMAIL_SEND_SERVER tr("smtp.sina.com")
#define KEY_EMAIL_SEND_PORT tr("PORT")
#define VALUE_EMAIL_SEND_PORT tr("25")
#define KEY_EMAIL_SEND_CONNECTTYPE tr("CONNECT_TYPE")
#define VALUE_EMAIL_SEND_CONNECTTYPE tr("0")
#define KEY_EMAIL_SEND_RECEIVER tr("RECEIVER")
#define VALUE_EMAIL_SEND_RECEIVER tr("1327783389@qq.com")
#define KEY_EMAIL_SEND_INTERVAL tr("SEND_INTERVAL")
#define VALUE_EMAIL_SEND_INTERVAL tr("10")
//#define GROUP_EMAIL_GET tr("GET")
#define KEY_EMAIL_GET_USER tr("USER")
#define VALUE_EMAIL_GET_USER tr("cnndc.rn")
#define KEY_EMAIL_GET_PASSWD tr("PASSWD")
#define VALUE_EMAIL_GET_PASSWD tr("367220")
#define KEY_EMAIL_GET_SERVER tr("SERVER")
#define VALUE_EMAIL_GET_SERVER tr("192.168.10.59")
#define KEY_EMAIL_GET_PORT tr("PORT")
#define VALUE_EMAIL_GET_PORT tr("143")
#define KEY_EMAIL_GET_CONNECTTYPE tr("CONNECT_TYPE")
#define VALUE_EMAIL_GET_CONNECTTYPE tr("0")
#define KEY_EMAIL_GET_FILE_SAVEPATH tr("FILE_SAVE_PATH")
#define VALUE_EMAIL_GET_FILE_SAVE_PATH tr("./datatest/mailload/")
#define KEY_EMAIL_GET_EML_SAVE_PATH tr("EML_SAVE_PATH")
#define VALUE_EMAIL_GET_EML_SAVE_PATH tr("./datatest/eml/")
#define KEY_EMAIL_GET_EML_INTERVAL_TIME tr("GET_EMAIL_INTERVAL_TIME")
#define VALUE_EMAIL_GET_EML_INTERVAL_TIME tr("600")
#define GROUP_EMAIL_GET_PROCESS tr("GET_PROCESS")
#define KEY_EMAIL_GET_FILE_SAVEPATH tr("FILE_SAVE_PATH")
#define VALUE_EMAIL_GET_FILE_SAVE_PATH tr("./datatest/mailload/")
#define KEY_EMAIL_GET_EML_SAVE_PATH tr("EML_SAVE_PATH")
#define VALUE_EMAIL_GET_EML_SAVE_PATH tr("./datatest/eml/")
#define KEY_EMAIL_GET_EML_INTERVAL_TIME tr("GET_EMAIL_INTERVAL_TIME")
//#define VALUE_EMAIL_GET_EML_INTERVAL_TIME tr("1800")
#define GROUP_EMAIL_GET tr("GET_MAIL")
#define GROUP_EMAIL_GET_ONE tr("GET_MAIL_1")
#define GROUP_EMAIL_GET_TWO tr("GET_MAIL_2")
#define KEY_EMAIL_GET_USER tr("USER")
#define VALUE_EMAIL_GET_USER tr("cnndc.rn")
#define KEY_EMAIL_GET_PASSWD tr("PASSWD")
#define VALUE_EMAIL_GET_PASSWD tr("367220")
#define KEY_EMAIL_GET_SERVER tr("SERVER")
#define VALUE_EMAIL_GET_SERVER tr("192.168.10.59")
#define KEY_EMAIL_GET_PORT tr("PORT")
#define VALUE_EMAIL_GET_PORT tr("143")
typedef struct _Message_Infomations_
{
/* Infomations */
QString msg_type;
QString msg_id;
QString msg_src_code;
QString ref_id_str;
QString ref_src_code;
QString seq_num;
QString tot_num;
QString product_id;
QString delivery_id;
QString data_type;
bool verify_srid;
}
MessageInfo, *PtMessageInfo;
Q_DECLARE_METATYPE(MessageInfo)
/* Commect Block */
typedef QString CommentBlock;
Q_DECLARE_METATYPE(CommentBlock)
namespace RadionuclideData
{
enum AnalyseDataType
{
InvalidData,
GammaAnalyseData,
BetaGammaAnalyseData
};
typedef struct _Header_Block_
{
/* Header Black */
QString designator; // designator
QString site_code; // site code
QString detector_code; // detector code
QString system_type; // system type: P for particulate; B for gas with 3-D β - γ coincidence detection; and
// G for all other gas systems (high-resolu-tion γ-spectrometry or 2-D β-γ coinci-dence detection)
QString sample_geometry; // sample geometry
QString spectrum_quantity; // spectrum qualifier: preliminary ( PREL )or full ( FULL)
QString sample_ref_id; // sample reference identification
QString measurement_id; // measurement identification
QString detector_bk_measurement_id; // detector background measurement identification
QString gas_bk_measurement_id; // gas background measurement identification (memory effect)
QString transmit_date; // transmit date (yyyy / mm / dd)
QString transmit_time; // transmit time (hh : mm : ss . s)
}
HeaderBlock, *PtHeaderBlock;
typedef struct _Acquisition_Block_
{
/* Acquisition Block */
QString acquisition_start_date; // acquisition start date (yyyy / mm / dd)
QString acquisition_start_time; // acquisition start time (hh : mm : ss . s)
double acquisition_real_time; // acquisition real time (s)
double acquisition_live_time; // acquisition live time (s)
}
AcquisitionBlock, *PtAcquisitionBlock;
typedef struct _Collection_Block_
{
/* Collection Block */
QString collection_start_date; // collection start date (yyyy / mm / dd)
QString collection_start_time; // collection start time (hh : mm : ss . s)
QString collection_stop_date; // collection stop date (yyyy / mm / dd)
QString collection_stop_time; // collection stop time (hh : mm : ss . s)
double air_volume; // total air volume sampled (standard cubic meters [scm])
}
CollectionBlock, *PtCollectionBlock;
typedef struct _Processing_Block_
{
/* Processing Block */
double sample_volume_of_Xe; // sample volume of Xe (cm 3 )
double uncertainty_1; // uncertainty (cm 3 )
double Xe_collection_yield; // Xe collection yield (Xe gas in sample/total Xe gas sampled)
double uncertainty_2; // uncertainty (Xe gas in sample/total Xe gas sampled)
QString archive_bottle_id; // archive bottle identification
}
ProcessingBlock, *PtProcessingBlock;
typedef struct _Sample_Block_
{
/* Sample Block */
double dimension_1;
double dimension_2;
}
SampleBlock, *PtSampleBlock;
typedef struct _Calibration_Block_
{
/* Calibration Block */
QString date_calibration; // date of last calibration (yyyy / mm / dd)
QString time_calibration; // time of last calibration (hh : mm : ss)
}
CalibrationBlock, *PtCalibrationBlock;
typedef struct _g_Energy_Block_
{
/* g_Energy Block */
QVector<double> g_energy; // γ -energy (keV)
QVector<double> centroid_channel; // centroid channel
QVector<double> uncertainty; // uncertainty (channels)
int record_count;
}
G_EnergyBlock, *PtG_EnergyBlock;
typedef struct _b_Energy_Block_
{
/* b_Energy Block */
QVector<double> electron_energy; // electron energy (keV)
QVector<QString> decay_mode; // decay mode descriptor: B for β-particle, C for conversion electron (CE)
QVector<double> channel; // maximum channel of β-particle distribution or centroid channel of CE (channels)
QVector<double> uncertainty; // uncertainty (channels)
int record_count;
}
B_EnergyBlock, *PtB_EnergyBlock;
typedef struct _g_Resolution_Block_
{
/* g_Resolution Block */
QVector<double> g_energy; // γ -energy (keV)
QVector<double> FWHM; // FWHM (keV)
QVector<double> uncertainty; // uncertainty (keV)
int record_count;
}
G_ResolutionBlock, *PtG_ResolutionBlock;
typedef struct _b_Resolution_Block_
{
/* b_Resolution Block */
QVector<double> electron_energy; // electron energy (keV)
QVector<double> FWHM; // FWHM (keV)
QVector<double> uncertainty; // uncertainty (keV)
int record_count;
}
B_ResolutionBlock, *PtB_ResolutionBlock;
typedef struct _g_Efficiency_Block_
{
/* g_Efficiency Block */
QVector<double> g_energy; // γ -energy (keV)
QVector<double> efficiency; // efficiency (counts in peak/photon emitted)
QVector<double> uncertainty; // uncertainty (counts in peak/photon emitted)
int record_count;
}
G_EfficiencyBlock, *PtG_EfficiencyBlock;
typedef struct _ROI_Limits_Block_
{
/* ROI_Limits Block */
QVector<QString> ROI_number; // ROI number
QVector<double> POI_B_x1; // 2-D ROI β-range start, x 1 (keV)
QVector<double> POI_B_x2; // 2-D ROI β-range stop, x 2 (keV)
QVector<double> POI_G_y1; // 2-D ROI γ-range start, y 1 (keV)
QVector<double> POI_G_y2; // 2-D ROI γ-range stop, y 2 (keV)
int record_count;
}
ROI_LimitsBlock, *PtROI_LimitsBlock;
typedef struct _BG_Efficiency_Block_
{
/* b-gEfficiency Block */
QVector<QString> nuclide_name; // nuclide name
QVector<QString> ROI_number; // ROI number
QVector<double> bg_efficiency; // β-γ coincidence efficiency (counts in ROI/β-γ pair emitted)
QVector<double> uncertainty; // uncertainty (counts in ROI/β-γ pair emitted)
int record_count;
}
BG_EfficiencyBlock, *PtBG_EfficiencyBlock;
typedef struct _Totaleff_Block_
{
/* Totaleff Block */
QVector<double> g_energy; // γ-energy (keV)
QVector<double> total_efficiency; // total efficiency (counts/photon emitted)
QVector<double> uncertainty; // uncertainty (counts/photon emitted)
int record_count;
}
TotaleffBlock, *PtTotaleffBlock;
typedef struct _Ratios_Block_
{
/* Ratios Block */
QVector<QString> ratio_id; // ratio identifier
QVector<QString> ROI_num_highter_G_energy_ROI; // ROI number for the higher γ -energy ROI
QVector<QString> ROI_num_lower_G_energy_ROI; // ROI number for the lower γ -energy ROI
QVector<double> count_ratio; // Q_DECLARE_METATYPE(RMSSOHData::HeaderBlock)count ratio(counts in higher γ -energy ROI/counts in lower γ -energy ROI)
QVector<double> count_ratio_uncertainty; // count ratio uncertainty (percent)
int record_count;
}
RatiosBlock, *PtRatiosBlock;
typedef struct _G_Spectrum_Block_
{
/* g_Spectrum Block */
long num_g_channel; // number of γ channels
long g_energy_span; // γ-energy span (keV)
long begin_channel; // begin of channels
QVector<long long> counts; // count at channel
//Add By XYL 20170721
_G_Spectrum_Block_()
{
num_g_channel = 0;
g_energy_span = 0;
begin_channel = 0;
}
}
G_SpectrumBlock, *PtG_SpectrumBlock;
typedef struct _B_Spectrum_Block_
{
/* b_Spectrum Block */
long num_b_channel; // number of β -channels
long b_energy_span; // β -energy span (keV)
long begin_channel; // begin of channels
QVector<long long> counts; // counts at channels
}
B_SpectrumBlock, *PtB_SpectrumBlock;
typedef struct _Histogram_Block_
{
/* Histogram Block */
long b_channels; // β-channels
long g_channels; // γ-channels
long b_energy_span; // β-energy span
long g_energy_span; // γ-energy span
QVector<long long> counts; // counts at channels
}
HistogramBlock, *PtHistogramBlock;
typedef struct _Certificate_Block_
{
/* Certificate Block */
double total_source_activity; // total source activity (Bq)
QString assay_date; // assay date (yyyy / mm / dd)
QString assay_time; // assay time (hh : mm : ss)
QString units_activity; // units of activity: “B,” “b” for Bq or “[blank]”; if nothing, then “B” is assigned
QVector<QString> nuclide_name; // nuclide name
QVector<QString> half_life_time; // half-life in seconds, hours, days, or years
QVector<QString> time_unit; // time unit(Y, D, H, S)
QVector<double> activity_nuclide_time_assay;// activity of nuclide at time of assay
QVector<double> uncertainty; // uncertainty (%)
QVector<double> g_energy; // γ-energy (keV)
QVector<double> g_intensity; // γ-intensity (percent)
QVector<QString> electron_decay_mode; // electron decay mode descriptor: B for β particle or C for conversion electron (CE), 0 for none (that is, γ-only source)
QVector<double> maximum_energy; // maximum β-particle energy or CE energy (keV)
QVector<double> intensity_b_particle; // intensity of β-particle (percent)
int record_count;
//Add By XYL 20170721
_Certificate_Block_()
{
total_source_activity = 0;
record_count = 0;
QString assay_date = "";
QString assay_time = "";
QString units_activity = "";
}
}
CertificateBlock, *PtCertificateBlock;
}
Q_DECLARE_METATYPE(RadionuclideData::HeaderBlock)
Q_DECLARE_METATYPE(RadionuclideData::AcquisitionBlock)
Q_DECLARE_METATYPE(RadionuclideData::CollectionBlock)
Q_DECLARE_METATYPE(RadionuclideData::ProcessingBlock)
Q_DECLARE_METATYPE(RadionuclideData::SampleBlock)
Q_DECLARE_METATYPE(RadionuclideData::CalibrationBlock)
Q_DECLARE_METATYPE(RadionuclideData::G_EnergyBlock)
Q_DECLARE_METATYPE(RadionuclideData::B_EnergyBlock)
Q_DECLARE_METATYPE(RadionuclideData::G_ResolutionBlock)
Q_DECLARE_METATYPE(RadionuclideData::B_ResolutionBlock)
Q_DECLARE_METATYPE(RadionuclideData::G_EfficiencyBlock)
Q_DECLARE_METATYPE(RadionuclideData::ROI_LimitsBlock)
Q_DECLARE_METATYPE(RadionuclideData::BG_EfficiencyBlock)
Q_DECLARE_METATYPE(RadionuclideData::TotaleffBlock)
Q_DECLARE_METATYPE(RadionuclideData::RatiosBlock)
Q_DECLARE_METATYPE(RadionuclideData::G_SpectrumBlock)
Q_DECLARE_METATYPE(RadionuclideData::B_SpectrumBlock)
Q_DECLARE_METATYPE(RadionuclideData::HistogramBlock)
Q_DECLARE_METATYPE(RadionuclideData::CertificateBlock)
namespace MetData
{
typedef QString MetDataStationCode; // station code
typedef struct _Met_Data_Item_
{
QString met_start_date; // met start date (yyyy/mm/dd)
QString met_start_time; // met start time (hh:mm:ss)
QString met_end_date; // met end date (yyyy/mm/dd)
QString met_end_time; // met end time (hh:mm:ss)
double average_outside_temperature; // average outside temperature (°C)
int average_wind_direction; // average wind-direction (degrees from north)
double average_wind_speed; // average wind-speed (m/s)
double average_barometric_reading; // average barometric reading (hPa)
int humidity; // average relative humidity (percent relative humidity)
double rainfall; // rainfall (mm)
}
MetDataItem, *PtMetDataItem;
}
Q_DECLARE_METATYPE(MetData::MetDataItem)
namespace RMSSOHData
{
typedef struct _Header_Block_
{
/* Header block */
QString designator; // designator
QString station_code; // station code
QString detector_code; // detector code or NA if 1) there is more than one detector or 2) data are from the sam-pling site of a split station
QString start_date; // SOH data sampling period start date (yyyy/mm/dd)
QString start_time; // SOH data sampling period start time (hh:mm:ss)
QString end_date; // SOH data sampling period end date (yyyy/mm/dd)
QString end_time; // SOH data sampling period end time (hh:mm:ss)
QString transmit_date; // transmit date (yyyy/mm/dd)
QString transmit_time; // transmit time (hh:mm:ss)
}
HeaderBlock, *PtHeaderBlock;
typedef struct _Air_Sampler_Flow_Block_
{
/* Air Sampler Flow block */
QVector<double> average_flow_rate; // average flow rate (standard cubic metersper hour (scm/h))
QVector<double> flow_rate_standard_deviation; // flow rate standard deviation (scm/h)
QVector<QString> start_date; // SOH data sampling interval start date (yyyy/mm/dd)
QVector<QString> start_time; // SOH data sampling interval start time (hh:mm:ss)
QVector<long> interval_duration; // SOH data sampling interval duration (s)
int record_count;
}
AirSamplerFlowBlock, *PtAirSamplerFlowBlock;
typedef struct _Air_Sampler_Env_Block_
{
/* Air Sampler Env block */
QVector<double> temperature; // average air temperature after filter (°C)
QVector<double> pressure; // average static air pressure after filter (hPa)
QVector<QString> date; // date (yyyy/mm/dd)
QVector<QString> time; // time (hh:mm:ss)
QVector<long> interval_duration; // SOH data sampling interval duration (s)
int record_count;
}
AirSamplerEnvBlock, *PtAirSamplerEnvBlock;
typedef struct _Det_Env_Block_
{
/* Det Env block */
QVector<double> room_temperature; // average room temperature (°C)
QVector<QString> detector_shield_status; // detector shield status (OPEN or CLOSED)
QVector<short> humidity; // average room humidity (in percent relative humidity)
QVector<long> voltage; // detector high voltage (V)
QVector<long> crystal_temperature; // average crystal temperature (°C)
QVector<QString> electric_cooler_status; // electric cooler status (ON or OFF)
QVector<double> fill_fraction; // liquid nitrogen fill-fraction
QVector<double> leakage; // detector leakage current (nanoamperes [nA])
QVector<QString> date; // date (yyyy/mm/dd)
QVector<QString> time; // time (hh:mm:ss)
QVector<long> interval_duration; // SOH data sampling interval duration (s)
int record_count;
}
DetEnvBlock, *PtDetEnvBlock;
typedef struct _NIMBIN_Block_
{
/* NIMBIN block */
QVector<QString> flag; // +/-
QVector<short> voltage; // average NIMBIN voltage (V)
QVector<QString> date; // date (yyyy/mm/dd)
QVector<QString> time; // time (hh:mm:ss)
QVector<long> interval_duration; // SOH data sampling interval duration (s)
int record_count;
}
NIMBIN_Block, *PtNIMBIN_Block;
typedef struct _Power_Supply_Block_
{
/* Power Supply block */
QVector<QString> MAIN; // MAIN (for MAIN power supply)
QVector<QString> main_power_status; // status of main power supply (ON/OFF)
QVector<QString> AUX; // AUX (for AUXiliary power supply)
QVector<QString> aux_power_status; // status of auxiliary power supply (ON/OFF)
QVector<QString> UPS; // UPS (for Uninterrupted Power Supply)
QVector<QString> ups_status; // status of uninterruptedly power supply (ON/ OFF)
QVector<QString> date; // date (yyyy/mm/dd)
QVector<QString> time; // time (hh:mm:ss)
QVector<long> interval_duration; // SOH data sampling interval duration (s)
int record_count;
}
PowerSupplyBlock, *PtPowerSupplyBlock;
typedef struct _Equip_Status_Block_
{
/* Equip Status block */
QVector<QString> C_value; // status of sampling system (ON/OFF) or the SRID of the sample being collected
QVector<QString> P_value; // status of sample preparation, processing, or decay (ON/OFF) or the SRID of the sample being processed or decayed
QVector<QString> A_value; // status of detector system (ON/OFF) or the SRID of the sample being counted
QVector<QString> date; // date (yyyy/mm/dd)
QVector<QString> time; // time (hh:mm:ss)
QVector<long> interval_duration; // SOH data sampling interval duration (s)
int record_count;
}
EquipStatusBlock, *PtEquipStatusBlock;
typedef struct _Tamper_Env_Block_
{
/* Tamper Env block */
QVector<QString> tamper_sensor_name; // tamper sensor name
QVector<QString> tamper_sensor_status; // tamper sensor status (OPEN or CLOSED)
QVector<QString> date; // date (yyyy/mm/dd)
QVector<QString> time; // time (hh:mm:ss)
QVector<long> interval_duration; // SOH data sampling interval duration (s)
int record_count;
}
TamperEnvBlock, *PtTamperEnvBlock;
typedef struct _Process_Sensors_Block_
{
/* Process Sensors block */
QVector<QString> sensor_type; // sensor type (TEMP, PRESSURE,PROCESSFLOW, VOLTAGE, COUN-TRATES, DEWPOINT, CO2VOLUME)
QVector<QString> sensor_name; // tamper sensor status (OPEN or CLOSED)
QVector<double> sensor_reading; // sensor reading (TEMP in °C, PRESSURE in Pa, PROCESSFLOW in m3/h, VOLT-AGE in V, COUNTRATE in counts/s, DEWPOINT in °C, CO2VOLUME in cm3)
QVector<QString> date; // date (yyyy/mm/dd)
QVector<QString> time; // time (hh:mm:ss)
QVector<long> duration; // SOH duration (s)
int record_count;
}
ProcessSensorsBlock, *PtProcessSensorsBlock;
typedef struct _Chromatogram_Block_
{
/* Chromatogram block */
QString srid; // the SRID of the sample being counted
QVector<long> interval_number; // interval number (starts at 1)
QVector<long> interval_start_channel; // interval start channel
QVector<double> duration; // duration between chromatogram readings (in seconds [s])
int interval_record_count;
long total_number; // total number of chromatogram readings
QVector<long> detector_response; // detector response
}
ChromatogramBlock, *PtChromatogramBlock;
}
Q_DECLARE_METATYPE(RMSSOHData::HeaderBlock)
Q_DECLARE_METATYPE(RMSSOHData::AirSamplerFlowBlock)
Q_DECLARE_METATYPE(RMSSOHData::AirSamplerEnvBlock)
Q_DECLARE_METATYPE(RMSSOHData::DetEnvBlock)
Q_DECLARE_METATYPE(RMSSOHData::NIMBIN_Block)
Q_DECLARE_METATYPE(RMSSOHData::PowerSupplyBlock)
Q_DECLARE_METATYPE(RMSSOHData::EquipStatusBlock)
Q_DECLARE_METATYPE(RMSSOHData::TamperEnvBlock)
Q_DECLARE_METATYPE(RMSSOHData::ProcessSensorsBlock)
Q_DECLARE_METATYPE(RMSSOHData::ChromatogramBlock)
namespace AlertData
{
typedef QString AlertsDescribe;
typedef struct _Alerts_Info_
{
QString station_code;
QString alert_type;
QString date;
QString time;
AlertsDescribe desc;
}
AlertsInfo, *PtAlertsInfo;
}
Q_DECLARE_METATYPE(AlertData::AlertsInfo)
#endif // DATA_MANAGE_DEFINE_H

222
Fit.cpp Normal file
View File

@ -0,0 +1,222 @@
#include "Fit.h"
#include <QtMath>
bool CFit:: LinearFit(QVector<double>& _watch_x,QVector<double>& _watch_y,QVector<double>& _outputData,double &_output_vari)
{
Q_UNUSED(_output_vari);
//客户默认使用使用的线性
if(_watch_x.size()!=_watch_y.size())
{
return false;
}
QVector<double>::size_type size = _watch_x.size();
double AA=0.0,BB=0.0,CC=0.0,DD=0.0;
for(QVector<double>::size_type pos=0;pos<size;pos++)
{
AA += _watch_y[pos];
BB += _watch_x[pos];
CC += _watch_y[pos]*_watch_x[pos];
DD += _watch_x[pos]*_watch_x[pos];
}
double divison = (BB*BB-(size+1)*DD);
if(0.0 == divison)
{
return false;
}
double factor_one = (AA*BB-(size+1)*CC)/divison;
double factor_two = (BB*CC-AA*DD)/divison;
_outputData.clear();
_outputData.append(factor_one);
_outputData.append(factor_two);
return true;
}
bool CFit::LinearFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<int>& _output_y)
{
if(_fit_para.size()<2)
{
return false;
}
_output_y.clear();
double dTemp = 0.0;
QVector<double>::size_type size = _watch_x.size();
for(QVector<double>::size_type pos=0;pos<size;pos++)
{
dTemp = _fit_para.at(0)*_watch_x.at(pos)+_fit_para.at(1);
_output_y.append(dTemp);
}
return true;
}
bool CFit::LinearFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<double>& _output_y)
{
if(_fit_para.size()<2)
{
return false;
}
_output_y.clear();
double dTemp = 0.0;
QVector<double>::size_type size = _watch_x.size();
for(QVector<double>::size_type pos=0;pos<size;pos++)
{
dTemp = _fit_para.at(0)*_watch_x.at(pos)+_fit_para.at(1);
_output_y.append(dTemp);
}
return true;
}
bool CFit::_2PloynimialFit(QVector<double>& _watch_x,QVector<double>& _watch_y,QVector<double>& _outputData,double &_output_vari)
{
Q_UNUSED(_output_vari);
QVector<double> rData(3,0);
//取整运算判断:
double divison = 0.0;
divison = (1*ArrayPowerSumAverage(_watch_y,4)-qPow(ArrayPowerSumAverage(_watch_y,2),2));
if(0.0 == divison)
{
return false;
}
divison = (1*ArrayPowerSumAverage(_watch_y,2)-qPow(ArrayPowerSumAverage(_watch_y),2));
if(0.0 == divison)
{
return false;
}
divison = (1-
((ArrayPowerSumAverage(_watch_y)*ArrayPowerSumAverage(_watch_y,2)-1*ArrayPowerSumAverage(_watch_y,3)) / \
(1*ArrayPowerSumAverage(_watch_y,2)-qPow(ArrayPowerSumAverage(_watch_y),2))) * \
((ArrayPowerSumAverage(_watch_y)*ArrayPowerSumAverage(_watch_y,2)-1*ArrayPowerSumAverage(_watch_y,3)) / \
(1*ArrayPowerSumAverage(_watch_y,4)-qPow(ArrayPowerSumAverage(_watch_y,2),2))) \
);
if(0.0 == divison)
{
return false;
}
//开始计算方程系数
rData[2] = ( \
((1*TwoArrayPowerSumAverage(_watch_x,_watch_y,2)-ArrayPowerSumAverage(_watch_x)*ArrayPowerSumAverage(_watch_y,2))/
(1*ArrayPowerSumAverage(_watch_y,4)-qPow(ArrayPowerSumAverage(_watch_y,2),2))) + \
((1*TwoArrayPowerSumAverage(_watch_y,_watch_x)-ArrayPowerSumAverage(_watch_x)*ArrayPowerSumAverage(_watch_y)) / \
(1*ArrayPowerSumAverage(_watch_y,2)-qPow(ArrayPowerSumAverage(_watch_y),2))) * \
((ArrayPowerSumAverage(_watch_y)*ArrayPowerSumAverage(_watch_y,2)-1*ArrayPowerSumAverage(_watch_y,3)) / \
(1*ArrayPowerSumAverage(_watch_y,4)-qPow(ArrayPowerSumAverage(_watch_y,2),2))) \
) / \
(1-
((ArrayPowerSumAverage(_watch_y)*ArrayPowerSumAverage(_watch_y,2)-1*ArrayPowerSumAverage(_watch_y,3)) / \
(1*ArrayPowerSumAverage(_watch_y,2)-qPow(ArrayPowerSumAverage(_watch_y),2))) * \
((ArrayPowerSumAverage(_watch_y)*ArrayPowerSumAverage(_watch_y,2)-1*ArrayPowerSumAverage(_watch_y,3)) / \
(1*ArrayPowerSumAverage(_watch_y,4)-qPow(ArrayPowerSumAverage(_watch_y,2),2))) \
);
rData[1] = ( \
(1*TwoArrayPowerSumAverage(_watch_y,_watch_x)-ArrayPowerSumAverage(_watch_x)*ArrayPowerSumAverage(_watch_y)) / \
(1*ArrayPowerSumAverage(_watch_y,2)-qPow(ArrayPowerSumAverage(_watch_y),2)) \
)+ \
rData[2]*( \
(ArrayPowerSumAverage(_watch_y)*ArrayPowerSumAverage(_watch_y,2)-1*ArrayPowerSumAverage(_watch_y,3))/ \
(1*ArrayPowerSumAverage(_watch_y,2)-qPow(ArrayPowerSumAverage(_watch_y),2)) \
);
rData[0] = ( \
ArrayPowerSumAverage(_watch_x)-rData[1]*ArrayPowerSumAverage(_watch_y)-rData[2]*ArrayPowerSumAverage(_watch_y,2) \
)/ \
1;
_outputData = rData;
return true;
}
bool CFit::_2PloynimialFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<int>& _output_y)
{
_output_y.clear();
if(_fit_para.size()<3||_watch_x.size()<0) //刻度系数大小错误 或 限制数据不存在
{
return false;
}
int dataTemp = 0;
for(QVector<double>::size_type pos=0;pos<_watch_x.size();pos++)
{
dataTemp = int(_fit_para[0]+_fit_para[1]*_watch_x[pos]+_fit_para[2]*_watch_x[pos]*_watch_x[pos]+0.5);
_output_y.append(dataTemp);
}
return true;
}
bool CFit::_2PloynimialFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<double>& _output_y)
{
_output_y.clear();
if(_fit_para.size()<3||_watch_x.size()<0) //刻度系数大小错误 或 限制数据不存在
{
return false;
}
double dataTemp = 0;
for(QVector<double>::size_type pos=0;pos<_watch_x.size();pos++)
{
dataTemp = _fit_para[0]+_fit_para[1]*_watch_x[pos]+_fit_para[2]*_watch_x[pos]*_watch_x[pos];
_output_y.append(dataTemp);
}
return true;
}
bool CFit::_3PloynimialFit(QVector<double>& _watch_x,QVector<double>& _watch_y,QVector<double>& _outputData,double &_output_vari)
{
Q_UNUSED(_watch_x);
Q_UNUSED(_watch_y);
Q_UNUSED(_outputData);
Q_UNUSED(_output_vari);
return false;
}
bool CFit::_3PloynimialFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<int>& _output_y)
{
Q_UNUSED(_watch_x);
Q_UNUSED(_fit_para);
Q_UNUSED(_output_y);
return false;
}
bool CFit::_3PloynimialFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<double>& _output_y)
{
Q_UNUSED(_watch_x);
Q_UNUSED(_fit_para);
Q_UNUSED(_output_y);
return false;
}
bool CFit::GaussFit(QVector<double>& _watch_x,QVector<double>& _watch_y,QVector<double>& _outputData,double &_output_vari)
{
Q_UNUSED(_watch_x);
Q_UNUSED(_watch_y);
Q_UNUSED(_outputData);
Q_UNUSED(_output_vari);
return false;
}
bool CFit::GaussFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<int>& _output_y)
{
Q_UNUSED(_watch_x);
Q_UNUSED(_fit_para);
Q_UNUSED(_output_y);
return false;
}
bool CFit::GaussFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<double>& _output_y)
{
Q_UNUSED(_watch_x);
Q_UNUSED(_fit_para);
Q_UNUSED(_output_y);
return false;
}
double CFit::ArrayPowerSumAverage(QVector<double>& _data,int _pow)
{
double rData=0;
size_t size = _data.size();
for(size_t pos=0;pos<size;pos++)
{
rData += qPow(_data.at(pos),_pow);
}
if(size)
{
rData /=size;
}
return rData;
}
double CFit::TwoArrayPowerSumAverage(QVector<double>& _first,QVector<double>& _second,int _pow)
{
double rData=0;
size_t minSize = (_first.size()<=_second.size()?_first.size():_second.size());
for(size_t pos=0;pos<minSize;pos++)
{
rData+= _first.at(pos)*qPow(_second.at(pos),_pow);
}
if(minSize)
{
rData /= minSize;
}
return rData;
}

126
Fit.h Normal file
View File

@ -0,0 +1,126 @@
#ifndef FIT_H
#define FIT_H
////////////////////////////////////////////////////////////////////////
// 类说明:此类为拟合算法类
//
// 注意事项1、此类包含拟合系数计算 和拟合方程计算
//
////////////////////////////////////////////////////////////////////////
#include <QVector>
class CFit
{
public:
/////////////////////////////////////////////////////////////////////
// 函数说明LinearFit 线性拟合
// 参数说明_watch_x: 观察值x 数组
// _watch_y 观察值y 数组
// _outputData: 拟合返回值
// _output_vari:拟合误差值
//
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool LinearFit(QVector<double>& _watch_x,QVector<double>& _watch_y,QVector<double>& _outputData,double &_output_vari);
// 函数说明LinearFitEquation 拟合方程y = int(_fit_para[0]*_watch_x[n..]+_fit_para[1])
// 参数说明_watch_x: 观察值x 数组
// _fit_para 二次拟合方程系数
// _output_y 返回值
//
// 返回值: true:正确返回
// fale:错误返
static bool LinearFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<int>& _output_y);
static bool LinearFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<double>& _output_y);
/////////////////////////////////////////////////////////////////////
// 函数说明_2PloynimialFit 2次拟合
// 参数说明_watch_x: 观察值x 数组
// _watch_y 观察值y 数组
// _outputData: 拟合返回值
// _output_vari:拟合误差值
//
// 返回值: true:正确返回
// fale:错误返回
/////////////////////////////////////////////////////////////////////
static bool _2PloynimialFit(QVector<double>& _watch_x,QVector<double>& _watch_y,QVector<double>& _outputData,double &_output_vari);
/////////////////////////////////////////////////////////////////////
// 函数说明_2PloynimialFitEquation 拟合方程y = int(_fit_para[0]+_fit_para[1]*_watch_x[n..]+_fit_para[2]*_watch_x[n..]*_watch_x[n..]+0.5)
// 参数说明_watch_x: 观察值x 数组
// _fit_para 二次拟合方程系数
// _output_y 返回值
//
// 返回值: true:正确返回
// fale:错误返回
/////////////////////////////////////////////////////////////////////
static bool _2PloynimialFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<int>& _output_y);
/////////////////////////////////////////////////////////////////////
// 函数说明__3PloynimialFit 3次拟合
// 参数说明_watch_x: 观察值x 数组
// _watch_y 观察值y 数组
// _outputData: 拟合返回值
// _output_vari:拟合误差值
//
// 返回值: true:正确返回
// fale:错误返回
/////////////////////////////////////////////////////////////////////
/// \brief _3PloynimialFit
/// \param _watch_x
/// \param _watch_y
/// \param _outputData
/// \param _output_vari
/// \return
static bool _2PloynimialFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<double>& _output_y);
static bool _3PloynimialFit(QVector<double>& _watch_x,QVector<double>& _watch_y,QVector<double>& _outputData,double &_output_vari);
/////////////////////////////////////////////////////////////////////
// 函数说明__3PloynimialFit 3次拟合方程
// 参数说明_watch_x: 观察值x 数组
// _watch_y 观察值y 数组
// _outputData: 拟合返回值
// _output_vari:拟合误差值
//
// 返回值: true:正确返回
// fale:错误返回
/////////////////////////////////////////////////////////////////////
static bool _3PloynimialFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<int>& _output_y);
static bool _3PloynimialFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<double>& _output_y);
/////////////////////////////////////////////////////////////////////
// 函数说明GaussFit 高斯拟合
// 参数说明_watch_x: 观察值x 数组
// _watch_y 观察值y 数组
// _outputData: 拟合返回值
// _output_vari:拟合误差值
//
// 返回值: true:正确返回
// fale:错误返回
/////////////////////////////////////////////////////////////////////
static bool GaussFit(QVector<double>& _watch_x,QVector<double>& _watch_y,QVector<double>& _outputData,double &_output_vari);
/////////////////////////////////////////////////////////////////////
// 函数说明GaussFit 高斯拟合方程
// 参数说明_watch_x: 观察值x 数组
// _watch_y 观察值y 数组
// _outputData: 拟合返回值
// _output_vari:拟合误差值
//
// 返回值: true:正确返回
// fale:错误返回
/////////////////////////////////////////////////////////////////////
static bool GaussFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<int>& _output_y);
static bool GaussFitEquation(QVector<double>& _watch_x,QVector<double>& _fit_para,QVector<double>& _output_y);
private:
/////////////////////////////////////////////////////////////////////
// 函数说明_ArrayPowerSumAverage 数组数据n次方 和的平均值 空数组返回值为零
// 参数说明_data: 需要处理的数据
//
// 返回值: 输入数组为空时 0
/////////////////////////////////////////////////////////////////////
static double ArrayPowerSumAverage(QVector<double>& _data,int _pow=1);
/////////////////////////////////////////////////////////////////////
// 函数说明_ArrayPowerSumAverage 数组first数据乘以数组sencond数据n次方 和的平均值
// 参数说明_data: 需要处理的数据
//
// 返回值: 输入数组为空时 0
/////////////////////////////////////////////////////////////////////
static double TwoArrayPowerSumAverage(QVector<double>& _first,QVector<double>& _second,int _pow=1);
};
#endif

12
FitDef.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef FIT_DEFINE_H
#define FIT_DEFINE_H
#include <QVector>
//2次拟合输入参数
typedef struct tag2PloynimilFit
{
QVector<double> first;
QVector<double> second;
}*p2Ploynimainl,_2Ploynimial;
#endif

371
MDC.cpp Normal file
View File

@ -0,0 +1,371 @@
#include "MDC.h"
#include <QtMath>
#include <QtGlobal>
double CMdc::CalcSqrt(QVector<double>& _data,QVector<double>::size_type _pos)
{
double rData=0.0;
if(_pos < _data.size())
{
rData = _data[_pos]*_data[_pos];
}
return rData;
}
double CMdc::CalcLD(QVector<double>& _data,QVector<double>::size_type _pos)
{
double rData=0.0;
if(_pos < _data.size())
{
rData = _data[_pos]+LD(_data[_pos]);
}
return rData;
}
bool CMdc::MDC(MDCI& _input,global::XeType& _input_Xetype,MDCO& _output)
{
bool bRet=false;
bRet = LC(_input,_input_Xetype,_output.lcPara);
if(!bRet)
{
return false;
}
bRet = MDCFromLC(_input,_input_Xetype,_output);
return bRet;
}
bool CMdc::MDCFromLC(MDCI& _input,global::XeType _input_Xetype,MDCO& _output)
{
const int cts_grpnum = 3; //净计数 3数1组
// const int pos_cts = 0; //净计数偏移
// const int pos_vari = 1; //误差偏移
const int pos_0_vari = 2; //0信号误差偏移
const int factor_grpnum = 1; //感兴趣区浓度计算系数
const int min_cts = 10*cts_grpnum+pos_0_vari;
const int min_factor = 10*factor_grpnum;
//净计数数组大小判断
if(min_cts>=_input.ROI_netcts.size())
{
return false;
}
//感兴趣区浓度计算系数
if(min_factor>=_input.ROI_con_counts_factor.size())
{
return false;
}
//除数为零判断
if(_input.ROI_con_counts_factor[2*factor_grpnum]==0.0 || \
_input.ROI_con_counts_factor[3*factor_grpnum]==0.0 || \
_input.ROI_con_counts_factor[5*factor_grpnum]==0.0 || \
_input.ROI_con_counts_factor[6*factor_grpnum]==0.0 || \
_input.ROI_netcts[3*cts_grpnum+pos_0_vari]==0.0 || \
_input.ROI_netcts[7*cts_grpnum+pos_0_vari]==0.0 || \
_input.ROI_netcts[8*cts_grpnum+pos_0_vari]==0.0 || \
_input.ROI_netcts[9*cts_grpnum+pos_0_vari]==0.0 || \
_input.ROI_netcts[10*cts_grpnum+pos_0_vari]==0.0)
{
return false;
}
//Use ROIs 2
_output.mdcPara.MDC_Xe135 = _output.lcPara.LC_Xe135+global::cst_k*qSqrt(\
CalcLD(_input.ROI_netcts,2*cts_grpnum+pos_0_vari)/CalcSqrt(_input.ROI_con_counts_factor,2*factor_grpnum)\
);
if(qIsNaN(_output.mdcPara.MDC_Xe135))
{
return false;
}
//Use ROIs 5
_output.mdcPara.MDC_Xe131m = _output.lcPara.LC_Xe131m+global::cst_k*qSqrt(\
CalcLD(_input.ROI_netcts,5*cts_grpnum+pos_0_vari)/CalcSqrt(_input.ROI_con_counts_factor,5*factor_grpnum)\
);
//Use ROIs 6
_output.mdcPara.MDC_Xe133m = _output.lcPara.LC_Xe133m+global::cst_k*qSqrt(\
CalcLD(_input.ROI_netcts,6*cts_grpnum+pos_0_vari)/CalcSqrt(_input.ROI_con_counts_factor,6*factor_grpnum)\
);
if(qIsNaN(_output.mdcPara.MDC_Xe133m))
{
return false;
}
switch ( _input_Xetype)
{
case global::none:
{
//Use ROIs 3 4
double temp = (CalcSqrt(_input.ROI_con_counts_factor,3*factor_grpnum)*CalcLD(_input.ROI_netcts,4*cts_grpnum+pos_0_vari)+\
CalcSqrt(_input.ROI_con_counts_factor,4*factor_grpnum)*CalcLD(_input.ROI_netcts,3*cts_grpnum+pos_0_vari));
if(temp == 0.0)
{
return false;
}
_output.mdcPara.MDC_Xe133 = _output.lcPara.LC_Xe133+ global::cst_k*qSqrt(\
(CalcLD(_input.ROI_netcts,3*cts_grpnum+pos_0_vari)* CalcLD(_input.ROI_netcts,4*cts_grpnum+pos_0_vari))/ \
temp\
);
if(qIsNaN(_output.mdcPara.MDC_Xe133))
{
return false;
}
}
break;
case global::_131m:
{
//Use ROIs 3 7 9
//Roi 3
double VD3 = CalcLD(_input.ROI_netcts,3*cts_grpnum+pos_0_vari)/CalcSqrt(_input.ROI_con_counts_factor,3*factor_grpnum);
//Roi 7 9
double temp = (CalcSqrt(_input.ROI_con_counts_factor,7*factor_grpnum)*CalcLD(_input.ROI_netcts,9*cts_grpnum+pos_0_vari)+\
CalcSqrt(_input.ROI_con_counts_factor,9*factor_grpnum)*CalcLD(_input.ROI_netcts,7*cts_grpnum+pos_0_vari));
if(temp == 0.0)
{
return false;
}
double VD79 = (\
(CalcLD(_input.ROI_netcts,7*cts_grpnum+pos_0_vari)* CalcLD(_input.ROI_netcts,9*cts_grpnum+pos_0_vari))/ \
temp\
);
//Roi 3 7 9
if(0.0==VD3||0.0==VD79||0==(1/VD3+1/VD79))
{
return false;
}
double VD379 = 1/(1/VD3+1/VD79);
_output.mdcPara.MDC_Xe133 = global::cst_k/qSqrt(\
CalcSqrt(_input.ROI_con_counts_factor,3*factor_grpnum)/_input.ROI_netcts[3*cts_grpnum+pos_0_vari]+\
CalcSqrt(_input.ROI_con_counts_factor,7*factor_grpnum)/_input.ROI_netcts[7*cts_grpnum+pos_0_vari]+\
CalcSqrt(_input.ROI_con_counts_factor,9*factor_grpnum)/_input.ROI_netcts[9*cts_grpnum+pos_0_vari])+\
global::cst_k*qSqrt(VD379);
if(qIsNaN(_output.mdcPara.MDC_Xe133))
{
return false;
}
}
break;
case global::_133m:
{
//Use ROIs 3 8 10
//Roi 3
double VD3 = CalcLD(_input.ROI_netcts,3*cts_grpnum+pos_0_vari)/CalcSqrt(_input.ROI_con_counts_factor,3*factor_grpnum);
//Roi 8 10
double temp = (CalcSqrt(_input.ROI_con_counts_factor,7*factor_grpnum)*CalcLD(_input.ROI_netcts,9*cts_grpnum+pos_0_vari)+\
CalcSqrt(_input.ROI_con_counts_factor,9*factor_grpnum)*CalcLD(_input.ROI_netcts,7*cts_grpnum+pos_0_vari));
if(temp == 0.0)
{
return false;
}
double VD810 =(\
(CalcLD(_input.ROI_netcts,8*cts_grpnum+pos_0_vari)* CalcLD(_input.ROI_netcts,10*cts_grpnum+pos_0_vari))/ \
temp\
);
//Roi 3 8 10
if(0.0==VD3||0.0==VD810||0==(1/VD3+1/VD810))
{
return false;
}
double VD3810 = 1/(1/VD3+1/VD810);
_output.mdcPara.MDC_Xe133 = global::cst_k/qSqrt(\
CalcSqrt(_input.ROI_con_counts_factor,3*factor_grpnum)/_input.ROI_netcts[3*cts_grpnum+pos_0_vari]+\
CalcSqrt(_input.ROI_con_counts_factor,8*factor_grpnum)/_input.ROI_netcts[8*cts_grpnum+pos_0_vari]+\
CalcSqrt(_input.ROI_con_counts_factor,10*factor_grpnum)/_input.ROI_netcts[10*cts_grpnum+pos_0_vari])+\
global::cst_k*qSqrt(VD3810);
if(qIsNaN(_output.mdcPara.MDC_Xe133))
{
return false;
}
}
break;
case global::both:
{
//Use ROIs 3 7 8
//Roi 3
double VD3 =CalcLD(_input.ROI_netcts,3*cts_grpnum+pos_0_vari)/CalcSqrt(_input.ROI_con_counts_factor,3*factor_grpnum);
//Roi 8 10
//Roi 7 8
double VD78 = (\
(CalcLD(_input.ROI_netcts,7*cts_grpnum+pos_0_vari)* CalcLD(_input.ROI_netcts,8*cts_grpnum+pos_0_vari))/ \
(CalcSqrt(_input.ROI_con_counts_factor,7*factor_grpnum)*CalcLD(_input.ROI_netcts,8*cts_grpnum+pos_0_vari)+\
CalcSqrt(_input.ROI_con_counts_factor,8*factor_grpnum)*CalcLD(_input.ROI_netcts,7*cts_grpnum+pos_0_vari))\
);
//Roi 3 7 8
if(0.0==VD3||0.0==VD78||0==(1/VD3+1/VD78))
{
return false;
}
double VD378 = 1/(1/VD3+1/VD78);
_output.mdcPara.MDC_Xe133 = global::cst_k/qSqrt(\
CalcSqrt(_input.ROI_con_counts_factor,3*factor_grpnum)/_input.ROI_netcts[3*cts_grpnum+pos_0_vari]+\
CalcSqrt(_input.ROI_con_counts_factor,7*factor_grpnum)/_input.ROI_netcts[7*cts_grpnum+pos_0_vari]+\
CalcSqrt(_input.ROI_con_counts_factor,8*factor_grpnum)/_input.ROI_netcts[8*cts_grpnum+pos_0_vari])+\
global::cst_k*qSqrt(VD378);
if(qIsNaN(_output.mdcPara.MDC_Xe133))
{
return false;
}
}
break;
default:
break;
}
//计算没有使用,客户需要存储数据库
for(int pos=2;pos<=10;pos++)
{
if((2+3*pos)<_input.ROI_netcts.size() && (pos)<_input.ROI_con_counts_factor.size())
{
if((_input.ROI_con_counts_factor[pos]!=0.0)
&& (_input.ROI_con_counts_factor[pos]*_input.ROI_con_counts_factor[pos] != 0.0))
{
double temp=global::cst_k*qSqrt(_input.ROI_netcts[2+3*pos])/_input.ROI_con_counts_factor[pos]+
global::cst_k*qSqrt((_input.ROI_netcts[2+3*pos]+LD(_input.ROI_netcts[2+3*pos]))/
(_input.ROI_con_counts_factor[pos]*_input.ROI_con_counts_factor[pos]));
if(qIsNaN(temp))
{
return false;
}
_output.mdcPara.MDC.append(temp);
// double temp= global::cst_k*qSqrt(_input.ROI_netcts[2+3*pos]);
// _output.mdcPara.MDC_CTS.append(temp);
}
}
}
return true;
}
double CMdc::LD(const double& _inputa)
{
return global::cst_k*global::cst_k+2*global::cst_k*qSqrt(_inputa);
}
bool CMdc::LC(MDCI& _input,global::XeType _input_Xetype,LCPara& _output)
{
const int cts_grpnum = 3; //净计数 3数1组
// const int pos_cts = 0; //净计数偏移
// const int pos_vari = 1; //误差偏移
const int pos_0_vari = 2; //0信号误差偏移
const int factor_grpnum = 1; //感兴趣区浓度计算系数
const int con_uncer_grpnum = 2; //感兴趣区浓度不平衡度 2数1组
const int pos_con = 0; //浓度偏移
// const int pos_uncer = 1; //不平衡度偏移
const int min_cts = 10*cts_grpnum+pos_0_vari;
const int min_factor = 10*factor_grpnum;
const int min_u = 3*con_uncer_grpnum+pos_con;
//净计数数组大小判断
if(min_cts>=_input.ROI_netcts.size())
{
return false;
}
//感兴趣区浓度计算系数
if(min_factor>=_input.ROI_con_counts_factor.size())
{
return false;
}
//感兴趣区浓度不平衡度
if(min_u>=_input.ROI_con_uncer.size())
{
return false;
}
//除数为零判断
if(_input.ROI_con_counts_factor[2*factor_grpnum]==0.0 ||\
_input.ROI_con_counts_factor[5*factor_grpnum]==0.0 ||\
_input.ROI_con_counts_factor[6*factor_grpnum]==0.0 ||\
_input.ROI_netcts[3*cts_grpnum+pos_0_vari]==0.0 ||\
_input.ROI_netcts[4*cts_grpnum+pos_0_vari]==0.0 ||\
_input.ROI_netcts[7*cts_grpnum+pos_0_vari]==0.0 ||\
_input.ROI_netcts[8*cts_grpnum+pos_0_vari]==0.0 ||\
_input.ROI_netcts[9*cts_grpnum+pos_0_vari]==0.0 ||\
_input.ROI_netcts[10*cts_grpnum+pos_0_vari]==0.0)
{
return false;
}
//Use ROIs 2
_output.LC_Xe135 = global::cst_k*qSqrt(_input.ROI_netcts[2*cts_grpnum+pos_0_vari])/_input.ROI_con_counts_factor[2*factor_grpnum];
if(qIsNaN( _output.LC_Xe135))
{
return false;
}
//Use ROIs 5
_output.LC_Xe131m = global::cst_k*qSqrt(_input.ROI_netcts[5*cts_grpnum+pos_0_vari])/_input.ROI_con_counts_factor[5*factor_grpnum];
if(qIsNaN( _output.LC_Xe131m))
{
return false;
}
//Use ROIs 6
_output.LC_Xe133m = global::cst_k*qSqrt(_input.ROI_netcts[6*cts_grpnum+pos_0_vari])/_input.ROI_con_counts_factor[6*factor_grpnum];
if(qIsNaN( _output.LC_Xe133m))
{
return false;
}
switch (_input_Xetype)
{
case global::none:
// Use ROIs 3 4
_output.LC_Xe133 =global::cst_k/qSqrt(\
(_input.ROI_con_counts_factor[3*factor_grpnum]*_input.ROI_con_counts_factor[3*factor_grpnum])/_input.ROI_netcts[3*cts_grpnum+pos_0_vari]+ \
( _input.ROI_con_counts_factor[4*factor_grpnum]*_input.ROI_con_counts_factor[4*factor_grpnum])/_input.ROI_netcts[4*cts_grpnum+pos_0_vari] \
);
if(qIsNaN( _output.LC_Xe133))
{
return false;
}
break;
case global::_131m:
// Use ROIs 3 7 9
_output.LC_Xe133 = global::cst_k/qSqrt(\
(_input.ROI_con_uncer[3*con_uncer_grpnum+pos_con]*_input.ROI_con_uncer[3*con_uncer_grpnum+pos_con])/_input.ROI_netcts[3*cts_grpnum+pos_0_vari]+ \
(_input.ROI_con_counts_factor[7*factor_grpnum]*_input.ROI_con_counts_factor[7*factor_grpnum])/_input.ROI_netcts[7*cts_grpnum+pos_0_vari]+ \
( _input.ROI_con_counts_factor[9*factor_grpnum]*_input.ROI_con_counts_factor[9*factor_grpnum])/_input.ROI_netcts[9*cts_grpnum+pos_0_vari] \
);
if(qIsNaN( _output.LC_Xe133))
{
return false;
}
break;
case global::_133m:
//# Use ROIs 3 8 10
_output.LC_Xe133 = global::cst_k/qSqrt(\
(_input.ROI_con_counts_factor[3*factor_grpnum]*_input.ROI_con_counts_factor[3*factor_grpnum])/_input.ROI_netcts[3*cts_grpnum+pos_0_vari]+ \
(_input.ROI_con_counts_factor[8*factor_grpnum]*_input.ROI_con_counts_factor[8*factor_grpnum])/_input.ROI_netcts[8*cts_grpnum+pos_0_vari]+ \
( _input.ROI_con_counts_factor[10*factor_grpnum]*_input.ROI_con_counts_factor[10*factor_grpnum])/_input.ROI_netcts[10*cts_grpnum+pos_0_vari] \
);
if(qIsNaN( _output.LC_Xe133))
{
return false;
}
break;
case global::both:
//# Use ROIs 3 7 8
_output.LC_Xe133 = global::cst_k/qSqrt(\
(_input.ROI_con_counts_factor[3*factor_grpnum]*_input.ROI_con_counts_factor[3*factor_grpnum])/_input.ROI_netcts[3*cts_grpnum+pos_0_vari]+ \
(_input.ROI_con_counts_factor[7*factor_grpnum]*_input.ROI_con_counts_factor[7*factor_grpnum])/_input.ROI_netcts[7*cts_grpnum+pos_0_vari]+ \
( _input.ROI_con_counts_factor[8*factor_grpnum]*_input.ROI_con_counts_factor[8*factor_grpnum])/_input.ROI_netcts[8*cts_grpnum+pos_0_vari] \
);
if(qIsNaN( _output.LC_Xe133))
{
return false;
}
break;
default:
break;
}
//计算没有使用,客户需要存储数据库
for(int pos=2;pos<=10;pos++)
{
if((2+3*pos)<_input.ROI_netcts.size() && (2*pos)<_input.ROI_con_uncer.size())
{
if(_input.ROI_con_uncer[2*pos]!=0.0)
{
double temp = global::cst_k*qSqrt(_input.ROI_netcts[2+3*pos])/(_input.ROI_netcts[3*pos]/_input.ROI_con_uncer[2*pos]);
_output.LC.append(temp);
temp= global::cst_k*qSqrt(_input.ROI_netcts[2+3*pos]);
if(qIsNaN(temp))
{
return false;
}
_output.LC_CTS.append(temp);
}
}
}
return true;
}

43
MDC.h Normal file
View File

@ -0,0 +1,43 @@
#ifndef MDC_H
#define MDC_H
////////////////////////////////////////////////////////////////////////
// 类说明此类为MDC计算
//
// 注意事项1、此类通过LC计算在进行MDC计算
// 2、传入参数应注意MDCI 结构
//
////////////////////////////////////////////////////////////////////////
#include "MDCDef.h"
#include "ProcessAlgorithmGlobalVar.h"
class CMdc
{
public:
/////////////////////////////////////////////////////////////////////
// 函数说明MDC MDC计算
// 参数说明MDCI :输入参数:介绍请查看结构说明
// Xetype :同位素类型:介绍请看数据结构说明
// MDCO :输出:介绍请查看结构说明
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool MDC(MDCI& _input,global::XeType& _input_Xetype,MDCO& _output);
private:
/////////////////////////////////////////////////////////////////////
// 函数说明LC LC计算
// 参数说明MDCI :输入参数:介绍请查看结构说明
// Xetype :同位素类型:介绍请看数据结构说明
// LCPara :输出:介绍请查看结构说明
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool LC(MDCI& _input,global::XeType _input_Xetype,LCPara& _output);
static bool MDCFromLC(MDCI& _input,global::XeType _input_Xetype,MDCO& _output);
static double LD(const double& _inputa);
//求平方 x*x
static double CalcSqrt(QVector<double>& _data,QVector<double>::size_type _pos);
//LD计算 (x+LD(X))
static double CalcLD(QVector<double>& _data,QVector<double>::size_type _pos);
};
#endif

38
MDCDef.h Normal file
View File

@ -0,0 +1,38 @@
#ifndef MDC_DEFINE_H
#define MDC_DEFINE_H
#include <QVector>
//MDC输入参数结构
typedef struct tagMDCI
{
QVector<double> ROI_netcts; // 感兴趣区净计数 [n..0] 净计数 [n..1]误差 3 [n...2] 0信号误差
QVector<double> ROI_con_uncer; // 感兴趣区浓度和不平和度 [n..0] 浓度 [n..1] 不确定度
QVector<double> ROI_con_counts_factor; // 感兴趣区浓度计数系数 [n...0] 系数
}*pMDCI,MDCI;
//LC参数结构
typedef struct tagLCPara
{
double LC_Xe135; //LC XE135
double LC_Xe131m; //LC XE131m
double LC_Xe133m; //LC XE133m
double LC_Xe133; //LC XE133
QVector<double> LC;
QVector<double> LC_CTS;
}*pLCPara,LCPara;
//MDC参数结构
typedef struct tagMDCPara
{
double MDC_Xe135; //MDC XE135
double MDC_Xe131m; //MDC XE131m
double MDC_Xe133m; //MDC XE133m
double MDC_Xe133; //MDC XE133
QVector<double> MDC;
QVector<double> MDC_CTS;
}*pMDCPara,MDCPara;
//MDC输出结构
typedef struct tagMDCO
{
LCPara lcPara;
MDCPara mdcPara;
}*pMDCO,MDCO;
#endif

84
MeteorologicalMessage.cpp Normal file
View File

@ -0,0 +1,84 @@
#include "MeteorologicalMessage.h"
#include <QFile>
using namespace MetData;
MeteorologicalMessage::MeteorologicalMessage():bIsValid(false)
{
}
MeteorologicalMessage::~MeteorologicalMessage()
{
}
bool MeteorologicalMessage::IsValid()
{
return bIsValid;
}
const QList<MetDataItem>& MeteorologicalMessage::GetMetDatas()
{
return met_datas;
}
const MetData::MetDataStationCode& MeteorologicalMessage::GetStationCode()
{
return station_code;
}
void MeteorologicalMessage::ClearData()
{
bIsValid = false;
met_datas.clear();
AbstractSpectrumDataMessage::ClearData();
}
bool MeteorologicalMessage::AnalyseMessgeBody(QTextStream &content)
{
const MessageInfo& msg = AbstractSpectrumDataMessage::GetMessageInfo();
if ( QLatin1String("MET")!=msg.data_type )
{
return bIsValid=false;
}
station_code = content.readLine();
met_datas.clear();
do
{
QString line = content.readLine();
if ( 0==line.compare(QLatin1String("STOP")) )
{
bIsValid = true; //检测到“STOP line”消息完整数据有效
break;
}
else if (content.atEnd())
{
bIsValid = false;
met_datas.clear();
break;
}
else
{
MetDataItem met_data_item;
QTextStream line_stream(&line);
line_stream >> met_data_item.met_start_date;
line_stream >> met_data_item.met_start_time;
line_stream >> met_data_item.met_end_date;
line_stream >> met_data_item.met_end_time;
line_stream >> met_data_item.average_outside_temperature;
line_stream >> met_data_item.average_wind_direction;
line_stream >> met_data_item.average_wind_speed;
line_stream >> met_data_item.average_barometric_reading;
line_stream >> met_data_item.humidity;
line_stream >> met_data_item.rainfall;
met_datas.append(met_data_item);
if (line_stream.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
}
while( !content.atEnd() );
return bIsValid;
}

28
MeteorologicalMessage.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef METEOROLOGICALDATA_H
#define METEOROLOGICALDATA_H
#include "AbstractSpectrumDataMessage.h"
#include "DataManager_Define.h"
#include <QTextStream>
class MeteorologicalMessage : public AbstractSpectrumDataMessage
{
public:
explicit MeteorologicalMessage();
~MeteorologicalMessage();
const QList<MetData::MetDataItem>& GetMetDatas();
const MetData::MetDataStationCode& GetStationCode();
virtual bool IsValid();
virtual void ClearData();
private:
virtual bool AnalyseMessgeBody(QTextStream& content);
private:
bool bIsValid;
MetData::MetDataStationCode station_code;
QList<MetData::MetDataItem> met_datas;
};
#endif // METEOROLOGICALDATA_H

View File

@ -0,0 +1,54 @@
#include <QSettings>
#include <QMutex>
#include "ProcessAlgorithmGlobalVar.h"
double global::cst_d_decay_133xeg_lam=1.5301e-6;
double global::cst_d_decay_131xem_lam=6.7416e-7;
double global::cst_d_decay_133xem_lam=3.6633e-6;
double global::cst_d_decay_135xeg_lam=2.10657e-5;
double global::cst_d_br_133xe_80=0.3800;
double global:: cst_d_br_133xe_30=0.49110;
double global::cst_d_br_131xem_30=0.5371;
double global::cst_d_br_133xem_30=0.55770;
double global::cst_d_br_135xeg=0.90200;
double global::cst_d_xe_air=0.087;
double global::cst_k = 1.64485;
int global::fit_type = 2;//默认为2次拟
QMutex mutex_algorithmvar_global;
void global::InitAlgorithmVar(QString& _cfgFileName)
{
QMutexLocker locker(&mutex_algorithmvar_global);
QSettings settings(_cfgFileName,QSettings::IniFormat);
settings.beginGroup(QLatin1String("algorithm"));
cst_d_decay_133xeg_lam = settings.value(QLatin1String("decay133xeglam"),cst_d_decay_133xeg_lam).toDouble();
cst_d_decay_131xem_lam = settings.value(QLatin1String("decay131xeglam"),cst_d_decay_131xem_lam).toDouble();
cst_d_decay_133xem_lam = settings.value(QLatin1String("decay133mxeglam"),cst_d_decay_133xem_lam).toDouble();
cst_d_decay_135xeg_lam = settings.value(QLatin1String("decay135xeglam"),cst_d_decay_135xeg_lam).toDouble();
cst_d_br_133xe_80 = settings.value(QLatin1String("dbr133xeg80"),cst_d_br_133xe_80).toDouble();
cst_d_br_133xe_30 = settings.value(QLatin1String("dbr133xeg30"),cst_d_br_133xe_30).toDouble();
cst_d_br_131xem_30 = settings.value(QLatin1String("131xem30"),cst_d_br_131xem_30).toDouble();
cst_d_br_133xem_30 = settings.value(QLatin1String("133xem30"),cst_d_br_133xem_30).toDouble();
cst_d_br_135xeg = settings.value(QLatin1String("135xeg"),cst_d_br_135xeg).toDouble();
cst_d_xe_air = settings.value(QLatin1String("dxeair"),cst_d_xe_air).toDouble();
cst_k = settings.value(QLatin1String("k"),cst_k).toDouble();
fit_type = settings.value(QLatin1String("fittype"),fit_type).toInt();
settings.endGroup();
}
void global::GenerateAlgorithmVar(QString& _cfgFileName)
{
QMutexLocker locker(&mutex_algorithmvar_global);
QSettings settings(_cfgFileName,QSettings::IniFormat);
settings.beginGroup(QLatin1String("algorithm"));
settings.setValue(QLatin1String("decay133xeglam"),cst_d_decay_133xeg_lam);
settings.setValue(QLatin1String("decay131xeglam"),cst_d_decay_131xem_lam);
settings.setValue(QLatin1String("decay133mxeglam"),cst_d_decay_133xem_lam);
settings.setValue(QLatin1String("decay135xeglam"),cst_d_decay_135xeg_lam);
settings.setValue(QLatin1String("dbr133xeg80"),cst_d_br_133xe_80);
settings.setValue(QLatin1String("dbr133xeg30"),cst_d_br_133xe_30);
settings.setValue(QLatin1String("131xem30"),cst_d_br_131xem_30);
settings.setValue(QLatin1String("133xem30"),cst_d_br_133xem_30);
settings.setValue(QLatin1String("135xeg"),cst_d_br_135xeg);
settings.setValue(QLatin1String("dxeair"),cst_d_xe_air);
settings.setValue(QLatin1String("k"),cst_k);
settings.setValue(QLatin1String("fittype"),fit_type);
settings.endGroup();
}

View File

@ -0,0 +1,25 @@
#ifndef PROCESS_ALGORITHM_GLOBALE_VAR_H
#define PROCESS_ALGORITHM_GLOBALE_VAR_H
#include <QString>
class global
{
//常数变量
public:
static double cst_d_decay_133xeg_lam;
static double cst_d_decay_131xem_lam;
static double cst_d_decay_133xem_lam;
static double cst_d_decay_135xeg_lam;
static double cst_d_br_133xe_80;
static double cst_d_br_133xe_30;
static double cst_d_br_131xem_30;
static double cst_d_br_133xem_30;
static double cst_d_br_135xeg;
static double cst_d_xe_air;
static double cst_k;
static int fit_type;
enum XeType{both,_131m,_133m,none};
static void InitAlgorithmVar(QString& _cfgFileName);
static void GenerateAlgorithmVar(QString& _cfgFileName);
};
#endif

281
ROI.cpp Normal file
View File

@ -0,0 +1,281 @@
#include "ROI.h"
#include "ProcessAlgorithmGlobalVar.h"
#include <QtMath>
bool CROI::CalcNetCounts(NetCountsI& _net_counts,QVector<double>& _output)
{
//计算同位素系数
bool bRet=false;
double F135;
double F133;
double F131m;
double F133m;
bRet = CalcF(_net_counts.time,global::cst_d_decay_135xeg_lam,F135);
if(!bRet)
{
return false;
}
bRet = CalcF(_net_counts.time,global::cst_d_decay_133xeg_lam,F133);
if(!bRet)
{
return false;
}
bRet = CalcF(_net_counts.time,global::cst_d_decay_131xem_lam,F131m);
if(!bRet)
{
return false;
}
bRet = CalcF(_net_counts.time,global::cst_d_decay_133xem_lam,F133m);
if(!bRet)
{
return false;
}
QVector<double> factor;
factor.append(F135);
factor.append(F133);
factor.append(F133);
factor.append(F131m);
factor.append(F133m);
factor.append(F133);
//通过系数计算净计数总数
bRet = CalcNetCountsByFactor(_net_counts,factor,_output);
if(!bRet)
{
return false;
}
return true;
}
bool CROI::CalcF(SGTime& _time,double _Xe,double& _output)
{
double drData = 1-qExp(-_Xe*_time.g_acquisition_real_time);
if(!_time.g_acquisition_live_time || !_time.s_acquisition_real_time || !drData)
{
return false;
}
else
{
drData = (_time.g_acquisition_real_time/_time.g_acquisition_live_time)*(_time.s_acquisition_live_time/_time.s_acquisition_real_time)*qExp(-_Xe*_time.gtos_acqStartDiff)* \
(1-qExp(-_Xe*_time.s_acquisition_real_time))/drData;
}
_output = drData;
return true;
}
bool CROI::CalcNetCountsByFactor(NetCountsI& _net_counts,QVector<double>& _factor,QVector<double>& _output)
{
QVector<double>::size_type size = _net_counts.g_netXe.size();
//参数传入判断
if(size!=_net_counts.s_netXe.size())
{
return false;
}
QVector<double> rData(size,0);
bool bPara1 = true;//默认为一行一个参数
QVector<double>::size_type bParaPos = 6; //系数起始位 此处理函数没有用到前六个系数
if(size>_factor.size()) //系数个数判断
{
bPara1 = false;
bParaPos = 0;
}
//提取数据
double factor = 1.0;
const int detuct_grpnm = 3;
const int pos_cts = 0; //扣除 计数偏移
const int pos_vari = 1; //偏差偏移
const int pos_level = 2; //关键水平偏移
const int pos_net_counts=0;//输出净计数 偏移值
const int pos_net_counts_vari=1; //净计数偏差 偏移值
const int pos_net_counts_0_vari=2; //净计数 0 信号偏移值
for(QVector<double>::size_type pos=2*detuct_grpnm;pos+pos_level<size;pos+=detuct_grpnm)
{
if(bParaPos<_factor.size())
{
factor = _factor.at(bParaPos);
if(bPara1)
{
bParaPos+=3;
}
else
{
bParaPos+=1;
}
}//获取系数
else
{
//系数等于上次系数
}
rData[pos+pos_net_counts] = _net_counts.s_netXe[pos+pos_cts] - factor*_net_counts.g_netXe[pos+pos_cts];
rData[pos+pos_net_counts_vari] = _net_counts.s_netXe[pos+pos_vari] + factor*factor*_net_counts.g_netXe[pos+pos_vari];
rData[pos+pos_net_counts_0_vari] = rData[pos+pos_vari] - qAbs(rData[pos+pos_cts]);
}
_output = rData;
return true;
}
bool CROI::CalcNetXects(NetXectsI& _input,QVector<double>& _output)
{
const int group_num = 3; //每组个数为3
const int pos_cts = 0; //净计数位置
const int pos_variance = 1; //误差位置
const int pos_level =2; //关键水平位置
const int pos_one_ratios =-1; //比率第一组相对下标值
const int pos_two_ratios =6; //比率第二组相对下标值
QVector<double> rData(group_num,0);
QVector<double>::size_type size = _input.roi_cts.size();
//大小判断
if(size-1+pos_two_ratios>=_input.roi_ratios.size()||size>_input.roi_detbg_cts.size())
{
return false;
}
// QVector<double>::size_type pos = 0;
double dKTemp;
double dVTemp;
double dLTemp;
double dKtempFactor=0.0;
double dVTempFactor=0.0;
for(QVector<double>::size_type pos=0;pos<size;pos++)
{
dKtempFactor=0.0;
dVTempFactor=0.0;
if(0 == pos) //第零组不做处理
{
//
}
else
{
if(rData.at(1*group_num+pos_cts)>rData.at(1*group_num+pos_level))
{
if(pos>=3)//第三组以后
{
double qvctRatiosData1 = _input.roi_ratios.at(pos+pos_one_ratios);
double qvctRatiosData2 = _input.roi_ratios.at(pos+pos_two_ratios);
if(rData.at(3*group_num+pos_cts)>rData.at(3*group_num+pos_level))//第三组k 大于第三组lk
{
dKtempFactor = -(qvctRatiosData1*rData.at(1*group_num+pos_cts) + qvctRatiosData2*rData.at(3*group_num+pos_cts));
dVTempFactor = qvctRatiosData1*qvctRatiosData1*rData.at(1*group_num+pos_variance)+qvctRatiosData2*qvctRatiosData2*rData.at(3*group_num+pos_variance);
}
else
{
dKtempFactor = -(qvctRatiosData1*rData.at(1*group_num+pos_cts));
dVTempFactor = qvctRatiosData1*qvctRatiosData1*rData.at(1*group_num+pos_variance);
}
}
else // 1 2 组处理
{
double qvctRatiosData = _input.roi_ratios.at(pos+pos_one_ratios);
dKtempFactor = -(qvctRatiosData*rData.at(1*group_num+pos_cts));
dVTempFactor = qvctRatiosData*qvctRatiosData*rData.at(1*group_num+pos_variance);
}
}
else
{
if(pos>=3)//第三组以后
{
double qvctRatiosData2 = _input.roi_ratios.at(pos+pos_two_ratios);
if(rData.at(3*group_num+pos_cts)>rData.at(3*group_num+pos_level))//第三组k 大于第三组lk
{
dKtempFactor = -(qvctRatiosData2*rData.at(3*group_num+pos_cts));
dVTempFactor = qvctRatiosData2*qvctRatiosData2*rData.at(3*group_num+pos_variance);
}
else
{
//没有系数
}
}
else// 1 2 组处理
{
//没有系数
}
}
}
//净计数
dKTemp = _input.roi_cts.at(pos)-_input.ratio*_input.roi_detbg_cts.at(pos)+dKtempFactor;
//不确定度
dVTemp = _input.roi_cts.at(pos)+_input.ratio*_input.ratio*_input.roi_detbg_cts.at(pos)+dVTempFactor;
//关键水平
if((dVTemp-dKTemp)<0)
{
return false;
}
dLTemp = global::cst_k*qSqrt(dVTemp-dKTemp);
rData.append(dKTemp);
rData.append(dVTemp);
rData.append(dLTemp);
}
_output = rData;
return true;
}
bool CROI::ExtractROIcts(ROIctsI& _input,ROIctsO& _output)
{
bool bRet = false;
//获取总计数
bRet = CalcROIctsByBoundary(_input.roi_boundary,_input.histogram,_output.roi_cts);
if(!bRet)
{
return false;
}
return true;
}
bool CROI::CalcROIctsByBoundary(ROIBoundary& _boundary,Histogram& _histogram,QVector<double>& _output)
{
//10个通道数据
QVector<double> qdDataTemp(10,0);
QString qsDataTemp;
//参数判断
if(_boundary.ROI_B_start_x.size()<10||\
_boundary.ROI_B_stop_x.size()<10||\
_boundary.ROI_G_start_y.size()<10||\
_boundary.ROI_G_stop_y.size()<10)
{
return false;
}
for(int roi=0;roi<10;roi++) //提取
{
qdDataTemp[roi] = 0;
QVector<int>::size_type base = 0;
// int row = 0;
int y=0;
for(;y<_boundary.ROI_G_start_y[roi];y++)
{
//row
}
base = y;
// QVector<int>::size_type y=_boundary.ROI_G_start_y[roi]-1;
// base = y+1;
for(y=0;y<(_boundary.ROI_G_stop_y[roi]-_boundary.ROI_G_start_y[roi]+1);y++)
{
for(QVector<int>::size_type x=_boundary.ROI_B_start_x[roi];x<=_boundary.ROI_B_stop_x[roi];x++)
{
if((base+y)*_histogram.b_channels+x<_histogram.counts.size()&&((base+y)*_histogram.b_channels+x)>=0)
{
qdDataTemp[roi] += _histogram.counts.at((base+y)*_histogram.b_channels+x);
}
else
{
return false;
}
}
}
}
_output = qdDataTemp;
return true;
}
bool CROI::CalcLimitToBoundary(QVector<double>& _ROI_limit,QVector<double>& _cal_coeffs,QVector<int>& _output)
{
_output.clear();
if(_cal_coeffs.size()<3||_ROI_limit.size()<0) //刻度系数大小错误 或 限制数据不存在
{
return false;
}
int dataTemp = 0;
for(QVector<double>::size_type pos=0;pos<_ROI_limit.size();pos++)
{
dataTemp = int(_cal_coeffs[0]+_cal_coeffs[1]*_ROI_limit[pos]+_cal_coeffs[2]*_ROI_limit[pos]*_ROI_limit[pos]+0.5);
_output.append(dataTemp);
}
return true;
}

91
ROI.h Normal file
View File

@ -0,0 +1,91 @@
#ifndef ROI_H
#define ROI_H
////////////////////////////////////////////////////////////////////////
// 类说明:此类为: 感兴趣区总计数 扣除探测器本底计数 净计数计算
//
// 注意事项:探测器本底计数 净计数有填充0的情况
// ExtractROIcts 提取感兴趣区总计数 用到了2poly拟合方程 如果用高斯拟合的话需要扩展函数
//
////////////////////////////////////////////////////////////////////////
#include "ROIDef.h"
class CROI
{
public:
/////////////////////////////////////////////////////////////////////
// 函数说明ExtractROIcts 提取感兴趣区总计数
// 参数说明ROIctsI :输入参数 请查看结构说明
// ROIctsO :输出 请查看结构说明
//
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool ExtractROIcts(ROIctsI& _input,ROIctsO& _output);
/////////////////////////////////////////////////////////////////////
// 函数说明CalcNetXects 扣除探测器本底谱的样品谱或气体谱ROI计数
// 参数说明NetXectsI : 输入参数,请查看结构说明
// _output [n..0] 计数 [n..1]计数偏差 [n..2]感兴趣区关键水平 [0-2]=0;
// the ROIs are numbered from one, so the first three
// positions are filled with zeroes.
//
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool CalcNetXects(NetXectsI& _input,QVector<double>& _output);
/////////////////////////////////////////////////////////////////////
// 函数说明CalcNetCounts 净计数计数
// 参数说明NetCountsI : 请查看结构说明
// _output: [n..0]净计数 [n..1]净计数偏差 [n..2]0信号偏差 [0-5]=0
// The array is indexed from zero to the maximum ROI
// number, and the ROIs analysed are numbered from two
// (Rn is not analysed), so the first 2 x 3 positions are
// filled with zeroes.
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool CalcNetCounts(NetCountsI& _net_counts,QVector<double>& _output);
private:
/////////////////////////////////////////////////////////////////////
// 函数说明CalcF 同位素计算
// 参数说明SGTime 样品普 气体本地谱时间参数
// _Xe 同位素常量值
// _output 返回值
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool CalcF(SGTime& _time,double _Xe,double& _output);
/////////////////////////////////////////////////////////////////////
// 函数说明CalcNetCounts 净计数计数
// 参数说明NetCountsI : 请查看结构说明
// _output: [n..0]净计数 [n..1]净计数偏差 [n..2]0信号偏差 [0-5]=0
// The array is indexed from zero to the maximum ROI
// number, and the ROIs analysed are numbered from two
// (Rn is not analysed), so the first 2 x 3 positions are
// filled with zeroes.
// _factor:系数
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool CalcNetCountsByFactor(NetCountsI& _net_counts,QVector<double>& _factor,QVector<double>& _output);
/////////////////////////////////////////////////////////////////////
// 函数说明CalcLimitToBoundary 计算限值的边界值
// 参数说明_ROI_limit :限值
// _cal_coeffs对应的刻度方程系数
// _output:返回值
//
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool CalcLimitToBoundary(QVector<double>& _ROI_limit,QVector<double>& _cal_coeffs,QVector<int>& _output);
/////////////////////////////////////////////////////////////////////
// 函数说明CalcROIctsByBoundary 通过边界值计算感兴趣总计数
// 参数说明_boundary :边界值
// _output:返回值
//
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool CalcROIctsByBoundary(ROIBoundary& _boundary,Histogram& _histogram,QVector<double>& _output);
};
#endif

143
ROIConUncer.cpp Normal file
View File

@ -0,0 +1,143 @@
#include "ROIConUncer.h"
#include "ProcessAlgorithmGlobalVar.h"
#include <QtMath>
double CRoiConUncer::CalcCorrect(SPara& _input,double _Xe)
{
double rData;
rData = (1-qExp(-_Xe*_input.s_coll_interval_time))* \
qExp(-_Xe*_input.s_pre_time)* \
(1-qExp(-_Xe*_input.s_acquisition_real_time));
return rData;
}
bool CRoiConUncer::CalcConc(SPara& _input,double _Xe,double& _output)
{
double rData=0.0;
if(CalcCorrect(_input,_Xe)==0.0||global::cst_d_xe_air==0.0||_input.s_volume_of_Xe/global::cst_d_xe_air==0.0)
{
return false;
}
else
{
rData = 1000*_Xe*_Xe/CalcCorrect(_input,_Xe)*(_input.s_coll_interval_time/(_input.s_volume_of_Xe/global::cst_d_xe_air));
}
_output = rData;
return true;
}
bool CRoiConUncer::CalcRoiConUncer(ConUncerI& _input,ConUncerO& _output)
{
bool bRet = false;
Factor factor; //系数处理
double dData;
bRet = CalcConc(_input.SPara, global::cst_d_decay_135xeg_lam,dData);
if(!bRet)
{
return false;
}
factor.calcFactor.append(dData);
bRet = CalcConc(_input.SPara, global::cst_d_decay_133xeg_lam,dData);
if(!bRet)
{
return false;
}
factor.calcFactor.append(dData);
factor.calcFactor.append(dData);
bRet = CalcConc(_input.SPara, global::cst_d_decay_131xem_lam,dData);
if(!bRet)
{
return false;
}
factor.calcFactor.append(dData);
bRet = CalcConc(_input.SPara, global::cst_d_decay_133xem_lam,dData);
if(!bRet)
{
return false;
}
factor.calcFactor.append(dData);
bRet = CalcConc(_input.SPara, global::cst_d_decay_133xeg_lam,dData);
if(!bRet)
{
return false;
}
factor.calcFactor.append(dData);
factor.bgbrFactor.append(global::cst_d_br_135xeg);
factor.bgbrFactor.append(global::cst_d_br_133xe_80);
factor.bgbrFactor.append(global::cst_d_br_133xe_30);
factor.bgbrFactor.append(global::cst_d_br_131xem_30);
factor.bgbrFactor.append(global::cst_d_br_133xem_30);
factor.bgbrFactor.append(global::cst_d_br_133xe_30);
//通过系数和输入值计算输出值
bRet = CalcRoiConUncerByFactor(_input._netCts,_input.s_bg_efficiency,factor,_output);
if(!bRet)
{
return false;
}
return true;
}
bool CRoiConUncer::CalcRoiConUncerByFactor(QVector<double>& _netCts,QVector<double>& _s_ROI_number_eff,Factor& _factor,ConUncerO& _output)
{
QVector<double> con_uncer(4,0); //浓度和不确定度 前两组置零
QVector<double> con_counts(2,0); //不确定度系数
double dCalcFactor=0.0;
double dbgbrFactor=0.0;
const int netCtsGroupNmber = 3; //净计数一组三个数据
QVector<double>::size_type qdNetctsPos=6;
QVector<double>::size_type qdBgeffsPos=0;
const int con_uncer_grpnm = 10;
const int pos_net_cts_vari = 1;
//提取数据
for(int pos=0;pos<con_uncer_grpnm;pos++)
{
//提取系数,最后的系数保持不变 一直使用
if(pos<_factor.bgbrFactor.size())
{
dbgbrFactor = _factor.bgbrFactor[pos];
}
if(pos<_factor.calcFactor.size())
{
dCalcFactor = _factor.calcFactor[pos];
}
if(_netCts.size()<=qdNetctsPos+pos_net_cts_vari||_s_ROI_number_eff.size()<=qdBgeffsPos)
{
break;
}
double dataDCTmep=0.0;
double dataCTmep=0.0;
if(qdNetctsPos+pos_net_cts_vari<_netCts.size()&&qdBgeffsPos<_s_ROI_number_eff.size())
{
double divsion = 0.0;
divsion = (_s_ROI_number_eff[qdBgeffsPos]*dbgbrFactor);
if(divsion == 0)
{
return false;
}
dataCTmep = (_netCts[qdNetctsPos]/divsion)*dCalcFactor;
divsion = _netCts[qdNetctsPos];
if(divsion == 0 || _netCts[qdNetctsPos+pos_net_cts_vari]<0)
{
return false;
}
dataDCTmep = dataCTmep*qSqrt(_netCts[qdNetctsPos+pos_net_cts_vari])/divsion;
con_uncer.append(dataCTmep); //浓度
con_uncer.append(dataDCTmep);//不确定度
divsion = dataCTmep;
if(divsion == 0)
{
return false;
}
con_counts.append(_netCts[qdNetctsPos]/dataCTmep);//不确定度系数
qdNetctsPos+=netCtsGroupNmber;
qdBgeffsPos++;
}
else
{
return false;
}
}
_output.ROI_con_uncer = con_uncer;
_output.ROI_con_counts_factor = con_counts;
return true;
}

38
ROIConUncer.h Normal file
View File

@ -0,0 +1,38 @@
#ifndef ROI_CON_UNCER_H
#define ROI_CON_UNCER_H
////////////////////////////////////////////////////////////////////////
// 类说明:此类为: 感兴趣区浓度和不确定度计算
//
// 注意事项1、传入参数应注意 结构
//
////////////////////////////////////////////////////////////////////////
#include <QVector>
#include "ROIConUncerDef.h"
class CRoiConUncer
{
public:
/////////////////////////////////////////////////////////////////////
// 函数说明CRoiConUncer 计算浓度和不确定度
// 参数说明ConUncerI:输入参数:请查看结构定义
// _output: 浓度和不确定度 [n..0]浓度 [n..1]不确定度
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool CalcRoiConUncer(ConUncerI& _input,ConUncerO& _output);
private:
/////////////////////////////////////////////////////////////////////
// 函数说明CRoiConUncer 计算浓度和不确定度
// 参数说明_netcts // 感兴趣区净计数 [n..0] 净计数 [n..1]误差 3 [n...2] 0信号误差
// _s_ROI_number_eff 感兴趣区能效个数
// _factor: 系数
// _output: 浓度和不确定度 [n..0]浓度 [n..1]不确定度
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool CalcRoiConUncerByFactor(QVector<double>& _netCts,QVector<double>& _s_ROI_number_eff,Factor& _factor,ConUncerO& _output);
static double CalcCorrect(SPara& _input,double _Xe);
static bool CalcConc(SPara& _input,double _Xe,double& _output);
};
#endif

33
ROIConUncerDef.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef ROI_CON_UNCER_DEFINE_H
#define ROI_CON_UNCER_DEFINE_H
#include <QVector>
//浓度和不确定度输出数据结构
typedef struct tagConUncerO
{
QVector<double> ROI_con_uncer; //感兴趣区浓度和不确定度 [n..0]浓度 [n..1]不确定度
QVector<double> ROI_con_counts_factor; //感兴趣区浓度计数系数 [n..0]系数
}*pConUncerO,ConUncerO;
typedef struct tagFactor
{
QVector<double> bgbrFactor; // #Branching ratio for betakeV gamma decay
QVector<double> calcFactor; //calc for #Decay constant for XE
}*pFactor,Factor;
//样品谱系数
typedef struct tagSPara
{
double s_coll_interval_time; //样本谱 Collection stop 和start 间隔时间
double s_pre_time; //样品谱 Collection stop 和 Acquisition start 间隔时间
double s_acquisition_real_time; //acquisition real time (s)
double s_volume_of_Xe; //sample volume of Xe (cm 3 )
}*pSPara,SPara;
//浓度和不确定度输入参数结构
typedef struct tagConUncerI
{
QVector<double> _netCts; // 感兴趣区净计数 [n..0] 净计数 [n..1]误差 3 [n...2] 0信号误差
// QVector<double> _s_ROI_number_eff; //感兴趣区能效个数
QVector<double> s_bg_efficiency; //样品谱 β-γ coincidence efficiency (counts in ROI/β-γ pair emitted)
tagSPara SPara;
}*pConUnerI,ConUncerI;
#endif

73
ROIDef.h Normal file
View File

@ -0,0 +1,73 @@
#ifndef ROI_DEFINE_H
#define ROI_DEFINE_H
#include <QVector>
#include <QString>
//感应区限值结构
/*typedef struct tagROILimit
{
QVector<double> ROI_B_start_x1;// ROI B-rang start,x1(keV)
QVector<double> ROI_B_stop_x2; // ROI B_rang stop,x2(kev)
QVector<double> ROI_G_start_y1;// ROI G-rang start,y1(keV)
QVector<double> ROI_G_stop_y2; // ROI G_rang stop,y2(kev)
}*pROILimit,ROILimit;
*/
//感兴趣区 边界值
typedef struct tagROIBoundary
{
QVector<int> ROI_B_start_x;
QVector<int> ROI_B_stop_x;
QVector<int> ROI_G_start_y;
QVector<int> ROI_G_stop_y;
}*pROIBoundary,ROIBoundary;
typedef struct tagHistogram
{
long b_channels; // β-channels
long g_channels; // γ-channels
QVector<long long> counts; // counts at channels
}*pHistogram,Histogram;
//计算感兴趣计数时需要传入数据的结构
typedef struct tagROIctsI
{
ROIBoundary roi_boundary;
Histogram histogram;
}*pROIctsI,ROIctsI;
//感兴趣区计数返回值结构
//感兴趣区计数返回值
typedef struct tagROIctsO
{
QVector<double> roi_cts; //感兴趣兴趣区总计数
}*pROIctsO,ROIctsO;
//计算感兴趣区净计数输入参数
typedef struct tagROINetXectsI
{
QVector<double> roi_cts; //样品普或者气体谱感兴趣总计数
QVector<double> roi_ratios; //感兴趣比率
QVector<double> roi_detbg_cts; //探测器本地谱感兴区总计数
double ratio; //样品谱LT和气体本底谱/探测器本底谱LT 比率值
}*pNetXectsI,NetXectsI;
//计算净计数总数计算输入参数
//数据校验结构 c
typedef struct tagSGTime //样品普和气体本地谱时间参数
{
double s_acquisition_real_time; //acquisition real time (s)
double s_acquisition_live_time; //acquisition live time (s)
double g_acquisition_real_time; //acquisition real time (s)
double g_acquisition_live_time; //acquisition live time (s)
double gtos_acqStartDiff; //气体本地谱与样品谱acquistion的相对时间
}*pSGTime,SGTime;
typedef struct tagROINetCountsI
{
QVector<double> s_netXe; //样品谱到探测器本地谱计数 [n..0] 计数 [n..1]计数偏差 [n..2]感兴趣区关键水平 [0-2]=0;
// the ROIs are numbered from one, so the first three
// positions are filled with zeroes.
QVector<double> g_netXe; //气体本地谱道探测器本地谱计数 [n..0] 计数 [n..1]计数偏差 [n..2]感兴趣区关键水平 [0-2]=0;
// the ROIs are numbered from one, so the first three
// positions are filled with zeroes.
SGTime time;
}*pNetCountsI,NetCountsI;
#endif

985
RadionuclideMessage.cpp Normal file
View File

@ -0,0 +1,985 @@
#include "RadionuclideMessage.h"
#include <QFile>
#include <QTextStream>
#include <QDebug>
#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 ]
}
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
{ // 数据错误,数据有效
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();
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)
{
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::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;
}

57
RadionuclideMessage.h Normal file
View File

@ -0,0 +1,57 @@
#ifndef RADIONUCLIDEMESSAGE_H
#define RADIONUCLIDEMESSAGE_H
#include "AbstractSpectrumDataMessage.h"
#include "DataManager_Define.h"
#include <QVariant>
class QTextStream;
class RadionuclideMessage : public AbstractSpectrumDataMessage
{
public:
explicit RadionuclideMessage();
~RadionuclideMessage();
bool AnalysePHD_Msg(QString &msg_string);
bool AnalysePHD_File(QString phd_name);
RadionuclideData::AnalyseDataType GetAnalyseDataType();
const QVariant GetBlockData(QString& block_name);
virtual bool IsValid();
virtual void ClearData();
static QVector<long> GetHistogramProjectedDataValue(
RadionuclideData::HistogramBlock &histogram, Qt::Orientation orientation);
private:
void InitBlockFlagInfo();
bool AnalyseMessgeBody(QTextStream& content);
bool Analyse_Header_Block(QTextStream& content, QString& nextBlock);
bool Analyse_Comment_Block(QTextStream& content, QString& nextBlock);
bool Analyse_Collection_Block(QTextStream& content, QString& nextBlock);
bool Analyse_Acquisition_Block(QTextStream& content, QString& nextBlock);
bool Analyse_Processing_Block(QTextStream& content, QString& nextBlock);
bool Analyse_Sample_Block(QTextStream& content, QString& nextBlock);
bool Analyse_g_Energy_Block(QTextStream& content, QString& nextBlock);
bool Analyse_b_Energy_Block(QTextStream& content, QString& nextBlock);
bool Analyse_g_Resolution_Block(QTextStream& content, QString& nextBlock);
bool Analyse_b_Resolution_Block(QTextStream& content, QString& nextBlock);
bool Analyse_g_Efficiency_Block(QTextStream& content, QString& nextBlock);
bool Analyse_ROI_Limits_Block(QTextStream& content, QString& nextBlock);
bool Analyse_bg_Efficiency_Block(QTextStream& content, QString& nextBlock);
bool Analyse_TotalEff_Block(QTextStream& content, QString& nextBlock);
bool Analyse_Ratios_Block(QTextStream& textStream, QString& nextBlock);
bool Analyse_g_Spectrum_Block(QTextStream& content, QString& nextBlock);
bool Analyse_b_Spectrum_Block(QTextStream& content, QString& nextBlock);
bool Analyse_Histogram_Block(QTextStream& content, QString& nextBlock);
bool Analyse_Calibration_Block(QTextStream& content, QString& nextBlock);
bool Analyse_Certificate_Block(QTextStream& content, QString& nextBlock);
bool Verity_SampleReferenceId(QString srid);
private:
bool bIsValid;
QStringList block_flag;
QVariantMap radionuclide_msg_data; // 因解析的数据的结构不同请其统一存储至QVariantMap容器中
RadionuclideData::AnalyseDataType analyse_data_type;
};
#endif // RADIONUCLIDEMESSAGE_H

6
ReadPHDFile.pri Normal file
View File

@ -0,0 +1,6 @@
INCLUDEPATH += $$PWD/include
#LIBS += -L$$PWD/lib -larmadillo
LIBS += -L$$PWD/lib -lblas
LIBS += -L$$PWD/lib -llapack
LIBS += -L$$PWD/lib -lgfortran

94
ReadPHDFile.pro Normal file
View File

@ -0,0 +1,94 @@
#-------------------------------------------------
#
# Project created by QtCreator 2015-12-28T13:49:57
#
#-------------------------------------------------
include(common.pri)
#QT += core gui xml
QT -= gui
#QT += gui
#QT += core
#greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ReadPHDFile
TEMPLATE = lib
#TEMPLATE = app
CONFIG += shared
CONFIG += c++11
#DEFINES += GAMMAANALYALG_LIBRARY
CONFIG(debug,debug|release){
DEFINES += DEBUG_INFO_OUTPUT
}
OBJECTS_DIR = $$PROJECT_OBJ/ReadPHDFile
MOC_DIR = $$PROJECT_MOC/ReadPHDFile
RCC_DIR = $$PROJECT_RCC/ReadPHDFile
UI_DIR = $$PROJECT_UI/ReadPHDFile
DESTDIR = $$PROJECT_LIB
SOURCES += \
AbstractSpectrumDataMessage.cpp \
AlertMessage.cpp \
BgWork.cpp \
CplusToJava.cpp \
Fit.cpp \
MDC.cpp \
MeteorologicalMessage.cpp \
ProcessAlgorithmGlobalVar.cpp \
ROI.cpp \
ROIConUncer.cpp \
RadionuclideMessage.cpp \
StateOfHealthMessage.cpp \
XeConUncer.cpp \
org_jeecg_modules_native_jni_EnergySpectrumHandler.cpp
HEADERS += \
AbstractSpectrumDataMessage.h \
AlertMessage.h \
BgWork.h \
BgWorkDef.h \
CplusToJava.h \
DataManager_Define.h \
Fit.h \
FitDef.h \
MDC.h \
MDCDef.h \
MeteorologicalMessage.h \
ProcessAlgorithmGlobalVar.h \
ROI.h \
ROIConUncer.h \
ROIConUncerDef.h \
ROIDef.h \
RadionuclideMessage.h \
StateOfHealthMessage.h \
XeConUncer.h \
XeConUncerDef.h \
org_jeecg_modules_native_jni_EnergySpectrumHandler.h
#FORMS += mainwindow.ui
win32:INCLUDEPATH += "C:/java64/jdk/include"
win32:INCLUDEPATH += "C:/java64/jdk/include/win32"
QMAKE_LFLAGS += -Wl,--kill-at
#LIBS += -L$$PROJECT_LIB -l$$DATAMANAGER_NAME
#LIBS += -L$$PROJECT_LIB -lgammaAlgorithm
#LIBS += -L$$PWD/lib -larmadillo
#LIBS += -L$$PWD/lib -lblas
#LIBS += -L$$PWD/lib -llapack
DISTFILES += # GammaAnalyALG.pri #\
#helpApat_list.txt \
#msgparse.txt \
#struct_UserData.txt \
#importMsg.txt \
#aatami_start.txt \
#loadCtrlFcn.txt \
#FitFunc.txt \
#loadCtrlGUI.txt \
#setupInit.txt \
#standardsetting.txt \

337
ReadPHDFile.pro.user Normal file
View File

@ -0,0 +1,337 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.9.1, 2024-05-10T10:35:27. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{358ed4f8-d345-4a95-a955-ca552bad5e85}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
<value type="QString">-fno-delayed-template-parsing</value>
</valuelist>
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.13.0 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.13.0 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5130.win64_mingw73_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/project/build-ReadPHDFile-Desktop_Qt_5_13_0_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/project/build-ReadPHDFile-Desktop_Qt_5_13_0_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/project/build-ReadPHDFile-Desktop_Qt_5_13_0_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy Configuration</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
<value type="QString">cpu-cycles</value>
</valuelist>
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
<value type="int" key="Analyzer.Perf.Frequency">250</value>
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">21</value>
</data>
<data>
<variable>Version</variable>
<value type="int">21</value>
</data>
</qtcreator>

521
StateOfHealthMessage.cpp Normal file
View File

@ -0,0 +1,521 @@
#include "StateOfHealthMessage.h"
#include <QFile>
using namespace RMSSOHData;
StateOfHealthMessage::StateOfHealthMessage()
{
bIsValid = false;
InitBlockFlagInfo();
}
StateOfHealthMessage::~StateOfHealthMessage()
{
}
bool StateOfHealthMessage::IsValid()
{
return bIsValid;
}
const QVariant StateOfHealthMessage::GetBlockData(QString &block_name)
{
if ( rmssoh_msg_data.contains(block_name) )
{
return rmssoh_msg_data[block_name];
}
return QVariant();
}
void StateOfHealthMessage::ClearData()
{
bIsValid = false;
rmssoh_msg_data.clear();
AbstractSpectrumDataMessage::ClearData();
}
void StateOfHealthMessage::InitBlockFlagInfo()
{
block_flag.append(QLatin1String("#Header")); // [ 0 ]
block_flag.append(QLatin1String("#Comment")); // [ 1 ]
block_flag.append(QLatin1String("#AirSamplerFlow")); // [ 2 ]
block_flag.append(QLatin1String("#AirSamplerEnv")); // [ 3 ]
block_flag.append(QLatin1String("#DetEnv")); // [ 4 ]
block_flag.append(QLatin1String("#NIMBIN")); // [ 5 ]
block_flag.append(QLatin1String("#PowerSupply")); // [ 6 ]
block_flag.append(QLatin1String("#EquipStatus")); // [ 7 ]
block_flag.append(QLatin1String("#TamperEnv")); // [ 8 ]
block_flag.append(QLatin1String("#ProcessSensors")); // [ 9 ]
block_flag.append(QLatin1String("#Chromatogram")); // [ 10 ]
block_flag.append(QLatin1String("STOP")); // [ STOP ]
block_flag.append(QLatin1String("BEGIN")); // [ BEGIN ]
}
bool StateOfHealthMessage::AnalyseMessgeBody(QTextStream &content)
{
const MessageInfo& msg = AbstractSpectrumDataMessage::GetMessageInfo();
if ( QLatin1String("RMSSOH") != msg.data_type )
{
return bIsValid = false;
}
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_AirSamplerFlow_Block(content, line);
}
else if ( 0==line.compare(block_flag.at(3)) && bRet)
{
bRet &= Analyse_AirSamplerEnv_Block(content, line);
}
else if ( 0==line.compare(block_flag.at(4)) && bRet)
{
bRet &= Analyse_DetEnv_Block(content, line);
}
else if ( 0==line.compare(block_flag.at(5)) && bRet)
{
bRet &= Analyse_NIMBIN_Block(content, line);
}
else if ( 0==line.compare(block_flag.at(6)) && bRet)
{
bRet &= Analyse_PowerSupply_Block(content, line);
}
else if ( 0==line.compare(block_flag.at(7)) && bRet)
{
bRet &= Analyse_EquipStatus_Block(content, line);
}
else if ( 0==line.compare(block_flag.at(8)) && bRet)
{
bRet &= Analyse_TamperEnv_Block(content, line);
}
else if ( 0==line.compare(block_flag.at(9)) && bRet)
{
bRet &= Analyse_ProcessSensors_Block(content, line);
}
else if ( 0==line.compare(block_flag.at(10)) && bRet)
{
bRet &= Analyse_ChromatogramBlock(content, line);
}
else
{ // 数据错误,数据有效
bIsValid = false;
bRet = bIsValid;
}
if (0==line.compare(block_flag.at(11)) && bRet )
{
bIsValid = true; //检测到“STOP line”消息完整数据有效
break;
}
else if (content.atEnd())
{
bIsValid = false;
rmssoh_msg_data.clear();
bRet = bIsValid;
break;
}
}
while( bRet );
return bRet;
}
bool StateOfHealthMessage::Analyse_Header_Block(QTextStream &content, QString &nextBlock)
{
HeaderBlock Header;
QString &line = nextBlock;
Header.designator = line.mid(8);
content >> Header.station_code >> Header.detector_code;
content >> Header.start_date >> Header.start_time >> Header.end_date >> Header.end_time >> Header.transmit_date >> Header.transmit_time;
rmssoh_msg_data.insert(block_flag.at(0), QVariant::fromValue(Header));
content >> nextBlock;
content.readLine();
return (content.status()==QTextStream::Ok)?true:false;
}
bool StateOfHealthMessage::Analyse_Comment_Block(QTextStream& content, QString& nextBlock)
{
CommentBlock comment;
nextBlock = content.readLine();
while ( !block_flag.contains(nextBlock) && !content.atEnd())
{
if ( !nextBlock.isEmpty() )
{
comment.append(nextBlock + QLatin1String("\n"));
}
nextBlock = content.readLine();
}
rmssoh_msg_data.insert(block_flag.at(1), QVariant::fromValue(comment));
return (content.status()==QTextStream::Ok)?true:false;
}
bool StateOfHealthMessage::Analyse_AirSamplerFlow_Block(QTextStream &content, QString &nextBlock)
{
AirSamplerFlowBlock air_sampler_flow;
int row_count = 0;
nextBlock = content.readLine();
while (!block_flag.contains(nextBlock) && !content.atEnd())
{
double average_flow_rate;
double flow_rate_standard_deviation;
QString start_date;
QString start_time;
long interval_duration;
QTextStream line_content(&nextBlock);
line_content >> average_flow_rate >> flow_rate_standard_deviation >> start_date >> start_time >> interval_duration;
air_sampler_flow.average_flow_rate << average_flow_rate;
air_sampler_flow.flow_rate_standard_deviation << flow_rate_standard_deviation;
air_sampler_flow.start_date << start_date;
air_sampler_flow.start_time << start_time;
air_sampler_flow.interval_duration << interval_duration;
++ row_count;
nextBlock = content.readLine();
if (line_content.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
air_sampler_flow.record_count = row_count;
rmssoh_msg_data.insert( block_flag.at(2), QVariant::fromValue(air_sampler_flow) );
return (content.status()==QTextStream::Ok)?true:false;
}
bool StateOfHealthMessage::Analyse_AirSamplerEnv_Block(QTextStream &content, QString &nextBlock)
{
AirSamplerEnvBlock air_sampler_env;
int row_count = 0;
nextBlock = content.readLine();
while (!block_flag.contains(nextBlock) && !content.atEnd())
{
double temperature;
double pressure;
QString date;
QString time;
long interval_duration;
QTextStream line_content(&nextBlock);
line_content >> temperature >> pressure >> date >> time >> interval_duration;
air_sampler_env.temperature << temperature;
air_sampler_env.pressure << pressure;
air_sampler_env.date << date;
air_sampler_env.time << time;
air_sampler_env.interval_duration << interval_duration;
++ row_count;
nextBlock = content.readLine();
if (line_content.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
air_sampler_env.record_count = row_count;
rmssoh_msg_data.insert( block_flag.at(3), QVariant::fromValue(air_sampler_env) );
return (content.status()==QTextStream::Ok)?true:false;
}
bool StateOfHealthMessage::Analyse_DetEnv_Block(QTextStream &content, QString &nextBlock)
{
DetEnvBlock det_env;
int row_count = 0;
nextBlock = content.readLine();
while (!block_flag.contains(nextBlock) && !content.atEnd())
{
double room_temperature;
QString detector_shield_status;
short humidity;
long voltage;
long crystal_temperature;
QString electric_cooler_status;
double fill_fraction;
double leakage;
QString date;
QString time;
long interval_duration;
QTextStream line_content(&nextBlock);
line_content >> room_temperature >> detector_shield_status >> humidity >> voltage >> \
crystal_temperature >> electric_cooler_status >> fill_fraction >> leakage >> \
date >> time >> interval_duration;
det_env.room_temperature << room_temperature;
det_env.detector_shield_status << detector_shield_status;
det_env.humidity << humidity;
det_env.voltage << voltage;
det_env.crystal_temperature << crystal_temperature;
det_env.electric_cooler_status << electric_cooler_status;
det_env.fill_fraction << fill_fraction;
det_env.leakage << leakage;
det_env.date << date;
det_env.time << time;
det_env.interval_duration << interval_duration;
++ row_count;
nextBlock = content.readLine();
if (line_content.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
det_env.record_count = row_count;
rmssoh_msg_data.insert( block_flag.at(4), QVariant::fromValue(det_env) );
return (content.status()==QTextStream::Ok)?true:false;
}
bool StateOfHealthMessage::Analyse_NIMBIN_Block(QTextStream &content, QString &nextBlock)
{
NIMBIN_Block nimbin;
int row_count = 0;
nextBlock = content.readLine();
while (!block_flag.contains(nextBlock) && !content.atEnd())
{
QString flag;
short voltage;
QString date;
QString time;
long interval_duration;
QTextStream line_content(&nextBlock);
line_content >> flag >> voltage >> date >> time >> interval_duration;
nimbin.flag << flag;
nimbin.voltage << voltage;
nimbin.date << date;
nimbin.time << time;
nimbin.interval_duration << interval_duration;
++ row_count;
nextBlock = content.readLine();
if (line_content.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
nimbin.record_count = row_count;
rmssoh_msg_data.insert( block_flag.at(5), QVariant::fromValue(nimbin) );
return (content.status()==QTextStream::Ok)?true:false;
}
bool StateOfHealthMessage::Analyse_PowerSupply_Block(QTextStream &content, QString &nextBlock)
{
PowerSupplyBlock power_supply;
int row_count = 0;
nextBlock = content.readLine();
while (!block_flag.contains(nextBlock) && !content.atEnd())
{
QString MAIN;
QString main_power_status;
QString AUX;
QString aux_power_status;
QString UPS;
QString ups_status;
QString date;
QString time;
long interval_duration;
QTextStream line_content(&nextBlock);
line_content >> MAIN >> main_power_status >> AUX >> aux_power_status >> UPS >> ups_status >> date >> time >> interval_duration;
power_supply.MAIN << MAIN;
power_supply.main_power_status << main_power_status;
power_supply.AUX << AUX;
power_supply.aux_power_status << aux_power_status;
power_supply.UPS << ups_status;
power_supply.date << date;
power_supply.time << time;
power_supply.interval_duration << interval_duration;
++ row_count;
nextBlock = content.readLine();
if (line_content.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
power_supply.record_count = row_count;
rmssoh_msg_data.insert( block_flag.at(6), QVariant::fromValue(power_supply) );
return (content.status()==QTextStream::Ok)?true:false;
}
bool StateOfHealthMessage::Analyse_EquipStatus_Block(QTextStream &content, QString &nextBlock)
{
EquipStatusBlock equip_status;
int row_count = 0;
nextBlock = content.readLine();
while (!block_flag.contains(nextBlock) && !content.atEnd())
{
QString temp_flag;
QString C_value;
QString P_value;
QString A_value;
QString date;
QString time;
long interval_duration;
QTextStream line_content(&nextBlock);
line_content >> temp_flag >> C_value >> temp_flag >> P_value >> temp_flag >> A_value >> date >> time >> interval_duration;
equip_status.C_value << C_value;
equip_status.P_value << P_value;
equip_status.A_value << A_value;
equip_status.date << date;
equip_status.time << time;
equip_status.interval_duration << interval_duration;
++ row_count;
nextBlock = content.readLine();
if (line_content.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
equip_status.record_count = row_count;
rmssoh_msg_data.insert( block_flag.at(7), QVariant::fromValue(equip_status) );
return (content.status()==QTextStream::Ok)?true:false;
}
bool StateOfHealthMessage::Analyse_TamperEnv_Block(QTextStream &content, QString &nextBlock)
{
TamperEnvBlock tamper_env;
int row_count = 0;
nextBlock = content.readLine();
while (!block_flag.contains(nextBlock) && !content.atEnd())
{
QString tamper_sensor_name;
QString tamper_sensor_status;
QString date;
QString time;
long interval_duration;
QTextStream line_content(&nextBlock);
line_content >> tamper_sensor_name >> tamper_sensor_status >> date >> time >> interval_duration;
tamper_env.tamper_sensor_name << tamper_sensor_name;
tamper_env.tamper_sensor_status << tamper_sensor_status;
tamper_env.date << date;
tamper_env.time << time;
tamper_env.interval_duration << interval_duration;
++ row_count;
nextBlock = content.readLine();
if (line_content.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
tamper_env.record_count = row_count;
rmssoh_msg_data.insert( block_flag.at(8), QVariant::fromValue(tamper_env) );
return (content.status()==QTextStream::Ok)?true:false;
}
bool StateOfHealthMessage::Analyse_ProcessSensors_Block(QTextStream &content, QString &nextBlock)
{
ProcessSensorsBlock process_sensors;
int row_count = 0;
nextBlock = content.readLine();
while (!block_flag.contains(nextBlock) && !content.atEnd())
{
QString sensor_type;
QString sensor_name;
double sensor_reading;
QString date;
QString time;
long duration;
QTextStream line_content(&nextBlock);
line_content >> sensor_type >> sensor_name >> sensor_reading >> date >> time >> duration;
process_sensors.sensor_type << sensor_type;
process_sensors.sensor_name << sensor_name;
process_sensors.sensor_reading << sensor_reading;
process_sensors.date << date;
process_sensors.time << time;
process_sensors.duration << duration;
++ row_count;
nextBlock = content.readLine();
if (line_content.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
process_sensors.record_count = row_count;
rmssoh_msg_data.insert( block_flag.at(9), QVariant::fromValue(process_sensors) );
return (content.status()==QTextStream::Ok)?true:false;
}
bool StateOfHealthMessage::Analyse_ChromatogramBlock(QTextStream &content, QString &nextBlock)
{
ChromatogramBlock chromatogram;
content >> chromatogram.srid;
content >> chromatogram.total_number;
int row_count = 0;
nextBlock = content.readLine();
while (!block_flag.contains(nextBlock) && !content.atEnd())
{
QTextStream line_content(&nextBlock);
long interval_number;
long interval_start_channel;
double duration;
line_content >> interval_number;
if ( 0==interval_number )
{
break;
}
line_content >> interval_start_channel >> duration;
++ row_count;
nextBlock = content.readLine();
if (line_content.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
chromatogram.interval_record_count = row_count;
while (!block_flag.contains(nextBlock) && !content.atEnd())
{
QTextStream line_content(&nextBlock);
long detector_response;
line_content >> detector_response;
chromatogram.detector_response << detector_response;
nextBlock = content.readLine();
if (line_content.status()==QTextStream::ReadCorruptData)
{
return false;
}
}
rmssoh_msg_data.insert( block_flag.at(10), QVariant::fromValue(chromatogram) );
return (content.status()==QTextStream::Ok)?true:false;
}

40
StateOfHealthMessage.h Normal file
View File

@ -0,0 +1,40 @@
#ifndef STATEOFHEALTHDATA_H
#define STATEOFHEALTHDATA_H
#include "AbstractSpectrumDataMessage.h"
#include "DataManager_Define.h"
#include <QTextStream>
#include <QVariantMap>
class StateOfHealthMessage : public AbstractSpectrumDataMessage
{
public:
explicit StateOfHealthMessage();
~StateOfHealthMessage();
virtual bool IsValid();
const QVariant GetBlockData(QString& block_name);
virtual void ClearData();
private:
void InitBlockFlagInfo();
virtual bool AnalyseMessgeBody(QTextStream& content);
bool Analyse_Header_Block(QTextStream& content, QString& nextBlock);
bool Analyse_Comment_Block(QTextStream& content, QString& nextBlock);
bool Analyse_AirSamplerFlow_Block(QTextStream& content, QString& nextBlock);
bool Analyse_AirSamplerEnv_Block(QTextStream& content, QString& nextBlock);
bool Analyse_DetEnv_Block(QTextStream& content, QString& nextBlock);
bool Analyse_NIMBIN_Block(QTextStream& content, QString& nextBlock);
bool Analyse_PowerSupply_Block(QTextStream& content, QString& nextBlock);
bool Analyse_EquipStatus_Block(QTextStream& content, QString& nextBlock);
bool Analyse_TamperEnv_Block(QTextStream& content, QString& nextBlock);
bool Analyse_ProcessSensors_Block(QTextStream& content, QString& nextBlock);
bool Analyse_ChromatogramBlock(QTextStream& content, QString& nextBlock);
private:
bool bIsValid;
QStringList block_flag;
QVariantMap rmssoh_msg_data;
};
#endif // STATEOFHEALTHDATA_H

107
XeConUncer.cpp Normal file
View File

@ -0,0 +1,107 @@
#include "XeConUncer.h"
#include <QtMath>
bool CXeConUncer::CalcXeConUncer(XeConUncerI &_input, XeConUncerO &_output, global::XeType& _output_Xetype)
{
const int cu_grp_num = 2;//浓度和不确定度组数据 2数为一组
const int pos_con=0; //浓度偏移
const int pos_uncer=1; //不确定度偏移
const int cts_grp_num = 3; ////气体,样品扣除探测器本地谱数据计数 [n..0]计数 [n..1]偏差 [n..2]关键水平
const int pos_cts = 0;
// const int pos_vari = 1;
const int pos_level = 2;
const int max_g_s = 6*cts_grp_num+pos_level; //气体,样品扣除探测器本地谱数据应包含的数据大小
bool bError = false;
if(8*cu_grp_num+pos_uncer>=_input.ROI_con_uncer.size()||max_g_s>=_input.s_netXe.size()||max_g_s>=_input.g_netXe.size())
{
return false;
}
_output.Xe135_con = _input.ROI_con_uncer[2*cu_grp_num+pos_con];
_output.Xe135_uncer=_input.ROI_con_uncer[2*cu_grp_num+pos_uncer];
_output.Xe131m_con= _input.ROI_con_uncer[5*cu_grp_num+pos_con];
_output.Xe131m_uncer= _input.ROI_con_uncer[5*cu_grp_num+pos_uncer];
_output.Xe133m_con= _input.ROI_con_uncer[6*cu_grp_num+pos_con];
_output.Xe133m_uncer= _input.ROI_con_uncer[6*cu_grp_num+pos_uncer];
double dVarsum=0.0;
//第n组计数 和 关键水平比较
if(_input.s_netXe[5*cts_grp_num+pos_cts]>=_input.s_netXe[5*cts_grp_num+pos_level]||_input.g_netXe[5*cts_grp_num+pos_cts]>=_input.g_netXe[5*cts_grp_num+pos_level])
{
if(_input.s_netXe[6*cts_grp_num+pos_cts]>=_input.s_netXe[6*cts_grp_num+pos_level]||_input.g_netXe[6*cts_grp_num+pos_cts]>=_input.g_netXe[6*cts_grp_num+pos_level])
{
dVarsum = CalcUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
CalcUncer(_input.ROI_con_uncer[7*cu_grp_num+pos_uncer],bError)+ \
CalcUncer(_input.ROI_con_uncer[8*cu_grp_num+pos_uncer],bError);
_output.Xe133_con = (CalcConUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_con],_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
CalcConUncer(_input.ROI_con_uncer[7*cu_grp_num+pos_con],_input.ROI_con_uncer[7*cu_grp_num+pos_uncer],bError)+ \
CalcConUncer(_input.ROI_con_uncer[8*cu_grp_num+pos_con],_input.ROI_con_uncer[8*cu_grp_num+pos_uncer],bError) \
)/dVarsum;
_output_Xetype = global::both;
}
else
{
dVarsum = CalcUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
CalcUncer(_input.ROI_con_uncer[7*cu_grp_num+pos_uncer],bError)+ \
CalcUncer(_input.ROI_con_uncer[9*cu_grp_num+pos_uncer],bError);
_output.Xe133_con = (CalcConUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_con],_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
CalcConUncer(_input.ROI_con_uncer[7*cu_grp_num+pos_con],_input.ROI_con_uncer[7*cu_grp_num+pos_uncer],bError)+ \
CalcConUncer(_input.ROI_con_uncer[9*cu_grp_num+pos_con],_input.ROI_con_uncer[9*cu_grp_num+pos_uncer],bError) \
)/dVarsum;
_output_Xetype = global::_131m;
}
}
else if(_input.s_netXe[6*cts_grp_num+pos_cts]>=_input.s_netXe[6*cts_grp_num+pos_level]||_input.g_netXe[6*cts_grp_num+pos_cts]>=_input.g_netXe[6*cts_grp_num+pos_level])
{
dVarsum = CalcUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
CalcUncer(_input.ROI_con_uncer[8*cu_grp_num+pos_uncer],bError)+ \
CalcUncer(_input.ROI_con_uncer[10*cu_grp_num+pos_uncer],bError);
_output.Xe133_con = (CalcConUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_con],_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
CalcConUncer(_input.ROI_con_uncer[8*cu_grp_num+pos_con],_input.ROI_con_uncer[8*cu_grp_num+pos_uncer],bError)+ \
CalcConUncer(_input.ROI_con_uncer[10*cu_grp_num+pos_con],_input.ROI_con_uncer[10*cu_grp_num+pos_uncer],bError) \
)/dVarsum;
_output_Xetype = global::_133m;
}
else
{
dVarsum = CalcUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
CalcUncer(_input.ROI_con_uncer[4*cu_grp_num+pos_uncer],bError);
_output.Xe133_con = (CalcConUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_con],_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
CalcConUncer(_input.ROI_con_uncer[4*cu_grp_num+pos_con],_input.ROI_con_uncer[4*cu_grp_num+pos_uncer],bError) \
)/dVarsum;
_output_Xetype = global::none;
}
if((1/dVarsum)<0)
{
return false;
}
_output.Xe133_uncer = qSqrt(1/dVarsum);
if(bError)
{
return false;
}
return true;
}
double CXeConUncer::CalcUncer(double _uncer,bool& _bError)
{
double rData=0.0;
if(_uncer == 0.0)
{
_bError = true;
}
else
{
rData=1/(_uncer*_uncer);
}
return rData;
}
double CXeConUncer::CalcConUncer(double _con,double _uncer,bool& _bError)
{
double rData=0.0;
if(_uncer == 0.0)
{
_bError = true;
}
else
{
rData = _con/(_uncer*_uncer);
}
return rData;
}

31
XeConUncer.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef XE_CON_UNCER_H
#define XE_CON_UNCER_H
////////////////////////////////////////////////////////////////////////
// 类说明:此类为: 同位素浓度和不确定度计算
//
// 注意事项1、传入参数应注意 结构
//
///////////////////////////////////////////////////////////////////////
#include "XeConUncerDef.h"
#include "ProcessAlgorithmGlobalVar.h"
class CXeConUncer
{
public:
/////////////////////////////////////////////////////////////////////
// 函数说明CalcXeConUncer 同位素计算浓度和不确定度
// 参数说明XeConUncerI 传入参数:请查看结构定义
// XeConUncerO 输出:请查看结构定义
// _output_Xetype // 同位素类型
// 返回值: true:正确返回
// fale:错误返回
//////////////////////////////////////////////////////////////////////
static bool CalcXeConUncer(XeConUncerI& _input,XeConUncerO& _output,global::XeType& _output_Xetype);
private:
//不确定度计算 1/(_uncer*_uncer)
static double CalcUncer(double _uncer,bool& _bError);
//浓度不确定度计算 _con/(_uncer*_uncer)
static double CalcConUncer(double _con,double _uncer,bool& _bError);
};
#endif

22
XeConUncerDef.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef XE_CON_UNCER_DEFINE_H
#define XE_CON_UNCER_DEFINE_H
#include <QVector>
typedef struct tagXeConUncerI
{
QVector<double> ROI_con_uncer; //感兴趣区浓度和不确定度 [n..0]浓度 [n..1]不确定度
QVector<double> s_netXe; //样品普扣除探测器本地谱计数 [n..0] 计数 [n..1]计数偏差 [n..2]感兴趣区关键水平
QVector<double> g_netXe; //气体本地谱扣除探测器本地谱计数 [n..0] 计数 [n..1]计数偏差 [n..2]感兴趣区关键水平
}*pXeConUncerI,XeConUncerI;
typedef struct tagXeConUncerO
{
double Xe135_con; //135不浓度
double Xe135_uncer; //135不确定度
double Xe131m_con;
double Xe131m_uncer;
double Xe133m_con;
double Xe133m_uncer;
double Xe133_con;
double Xe133_uncer;
}*pXeConUncerO,XeConUncerO;
#endif

19
common.pri Normal file
View File

@ -0,0 +1,19 @@
VERSION_PATH = asrmd_c++_bin_release
VERSION_TEMP_PATH = asrmd_c++_temp_release
CONFIG(debug,debug|release){
VERSION_PATH = asrmd_c++_bin_debug
VERSION_TEMP_PATH = asrmd_c++_temp_debug
}
PROJECT_BIN = $$PWD/../$$VERSION_PATH
PROJECT_LIB = $$PWD/../$$VERSION_PATH
PROJECT_PLUGINS = $$PWD/../$$VERSION_PATH/plugins
PROJECT_MOC = $$PWD/../$$VERSION_TEMP_PATH/moc
PROJECT_OBJ = $$PWD/../$$VERSION_TEMP_PATH/obj
PROJECT_RCC = $$PWD/../$$VERSION_TEMP_PATH/rcc
PROJECT_UI = $$PWD/../$$VERSION_TEMP_PATH/ui
unix {
PROJECT_LIB = $$PWD/../$$VERSION_PATH/lib
QMAKE_RPATHDIR += :\'\$\$ORIGIN\':\'\$\$ORIGIN/lib\'
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,116 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_jeecg_modules_native_jni_EnergySpectrumHandler */
#ifndef _Included_org_jeecg_modules_native_jni_EnergySpectrumHandler
#define _Included_org_jeecg_modules_native_jni_EnergySpectrumHandler
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: getSourceData
* Signature: (Ljava/lang/String;)Lorg/jeecg/modules/native_jni/struct/EnergySpectrumStruct;
*/
//解析文件
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_getSourceData
(JNIEnv*, jclass, jstring);
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: CalcBgBoundary
* Signature: (Lorg/jeecg/modules/native_jni/struct/CalcBgBoundaryParam;)Lorg/jeecg/modules/native_jni/struct/BgBoundary;
*/
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_CalcBgBoundary
(JNIEnv*, jclass, jobject);
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: GetFileFittingPara
* Signature: (Ljava/util/List;Ljava/util/List;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_GetFileFittingPara
(JNIEnv*, jclass, jobject, jobject);
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: GetFileFittingData
* Signature: (Ljava/util/List;Ljava/util/List;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_GetFileFittingData
(JNIEnv*, jclass, jobject, jobject);
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: bgAnalyse
* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/jeecg/modules/native_jni/struct/BgAnalyseResult;
*/
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_bgAnalyse
(JNIEnv*, jclass, jstring sample, jstring gas, jstring detbgr);
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: bgReAnalyse
* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/jeecg/modules/entity/vo/BgCalibratePara;)Lorg/jeecg/modules/native_jni/struct/BgAnalyseResult;
*/
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_bgReAnalyse
(JNIEnv *, jclass, jstring, jstring, jstring, jobject);
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: getAlertSourceData
* Signature: (Ljava/lang/String;)Lorg/jeecg/modules/native_jni/struct/AlertSpectrumStruct;
*/
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_getAlertSourceData
(JNIEnv*, jclass, jstring);
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: getMetSourceData
* Signature: (Ljava/lang/String;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_getMetSourceData
(JNIEnv*, jclass, jstring);
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: getSOHSourceData
* Signature: (Ljava/lang/String;)Lorg/jeecg/modules/native_jni/struct/SOHSpectrumStruct;
*/
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_getSOHSourceData
(JNIEnv*, jclass, jstring);
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: GetFittingPara
* Signature: (Ljava/util/List;Ljava/util/List;Ljava/lang/String;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_GetFittingPara
(JNIEnv *, jclass, jobject, jobject, jstring);
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: GetFittingData
* Signature: (Ljava/util/List;Ljava/lang/String;Ljava/util/List;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_GetFittingData
(JNIEnv *, jclass, jobject, jstring, jobject);
JNIEXPORT void JNICALL test_bate();
/*
* Class: org_jeecg_modules_native_jni_EnergySpectrumHandler
* Method: BetaGammaSpectrumAnalyzeFunc
* Signature: (Lorg/jeecg/modules/entity/vo/SpectrumGroup;)Lorg/jeecg/modules/native_jni/struct/BgAnalyseResult;
*//*
JNIEXPORT jobject JNICALL Java_org_jeecg_modules_native_1jni_EnergySpectrumHandler_BetaGammaSpectrumAnalyzeFunc
(JNIEnv*, jclass, jobject);*/
#ifdef __cplusplus
}
#endif
#endif