diff --git a/src/gstar/Annotation/ScanRegionGraphicsItem.cpp b/src/gstar/Annotation/ScanRegionGraphicsItem.cpp index 3751e9e..9813d90 100644 --- a/src/gstar/Annotation/ScanRegionGraphicsItem.cpp +++ b/src/gstar/Annotation/ScanRegionGraphicsItem.cpp @@ -147,7 +147,14 @@ void ScanRegionGraphicsItem::onScanUpdated(const BlueskyPlan& plan) { setPropertyValue(DEF_STR_DISPLAY_NAME, _scan_dialog.getScanName()); - emit scanUpdated(plan); + BlueskyPlan nplan = plan; + nplan.name = _scan_dialog.getScanName(); + BlueskyParam meta_data; + meta_data.name = "md"; + meta_data.default_val = nplan.name; + meta_data.description = "Link to scan name"; + nplan.parameters["md"] = meta_data; + emit scanUpdated(nplan); } /* diff --git a/src/mvc/BatchRoiFitWidget.cpp b/src/mvc/BatchRoiFitWidget.cpp index b5d7cca..cd1c35f 100644 --- a/src/mvc/BatchRoiFitWidget.cpp +++ b/src/mvc/BatchRoiFitWidget.cpp @@ -54,8 +54,8 @@ void BatchRoiFitWidget::createLayout() _cb_opt_method = new QComboBox(); _cb_opt_method->addItem(STR_HYBRID_MP_FIT); - _cb_opt_method->addItem(STR_LM_FIT); _cb_opt_method->addItem(STR_MP_FIT); + _cb_opt_method->addItem(STR_LM_FIT); connect(_cb_opt_method, &QComboBox::currentTextChanged, this, &BatchRoiFitWidget::optimizer_changed); _file_list_model = new QStandardItemModel(); diff --git a/src/mvc/BlueskyComm.h b/src/mvc/BlueskyComm.h index 5925414..637f69d 100644 --- a/src/mvc/BlueskyComm.h +++ b/src/mvc/BlueskyComm.h @@ -118,7 +118,7 @@ class BlueskyComm : public QThread QJsonObject item; - item["name"] = plan.name; + item["name"] = plan.type; item["item_type"] = "plan"; QJsonObject kwargs; @@ -137,6 +137,11 @@ class BlueskyComm : public QThread { // bool ret = false; + + if(_zmq_comm_socket == nullptr) + { + return ret; + } zmq::message_t message; QByteArray msg_arr = gen_send_mesg("environment_open", nullptr); _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); @@ -163,6 +168,10 @@ class BlueskyComm : public QThread { // bool ret = false; + if(_zmq_comm_socket == nullptr) + { + return ret; + } zmq::message_t message; QByteArray msg_arr = gen_send_mesg("environment_close", nullptr); _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); @@ -189,6 +198,10 @@ class BlueskyComm : public QThread { // bool ret = false; + if(_zmq_comm_socket == nullptr) + { + return ret; + } zmq::message_t message; QByteArray msg_arr = gen_send_mesg("queue_start", nullptr); _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); @@ -215,6 +228,10 @@ class BlueskyComm : public QThread { // bool ret = false; + if(_zmq_comm_socket == nullptr) + { + return ret; + } zmq::message_t message; QByteArray msg_arr = gen_send_mesg("queue_stop", nullptr); _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); @@ -240,6 +257,10 @@ class BlueskyComm : public QThread bool queue_plan(QString &msg, const BlueskyPlan& plan) { bool ret = false; + if(_zmq_comm_socket == nullptr) + { + return ret; + } zmq::message_t message; QJsonObject params; @@ -274,7 +295,10 @@ class BlueskyComm : public QThread //params["user_group"] = "primary"; //obj["params"] = params; - + if(_zmq_comm_socket == nullptr) + { + return ret; + } std::map params; params["user_group"] = "primary"; QByteArray msg_arr = gen_send_mesg("plans_allowed", ¶ms); @@ -350,6 +374,10 @@ class BlueskyComm : public QThread bool get_queued_scans(QString &msg, std::vector &queued_plans, BlueskyPlan &running_plan) { bool ret = false; + if(_zmq_comm_socket == nullptr) + { + return ret; + } running_plan.name = ""; running_plan.uuid = ""; zmq::message_t message; @@ -393,7 +421,7 @@ class BlueskyComm : public QThread QJsonObject param = itr2.toObject(); if(param.contains("name")) { - plan.name = param["name"].toString(); + plan.type = param["name"].toString(); } if(param.contains("args")) { @@ -409,6 +437,10 @@ class BlueskyComm : public QThread bsp.name = pitr; bsp.default_val = kwargs[pitr].toString(); plan.parameters[pitr] = bsp; + if(pitr == "md") // use meta data to link to scan name + { + plan.name = bsp.default_val; + } } } if(param.contains("user")) diff --git a/src/mvc/BlueskyPlan.h b/src/mvc/BlueskyPlan.h index 9e744a4..ca97ad3 100644 --- a/src/mvc/BlueskyPlan.h +++ b/src/mvc/BlueskyPlan.h @@ -33,6 +33,7 @@ struct BlueskyPlan user=""; } QString name; + QString type; QString description; QString module; std::unordered_map parameters; diff --git a/src/mvc/LiveMapsElementsWidget.cpp b/src/mvc/LiveMapsElementsWidget.cpp index d2e3137..0f4a4f9 100644 --- a/src/mvc/LiveMapsElementsWidget.cpp +++ b/src/mvc/LiveMapsElementsWidget.cpp @@ -288,6 +288,10 @@ void LiveMapsElementsWidget::image_changed(int start, int end) void LiveMapsElementsWidget::updateScansAvailable() { QString msg; + if(_qserverComm == nullptr) + { + updateIp(); + } if (false == _qserverComm->get_avail_scans(_avail_scans, msg)) { _scan_queue_widget->newDataArrived( msg ); @@ -300,6 +304,10 @@ void LiveMapsElementsWidget::updateScansAvailable() void LiveMapsElementsWidget::getQueuedScans() { QString msg; + if(_qserverComm == nullptr) + { + updateIp(); + } if (false == _qserverComm->get_queued_scans(msg, _queued_scans, _running_scan)) { _scan_queue_widget->newDataArrived( msg ); @@ -315,6 +323,10 @@ void LiveMapsElementsWidget::getQueuedScans() void LiveMapsElementsWidget::callOpenEnv() { QString msg; + if(_qserverComm == nullptr) + { + updateIp(); + } if (false == _qserverComm->open_env(msg)) { //_scan_queue_widget->newDataArrived( msg ); @@ -332,6 +344,10 @@ void LiveMapsElementsWidget::callOpenEnv() void LiveMapsElementsWidget::callCloseEnv() { QString msg; + if(_qserverComm == nullptr) + { + updateIp(); + } if (false == _qserverComm->close_env(msg)) { //_scan_queue_widget->newDataArrived( msg ); @@ -349,6 +365,10 @@ void LiveMapsElementsWidget::callCloseEnv() void LiveMapsElementsWidget::callStartQueue() { QString msg; + if(_qserverComm == nullptr) + { + updateIp(); + } if (false == _qserverComm->start_queue(msg)) { //_scan_queue_widget->newDataArrived( msg ); @@ -366,6 +386,10 @@ void LiveMapsElementsWidget::callStartQueue() void LiveMapsElementsWidget::callStopQueue() { QString msg; + if(_qserverComm == nullptr) + { + updateIp(); + } if (false == _qserverComm->stop_queue(msg)) { //_scan_queue_widget->newDataArrived( msg ); @@ -383,6 +407,10 @@ void LiveMapsElementsWidget::callStopQueue() void LiveMapsElementsWidget::queueScan(const BlueskyPlan& plan) { QString msg; + if(_qserverComm == nullptr) + { + updateIp(); + } if (false == _qserverComm->queue_plan(msg, plan)) { diff --git a/src/mvc/ScanQueueTableModel.h b/src/mvc/ScanQueueTableModel.h index e3c95fa..0ada60d 100644 --- a/src/mvc/ScanQueueTableModel.h +++ b/src/mvc/ScanQueueTableModel.h @@ -20,8 +20,9 @@ class ScanQueueTableModel : public QAbstractTableModel ScanQueueTableModel(QObject* parent = nullptr) : QAbstractTableModel(parent) { _headers[0] = "name"; - _headers[1] = "user"; - _headers[2] = "uuid"; + _headers[1] = "type"; + _headers[2] = "user"; + _headers[3] = "uuid"; } //--------------------------------------------------------------------------- int rowCount(const QModelIndex& parent = QModelIndex()) const override @@ -31,7 +32,7 @@ class ScanQueueTableModel : public QAbstractTableModel int columnCount(const QModelIndex& parent = QModelIndex()) const override { - return 3; + return 4; } //--------------------------------------------------------------------------- void appendRow(const BlueskyPlan& row) @@ -86,8 +87,10 @@ class ScanQueueTableModel : public QAbstractTableModel case 0: return rowData.name; case 1: - return rowData.user; + return rowData.type; case 2: + return rowData.user; + case 3: return rowData.uuid; }; } @@ -102,7 +105,7 @@ class ScanQueueTableModel : public QAbstractTableModel // Horizontal headers if (orientation == Qt::Horizontal) { - if(section > 3) + if(section > 4) { return QVariant(); } @@ -147,7 +150,7 @@ class ScanQueueTableModel : public QAbstractTableModel { if (role == Qt::EditRole && index.isValid()) { - if( index.row() < _data.size() && index.column() == 1) + if( index.row() < _data.size() && index.column() == 2) { _data[index.row()].user = value.toString(); return true; @@ -162,7 +165,7 @@ class ScanQueueTableModel : public QAbstractTableModel private: QList _data; - QString _headers[3]; + QString _headers[4]; }; diff --git a/src/mvc/ScanQueueWidget.cpp b/src/mvc/ScanQueueWidget.cpp index 43f2de1..10c6e12 100644 --- a/src/mvc/ScanQueueWidget.cpp +++ b/src/mvc/ScanQueueWidget.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "core/defines.h" @@ -38,10 +39,15 @@ void ScanQueueWidget::_createLayout() _scan_running_table_view = new QTableView(); _scan_running_table_view->setFixedHeight(100); _scan_running_table_view->setModel(_scan_running_table_model); + _scan_running_table_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); + // _scan_running_table_view->horizontalHeader()->resizeSections(QHeaderView::Interactive); _scan_queue_table_model = new ScanQueueTableModel(); _scan_queue_table_view = new QTableView(); _scan_queue_table_view->setModel(_scan_queue_table_model); + _scan_queue_table_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); + // _scan_queue_table_view->horizontalHeader()->resizeSections(QHeaderView::Interactive); + QSize btn_size(33,33); @@ -105,12 +111,14 @@ void ScanQueueWidget::_createLayout() void ScanQueueWidget::updateQueuedItems( std::vector &queued_plans, BlueskyPlan &running_plan) { _scan_queue_table_model->setAllData(queued_plans); + _scan_queue_table_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); std::vector runlist; if(running_plan.uuid.length() > 0) { runlist.push_back(running_plan); } _scan_running_table_model->setAllData(runlist); + _scan_running_table_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); } //--------------------------------------------------------------------------- diff --git a/src/mvc/ScanRegionDialog.cpp b/src/mvc/ScanRegionDialog.cpp index fb83709..9e22d5c 100644 --- a/src/mvc/ScanRegionDialog.cpp +++ b/src/mvc/ScanRegionDialog.cpp @@ -115,7 +115,7 @@ void ScanRegionDialog::onUpdate() void ScanRegionDialog::onUpdateAndQueue() { BlueskyPlan plan; - plan.name = _scan_type->currentText(); + plan.type = _scan_type->currentText(); _scan_table_model->getCurrentParams(plan); emit ScanUpdated(plan); close();