diff --git a/src/core/uProbeX.cpp b/src/core/uProbeX.cpp index 95090df..8211559 100644 --- a/src/core/uProbeX.cpp +++ b/src/core/uProbeX.cpp @@ -117,6 +117,7 @@ uProbeX::~uProbeX() } } m_subWindows.clear(); + exitApplication(); } //--------------------------------------------------------------------------- @@ -855,6 +856,12 @@ void uProbeX::openMapsWorkspace(QString dirName) QDir dir(dirName); dir.mkdir("img.dat"); dir.mkdir("output"); + QString ss1 = QString("output") + QDir::separator() + QString::fromStdString(STR_FIT_SPEC_DIR); + dir.mkdir(ss1); + ss1 = QString("output") + QDir::separator() + QString::fromStdString(STR_INT_SPEC_DIR); + dir.mkdir(ss1); + ss1 = QString("output") + QDir::separator() + QString::fromStdString(STR_FIT_PARAM_DIR); + dir.mkdir(ss1); QStringList recentPaths = Preferences::inst()->getValue(STR_RECENT_MAPS_WORKSPACES).toStringList(); recentPaths.removeAll(dirName); diff --git a/src/mvc/BatchRoiFitWidget.cpp b/src/mvc/BatchRoiFitWidget.cpp index 921e1ab..7605b97 100644 --- a/src/mvc/BatchRoiFitWidget.cpp +++ b/src/mvc/BatchRoiFitWidget.cpp @@ -172,6 +172,7 @@ void BatchRoiFitWidget::runProcessing() //run in thread analysis_job.dataset_directory = _directory; + analysis_job.output_dir = _directory; if (_optimizer_widget->isHybrid()) { analysis_job.optimize_fit_routine = OPTIMIZE_FIT_ROUTINE::HYBRID; diff --git a/src/mvc/BlueskyComm.h b/src/mvc/BlueskyComm.h index 359c502..bdec583 100644 --- a/src/mvc/BlueskyComm.h +++ b/src/mvc/BlueskyComm.h @@ -20,29 +20,20 @@ //--------------------------------------------------------------------------- -class BlueskyComm : public QThread +class BlueskyComm { - Q_OBJECT - public: /** * Constructor. */ - BlueskyComm(QString str_ip, QObject* parent = nullptr) : QThread(parent) + BlueskyComm(zmq::context_t *context, QString str_ip) { std::string conn_str = "tcp://"+str_ip.toStdString()+":60615"; - std::string lsn_str = "tcp://"+str_ip.toStdString()+":60625"; - _context = new zmq::context_t(1); - _zmq_comm_socket = new zmq::socket_t(*_context, ZMQ_REQ); + _zmq_comm_socket = new zmq::socket_t(*context, ZMQ_REQ); _zmq_comm_socket->connect(conn_str); - _zmq_lsn_socket = new zmq::socket_t(*_context, ZMQ_SUB); - _zmq_lsn_socket->connect(lsn_str); - _zmq_lsn_socket->set(zmq::sockopt::subscribe, "QS_Console"); - _zmq_lsn_socket->set(zmq::sockopt::rcvtimeo, 1000); //set timeout to 1000ms - } //--------------------------------------------------------------------------- @@ -57,19 +48,7 @@ class BlueskyComm : public QThread _zmq_comm_socket->close(); delete _zmq_comm_socket; } - if(_zmq_lsn_socket != nullptr) - { - _zmq_lsn_socket->close(); - delete _zmq_lsn_socket; - } - if (_context != nullptr) - { - _context->close(); - delete _context; - } _zmq_comm_socket = nullptr; - _zmq_lsn_socket = nullptr; - _context = nullptr; } //--------------------------------------------------------------------------- @@ -172,9 +151,9 @@ class BlueskyComm : public QThread zmq::message_t message; QByteArray msg_arr = gen_send_mesg("environment_open", nullptr); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); @@ -206,9 +185,9 @@ class BlueskyComm : public QThread zmq::message_t message; QByteArray msg_arr = gen_send_mesg("environment_close", nullptr); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); @@ -240,9 +219,9 @@ class BlueskyComm : public QThread zmq::message_t message; QByteArray msg_arr = gen_send_mesg("queue_start", nullptr); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); @@ -274,9 +253,9 @@ class BlueskyComm : public QThread zmq::message_t message; QByteArray msg_arr = gen_send_mesg("queue_stop", nullptr); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); @@ -312,9 +291,9 @@ class BlueskyComm : public QThread params["user_group"] = "primary"; QByteArray msg_arr = gen_send_mesg2("queue_item_add", params); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); @@ -350,9 +329,9 @@ class BlueskyComm : public QThread params["user_group"] = "primary"; QByteArray msg_arr = gen_send_mesg2("queue_item_update", params); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); @@ -388,9 +367,9 @@ class BlueskyComm : public QThread params["pos_dest"] = destRow; QByteArray msg_arr = gen_send_mesg2("queue_item_move", params); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); @@ -424,9 +403,9 @@ class BlueskyComm : public QThread params["pos"] = row; QByteArray msg_arr = gen_send_mesg2("queue_item_remove", params); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); @@ -462,9 +441,9 @@ class BlueskyComm : public QThread params["user_group"] = "primary"; QByteArray msg_arr = gen_send_mesg("plans_allowed", ¶ms); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none);; + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg);; - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); @@ -568,9 +547,9 @@ class BlueskyComm : public QThread zmq::message_t message; QByteArray msg_arr = gen_send_mesg("queue_get", nullptr); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); @@ -781,9 +760,9 @@ class BlueskyComm : public QThread zmq::message_t message; QByteArray msg_arr = gen_send_mesg("history_clear", nullptr); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { msg = QString::fromUtf8((char*)message.data(), message.size()); @@ -808,9 +787,9 @@ class BlueskyComm : public QThread zmq::message_t message; QByteArray msg_arr = gen_send_mesg("history_get", nullptr); zmq::message_t zmsg(msg_arr.data(), msg_arr.length()); - zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg, zmq::send_flags::none); + zmq::send_result_t s_res = _zmq_comm_socket->send(zmsg); - zmq::recv_result_t r_res = _zmq_comm_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t r_res = _zmq_comm_socket->recv(message); if(r_res.has_value()) { if(raw_mesg) @@ -963,54 +942,10 @@ class BlueskyComm : public QThread //--------------------------------------------------------------------------- -public slots: - void run() override - { - _running = true; - zmq::message_t token, message; - while(_running) - { - zmq::recv_result_t r_res = _zmq_lsn_socket->recv(token, zmq::recv_flags::none); - if(r_res.has_value()) - { - std::string s1 ((char*)token.data(), token.size()); - if(s1 == "QS_Console") - { - zmq::recv_result_t r_res2 = _zmq_comm_socket->recv(message, zmq::recv_flags::none); - if(r_res2.has_value()) - { - QJsonObject rootJson = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); - if(rootJson.contains("msg")) - { - QString msg = rootJson["msg"].toString(); - msg.chop(1); - emit newData(msg); - } - else - { - // logI<close(); - } - void stop() {_running = false;} - -signals: - void newData(const QString&); - protected: - bool _running; - - zmq::context_t *_context; - zmq::socket_t *_zmq_comm_socket; - zmq::socket_t *_zmq_lsn_socket; - }; diff --git a/src/mvc/FileTabWidget.cpp b/src/mvc/FileTabWidget.cpp index 5e827c7..5316f1e 100644 --- a/src/mvc/FileTabWidget.cpp +++ b/src/mvc/FileTabWidget.cpp @@ -38,6 +38,11 @@ FileTabWidget::FileTabWidget(QWidget* parent) : QWidget(parent) _file_list_view->setSelectionMode(QAbstractItemView::ExtendedSelection); //MultiSelection _file_list_view->setSortingEnabled(true); + //_file_list_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); + _file_list_view->horizontalHeader()->resizeSections(QHeaderView::Interactive); + _file_list_view->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents); + + // if preferences saves on select changes loaded dataset connect(_file_list_view->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &FileTabWidget::onFileRowChange); @@ -220,9 +225,6 @@ void FileTabWidget::set_file_list(const std::map& fileinfo_l { _file_list_model->appendRow( RowData(QIcon(":/images/circle_gray.png"), itr.first, (double)itr.second.size()/divisor)); } - - _file_list_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); - _file_list_view->horizontalHeader()->resizeSections(QHeaderView::Interactive); } //--------------------------------------------------------------------------- @@ -280,9 +282,6 @@ void FileTabWidget::update_file_list(const std::map& fileinf _file_list_model->appendRow(RowData(QIcon(":/images/circle_gray.png"), itr.first, (double)itr.second.size()/divisor)); } } - - _file_list_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); - _file_list_view->horizontalHeader()->resizeSections(QHeaderView::Interactive); } //--------------------------------------------------------------------------- diff --git a/src/mvc/FitParamsTableModel.cpp b/src/mvc/FitParamsTableModel.cpp index 6fa70ad..eb60d90 100644 --- a/src/mvc/FitParamsTableModel.cpp +++ b/src/mvc/FitParamsTableModel.cpp @@ -187,22 +187,30 @@ QVariant FitParamsTableModel::data(const QModelIndex &index, int role) const data_struct::Fit_Param fitp = _fit_parameters.at(_row_indicies[row]); if (index.column() == VALUE || index.column() == MIN_VAL) { - if (fitp.bound_type == data_struct::E_Bound_Type::LIMITED_LO || fitp.bound_type == data_struct::E_Bound_Type::LIMITED_LO_HI) + if (fitp.value < fitp.min_val) { - if (fitp.value < fitp.min_val) + if (fitp.bound_type == data_struct::E_Bound_Type::LIMITED_LO || fitp.bound_type == data_struct::E_Bound_Type::LIMITED_LO_HI) { return QColor(Qt::red); } + else + { + return QColor(Qt::darkYellow); + } } } if (index.column() == VALUE || index.column() == MAX_VAL) { - if (fitp.bound_type == data_struct::E_Bound_Type::LIMITED_HI || fitp.bound_type == data_struct::E_Bound_Type::LIMITED_LO_HI) + if (fitp.value > fitp.max_val) { - if (fitp.value > fitp.max_val) + if (fitp.bound_type == data_struct::E_Bound_Type::LIMITED_HI || fitp.bound_type == data_struct::E_Bound_Type::LIMITED_LO_HI) { return QColor(Qt::red); } + else + { + return QColor(Qt::darkYellow); + } } } } diff --git a/src/mvc/LiveMapsElementsWidget.cpp b/src/mvc/LiveMapsElementsWidget.cpp index a435b47..54ee6ba 100644 --- a/src/mvc/LiveMapsElementsWidget.cpp +++ b/src/mvc/LiveMapsElementsWidget.cpp @@ -20,10 +20,12 @@ LiveMapsElementsWidget::LiveMapsElementsWidget(QString ip, QString port, QWidget _qserverComm = nullptr; _mapsElementsWidget = nullptr; _last_packet = nullptr; + _qserverComm = nullptr; //_currentModel = new MapsH5Model(); _currentModel = nullptr; _num_images = 0; _prev_dataset_name = " "; + _context = new zmq::context_t(1); _qserver_ip_addr = new QLineEdit("127.0.0.1"); _qline_ip_addr = new QLineEdit(); if(ip.length() > 0) @@ -62,6 +64,11 @@ LiveMapsElementsWidget::~LiveMapsElementsWidget() } _currentModel = nullptr; + if(_qserverComm != nullptr) + { + delete _qserverComm; + } + if(_streamWorker != nullptr) { _streamWorker->stop(); @@ -77,6 +84,13 @@ LiveMapsElementsWidget::~LiveMapsElementsWidget() _mapsElementsWidget = nullptr; } + if (_context != nullptr) + { + _context->close(); + delete _context; + } + _context = nullptr; + } //--------------------------------------------------------------------------- @@ -167,15 +181,9 @@ void LiveMapsElementsWidget::updateIp() if(_qserverComm != nullptr) { - disconnect(_qserverComm, &BlueskyComm::newData, _scan_queue_widget, &ScanQueueWidget::newDataArrived); - _qserverComm->stop(); - _qserverComm->quit(); - _qserverComm->wait(); delete _qserverComm; } - _qserverComm = new BlueskyComm(_qserver_ip_addr->text(), this); - connect(_qserverComm, &BlueskyComm::newData, _scan_queue_widget, &ScanQueueWidget::newDataArrived); - _qserverComm->start(); + _qserverComm = new BlueskyComm(_context, _qserver_ip_addr->text()); if(_streamWorker != nullptr) { @@ -185,8 +193,9 @@ void LiveMapsElementsWidget::updateIp() _streamWorker->wait(); delete _streamWorker; } - _streamWorker = new NetStreamWorker(_qline_ip_addr->text(), _qline_port->text(), this); + _streamWorker = new NetStreamWorker(_context, _qline_ip_addr->text(), _qline_port->text(), _qserver_ip_addr->text(), this); connect(_streamWorker, &NetStreamWorker::newData, this, &LiveMapsElementsWidget::newDataArrived); + connect(_streamWorker, &NetStreamWorker::newStringData, _scan_queue_widget, &ScanQueueWidget::newDataArrived); _streamWorker->start(); if(_last_packet != nullptr) delete _last_packet; diff --git a/src/mvc/LiveMapsElementsWidget.h b/src/mvc/LiveMapsElementsWidget.h index 1b4a83d..2fa1ecc 100644 --- a/src/mvc/LiveMapsElementsWidget.h +++ b/src/mvc/LiveMapsElementsWidget.h @@ -130,6 +130,8 @@ public slots: std::string _prev_dataset_name; + zmq::context_t *_context; + int _num_images; }; diff --git a/src/mvc/MapsElementsWidget.cpp b/src/mvc/MapsElementsWidget.cpp index a12db03..aa796e4 100644 --- a/src/mvc/MapsElementsWidget.cpp +++ b/src/mvc/MapsElementsWidget.cpp @@ -1138,7 +1138,15 @@ void MapsElementsWidget::on_export_fit_params(data_struct::Fit_ParametersgetParamOverride(-1); + } + if (param_override == nullptr) + { + // generate param file + param_override = new data_struct::Params_Override(); } h5Model->set_fit_parameters_override(param_override); emit loaded_model(name, mt); diff --git a/src/mvc/NetStreamWorker.h b/src/mvc/NetStreamWorker.h index a47fd80..52c1f6a 100644 --- a/src/mvc/NetStreamWorker.h +++ b/src/mvc/NetStreamWorker.h @@ -12,6 +12,10 @@ #include #include "io/net/basic_serializer.h" #include +#include +#include +#include + //--------------------------------------------------------------------------- @@ -25,18 +29,23 @@ class NetStreamWorker : public QThread /** * Constructor. */ - NetStreamWorker(QString str_ip, QString port, QObject* parent = nullptr) : QThread(parent) + NetStreamWorker(zmq::context_t *context, QString str_ip, QString port, QString qserv_addr, QObject* parent = nullptr) : QThread(parent) { std::string conn_str = "tcp://"+str_ip.toStdString()+":"+port.toStdString(); - _context = new zmq::context_t(1); - _zmq_socket = new zmq::socket_t(*_context, ZMQ_SUB); + _zmq_socket = new zmq::socket_t(*context, ZMQ_SUB); _zmq_socket->connect(conn_str); _zmq_socket->set(zmq::sockopt::subscribe, "XRF-Counts"); _zmq_socket->set(zmq::sockopt::subscribe, "XRF-Spectra"); _zmq_socket->set(zmq::sockopt::subscribe, "XRF-Counts-and-Spectra"); _zmq_socket->set(zmq::sockopt::rcvtimeo, 1000); //set timeout to 1000ms + std::string conn_str2 = "tcp://"+qserv_addr.toStdString()+":60625"; + _zmq_qserv_socket = new zmq::socket_t(*context, ZMQ_SUB); + _zmq_qserv_socket->connect(conn_str2); + _zmq_qserv_socket->set(zmq::sockopt::subscribe, "QS_Console"); + _zmq_qserv_socket->set(zmq::sockopt::rcvtimeo, 1000); //set timeout to 1000ms + } /** @@ -49,13 +58,14 @@ class NetStreamWorker : public QThread _zmq_socket->close(); delete _zmq_socket; } - if (_context != nullptr) + _zmq_socket = nullptr; + + if(_zmq_qserv_socket != nullptr) { - _context->close(); - delete _context; + _zmq_qserv_socket->close(); + delete _zmq_qserv_socket; } - _zmq_socket = nullptr; - _context = nullptr; + _zmq_qserv_socket = nullptr; } public slots: @@ -66,13 +76,13 @@ public slots: zmq::message_t token, message; while(_running) { - zmq::recv_result_t res = _zmq_socket->recv(token, zmq::recv_flags::none); + zmq::recv_result_t res = _zmq_socket->recv(token, zmq::recv_flags::dontwait); if(res.has_value()) { std::string s1 ((char*)token.data(), token.size()); if(s1 == "XRF-Counts-and-Spectra") { - zmq::recv_result_t res2 = _zmq_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t res2 = _zmq_socket->recv(message); if(res2.has_value()) { new_packet = _serializer.decode_counts_and_spectra((char*)message.data(), message.size()); @@ -81,7 +91,7 @@ public slots: } else if(s1 == "XRF-Counts") { - zmq::recv_result_t res2 = _zmq_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t res2 = _zmq_socket->recv(message); if(res2.has_value()) { new_packet = _serializer.decode_counts((char*)message.data(), message.size()); @@ -90,7 +100,7 @@ public slots: } else if(s1 == "XRF-Spectra") { - zmq::recv_result_t res2 = _zmq_socket->recv(message, zmq::recv_flags::none); + zmq::recv_result_t res2 = _zmq_socket->recv(message); if(res2.has_value()) { new_packet = _serializer.decode_spectra((char*)message.data(), message.size()); @@ -98,22 +108,49 @@ public slots: } } } + + res = _zmq_qserv_socket->recv(token, zmq::recv_flags::dontwait); + if(res.has_value()) + { + std::string s1 ((char*)token.data(), token.size()); + if(s1 == "QS_Console") + { + zmq::recv_result_t r_res2 = _zmq_qserv_socket->recv(message); + if(r_res2.has_value()) + { + QJsonObject rootJson = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); + if(rootJson.contains("msg")) + { + QString msg = rootJson["msg"].toString(); + msg.chop(1); + emit newStringData(msg); + } + else + { + // logI<close(); + _zmq_qserv_socket->close(); } void stop() {_running = false;} signals: void newData(data_struct::Stream_Block *new_packet); + void newStringData(QString); + protected: bool _running; - zmq::context_t *_context; - zmq::socket_t *_zmq_socket; + zmq::socket_t *_zmq_qserv_socket; + io::net::Basic_Serializer _serializer; }; diff --git a/src/mvc/PerPixelFitWidget.cpp b/src/mvc/PerPixelFitWidget.cpp index 034dd73..d845054 100644 --- a/src/mvc/PerPixelFitWidget.cpp +++ b/src/mvc/PerPixelFitWidget.cpp @@ -57,6 +57,7 @@ void PerPixelFitWidget::runProcessing() // TODO: fix so we can do float data_struct::Analysis_Job analysis_job; analysis_job.dataset_directory = _directory; + analysis_job.output_dir = analysis_job.dataset_directory; _optionsWidget->setRunning(); _optionsWidget->updateAnalysisJob(analysis_job);