优化数据处理任务
This commit is contained in:
parent
c558e12697
commit
af36a5a21c
|
|
@ -62,16 +62,24 @@ void DataProcessTask::run()
|
|||
if (!IsValidSetWorkParameters()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!processTask()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool task_ok = processTask();
|
||||
if ((GetFinishedNotifier() != nullptr) && (GetFinishedNotifierProcess() != nullptr)) {
|
||||
QMetaObject::invokeMethod(_finished_notifier, _finished_notifier_process, Qt::QueuedConnection, Q_ARG(QString, _project_name));
|
||||
QMetaObject::invokeMethod(
|
||||
_finished_notifier,
|
||||
_finished_notifier_process,
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(bool, task_ok),
|
||||
Q_ARG(QString, _project_name),
|
||||
Q_ARG(QVariant, _task_result_data)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void DataProcessTask::updateTaskResultData(const QVariant &task_result_data)
|
||||
{
|
||||
this->_task_result_data = task_result_data;
|
||||
}
|
||||
|
||||
void ParticleDataTask::SetAllChannelParticleDataFilename(const QString& all_channel_particle_data_filename)
|
||||
{
|
||||
this->_all_channel_particle_data_filename = all_channel_particle_data_filename;
|
||||
|
|
@ -336,7 +344,8 @@ bool EveryChannelParticleCountDataTask::processEveryChannelParticleData()
|
|||
// 更新项目模型中的所有通道粒子总计数数据文件名
|
||||
// project_model->SetAllChannelParticleTotalCountDataFilename(all_channel_total_count_filename);
|
||||
}
|
||||
|
||||
const QString& info = QStringLiteral(u"所有通道粒子计数处理完成.");
|
||||
LOG_INFO(info);
|
||||
return ret_ok;
|
||||
}
|
||||
|
||||
|
|
@ -389,17 +398,16 @@ std::vector<std::string> splitFile(const std::string& input_file, size_t chunk_s
|
|||
> reader(input_file);
|
||||
reader.read_header(io::ignore_extra_column, board_id_str, channel_id_str, address_str, time_str);
|
||||
|
||||
int chunkIndex = 0;
|
||||
int chunk_index = 0;
|
||||
|
||||
while (true) {
|
||||
std::vector<CsvRow> rows;
|
||||
size_t currentSize = 0;
|
||||
size_t current_size = 0;
|
||||
|
||||
uint board_id;
|
||||
uint channel_id;
|
||||
uint address;
|
||||
unsigned long long time;
|
||||
|
||||
while (reader.read_row(board_id, channel_id, address, time)) {
|
||||
CsvRow row;
|
||||
row.board_id = board_id;
|
||||
|
|
@ -408,63 +416,56 @@ std::vector<std::string> splitFile(const std::string& input_file, size_t chunk_s
|
|||
row.time = time;
|
||||
|
||||
// Estimate row size
|
||||
currentSize += std::to_string(board_id).size() + std::to_string(channel_id).size() + std::to_string(address).size() + std::to_string(time).size() + 4; // +4 for commas
|
||||
|
||||
if (currentSize > chunk_size && !rows.empty()) {
|
||||
current_size += std::to_string(board_id).size() + std::to_string(channel_id).size() + std::to_string(address).size() + std::to_string(time).size() + 4;
|
||||
if (current_size > chunk_size && !rows.empty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
rows.push_back(row);
|
||||
}
|
||||
|
||||
if (rows.empty())
|
||||
break;
|
||||
|
||||
std::sort(rows.begin(), rows.end(), [](const CsvRow& a, const CsvRow& b) {
|
||||
return a.time < b.time;
|
||||
});
|
||||
|
||||
std::string chunkFile = input_file + ".chunk" + std::to_string(chunkIndex);
|
||||
std::ofstream outFile(chunkFile);
|
||||
std::string chunk_file = input_file + ".chunk" + std::to_string(chunk_index);
|
||||
std::ofstream outFile(chunk_file);
|
||||
for (const auto& row : rows) {
|
||||
outFile << row.board_id << "," << row.channel_id << "," << row.address << "," << row.time << "\n";
|
||||
}
|
||||
outFile.close();
|
||||
|
||||
chunks.push_back(chunkFile);
|
||||
chunkIndex++;
|
||||
chunks.push_back(chunk_file);
|
||||
chunk_index++;
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
throw(e);
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
void mergeChunks(const std::vector<std::string>& chunks, const std::string& output_file)
|
||||
{
|
||||
std::vector<std::unique_ptr<io::CSVReader<4>>> chunkReaders;
|
||||
std::priority_queue<CsvRow> minHeap;
|
||||
std::vector<std::unique_ptr<io::CSVReader<4>>> chunk_readers;
|
||||
std::priority_queue<CsvRow> min_heap;
|
||||
|
||||
for (const auto& chunk : chunks) {
|
||||
auto reader = std::make_unique<io::CSVReader<4>>(chunk);
|
||||
chunkReaders.push_back(std::move(reader));
|
||||
chunk_readers.push_back(std::move(reader));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < chunkReaders.size(); i++) {
|
||||
for (size_t i = 0; i < chunk_readers.size(); i++) {
|
||||
uint board_id;
|
||||
uint channel_id;
|
||||
uint address;
|
||||
unsigned long long time;
|
||||
|
||||
if (chunkReaders[i]->read_row(board_id, channel_id, address, time)) {
|
||||
if (chunk_readers[i]->read_row(board_id, channel_id, address, time)) {
|
||||
CsvRow row;
|
||||
row.board_id = board_id;
|
||||
row.channel_id = channel_id;
|
||||
row.address = address;
|
||||
row.time = time;
|
||||
row.chunk_index = i;
|
||||
minHeap.push(row);
|
||||
min_heap.push(row);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -475,35 +476,33 @@ void mergeChunks(const std::vector<std::string>& chunks, const std::string& outp
|
|||
std::ofstream outFile(output_file);
|
||||
outFile << board_id_str << "," << channel_id_str << "," << address_str << "," << time_str << "\n";
|
||||
|
||||
while (!minHeap.empty()) {
|
||||
CsvRow current = minHeap.top();
|
||||
minHeap.pop();
|
||||
while (!min_heap.empty()) {
|
||||
CsvRow current = min_heap.top();
|
||||
min_heap.pop();
|
||||
|
||||
outFile << current.board_id << "," << current.channel_id << "," << current.address << "," << current.time << "\n";
|
||||
|
||||
size_t chunk_index = current.chunk_index;
|
||||
if (chunkReaders[chunk_index]) {
|
||||
if (chunk_readers[chunk_index]) {
|
||||
uint board_id;
|
||||
uint channel_id;
|
||||
uint address;
|
||||
unsigned long long time;
|
||||
|
||||
if (chunkReaders[chunk_index]->read_row(board_id, channel_id, address, time)) {
|
||||
if (chunk_readers[chunk_index]->read_row(board_id, channel_id, address, time)) {
|
||||
CsvRow row;
|
||||
row.board_id = board_id;
|
||||
row.channel_id = channel_id;
|
||||
row.address = address;
|
||||
row.time = time;
|
||||
row.chunk_index = chunk_index;
|
||||
minHeap.push(row);
|
||||
min_heap.push(row);
|
||||
} else {
|
||||
chunkReaders[chunk_index].reset();
|
||||
chunk_readers[chunk_index].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outFile.close();
|
||||
|
||||
for (const auto& chunk : chunks) {
|
||||
std::remove(chunk.c_str());
|
||||
}
|
||||
|
|
@ -517,7 +516,7 @@ bool ParticleDataSortTask::processEveryChannelParticleData()
|
|||
sorted_result_output_dir.mkpath(sorted_result_dir);
|
||||
|
||||
const QString& all_channel_particle_data_filename = GetAllChannelParticleDataFilename();
|
||||
QString sorted_output_filename = sorted_result_output_dir.filePath(QStringLiteral(u"粒子数据[已排序].csv"));
|
||||
QString sorted_output_filename = sorted_result_output_dir.filePath(QStringLiteral(u"粒子数据.csv"));
|
||||
|
||||
try {
|
||||
const size_t CHUNK_SIZE = 100 * 1024 * 1024; // 100MB chunks
|
||||
|
|
@ -538,7 +537,7 @@ bool ParticleDataSortTask::processEveryChannelParticleData()
|
|||
|
||||
} catch (const std::exception& e) {
|
||||
const QString& e_what = QString::fromLatin1(e.what());
|
||||
QString error = QString(QStringLiteral(u"处理%1异常:%2")).arg(all_channel_particle_data_filename).arg(QString::fromStdString(e.what()));
|
||||
QString error = QString(QStringLiteral(u"处理%1异常:%2")).arg(all_channel_particle_data_filename).arg(e_what);
|
||||
LOG_ERROR(error)
|
||||
ret_ok = false;
|
||||
} catch (...) {
|
||||
|
|
@ -546,15 +545,7 @@ bool ParticleDataSortTask::processEveryChannelParticleData()
|
|||
LOG_ERROR(error)
|
||||
ret_ok = false;
|
||||
}
|
||||
|
||||
const QString& project_name = GetProjectName();
|
||||
MeasureAnalysisProjectModel* project_model = ProjectList::Instance()->GetProjectModel(project_name);
|
||||
if (project_model == nullptr) {
|
||||
ret_ok = false;
|
||||
} else {
|
||||
project_model->SetSortedParticleDataFilename(sorted_output_filename);
|
||||
}
|
||||
|
||||
this->updateTaskResultData(QVariant(sorted_output_filename));
|
||||
return ret_ok;
|
||||
}
|
||||
|
||||
|
|
@ -639,7 +630,7 @@ bool AutoFindPeaksTask::processTask()
|
|||
const QString& error = QStringLiteral(u"%1自动寻峰异常!").arg(ch_count_data_name);
|
||||
LOG_WARN(error);
|
||||
}
|
||||
const QString& info = QStringLiteral(u"%1自动寻峰完成").arg(ch_count_data_name);
|
||||
const QString& info = QStringLiteral(u"%1自动寻峰完成.").arg(ch_count_data_name);
|
||||
LOG_INFO(info);
|
||||
}
|
||||
}
|
||||
|
|
@ -651,7 +642,7 @@ bool AutoFindPeaksTask::processTask()
|
|||
} else {
|
||||
project_model->SetAnalysisCustomData(this->_analysis_type, QString("AutoFindPeaksResult"), result_filename);
|
||||
}
|
||||
const QString& info = QStringLiteral(u"自动寻峰完成");
|
||||
const QString& info = QStringLiteral(u"自动寻峰完成.");
|
||||
LOG_INFO(info);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -742,3 +733,18 @@ bool ChannelEnergyScaleFittingTask::processTask()
|
|||
LOG_INFO(info);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ApplyEnergyScaleTask::processTask()
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
const QString& project_name = GetProjectName();
|
||||
MeasureAnalysisProjectModel* project_model = ProjectList::Instance()->GetProjectModel(project_name);
|
||||
if (project_model == nullptr) {
|
||||
return false;
|
||||
}
|
||||
const QString& info = QStringLiteral(u"应用能量刻度完成.");
|
||||
LOG_INFO(info);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ namespace DataProcessWorkPool
|
|||
|
||||
virtual void run() override final;
|
||||
|
||||
protected:
|
||||
void updateTaskResultData(const QVariant& task_result_data);
|
||||
|
||||
private:
|
||||
virtual bool processTask() = 0;
|
||||
|
||||
|
|
@ -30,6 +33,7 @@ namespace DataProcessWorkPool
|
|||
QObject* _finished_notifier { nullptr };
|
||||
const char* _finished_notifier_process { nullptr };
|
||||
QString _project_name;
|
||||
QVariant _task_result_data;
|
||||
};
|
||||
|
||||
class ParticleDataTask : public DataProcessTask
|
||||
|
|
@ -120,6 +124,14 @@ namespace DataProcessWorkPool
|
|||
FitDataMap _channel_energy_scale_fit_data_map;
|
||||
QMap<QString, int> _fit_degree_map;
|
||||
};
|
||||
|
||||
class ApplyEnergyScaleTask : public DataProcessTask
|
||||
{
|
||||
private:
|
||||
virtual bool processTask() override;
|
||||
private:
|
||||
QString _project_name;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DATAPROCESSWORKPOOL_H
|
||||
|
|
|
|||
|
|
@ -151,32 +151,18 @@ void MainWindow::initAction()
|
|||
{
|
||||
auto new_measurement_analysis_handler = [this]() {
|
||||
NewMeasureAnalysisDlg new_measure_analysis_dlg;
|
||||
// new_measure_analysis_dlg.exec();
|
||||
if (QDialog::Accepted == new_measure_analysis_dlg.exec()) {
|
||||
ProjectList* project_list_model = ProjectList::Instance();
|
||||
auto project_model = project_list_model->GetCurrentProjectModel();
|
||||
if (project_model->GetIsMeasureComplete()) {
|
||||
const QString& project_name = project_model->GetProjectName();
|
||||
|
||||
// const QString& result_data_dir = QDir(project_model->GetProjectDir()).filePath("EveryChannelParticleData");
|
||||
// auto separate_task = new DataProcessWorkPool::EveryChannelParticleDataSeparateTask;
|
||||
// separate_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||
// separate_task->SetResultDataDir(result_data_dir);
|
||||
// separate_task->SetFinishedNotifier(this->_tree_measure_analysis, "onFinishedSeparateEveryChannelParticleData", project_name);
|
||||
// separate_task->StartTask();
|
||||
|
||||
// auto separate_task = new DataProcessWorkPool::ParticleDataSortTask;
|
||||
// separate_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||
// separate_task->SetSortedResultDir(project_model->GetProjectDir());
|
||||
// separate_task->StartTask();
|
||||
|
||||
const QString& all_channel_particle_data_filename = project_model->GetAllChannelParticleDataFilename();
|
||||
if (!all_channel_particle_data_filename.isEmpty()) {
|
||||
const QString& all_ch_count_dir = project_model->GetProjectDir();
|
||||
const QString& every_ch_count_dir = QDir(project_model->GetProjectDir()).filePath(QStringLiteral(u"通道道址计数"));
|
||||
auto count_task = new DataProcessWorkPool::EveryChannelParticleCountDataTask;
|
||||
count_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||
count_task->SetAllChannelParticleDataFilename(all_channel_particle_data_filename);
|
||||
count_task->SetAllChannelCountResultDir(all_ch_count_dir);
|
||||
count_task->SetEveryChannelCountResultDir(every_ch_count_dir);
|
||||
count_task->SetFinishedNotifier(project_list_model, "onChannelAddressCountProcessFinished", project_name);
|
||||
count_task->SetFinishedNotifier(project_list_model, "onChannelAddressCountProcessFinished", project_model->GetProjectName());
|
||||
count_task->StartTask();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,9 +318,13 @@ void BatchEnergyScaleDialog::onFitBtnClickedProcess()
|
|||
}
|
||||
}
|
||||
|
||||
void BatchEnergyScaleDialog::onEnergyScaleFitFinished(const QString &project_name)
|
||||
void BatchEnergyScaleDialog::onEnergyScaleFitFinished(bool ok, const QString &project_name, const QVariant& data)
|
||||
{
|
||||
Q_UNUSED(project_name);
|
||||
Q_UNUSED(data);
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
QDir result_dir(this->_workspace);
|
||||
const QString& result_filename = result_dir.filePath(QStringLiteral(u"多通道能量刻度拟合结果.json"));
|
||||
EnergyScaleDataModel result_model(result_filename);
|
||||
|
|
@ -346,6 +350,7 @@ void BatchEnergyScaleDialog::applyEnergyScaleFitResultData()
|
|||
const QString& energy_scale_result_filename = this->_energy_scale_data_model->GetDataFilename();
|
||||
if (QFile::copy(energy_scale_result_filename, energy_scale_data_filename)) {
|
||||
project_model->SetEnergyScaleFilename(energy_scale_data_filename);
|
||||
ProjectList::Instance()->ApplyEnergyScale(this->_project_name);
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(this, QStringLiteral(u"警告"), QStringLiteral(u"不能应用非完整的能量刻度!"));
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public slots:
|
|||
void onSelectedScaleRange(double min, double max);
|
||||
void onFitBtnClickedProcess();
|
||||
private slots:
|
||||
void onEnergyScaleFitFinished(const QString& project_name);
|
||||
void onEnergyScaleFitFinished(bool ok, const QString& project_name, const QVariant &data);
|
||||
|
||||
private:
|
||||
void insertSetEnergyValueToFilter(double energy);
|
||||
|
|
@ -37,7 +37,7 @@ private:
|
|||
void energyScaleDataChanged(const QStringList& channel_name_list);
|
||||
|
||||
signals:
|
||||
void applyEnergyScale();
|
||||
void applyEnergyScale(const QString& project_name);
|
||||
void close();
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -280,9 +280,13 @@ void MeasureAnalysisParticleCountPlotView::updatePlotPeakInfo(const QVariantMap
|
|||
this->_plot->replot();
|
||||
}
|
||||
|
||||
void MeasureAnalysisParticleCountPlotView::onAutoFindPeaksFinished(const QString& project_name)
|
||||
void MeasureAnalysisParticleCountPlotView::onAutoFindPeaksFinished(bool ok, const QString &project_name, const QVariant& data)
|
||||
{
|
||||
Q_UNUSED(project_name);
|
||||
Q_UNUSED(data);
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
this->_plot->CleanMarkers();
|
||||
this->_plot->replot();
|
||||
if (this->_find_peaks_result_dlg) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ private:
|
|||
void updatePlotPeakInfo(const QVariantMap& peak_infos);
|
||||
|
||||
private slots:
|
||||
void onAutoFindPeaksFinished(const QString& project_name);
|
||||
void onAutoFindPeaksFinished(bool ok, const QString &project_name, const QVariant& data);
|
||||
private slots:
|
||||
void onActionCurveShowSetting();
|
||||
void onActionFindPeaksResult();
|
||||
|
|
@ -44,6 +44,9 @@ private slots:
|
|||
void onActionEnergyScale();
|
||||
void onActionPlotConfigure();
|
||||
|
||||
signals:
|
||||
void applyEnergyScale();
|
||||
|
||||
private:
|
||||
QString _workspace;
|
||||
CustomQwtPlot* _plot = nullptr;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <QDir>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include "DataProcessWorkPool.h"
|
||||
|
||||
|
||||
MeasureAnalysisProjectModel::~MeasureAnalysisProjectModel()
|
||||
|
|
@ -430,15 +431,17 @@ MeasureAnalysisProjectModelList::~MeasureAnalysisProjectModelList()
|
|||
}
|
||||
}
|
||||
|
||||
bool MeasureAnalysisProjectModelList::AddProjectModel(MeasureAnalysisProjectModel* model)
|
||||
bool MeasureAnalysisProjectModelList::AddProjectModel(MeasureAnalysisProjectModel* model, bool save)
|
||||
{
|
||||
bool ok = true;
|
||||
const QString& project_name = model->GetProjectName();
|
||||
if (!_project_models.contains(project_name)) {
|
||||
_project_models[project_name] = model;
|
||||
intiProjectNodeStruce(model);
|
||||
SetCurrentProjectModel(project_name);
|
||||
model->SaveProjectModel();
|
||||
if (save) {
|
||||
this->SetCurrentProjectModel(project_name);
|
||||
model->SaveProjectModel();
|
||||
}
|
||||
} else {
|
||||
delete model;
|
||||
ok &= false;
|
||||
|
|
@ -610,8 +613,34 @@ QString MeasureAnalysisProjectModelList::GetNodeStatus(QStandardItem* item) cons
|
|||
return status_item ? status_item->text() : QString();
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModelList::onChannelAddressCountProcessFinished(const QString& project_name)
|
||||
void MeasureAnalysisProjectModelList::ApplyEnergyScale(const QString &project_name)
|
||||
{
|
||||
if (this->_project_models.contains(project_name)) {
|
||||
auto pro_model = this->_project_models[project_name];
|
||||
const QString& energy_scale_filename = pro_model->GetEnergyScaleFilename();
|
||||
QString status = QStringLiteral(u"未配置");
|
||||
if (energy_scale_filename.isEmpty()) {
|
||||
status = QStringLiteral(u"已配置");
|
||||
auto& node_map = this->_project_node_items[project_name];
|
||||
const QString& energy_scale_item_name = QStringLiteral(u"能量刻度");
|
||||
if (node_map.contains(energy_scale_item_name)) {
|
||||
auto energy_scale_item = node_map[energy_scale_item_name];
|
||||
this->SetNodeStatus(energy_scale_item, status);
|
||||
}
|
||||
pro_model->SaveProjectModel();
|
||||
|
||||
auto apply_erergy_scale_fit_task = new DataProcessWorkPool::ApplyEnergyScaleTask;
|
||||
apply_erergy_scale_fit_task->SetFinishedNotifier(this, "onApplyEnergyScaleProcessFinished", project_name);
|
||||
apply_erergy_scale_fit_task->StartTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModelList::onChannelAddressCountProcessFinished(bool ok, const QString& project_name, const QVariant &data)
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
if ( !ok )
|
||||
return;
|
||||
if (this->_project_models.contains(project_name)) {
|
||||
auto pro_model = this->_project_models[project_name];
|
||||
const QMap<uint, QString>& filename_list = pro_model->GetChannelAddressCountDataFilenameList();
|
||||
|
|
@ -648,6 +677,44 @@ void MeasureAnalysisProjectModelList::onChannelAddressCountProcessFinished(const
|
|||
}
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModelList::onApplyEnergyScaleProcessFinished(bool ok, const QString& project_name, const QVariant &data)
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
if ( !ok )
|
||||
return;
|
||||
if (this->_project_models.contains(project_name)) {
|
||||
auto pro_model = this->_project_models[project_name];
|
||||
auto& node_map = this->_project_node_items[project_name];
|
||||
QString status = QStringLiteral(u"无效");
|
||||
|
||||
const QString& energy_total_count_filename = pro_model->GetAllChannelEnergyTotalCountDataFilename();
|
||||
if (!energy_total_count_filename.isEmpty()) {
|
||||
status = QStringLiteral(u"有效");
|
||||
const QString& energy_total_count_item_name = QStringLiteral(u"能量计数");
|
||||
if (node_map.contains(energy_total_count_item_name)) {
|
||||
auto energy_total_count_item = node_map[energy_total_count_item_name];
|
||||
this->SetNodeStatus(energy_total_count_item, status);
|
||||
const QMap<uint, QString>& channel_energy_count_filename_list = pro_model->GetChannelEnergyCountDataFilenameList();
|
||||
for (auto it = channel_energy_count_filename_list.constBegin(); it != channel_energy_count_filename_list.constEnd(); ++it) {
|
||||
uint ch_num = it.key();
|
||||
QString item_name = QStringLiteral(u"通道%1能量计数").arg(ch_num);
|
||||
const QVariant& analys_type = QVariant::fromValue(AnalysisType::EnergyCountData);
|
||||
QStandardItem* node_item = AddChildNode(energy_total_count_item, item_name, status, analys_type, true);
|
||||
node_item->setData(project_name, ProjectName);
|
||||
node_item->setData(ch_num, ChannelNum);
|
||||
node_map[item_name] = node_item;
|
||||
}
|
||||
const QString& adrr_count_spec_item_name = QStringLiteral(u"能量计数谱");
|
||||
if (node_map.contains(adrr_count_spec_item_name)) {
|
||||
auto adrr_count_spec_item = node_map[adrr_count_spec_item_name];
|
||||
this->SetNodeStatus(adrr_count_spec_item, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
pro_model->SaveProjectModel();
|
||||
}
|
||||
}
|
||||
|
||||
void MeasureAnalysisProjectModelList::intiProjectNodeStruce(MeasureAnalysisProjectModel* pro_model)
|
||||
{
|
||||
if (!pro_model) {
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ public:
|
|||
static MeasureAnalysisProjectModelList* Instance();
|
||||
virtual ~MeasureAnalysisProjectModelList();
|
||||
|
||||
bool AddProjectModel(MeasureAnalysisProjectModel* model);
|
||||
bool AddProjectModel(MeasureAnalysisProjectModel* model, bool save = true);
|
||||
bool RmProjectModel(const QString& project_name);
|
||||
|
||||
MeasureAnalysisProjectModel* GetProjectModel(const QString& project_name);
|
||||
|
|
@ -152,8 +152,11 @@ public:
|
|||
void SetNodeStatus(QStandardItem* item, const QString& status);
|
||||
QString GetNodeStatus(QStandardItem* item) const;
|
||||
|
||||
void ApplyEnergyScale(const QString& project_name);
|
||||
|
||||
private slots:
|
||||
void onChannelAddressCountProcessFinished(const QString& project_name);
|
||||
void onChannelAddressCountProcessFinished(bool ok, const QString& project_name, const QVariant& data);
|
||||
void onApplyEnergyScaleProcessFinished(bool ok, const QString& project_name, const QVariant &data);
|
||||
|
||||
private:
|
||||
void intiProjectNodeStruce(MeasureAnalysisProjectModel *pro_model);
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index)
|
|||
view->SetViewDescription(view_name);
|
||||
view->InitViewWorkspace(project_name);
|
||||
view->SetAnalyzeDataFilename(data_files_set);
|
||||
|
||||
}
|
||||
if ( view ) {
|
||||
_item_views[item] = view;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include "DataProcessWorkPool.h"
|
||||
|
||||
NewMeasureAnalysisDlg::NewMeasureAnalysisDlg(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
|
|
@ -21,6 +22,8 @@ NewMeasureAnalysisDlg::~NewMeasureAnalysisDlg()
|
|||
|
||||
void NewMeasureAnalysisDlg::initialization()
|
||||
{
|
||||
ui->progressBar->setVisible(false);
|
||||
|
||||
QRegExp rx(R"(^[^\\/:*?"<>|]+$)");
|
||||
QValidator *validator = new QRegExpValidator(rx, this);
|
||||
ui->lineEdit_name->setValidator(validator);
|
||||
|
|
@ -102,6 +105,63 @@ void NewMeasureAnalysisDlg::initialization()
|
|||
connect(ui->btn_cancel, &QPushButton::clicked, this, &NewMeasureAnalysisDlg::reject);
|
||||
}
|
||||
|
||||
void NewMeasureAnalysisDlg::newProject(const QString& particle_data_filename)
|
||||
{
|
||||
const QString& project_name = ui->lineEdit_name->text();
|
||||
QString projects_dir_path = QDir(qApp->applicationDirPath()).filePath("Projects");
|
||||
QDir projects_dir(projects_dir_path);
|
||||
QString project_dir_path = projects_dir.filePath(project_name);
|
||||
|
||||
bool is_std_source = ui->checkBox_is_std_source->isChecked();
|
||||
ulong measure_preset_time = ui->spinBox_measure_preset_time->value();
|
||||
uint conform_time_win = ui->spinBox_conform_time->value();
|
||||
QString description_info = ui->plainTextEdit_description->toPlainText();
|
||||
MeasureAnalysisProjectModel::SpectrumType spec_type = MeasureAnalysisProjectModel::SpectrumType::None;
|
||||
if (ui->rbtn_sample_spec->isChecked()) {
|
||||
spec_type = MeasureAnalysisProjectModel::SpectrumType::Sample;
|
||||
} else if (ui->rbtn_background_spec->isChecked()) {
|
||||
spec_type = MeasureAnalysisProjectModel::SpectrumType::Background;
|
||||
}
|
||||
bool is_measure_complete = true;
|
||||
MeasureAnalysisProjectModel* model = new MeasureAnalysisProjectModel;
|
||||
model->SetProjectDir(project_dir_path);
|
||||
model->SetProjectName(project_name);
|
||||
model->SetSpectrumType(spec_type);
|
||||
model->SetIsStdSource(is_std_source);
|
||||
model->SetMeasurePresetTime(measure_preset_time);
|
||||
model->SetConformTimeWin(conform_time_win);
|
||||
model->SetDescriptionInfo(description_info);
|
||||
model->SetAllChannelParticleDataFilename(particle_data_filename);
|
||||
model->SetIsMeasureComplete(is_measure_complete);
|
||||
ProjectList::Instance()->AddProjectModel(model);
|
||||
NewMeasureAnalysisDlg::accept();
|
||||
}
|
||||
|
||||
void NewMeasureAnalysisDlg::onNewProjectFromFileFinished(bool ok, const QString& project_name, const QVariant &data)
|
||||
{
|
||||
QString projects_dir_path = QDir(qApp->applicationDirPath()).filePath("Projects");
|
||||
QDir projects_dir(projects_dir_path);
|
||||
QString project_dir_path = projects_dir.filePath(project_name);
|
||||
QDir project_dir(project_dir_path);
|
||||
if (ok) {
|
||||
QString all_channel_particle_data_filename = data.toString();
|
||||
QFileInfo data_file_info(all_channel_particle_data_filename);
|
||||
if ( data_file_info.exists(all_channel_particle_data_filename) ) {
|
||||
this->newProject(all_channel_particle_data_filename);
|
||||
}
|
||||
} else {
|
||||
project_dir.removeRecursively();
|
||||
|
||||
ui->stackedWidget->setEnabled(false);
|
||||
ui->btn_previous_step->setEnabled(false);
|
||||
ui->btn_next_step->setEnabled(false);
|
||||
ui->btn_ok->setEnabled(false);
|
||||
|
||||
const QString& data_file_path = ui->lineEdit_filename->property("data_file_path").toString();
|
||||
QMessageBox::warning(this, QStringLiteral(u"警告"), QStringLiteral(u"粒子数据%1异常,创建测量分析项目失败!").arg(data_file_path));
|
||||
}
|
||||
}
|
||||
|
||||
void NewMeasureAnalysisDlg::on_btn_ok_clicked()
|
||||
{
|
||||
const QString& project_name = ui->lineEdit_name->text();
|
||||
|
|
@ -112,56 +172,36 @@ void NewMeasureAnalysisDlg::on_btn_ok_clicked()
|
|||
QString projects_dir_path = QDir(qApp->applicationDirPath()).filePath("Projects");
|
||||
QDir projects_dir(projects_dir_path);
|
||||
QString project_dir_path = projects_dir.filePath(project_name);
|
||||
QDir project_dir(project_dir_path);
|
||||
QDir project_dir(project_dir_path);
|
||||
if (project_dir.exists()) {
|
||||
QMessageBox::warning(this, QStringLiteral(u"警告"), QStringLiteral(u"测量分析名称已存在,请重新输入!"));
|
||||
return;
|
||||
}
|
||||
MeasureAnalysisProjectModel::SpectrumType spec_type = MeasureAnalysisProjectModel::SpectrumType::None;
|
||||
if (ui->rbtn_sample_spec->isChecked()) {
|
||||
spec_type = MeasureAnalysisProjectModel::SpectrumType::Sample;
|
||||
} else if (ui->rbtn_background_spec->isChecked()) {
|
||||
spec_type = MeasureAnalysisProjectModel::SpectrumType::Background;
|
||||
}
|
||||
bool is_std_source = ui->checkBox_is_std_source->isChecked();
|
||||
ulong measure_preset_time = ui->spinBox_measure_preset_time->value();
|
||||
uint conform_time_win = ui->spinBox_conform_time->value();
|
||||
QString description_info = ui->plainTextEdit_description->toPlainText();
|
||||
bool is_measure_complete = false;
|
||||
|
||||
QString data_file_path;
|
||||
if (ui->checkBox_file_data->isChecked()) {
|
||||
data_file_path = ui->lineEdit_filename->property("data_file_path").toString();
|
||||
project_dir.mkpath(project_dir_path);
|
||||
if ( ui->checkBox_file_data->isChecked() ) {
|
||||
const QString& data_file_path = ui->lineEdit_filename->property("data_file_path").toString();
|
||||
if (data_file_path.isEmpty()) {
|
||||
QMessageBox::warning(this, QStringLiteral(u"警告"), QStringLiteral(u"请选择粒子数据文件!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
project_dir.mkpath(project_dir_path);
|
||||
// 拷贝粒子数据文件到项目目录
|
||||
QFileInfo data_file_info(data_file_path);
|
||||
QString all_channel_particle_data_filename = project_dir.filePath(data_file_info.fileName());
|
||||
if (!QFile::copy(data_file_path, all_channel_particle_data_filename)) {
|
||||
QMessageBox::warning(this, QStringLiteral(u"警告"), QStringLiteral(u"载入粒子数据文件到项目目录失败!"));
|
||||
project_dir.removeRecursively();
|
||||
return;
|
||||
auto separate_task = new DataProcessWorkPool::ParticleDataSortTask;
|
||||
separate_task->SetAllChannelParticleDataFilename(data_file_path);
|
||||
separate_task->SetSortedResultDir(project_dir_path);
|
||||
separate_task->SetFinishedNotifier(this, "onNewProjectFromFileFinished", project_name);
|
||||
separate_task->StartTask();
|
||||
ui->progressBar->setVisible(true);
|
||||
} else {
|
||||
is_measure_complete = true;
|
||||
this->newProject();
|
||||
}
|
||||
ui->stackedWidget->setEnabled(false);
|
||||
ui->btn_previous_step->setEnabled(false);
|
||||
ui->btn_next_step->setEnabled(false);
|
||||
ui->btn_ok->setEnabled(false);
|
||||
|
||||
MeasureAnalysisProjectModel* model = new MeasureAnalysisProjectModel;
|
||||
model->SetProjectDir(project_dir_path);
|
||||
model->SetProjectName(project_name);
|
||||
model->SetSpectrumType(spec_type);
|
||||
model->SetIsStdSource(is_std_source);
|
||||
model->SetMeasurePresetTime(measure_preset_time);
|
||||
model->SetConformTimeWin(conform_time_win);
|
||||
model->SetDescriptionInfo(description_info);
|
||||
model->SetAllChannelParticleDataFilename(all_channel_particle_data_filename);
|
||||
model->SetIsMeasureComplete(is_measure_complete);
|
||||
|
||||
ProjectList::Instance()->AddProjectModel(model);
|
||||
|
||||
NewMeasureAnalysisDlg::accept();
|
||||
// const QString& result_data_dir = QDir(project_model->GetProjectDir()).filePath("EveryChannelParticleData");
|
||||
// auto separate_task = new DataProcessWorkPool::EveryChannelParticleDataSeparateTask;
|
||||
// separate_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||
// separate_task->SetResultDataDir(result_data_dir);
|
||||
// separate_task->SetFinishedNotifier(this->_tree_measure_analysis, "onFinishedSeparateEveryChannelParticleData", project_name);
|
||||
// separate_task->StartTask();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,10 @@ public:
|
|||
|
||||
private:
|
||||
void initialization();
|
||||
void newProject(const QString &particle_data_filename = QString());
|
||||
|
||||
private slots:
|
||||
void onNewProjectFromFileFinished(bool ok, const QString& project_name, const QVariant &data);
|
||||
void on_btn_ok_clicked();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>534</width>
|
||||
<height>279</height>
|
||||
<width>550</width>
|
||||
<height>278</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -542,14 +542,36 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="textVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user