新的块
This commit is contained in:
parent
29acdf7eea
commit
b70e2d238a
|
@ -120,6 +120,7 @@ QString CplusToJava::jstring2QString(JNIEnv* env, jstring jstr)
|
|||
return qstr;
|
||||
}
|
||||
|
||||
|
||||
std::vector<double> CplusToJava::jobjectArray2vectorD(JNIEnv* env, jobjectArray listValue)
|
||||
{
|
||||
// 处理数组元素
|
||||
|
@ -128,15 +129,15 @@ std::vector<double> CplusToJava::jobjectArray2vectorD(JNIEnv* env, jobjectArray
|
|||
|
||||
for (int i = 0; i < arrayLen; i++) {
|
||||
jobject element = env->GetObjectArrayElement(listValue, i);
|
||||
if (element)
|
||||
{
|
||||
jdouble value = env->CallDoubleMethod(element, env->GetMethodID(env->FindClass("java/lang/Double"), "doubleValue", "()D"));
|
||||
results.push_back(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
results.push_back(qQNaN());
|
||||
}
|
||||
if (element)
|
||||
{
|
||||
jdouble value = env->CallDoubleMethod(element, env->GetMethodID(env->FindClass("java/lang/Double"), "doubleValue", "()D"));
|
||||
results.push_back(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
results.push_back(qQNaN());
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.9.1, 2024-08-16T10:07:31. -->
|
||||
<!-- Written by QtCreator 4.9.1, 2024-08-26T16:15:56. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
|
|
@ -224,6 +224,10 @@ bool RadionuclideMessage::AnalyseMessgeBody(QTextStream &content)
|
|||
{
|
||||
bRet &= Analyse_Certificate_Block(content, line);
|
||||
}
|
||||
else if ( 0==line.compare(block_flag.at(23)) && bRet)
|
||||
{
|
||||
bRet &= Analyse_Gps_Block(content, line);
|
||||
}
|
||||
else if ( 0==line.compare(block_flag.at(24)) && bRet)
|
||||
{
|
||||
bRet &= Analyse_b_self_Attenuation_Block(content, line);
|
||||
|
@ -232,10 +236,7 @@ bool RadionuclideMessage::AnalyseMessgeBody(QTextStream &content)
|
|||
{
|
||||
bRet &= Analyse_b_Efficiency_Block(content, line);
|
||||
}
|
||||
else if ( 0==line.compare(block_flag.at(23)) && bRet)
|
||||
{
|
||||
bRet &= Analyse_Gps_Block(content, line);
|
||||
}
|
||||
|
||||
else
|
||||
{ // 数据错误,数据有效
|
||||
bIsValid = false;
|
||||
|
|
|
@ -3249,125 +3249,137 @@ JNIEXPORT void JNICALL test_analyseSpectrum(const char* pszPath)
|
|||
}
|
||||
|
||||
|
||||
jstring Java_org_jeecg_modules_native_1jni_CalValuesHandler_selfBgAnalyse(JNIEnv *env, jclass, jstring phdFile, jstring json)
|
||||
{
|
||||
QString phdPath = CplusToJava::jstring2QString(env, phdFile);
|
||||
//phd转换
|
||||
PHDFile* phd = new PHDFile;
|
||||
//jstring Java_org_jeecg_modules_native_1jni_CalValuesHandler_selfBgAnalyse(JNIEnv *env, jclass, jstring phdFile, jstring json)
|
||||
//{
|
||||
// QString phdPath = CplusToJava::jstring2QString(env, phdFile);
|
||||
// //phd转换
|
||||
// PHDFile* phd = new PHDFile;
|
||||
|
||||
phd->filepath = phdPath;
|
||||
if(!AlgFunc::LoadSpectrum(phd))
|
||||
{
|
||||
return env->NewStringUTF("");
|
||||
}
|
||||
// phd->filepath = phdPath;
|
||||
// if(!AlgFunc::LoadSpectrum(phd))
|
||||
// {
|
||||
// printf("load error!\n");
|
||||
// return env->NewStringUTF("");
|
||||
// }
|
||||
|
||||
QDateTime collectStart = QDateTime::fromString(phd->collect.collection_start_date + " " + phd->collect.collection_start_time, QString(DATATIME_FORMAT));
|
||||
QDateTime collectStop = QDateTime::fromString(phd->collect.collection_stop_date + " " + phd->collect.collection_stop_time, QString(DATATIME_FORMAT));
|
||||
QDateTime acqStart = QDateTime::fromString(phd->acq.acquisition_start_date + " " + phd->acq.acquisition_start_time, QString(DATATIME_FORMAT));
|
||||
double tc = collectStart.secsTo(collectStop); // 采样时间
|
||||
double tp = collectStop.secsTo(acqStart); // 衰变时间
|
||||
double tr = phd->acq.acquisition_real_time; // 能谱获取实时间
|
||||
double tl = phd->acq.acquisition_live_time; // 能谱获取活时间
|
||||
// QMap<QString, double> sendOdds;
|
||||
// QMap<QString, double> halfLife;
|
||||
// QMap<QString, double> area;
|
||||
// QDateTime collectStart = QDateTime::fromString(phd->collect.collection_start_date + " " + phd->collect.collection_start_time, QString(DATATIME_FORMAT));
|
||||
// QDateTime collectStop = QDateTime::fromString(phd->collect.collection_stop_date + " " + phd->collect.collection_stop_time, QString(DATATIME_FORMAT));
|
||||
// QDateTime acqStart = QDateTime::fromString(phd->acq.acquisition_start_date + " " + phd->acq.acquisition_start_time, QString(DATATIME_FORMAT));
|
||||
// double tc = collectStart.secsTo(collectStop); // 采样时间
|
||||
// double tp = collectStop.secsTo(acqStart); // 衰变时间
|
||||
// double tr = phd->acq.acquisition_real_time; // 能谱获取实时间
|
||||
// double tl = phd->acq.acquisition_live_time; // 能谱获取活时间
|
||||
//// QMap<QString, double> sendOdds;
|
||||
//// QMap<QString, double> halfLife;
|
||||
//// QMap<QString, double> area;
|
||||
|
||||
QString jsonStr = CplusToJava::jstring2QString(env, json);
|
||||
QJsonDocument doc;
|
||||
doc = QJsonDocument::fromJson(jsonStr.toUtf8());
|
||||
QJsonObject inObj = doc.object();
|
||||
// QString jsonStr = CplusToJava::jstring2QString(env, json);
|
||||
// printf("json str:%s\n",jsonStr.toStdString().c_str());
|
||||
// QJsonDocument doc;
|
||||
// doc = QJsonDocument::fromJson(jsonStr.toUtf8());
|
||||
// QJsonObject inObj = doc.object();
|
||||
|
||||
// QMap<QString, double> sendOdds = {{"XE-131m",(43.9) / 100.0},{"XE-133m",(45.7) / 100.0},{"XE-133",37 / 100.0},{"XE-135",90 / 100.0}};
|
||||
// QMap<QString, double> halfLife = {{"XE-131m",11.93400 * (24 * 60 * 60)},{"XE-133m",2.190000 * (24 * 60 * 60)},{"XE-133",5.243000 * (24 * 60 * 60)},{"XE-135",0.380832 * (24 * 60 * 60)}};
|
||||
//// QMap<QString, double> halfLife = {{"XE-131m",11.93400},{"XE-133m",2.190000 },{"XE-133",5.243000 },{"XE-135",0.380832 }};
|
||||
// QMap<QString, double> area = {{"XE-131m",579},{"XE-133m",925},{"XE-133",2361},{"XE-135",363}};
|
||||
QJsonArray data;
|
||||
for(int i = 0; i < phd->bSelfAttenuation.devNames.size(); i++)
|
||||
{
|
||||
QString name = phd->bSelfAttenuation.devNames[i];
|
||||
std::array<double, 3> self = phd->bSelfAttenuation.xenon[i];
|
||||
std::array<double, 3> self2 = phd->bSelfAttenuation.nitrogen[i];
|
||||
//// QMap<QString, double> sendOdds = {{"XE-131m",(43.9) / 100.0},{"XE-133m",(45.7) / 100.0},{"XE-133",37 / 100.0},{"XE-135",90 / 100.0}};
|
||||
//// QMap<QString, double> halfLife = {{"XE-131m",11.93400 * (24 * 60 * 60)},{"XE-133m",2.190000 * (24 * 60 * 60)},{"XE-133",5.243000 * (24 * 60 * 60)},{"XE-135",0.380832 * (24 * 60 * 60)}};
|
||||
////// QMap<QString, double> halfLife = {{"XE-131m",11.93400},{"XE-133m",2.190000 },{"XE-133",5.243000 },{"XE-135",0.380832 }};
|
||||
//// QMap<QString, double> area = {{"XE-131m",579},{"XE-133m",925},{"XE-133",2361},{"XE-135",363}};
|
||||
// QJsonArray data;
|
||||
// for(int i = 0; i < phd->bSelfAttenuation.devNames.size(); i++)
|
||||
// {
|
||||
// QString name = phd->bSelfAttenuation.devNames[i];
|
||||
// std::array<double, 3> self = phd->bSelfAttenuation.xenon[i];
|
||||
// std::array<double, 3> self2 = phd->bSelfAttenuation.nitrogen[i];
|
||||
|
||||
double vxe, vn2;
|
||||
vxe = phd->process.sample_volume_of_Xe;
|
||||
vn2 = phd->process.Xe_collection_yield;
|
||||
QJsonObject factorObj = inObj[name].toObject();
|
||||
// double vxe, vn2;
|
||||
// vxe = phd->process.sample_volume_of_Xe;
|
||||
// vn2 = phd->process.Xe_collection_yield;
|
||||
// QJsonObject factorObj = inObj[name].toObject();
|
||||
|
||||
double halfLife = factorObj["halflife"].toString().toDouble() * (24 * 60 * 60);
|
||||
double sendOdds = factorObj["yield"].toString().toDouble() / 100.0;
|
||||
double area = factorObj["area"].toString().toDouble();
|
||||
// double halfLife = factorObj["halflife"].toString().toDouble() * (24 * 60 * 60);
|
||||
// double sendOdds = factorObj["yield"].toString().toDouble() / 100.0;
|
||||
// double area = factorObj["area"].toString().toDouble();
|
||||
// printf("halfLife:%f\n",halfLife);
|
||||
// printf("sendOdds:%f\n",sendOdds);
|
||||
// printf("area:%f\n",area);
|
||||
|
||||
double bgeff, geff;
|
||||
double f;
|
||||
double fxe = self[0] - self[1] * vxe + self[2] * pow(10, -5) * pow(vxe,2);
|
||||
double fn2 = self2[0] - self2[0] * vn2 + self2[2] * pow(10, -4) * pow(vn2, 2);
|
||||
f = fxe * fn2;
|
||||
// if(phd->bSelfAttenuation.devNames[i].compare("XE-133") == 0)
|
||||
|
||||
// double bgeff, geff;
|
||||
// double f;
|
||||
// double fxe = self[0] - self[1] * vxe + self[2] * pow(10, -5) * pow(vxe,2);
|
||||
// double fn2 = self2[0] - self2[0] * vn2 + self2[2] * pow(10, -4) * pow(vn2, 2);
|
||||
// f = fxe * fn2;
|
||||
//// if(phd->bSelfAttenuation.devNames[i].compare("XE-133") == 0)
|
||||
//// {
|
||||
//// double fxe133 = self[0] - self[1] * vxe + self[2] * pow(10, -5) * pow(vxe,2);
|
||||
//// double fn2133 = self2[0] - self2[0] * vn2 + self2[2] * pow(10, -4) * pow(vn2, 2);
|
||||
//// f = fxe133 * fn2133;
|
||||
|
||||
//// }
|
||||
//// else if(phd->bSelfAttenuation.devNames[i].compare("XE-135") == 0)
|
||||
//// {
|
||||
//// double fxe135 = self[0] - self[1] * vxe + self[2] * pow(10, -5) * pow(vxe,2);
|
||||
//// double fn2135 = self2[0] - self2[0] * vn2 + self2[2] * pow(10, -4) * pow(vn2, 2);
|
||||
//// f = fxe135 * fn2135;
|
||||
//// }
|
||||
//// else if(phd->bSelfAttenuation.devNames[i].compare("XE-133m") == 0)
|
||||
//// {
|
||||
//// f = 1;
|
||||
//// }
|
||||
//// else if(phd->bSelfAttenuation.devNames[i].compare("XE-131m") == 0)
|
||||
//// {
|
||||
//// f = 1;
|
||||
//// }
|
||||
|
||||
// for(int i2 = 0; i2 < phd->nMapbgEffiKD[CalPHD].nuclide_name.size(); i2++)
|
||||
// {
|
||||
// double fxe133 = self[0] - self[1] * vxe + self[2] * pow(10, -5) * pow(vxe,2);
|
||||
// double fn2133 = self2[0] - self2[0] * vn2 + self2[2] * pow(10, -4) * pow(vn2, 2);
|
||||
// f = fxe133 * fn2133;
|
||||
|
||||
// }
|
||||
// else if(phd->bSelfAttenuation.devNames[i].compare("XE-135") == 0)
|
||||
// {
|
||||
// double fxe135 = self[0] - self[1] * vxe + self[2] * pow(10, -5) * pow(vxe,2);
|
||||
// double fn2135 = self2[0] - self2[0] * vn2 + self2[2] * pow(10, -4) * pow(vn2, 2);
|
||||
// f = fxe135 * fn2135;
|
||||
// }
|
||||
// else if(phd->bSelfAttenuation.devNames[i].compare("XE-133m") == 0)
|
||||
// {
|
||||
// f = 1;
|
||||
// }
|
||||
// else if(phd->bSelfAttenuation.devNames[i].compare("XE-131m") == 0)
|
||||
// {
|
||||
// f = 1;
|
||||
// if(phd->nMapbgEffiKD[CalPHD].nuclide_name[i2].compare(name) == 0)
|
||||
// {
|
||||
// bgeff = phd->nMapbgEffiKD[CalPHD].bg_efficiency[i2];
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
for(int i2 = 0; i2 < phd->nMapbgEffiKD[CalPHD].nuclide_name.size(); i2++)
|
||||
{
|
||||
if(phd->nMapbgEffiKD[CalPHD].nuclide_name[i2].compare(name) == 0)
|
||||
{
|
||||
bgeff = phd->nMapbgEffiKD[CalPHD].bg_efficiency[i2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
// for(int i2 = 0; i2 < phd->nMapEffiKD[CalPHD].dev_name.size(); i2++)
|
||||
// {
|
||||
// if(phd->nMapEffiKD[CalPHD].dev_name[i2].compare(name) == 0)
|
||||
// {
|
||||
// geff = phd->nMapEffiKD[CalPHD].efficiency[i2];
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
for(int i2 = 0; i2 < phd->nMapEffiKD[CalPHD].dev_name.size(); i2++)
|
||||
{
|
||||
if(phd->nMapEffiKD[CalPHD].dev_name[i2].compare(name) == 0)
|
||||
{
|
||||
geff = phd->nMapEffiKD[CalPHD].efficiency[i2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
// double e = exp(1.0); // 计算e的值
|
||||
// double ln2 = log(2);
|
||||
// double T = (halfLife);
|
||||
// double lambda = ln2 / T;
|
||||
// double kc = lambda * tr / (1 - pow(e, -(lambda * tr)));
|
||||
// double a_up = (area / f);
|
||||
// double a_low = (tl * bgeff * geff * sendOdds);
|
||||
// double a = (a_up / a_low) * kc;
|
||||
// double ac_mi = lambda * tp;
|
||||
// double ac_e = pow(e, ac_mi);
|
||||
// double ac_kc = (lambda * tc) / (1 - pow(e, -(lambda * tc)));
|
||||
|
||||
double e = exp(1.0); // 计算e的值
|
||||
double ln2 = log(2);
|
||||
double T = (halfLife);
|
||||
double lambda = ln2 / T;
|
||||
double kc = lambda * tr / (1 - pow(e, -(lambda * tr)));
|
||||
double a_up = (area / f);
|
||||
double a_low = (tl * bgeff * geff * sendOdds);
|
||||
double a = (a_up / a_low) * kc;
|
||||
double ac_mi = lambda * tp;
|
||||
double ac_e = pow(e, ac_mi);
|
||||
double ac_kc = (lambda * tc) / (1 - pow(e, -(lambda * tc)));
|
||||
// double ac = (1000 * a / (vxe / 0.087)) * ac_e * ac_kc;
|
||||
// qDebug() << "ac : " << ac;
|
||||
// double cBaseLine = factorObj["baseline"].toString().toDouble();
|
||||
// double ld = 2.71 + 4.65 * sqrt(cBaseLine);
|
||||
// double mda = (ld / a_low) * kc;
|
||||
// double mdc = (1000 * mda / (vxe / 0.087)) * ac_e * ac_kc;
|
||||
|
||||
double ac = (1000 * a / (vxe / 0.087)) * ac_e * ac_kc;
|
||||
qDebug() << "ac : " << ac;
|
||||
// QJsonObject obj;
|
||||
// obj["name"] = name;
|
||||
// obj["conc"] = ac;
|
||||
// obj["mda"] = mda;
|
||||
// obj["mdc"] = mdc;
|
||||
// data.push_back(obj);
|
||||
// }
|
||||
|
||||
QJsonObject obj;
|
||||
obj["name"] = name;
|
||||
obj["ac"] = ac;
|
||||
data.push_back(obj);
|
||||
}
|
||||
|
||||
QJsonDocument document;
|
||||
document.setArray(data);
|
||||
QByteArray simpbyte_array = document.toJson(QJsonDocument::Compact);
|
||||
QString simpjson_str(simpbyte_array);
|
||||
|
||||
jstring jresult = env->NewStringUTF(simpjson_str.toStdString().c_str());
|
||||
return jresult;
|
||||
}
|
||||
// QJsonDocument document;
|
||||
// document.setArray(data);
|
||||
// QByteArray simpbyte_array = document.toJson(QJsonDocument::Compact);
|
||||
// QString simpjson_str(simpbyte_array);
|
||||
// printf("result : %s\n", simpjson_str.toStdString().c_str());
|
||||
// jstring jresult = env->NewStringUTF(simpjson_str.toStdString().c_str());
|
||||
// return jresult;
|
||||
//}
|
||||
|
|
|
@ -158,13 +158,13 @@ JNIEXPORT jstring JNICALL Java_org_jeecg_modules_native_1jni_CalValuesHandler_an
|
|||
JNIEXPORT jstring JNICALL Java_org_jeecg_modules_native_1jni_CalValuesHandler_fitPeakFull
|
||||
(JNIEnv *, jclass, jstring, jobject, jobject, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_jeecg_modules_native_jni_CalValuesHandler
|
||||
* Method: selfBgAnalyse
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_jeecg_modules_native_1jni_CalValuesHandler_selfBgAnalyse
|
||||
(JNIEnv *, jclass, jstring, jstring);
|
||||
///*
|
||||
// * Class: org_jeecg_modules_native_jni_CalValuesHandler
|
||||
// * Method: selfBgAnalyse
|
||||
// * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
||||
// */
|
||||
//JNIEXPORT jstring JNICALL Java_org_jeecg_modules_native_1jni_CalValuesHandler_selfBgAnalyse
|
||||
//(JNIEnv *, jclass, jstring, jstring);
|
||||
|
||||
JNIEXPORT void JNICALL test_analyseSpectrum(const char* pszPath);
|
||||
|
||||
|
|
8
selfBgAnalyse.json
Normal file
8
selfBgAnalyse.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"XE-133":{
|
||||
"halflife":"11.12",
|
||||
"yield":"2.1",
|
||||
"area":"243",
|
||||
"baseline":"1.0"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user