From 97ae8cac4a523e1a0e634381e91f1c4670cbb943 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Mon, 29 Jul 2024 14:52:12 -0500 Subject: [PATCH 1/9] Adddd ZMQ connections to bluesky qserver. Gets info and can get available scans --- .../Annotation/ScanRegionGraphicsItem.cpp | 7 +- src/gstar/Annotation/ScanRegionGraphicsItem.h | 4 +- src/mvc/BlueskyComm.h | 91 ++++++++++++++++++- src/mvc/LiveMapsElementsWidget.cpp | 46 +++++++++- src/mvc/LiveMapsElementsWidget.h | 8 ++ src/mvc/ScanQueueWidget.cpp | 57 ++---------- src/mvc/ScanQueueWidget.h | 6 +- src/mvc/ScanRegionDialog.cpp | 35 ++++++- src/mvc/ScanRegionDialog.h | 10 +- src/mvc/VLM_Widget.cpp | 3 +- src/mvc/VLM_Widget.h | 5 + 11 files changed, 198 insertions(+), 74 deletions(-) diff --git a/src/gstar/Annotation/ScanRegionGraphicsItem.cpp b/src/gstar/Annotation/ScanRegionGraphicsItem.cpp index c36435b..e812724 100644 --- a/src/gstar/Annotation/ScanRegionGraphicsItem.cpp +++ b/src/gstar/Annotation/ScanRegionGraphicsItem.cpp @@ -15,10 +15,11 @@ using namespace gstar; //--------------------------------------------------------------------------- -ScanRegionGraphicsItem::ScanRegionGraphicsItem(AbstractGraphicsItem* parent) +ScanRegionGraphicsItem::ScanRegionGraphicsItem(std::unordered_map * avail_scans, AbstractGraphicsItem* parent) : UProbeRegionGraphicsItem(parent) { - + _avail_scans = avail_scans; + _scan_dialog.setAvailScans(avail_scans); connect(&_scan_dialog, &ScanRegionDialog::ScanUpdated, this, &ScanRegionGraphicsItem::onScanUpdated); prependProperty(new AnnotationProperty("Edit", QIcon(":/images/editing.png"))); @@ -124,7 +125,7 @@ const QString ScanRegionGraphicsItem::displayName() const ScanRegionGraphicsItem* ScanRegionGraphicsItem::cloneRegion() { - ScanRegionGraphicsItem* newRegion = new ScanRegionGraphicsItem(); + ScanRegionGraphicsItem* newRegion = new ScanRegionGraphicsItem(_avail_scans); //newRegion->m_outlineColor = m_outlineColor; newRegion->m_rect = m_rect; diff --git a/src/gstar/Annotation/ScanRegionGraphicsItem.h b/src/gstar/Annotation/ScanRegionGraphicsItem.h index 1242889..ca42980 100644 --- a/src/gstar/Annotation/ScanRegionGraphicsItem.h +++ b/src/gstar/Annotation/ScanRegionGraphicsItem.h @@ -24,6 +24,7 @@ #include "gstar/CoordinateModel.h" #include "gstar/Annotation/UProbeRegionGraphicsItem.h" #include "mvc/ScanRegionDialog.h" +#include "mvc/BlueSkyPlan.h" //--------------------------------------------------------------------------- @@ -46,7 +47,7 @@ Q_OBJECT * @param h - height * @param parent - parent Qt widget */ - ScanRegionGraphicsItem(AbstractGraphicsItem* parent = 0); + ScanRegionGraphicsItem(std::unordered_map * avail_scans, AbstractGraphicsItem* parent = 0); /** * @brief MarkerGraphicsItem @@ -155,6 +156,7 @@ public slots: private: ScanRegionDialog _scan_dialog; + std::unordered_map *_avail_scans; /* void initialScale(); diff --git a/src/mvc/BlueskyComm.h b/src/mvc/BlueskyComm.h index 2f7b816..4fd0260 100644 --- a/src/mvc/BlueskyComm.h +++ b/src/mvc/BlueskyComm.h @@ -13,6 +13,7 @@ #include #include #include "support/zmq/zmq.hpp" +#include "mvc/BlueskyPlan.h" #include //--------------------------------------------------------------------------- @@ -30,7 +31,7 @@ class BlueskyComm : public QThread BlueskyComm(QString str_ip, QObject* parent = nullptr) : QThread(parent) { - std::string conn_str = "tcp://"+str_ip.toStdString()+":60610"; // or 60615 + 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); @@ -67,6 +68,82 @@ class BlueskyComm : public QThread _context = nullptr; } + bool get_avail_scans(std::unordered_map &plans, QString &msg) + { + bool ret = false; + zmq::message_t message; + QJsonDocument doc; + QJsonObject obj; + QJsonObject params; + obj["method"] = "plans_allowed"; + params["user_group"] = "primary"; + obj["params"] = params; + doc.setObject(obj); + QByteArray msg_arr = doc.toJson(); + _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); + + _zmq_comm_socket->recv(&message); + QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); + if(reply.contains("success")) + { + if(reply["success"].toString() == "true") + { + ret = true; + } + } + if(reply.contains("plans_allowed")) + { + QJsonObject iojb = reply["plans_allowed"].toObject(); + for( auto itr : iojb) + { + QJsonObject pobj = itr.toObject(); + if(pobj.contains("name")) + { + plans[pobj["name"].toString()].name = pobj["name"].toString(); + if(pobj.contains("description")) + { + plans[pobj["name"].toString()].description = pobj["description"].toString(); + } + if(pobj.contains("module")) + { + plans[pobj["name"].toString()].module = pobj["module"].toString(); + } + if(pobj.contains("parameters")) + { + QJsonArray params_obj = pobj["parameters"].toArray(); + for( auto itr2 : params_obj) + { + QJsonObject param = itr2.toObject(); + if(param.contains("name")) + { + plans[pobj["name"].toString()].parameters[param["name"].toString()].name = param["name"].toString(); + if(param.contains("default")) + { + plans[pobj["name"].toString()].parameters[param["name"].toString()].default_val = param["default"].toString(); + } + if(param.contains("description")) + { + plans[pobj["name"].toString()].parameters[param["name"].toString()].description = param["description"].toString(); + } + } + } + } + } + + } + } + if(reply.contains("msg")) + { + msg = reply["msg"].toString(); + } + return ret; + } + + void get_queued_scans() + { + + } + public slots: void run() override { @@ -80,7 +157,15 @@ public slots: { if(_zmq_lsn_socket->recv(&message)) { - emit newData(QString::fromUtf8((char*)message.data(), message.size())); + QJsonObject rootJson = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); + if(rootJson.contains("msg")) + { + emit newData(rootJson["msg"].toString()); + } + else + { + // logI< 0) { @@ -83,15 +85,19 @@ void LiveMapsElementsWidget::createLayout() QVBoxLayout* layout = new QVBoxLayout(); QHBoxLayout* hlayout = new QHBoxLayout(); + QHBoxLayout* hlayout2 = new QHBoxLayout(); _btn_update = new QPushButton("Update"); connect(_btn_update, SIGNAL(released()), this, SLOT(updateIp())); - hlayout->addWidget(new QLabel("Computer:")); - hlayout->addWidget(_qline_ip_addr); - hlayout->addWidget(new QLabel("Port:")); - hlayout->addWidget(_qline_port); - hlayout->addWidget(_btn_update); + hlayout->addWidget(new QLabel("QServer Computer:")); + hlayout->addWidget(_qserver_ip_addr); + hlayout2->addWidget(new QLabel("XRF-Maps Computer:")); + hlayout2->addWidget(_qline_ip_addr); + hlayout2->addWidget(new QLabel("Port:")); + hlayout2->addWidget(_qline_port); + hlayout2->addWidget(_btn_update); layout->addLayout(hlayout); + layout->addLayout(hlayout2); // _textEdit = new QTextEdit(this); // _textEdit->resize(1024, 800); @@ -120,6 +126,7 @@ void LiveMapsElementsWidget::createLayout() _vlm_widget = new VLM_Widget(); + _vlm_widget->setAvailScans(&_avail_scans); _scan_queue_widget = new ScanQueueWidget(); @@ -141,6 +148,18 @@ void LiveMapsElementsWidget::createLayout() 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(); if(_streamWorker != nullptr) { @@ -156,6 +175,8 @@ void LiveMapsElementsWidget::updateIp() if(_last_packet != nullptr) delete _last_packet; _last_packet = nullptr; + + updateScansAvailable(); } //--------------------------------------------------------------------------- @@ -253,3 +274,18 @@ void LiveMapsElementsWidget::image_changed(int start, int end) { _mapsElementsWidget->setModel(_maps_h5_models[start-1]); } + +//--------------------------------------------------------------------------- + +void LiveMapsElementsWidget::updateScansAvailable() +{ + QString reply; + QString msg; + if (false == _qserverComm->get_avail_scans(_avail_scans, msg)) + { + _scan_queue_widget->newDataArrived( msg ); + } + +} + +//--------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/mvc/LiveMapsElementsWidget.h b/src/mvc/LiveMapsElementsWidget.h index b2b0ba5..1af4873 100644 --- a/src/mvc/LiveMapsElementsWidget.h +++ b/src/mvc/LiveMapsElementsWidget.h @@ -19,6 +19,7 @@ #include "mvc/MapsElementsWidget.h" #include "mvc/VLM_Widget.h" #include "mvc/ScanQueueWidget.h" +#include "mvc/BlueskyComm.h" //--------------------------------------------------------------------------- @@ -44,6 +45,7 @@ class LiveMapsElementsWidget : public QWidget QString getPort(){return _qline_port->text();} + void updateScansAvailable(); public slots: void newDataArrived(data_struct::Stream_Block* new_packet); @@ -73,6 +75,10 @@ public slots: NetStreamWorker* _streamWorker; + BlueskyComm* _qserverComm; + + QLineEdit *_qserver_ip_addr; + QLineEdit *_qline_ip_addr; QLineEdit *_qline_port; @@ -83,6 +89,8 @@ public slots: MapsH5Model *_currentModel; + std::unordered_map _avail_scans; + data_struct::Stream_Block* _last_packet; std::string _prev_dataset_name; diff --git a/src/mvc/ScanQueueWidget.cpp b/src/mvc/ScanQueueWidget.cpp index 65a1215..1e53c49 100644 --- a/src/mvc/ScanQueueWidget.cpp +++ b/src/mvc/ScanQueueWidget.cpp @@ -33,67 +33,24 @@ void ScanQueueWidget::_createLayout() QVBoxLayout* layout = new QVBoxLayout(); + _scan_table_view = new QTableView(); + layout->addWidget(new QLabel("Scan Queue")); + layout->addWidget(_scan_table_view); + _te_qs_console = new QTextEdit(this); _te_qs_console->scrollBarWidgets(Qt::AlignRight); + layout->addWidget(new QLabel("QServer Log")); layout->addWidget(_te_qs_console); setLayout(layout); -/* - QHBoxLayout* hlayout = new QHBoxLayout(); - _btn_update = new QPushButton("Update"); - connect(_btn_update, SIGNAL(released()), this, SLOT(updateIp())); - - hlayout->addWidget(new QLabel("Computer:")); - hlayout->addWidget(_qline_ip_addr); - hlayout->addWidget(new QLabel("Port:")); - hlayout->addWidget(_qline_port); - hlayout->addWidget(_btn_update); - layout->addLayout(hlayout); - - _mapsElementsWidget = new MapsElementsWidget(1,1,true); - //_mapsElementsWidget->setTabVisible(1, false); - _mapsElementsWidget->setTabVisible(2, false); - _mapsElementsWidget->setTabVisible(3, false); - _mapsElementsWidget->setTabVisible(4, false); - _mapsElementsWidget->setTabVisible(5, false); - //_mapsElementsWidget->setModel(_currentModel, nullptr, nullptr); - // _mapsElementsWidget->appendTab(_textEdit, "Log"); - - connect(_mapsElementsWidget, - SIGNAL(rangeChanged(int, int)), - this, - SLOT(image_changed(int, int))); - - if(_currentModel != nullptr) - { - connect(_currentModel, - SIGNAL(model_data_updated()), - _mapsElementsWidget, - SLOT(model_updated())); - } - - - _vlm_widget = new VLM_Widget(); - - _tab_widget = new QTabWidget(); - - _tab_widget->addTab(_mapsElementsWidget, "Counts"); - _tab_widget->addTab(_vlm_widget, "Scan Area"); - //_tab_widget->addTab(_scan_queue, "Queue"); - - - layout->addWidget(_tab_widget); - - _progressBar = new QProgressBar(this); - layout->addWidget(_progressBar); - setLayout(layout); -*/ + } //--------------------------------------------------------------------------- void ScanQueueWidget::newDataArrived(const QString& data) { + _te_qs_console->append(data); } //--------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/mvc/ScanQueueWidget.h b/src/mvc/ScanQueueWidget.h index e425ca0..5bf75e2 100644 --- a/src/mvc/ScanQueueWidget.h +++ b/src/mvc/ScanQueueWidget.h @@ -10,6 +10,7 @@ #include #include +#include //--------------------------------------------------------------------------- @@ -44,11 +45,8 @@ public slots: QTextEdit *_te_qs_console; -// QLineEdit *_qline_ip_addr; + QTableView* _scan_table_view; -// QLineEdit *_qline_port; - -// QPushButton *_btn_update; }; diff --git a/src/mvc/ScanRegionDialog.cpp b/src/mvc/ScanRegionDialog.cpp index 7a31dbc..d21ad7d 100644 --- a/src/mvc/ScanRegionDialog.cpp +++ b/src/mvc/ScanRegionDialog.cpp @@ -16,7 +16,7 @@ ScanRegionDialog::ScanRegionDialog() : QDialog() { - + _avail_scans = nullptr; _createLayout(); } @@ -36,15 +36,16 @@ void ScanRegionDialog::_createLayout() _scan_name = new QLineEdit(" "); _scan_type = new QComboBox(); + connect(_scan_type, &QComboBox::currentTextChanged, this, &ScanRegionDialog::scanChanged); - _scan_options = new QListWidget(); + _scan_options = new QTableView(); _btn_update = new QPushButton("Update"); _btn_update_and_queue = new QPushButton("Update and Queue"); _btn_cancel = new QPushButton("Cancel"); - connect(_btn_update, SIGNAL(pressed()), this, SLOT(onUpdate())); - connect(_btn_update_and_queue, SIGNAL(pressed()), this, SLOT(onUpdateAndQueue())); - connect(_btn_cancel, SIGNAL(pressed()), this, SLOT(close())); + connect(_btn_update, &QPushButton::pressed, this, &ScanRegionDialog::onUpdate); + connect(_btn_update_and_queue, &QPushButton::pressed, this, &ScanRegionDialog::onUpdateAndQueue); + connect(_btn_cancel, &QPushButton::pressed, this, &ScanRegionDialog::close); QVBoxLayout* main_layout = new QVBoxLayout(); @@ -74,6 +75,20 @@ void ScanRegionDialog::_createLayout() //--------------------------------------------------------------------------- +void ScanRegionDialog::setAvailScans(std::unordered_map * avail_scans) +{ + _avail_scans = avail_scans; + int i=0; + _scan_type->clear(); + for(auto itr : *avail_scans) + { + _scan_type->insertItem(i, itr.first); + i++; + } +} + +//--------------------------------------------------------------------------- + void ScanRegionDialog::updateProps(QList &anno_list) { for(auto &itr : anno_list) @@ -101,5 +116,15 @@ void ScanRegionDialog::onUpdateAndQueue() close(); } +//--------------------------------------------------------------------------- + +void ScanRegionDialog::scanChanged(const QString &scan_name) +{ + if(_avail_scans != nullptr) + { + + } +} + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- diff --git a/src/mvc/ScanRegionDialog.h b/src/mvc/ScanRegionDialog.h index 01b2a77..33d23f2 100644 --- a/src/mvc/ScanRegionDialog.h +++ b/src/mvc/ScanRegionDialog.h @@ -15,8 +15,9 @@ #include #include #include -#include +#include #include "gstar/AnnotationProperty.h" +#include "mvc/BlueskyPlan.h" //--------------------------------------------------------------------------- @@ -41,6 +42,7 @@ class ScanRegionDialog : public QDialog QString getScanName() { return _scan_name->text(); } + void setAvailScans(std::unordered_map * avail_scans); signals: void ScanUpdated(); @@ -51,6 +53,8 @@ public slots: void onUpdateAndQueue(); + void scanChanged(const QString &); + protected: void _createLayout(); @@ -66,7 +70,9 @@ public slots: QPushButton *_btn_cancel; - QListWidget* _scan_options; + QTableView* _scan_options; + + std::unordered_map *_avail_scans; }; diff --git a/src/mvc/VLM_Widget.cpp b/src/mvc/VLM_Widget.cpp index 7dfb566..1749817 100644 --- a/src/mvc/VLM_Widget.cpp +++ b/src/mvc/VLM_Widget.cpp @@ -115,6 +115,7 @@ VLM_Widget::~VLM_Widget() void VLM_Widget::_init() { + _avail_scans = nullptr; m_microProbePvSet = false; // m_pvXHandler = nullptr; // m_pvYHandler = nullptr; @@ -234,7 +235,7 @@ void VLM_Widget::addTopWindowPoints() void VLM_Widget::addMicroProbeRegion() { - ScanRegionGraphicsItem* annotation = new ScanRegionGraphicsItem(); + ScanRegionGraphicsItem* annotation = new ScanRegionGraphicsItem(_avail_scans); ////UProbeRegionGraphicsItem* annotation = new UProbeRegionGraphicsItem(); annotation->setMouseOverPixelCoordModel(m_coordinateModel); annotation->setLightToMicroCoordModel(m_lightToMicroCoordModel); diff --git a/src/mvc/VLM_Widget.h b/src/mvc/VLM_Widget.h index c76720e..26b27d8 100644 --- a/src/mvc/VLM_Widget.h +++ b/src/mvc/VLM_Widget.h @@ -31,6 +31,7 @@ #include #include #include +#include "mvc/BlueSkyPlan.h" class Solver; @@ -158,6 +159,8 @@ class VLM_Widget */ void addMicroProbeRegion(gstar::UProbeRegionGraphicsItem* annotation); + // TODO: make sure to update all ScansRegionGraphicsItems with new pointer + void setAvailScans(std::unordered_map * avail_scans) { _avail_scans = avail_scans;} public slots: /** @@ -659,6 +662,8 @@ protected slots: */ QMap m_actionMap; + std::unordered_map *_avail_scans; + }; From 5b7a5bf6a68456af5c532439a081a4e2e1d60621 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Mon, 29 Jul 2024 14:52:45 -0500 Subject: [PATCH 2/9] Added new stucts --- src/mvc/BlueskyPlan.cpp | 7 +++++++ src/mvc/BlueskyPlan.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/mvc/BlueskyPlan.cpp create mode 100644 src/mvc/BlueskyPlan.h diff --git a/src/mvc/BlueskyPlan.cpp b/src/mvc/BlueskyPlan.cpp new file mode 100644 index 0000000..cd23776 --- /dev/null +++ b/src/mvc/BlueskyPlan.cpp @@ -0,0 +1,7 @@ +/*----------------------------------------------------------------------------- + * Copyright (c) 2024, UChicago Argonne, LLC + * See LICENSE file. + *---------------------------------------------------------------------------*/ + +#include + diff --git a/src/mvc/BlueskyPlan.h b/src/mvc/BlueskyPlan.h new file mode 100644 index 0000000..566a47f --- /dev/null +++ b/src/mvc/BlueskyPlan.h @@ -0,0 +1,39 @@ +/*----------------------------------------------------------------------------- + * Copyright (c) 2024, UChicago Argonne, LLC + * See LICENSE file. + *---------------------------------------------------------------------------*/ + +#ifndef BLUESKY_PLAN_H +#define BLUESKY_PLAN_H + +//--------------------------------------------------------------------------- + +#include + +//--------------------------------------------------------------------------- +struct BlueSkyParam +{ + BlueSkyParam() + { + default_val = "0.0"; + } + QString name; + QString description; + QString default_val; +}; + +struct BlueskyPlan +{ + BlueskyPlan(){} + QString name; + QString description; + QString module; + std::unordered_map parameters; +}; + + +//--------------------------------------------------------------------------- + +#endif /* */ + +//--------------------------------------------------------------------------- From 4a3669ea0a1bb376808dc0fdf1b36c2068af7bc0 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Mon, 29 Jul 2024 16:42:25 -0500 Subject: [PATCH 3/9] Have it displaying Scan parameters in table --- src/mvc/ScanRegionDialog.cpp | 7 +- src/mvc/ScanRegionDialog.h | 3 + src/mvc/ScanTableModel.h | 180 +++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 src/mvc/ScanTableModel.h diff --git a/src/mvc/ScanRegionDialog.cpp b/src/mvc/ScanRegionDialog.cpp index d21ad7d..6f84d54 100644 --- a/src/mvc/ScanRegionDialog.cpp +++ b/src/mvc/ScanRegionDialog.cpp @@ -38,7 +38,9 @@ void ScanRegionDialog::_createLayout() _scan_type = new QComboBox(); connect(_scan_type, &QComboBox::currentTextChanged, this, &ScanRegionDialog::scanChanged); + _scan_table_model = new ScanTableModel(); _scan_options = new QTableView(); + _scan_options->setModel(_scan_table_model); _btn_update = new QPushButton("Update"); _btn_update_and_queue = new QPushButton("Update and Queue"); @@ -122,7 +124,10 @@ void ScanRegionDialog::scanChanged(const QString &scan_name) { if(_avail_scans != nullptr) { - + if(_avail_scans->count(scan_name) > 0) + { + _scan_table_model->setAllData(_avail_scans->at(scan_name)); + } } } diff --git a/src/mvc/ScanRegionDialog.h b/src/mvc/ScanRegionDialog.h index 33d23f2..2ef912a 100644 --- a/src/mvc/ScanRegionDialog.h +++ b/src/mvc/ScanRegionDialog.h @@ -18,6 +18,7 @@ #include #include "gstar/AnnotationProperty.h" #include "mvc/BlueskyPlan.h" +#include "mvc/ScanTableModel.h" //--------------------------------------------------------------------------- @@ -72,6 +73,8 @@ public slots: QTableView* _scan_options; + ScanTableModel *_scan_table_model; + std::unordered_map *_avail_scans; }; diff --git a/src/mvc/ScanTableModel.h b/src/mvc/ScanTableModel.h new file mode 100644 index 0000000..8577446 --- /dev/null +++ b/src/mvc/ScanTableModel.h @@ -0,0 +1,180 @@ +//----------------------------------------------------------------------------- + // Copyright (c) 2024, UChicago Argonne, LLC + // See LICENSE file. + //--------------------------------------------------------------------------- + +#ifndef ScanTableModel_H +#define ScanTableModel_H + +//--------------------------------------------------------------------------- + +#include + +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- + +class ScanTableModel : public QAbstractTableModel +{ +public: + ScanTableModel(QObject* parent = nullptr) : QAbstractTableModel(parent) + { + _headers[0] = "Name"; + _headers[1] = "Value"; + _headers[2] = "Desc"; + } + //--------------------------------------------------------------------------- + int rowCount(const QModelIndex& parent = QModelIndex()) const override + { + return _data.size(); + } + + int columnCount(const QModelIndex& parent = QModelIndex()) const override + { + return 3; + } + //--------------------------------------------------------------------------- + void appendRow(const BlueSkyParam& row) + { + int rown = _data.size(); + QModelIndex gIndex = index(rown, 0, QModelIndex()); + beginInsertRows(gIndex, rown, rown); + _data.append(row); + endInsertRows(); + } + + //--------------------------------------------------------------------------- + + void clear() + { + _data.clear(); + } + + //--------------------------------------------------------------------------- + + const BlueSkyParam& item(int row) + { + return _data.at(row); + } + + //--------------------------------------------------------------------------- + + const QString& getNameAtRow(int row) + { + if(_data.size() > row) + { + return _data.at(row).name; + } + return ""; + } + + //--------------------------------------------------------------------------- + + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override + { + if (!index.isValid() || index.row() >= _data.size() || index.column() >= 4) + { + return QVariant(); + } + + const BlueSkyParam& rowData = _data[index.row()]; + + if (role == Qt::DisplayRole) + { + switch(index.column()) + { + case 0: + return rowData.name; + case 1: + return rowData.default_val; + case 2: + return rowData.description; + }; + } + return QVariant(); + } + //--------------------------------------------------------------------------- + QVariant headerData(int section, Qt::Orientation orientation, int role) const + { + // Check this is DisplayRole + if (role != Qt::DisplayRole) return QVariant(); + + // Horizontal headers + if (orientation == Qt::Horizontal) + { + if(section > 3) + { + return QVariant(); + } + else + { + return _headers[section]; + } + } + + // Return empty data + return QVariant(); + } + + //--------------------------------------------------------------------------- + + Qt::ItemFlags flags(const QModelIndex &index) const + { + if (!index.isValid()) + { + return Qt::NoItemFlags; + } + + // Get desired index + int c = index.column(); + if(c == 1) + { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; + } + + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } + + //--------------------------------------------------------------------------- + + void setAllData(BlueskyPlan& scan) + { + QModelIndex gIndex = index(0, 0, QModelIndex()); + beginInsertRows(gIndex, 0, scan.parameters.size()); + _data.clear(); + for(auto itr : scan.parameters) + { + _data.append(itr.second); + } + endInsertRows(); + } + + //--------------------------------------------------------------------------- + + bool setData(const QModelIndex& index, const QVariant& value, int role) + { + if (role == Qt::EditRole && index.isValid()) + { + if( index.row() < _data.size() && index.column() == 1) + { + _data[index.row()].default_val = value.toString(); + return true; + } + return false; + } + return false; + + } + //--------------------------------------------------------------------------- + +private: + QList _data; + + QString _headers[3]; +}; + + +//--------------------------------------------------------------------------- + +#endif /* ScanTableModel.h */ + +//--------------------------------------------------------------------------- \ No newline at end of file From 617a3e65f445b537798a25d653d01e044c754e51 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Mon, 5 Aug 2024 15:58:03 -0500 Subject: [PATCH 4/9] Gets the queue and running plan and updates them --- .../Annotation/ScanRegionGraphicsItem.cpp | 2 +- src/gstar/Annotation/ScanRegionGraphicsItem.h | 4 +- src/mvc/BlueskyComm.h | 236 +++++++++++++++++- src/mvc/BlueskyPlan.h | 17 +- src/mvc/LiveMapsElementsWidget.cpp | 18 +- src/mvc/LiveMapsElementsWidget.h | 10 +- src/mvc/ScanQueueTableModel.h | 173 +++++++++++++ src/mvc/ScanQueueWidget.cpp | 40 ++- src/mvc/ScanQueueWidget.h | 16 +- src/mvc/ScanRegionDialog.cpp | 2 +- src/mvc/ScanRegionDialog.h | 4 +- src/mvc/ScanTableModel.h | 13 +- src/mvc/VLM_Widget.h | 4 +- 13 files changed, 505 insertions(+), 34 deletions(-) create mode 100644 src/mvc/ScanQueueTableModel.h diff --git a/src/gstar/Annotation/ScanRegionGraphicsItem.cpp b/src/gstar/Annotation/ScanRegionGraphicsItem.cpp index e812724..d82e222 100644 --- a/src/gstar/Annotation/ScanRegionGraphicsItem.cpp +++ b/src/gstar/Annotation/ScanRegionGraphicsItem.cpp @@ -15,7 +15,7 @@ using namespace gstar; //--------------------------------------------------------------------------- -ScanRegionGraphicsItem::ScanRegionGraphicsItem(std::unordered_map * avail_scans, AbstractGraphicsItem* parent) +ScanRegionGraphicsItem::ScanRegionGraphicsItem(std::map * avail_scans, AbstractGraphicsItem* parent) : UProbeRegionGraphicsItem(parent) { _avail_scans = avail_scans; diff --git a/src/gstar/Annotation/ScanRegionGraphicsItem.h b/src/gstar/Annotation/ScanRegionGraphicsItem.h index ca42980..823b2e9 100644 --- a/src/gstar/Annotation/ScanRegionGraphicsItem.h +++ b/src/gstar/Annotation/ScanRegionGraphicsItem.h @@ -47,7 +47,7 @@ Q_OBJECT * @param h - height * @param parent - parent Qt widget */ - ScanRegionGraphicsItem(std::unordered_map * avail_scans, AbstractGraphicsItem* parent = 0); + ScanRegionGraphicsItem(std::map * avail_scans, AbstractGraphicsItem* parent = 0); /** * @brief MarkerGraphicsItem @@ -156,7 +156,7 @@ public slots: private: ScanRegionDialog _scan_dialog; - std::unordered_map *_avail_scans; + std::map *_avail_scans; /* void initialScale(); diff --git a/src/mvc/BlueskyComm.h b/src/mvc/BlueskyComm.h index 4fd0260..ae13c4a 100644 --- a/src/mvc/BlueskyComm.h +++ b/src/mvc/BlueskyComm.h @@ -43,6 +43,8 @@ class BlueskyComm : public QThread } + //--------------------------------------------------------------------------- + /** * Destructor. */ @@ -68,18 +70,34 @@ class BlueskyComm : public QThread _context = nullptr; } - bool get_avail_scans(std::unordered_map &plans, QString &msg) + //--------------------------------------------------------------------------- + + QByteArray gen_send_mesg(QString method, std::map *params) { - bool ret = false; - zmq::message_t message; QJsonDocument doc; QJsonObject obj; - QJsonObject params; - obj["method"] = "plans_allowed"; - params["user_group"] = "primary"; - obj["params"] = params; + obj["method"] = method; + if(params != nullptr) + { + QJsonObject jparams; + for( auto itr : *params ) + { + jparams[itr.first] = itr.second ; + } + obj["params"] = jparams; + } doc.setObject(obj); - QByteArray msg_arr = doc.toJson(); + return doc.toJson(); + } + + //--------------------------------------------------------------------------- + + bool open_env(QString &msg) + { + // + bool ret = false; + zmq::message_t message; + QByteArray msg_arr = gen_send_mesg("environment_open", nullptr); _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); _zmq_comm_socket->recv(&message); @@ -91,6 +109,71 @@ class BlueskyComm : public QThread ret = true; } } + if(reply.contains("msg")) + { + msg = reply["msg"].toString(); + } + return ret; + } + + //--------------------------------------------------------------------------- + + bool close_env(QString &msg) + { + // + bool ret = false; + zmq::message_t message; + QByteArray msg_arr = gen_send_mesg("environment_close", nullptr); + _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); + + _zmq_comm_socket->recv(&message); + QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); + if(reply.contains("success")) + { + if(reply["success"].toString() == "true") + { + ret = true; + } + } + if(reply.contains("msg")) + { + msg = reply["msg"].toString(); + } + return ret; + } + + //--------------------------------------------------------------------------- + + bool get_avail_scans(std::map &plans, QString &msg) + { + bool ret = false; + zmq::message_t message; + + //params["user_group"] = "primary"; + //obj["params"] = params; + + std::map params; + params["user_group"] = "primary"; + QByteArray msg_arr = gen_send_mesg("plans_allowed", ¶ms); + _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); + + _zmq_comm_socket->recv(&message); + QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); + if(reply.contains("success")) + { + QString strReply = reply["success"].toString(); + if(strReply.length() > 0) + { + if(strReply == "true") + { + ret = true; + } + } + else + { + ret = reply["success"].toBool(); + } + } if(reply.contains("plans_allowed")) { QJsonObject iojb = reply["plans_allowed"].toObject(); @@ -139,11 +222,146 @@ class BlueskyComm : public QThread return ret; } - void get_queued_scans() + //--------------------------------------------------------------------------- + + bool get_queued_scans(QString &msg, std::vector &queued_plans, BlueskyPlan &running_plan) { + bool ret = false; + running_plan.name = ""; + running_plan.uuid = ""; + zmq::message_t message; + QByteArray msg_arr = gen_send_mesg("queue_get", nullptr); + _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); + _zmq_comm_socket->recv(&message); + + QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); + if(reply.contains("success")) + { + QString strReply = reply["success"].toString(); + if(strReply.length() > 0) + { + if(strReply == "true") + { + ret = true; + } + } + else + { + ret = reply["success"].toBool(); + } + } + if(reply.contains("items")) + { + /* + {'name': 'count', + 'args': [['det1', 'det2']], + 'kwargs': {'num': 10, 'delay': 1}, + 'item_type': 'plan', + 'user': 'qserver-cli', + 'user_group': 'primary', + 'item_uid': 'f66d959f-12e2-43a5-a67d-01b3d40b4f43'} + */ + queued_plans.clear(); + QJsonArray items = reply["items"].toArray(); + for( auto itr2 : items) + { + BlueskyPlan plan; + QJsonObject param = itr2.toObject(); + if(param.contains("name")) + { + plan.name = param["name"].toString(); + } + if(param.contains("args")) + { + //plan.args = param["args"].toString(); + } + if(param.contains("kwargs")) + { + QJsonObject kwargs = param["kwargs"].toObject(); + //plan.parameters + for(auto pitr : kwargs.keys()) + { + BlueskyParam bsp; + bsp.name = pitr; + bsp.default_val = kwargs[pitr].toString(); + plan.parameters[pitr] = bsp; + } + } + if(param.contains("user")) + { + plan.user = param["user"].toString(); + } + if(param.contains("item_uid")) + { + plan.uuid = param["item_uid"].toString(); + } + queued_plans.push_back(plan); + } + } + if(reply.contains("running_item")) + { + /* + "name": "count", + "args": [ + [ + "det4", + "det3" + ] + ], + "kwargs": { + "num": 10, + "delay": 1 + }, + "item_type": "plan", + "user": "qserver-cli", + "user_group": "primary", + "item_uid": "dacdd8fc-2903-490d-8027-7510d43fb1e2", + "properties": { + "time_start": 1722889109.0853188 + } + */ + + QJsonObject running_item = reply["running_item"].toObject(); + if(running_item.contains("name")) + { + running_plan.name = running_item["name"].toString(); + } + if(running_item.contains("args")) + { + //running_plan.name = running_item["args"].toString(); + } + if(running_item.contains("kwargs")) + { + QJsonObject kwargs = running_item["kwargs"].toObject(); + for(auto pitr : kwargs.keys()) + { + BlueskyParam bsp; + bsp.name = pitr; + bsp.default_val = kwargs[pitr].toString(); + running_plan.parameters[pitr] = bsp; + } + } + if(running_item.contains("user")) + { + running_plan.user = running_item["user"].toString(); + } + if(running_item.contains("item_uid")) + { + running_plan.uuid = running_item["item_uid"].toString(); + } + } + /* + if(reply.contains("plan_queue_uid")) + { + + } + */ + return ret; } + //--------------------------------------------------------------------------- + public slots: void run() override { diff --git a/src/mvc/BlueskyPlan.h b/src/mvc/BlueskyPlan.h index 566a47f..9e744a4 100644 --- a/src/mvc/BlueskyPlan.h +++ b/src/mvc/BlueskyPlan.h @@ -11,9 +11,9 @@ #include //--------------------------------------------------------------------------- -struct BlueSkyParam +struct BlueskyParam { - BlueSkyParam() + BlueskyParam() { default_val = "0.0"; } @@ -22,13 +22,22 @@ struct BlueSkyParam QString default_val; }; +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- + struct BlueskyPlan { - BlueskyPlan(){} + BlueskyPlan() + { + uuid=""; + user=""; + } QString name; QString description; QString module; - std::unordered_map parameters; + std::unordered_map parameters; + QString uuid; + QString user; }; diff --git a/src/mvc/LiveMapsElementsWidget.cpp b/src/mvc/LiveMapsElementsWidget.cpp index 66f6187..c587596 100644 --- a/src/mvc/LiveMapsElementsWidget.cpp +++ b/src/mvc/LiveMapsElementsWidget.cpp @@ -129,6 +129,7 @@ void LiveMapsElementsWidget::createLayout() _vlm_widget->setAvailScans(&_avail_scans); _scan_queue_widget = new ScanQueueWidget(); + connect(_scan_queue_widget, &ScanQueueWidget::queueNeedsToBeUpdated, this, &LiveMapsElementsWidget::getQueuedScans); _tab_widget = new QTabWidget(); _tab_widget->addTab(_mapsElementsWidget, "Counts"); @@ -177,6 +178,7 @@ void LiveMapsElementsWidget::updateIp() _last_packet = nullptr; updateScansAvailable(); + getQueuedScans(); } //--------------------------------------------------------------------------- @@ -279,7 +281,6 @@ void LiveMapsElementsWidget::image_changed(int start, int end) void LiveMapsElementsWidget::updateScansAvailable() { - QString reply; QString msg; if (false == _qserverComm->get_avail_scans(_avail_scans, msg)) { @@ -288,4 +289,19 @@ void LiveMapsElementsWidget::updateScansAvailable() } +//--------------------------------------------------------------------------- + +void LiveMapsElementsWidget::getQueuedScans() +{ + QString msg; + if (false == _qserverComm->get_queued_scans(msg, _queued_scans, _running_scan)) + { + _scan_queue_widget->newDataArrived( msg ); + } + else + { + _scan_queue_widget->updateQueuedItems(_queued_scans, _running_scan); + } +} + //--------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/mvc/LiveMapsElementsWidget.h b/src/mvc/LiveMapsElementsWidget.h index 1af4873..8df3f11 100644 --- a/src/mvc/LiveMapsElementsWidget.h +++ b/src/mvc/LiveMapsElementsWidget.h @@ -45,7 +45,6 @@ class LiveMapsElementsWidget : public QWidget QString getPort(){return _qline_port->text();} - void updateScansAvailable(); public slots: void newDataArrived(data_struct::Stream_Block* new_packet); @@ -54,6 +53,9 @@ public slots: void image_changed(int start, int end); + void updateScansAvailable(); + + void getQueuedScans(); protected: /** @@ -89,7 +91,11 @@ public slots: MapsH5Model *_currentModel; - std::unordered_map _avail_scans; + std::map _avail_scans; + + std::vector _queued_scans; + + BlueskyPlan _running_scan; data_struct::Stream_Block* _last_packet; diff --git a/src/mvc/ScanQueueTableModel.h b/src/mvc/ScanQueueTableModel.h new file mode 100644 index 0000000..e3c95fa --- /dev/null +++ b/src/mvc/ScanQueueTableModel.h @@ -0,0 +1,173 @@ +//----------------------------------------------------------------------------- + // Copyright (c) 2024, UChicago Argonne, LLC + // See LICENSE file. + //--------------------------------------------------------------------------- + +#ifndef ScanQueueTableModel_H +#define ScanQueueTableModel_H + +//--------------------------------------------------------------------------- + +#include +#include "mvc/BlueskyPlan.h" + +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- + +class ScanQueueTableModel : public QAbstractTableModel +{ +public: + ScanQueueTableModel(QObject* parent = nullptr) : QAbstractTableModel(parent) + { + _headers[0] = "name"; + _headers[1] = "user"; + _headers[2] = "uuid"; + } + //--------------------------------------------------------------------------- + int rowCount(const QModelIndex& parent = QModelIndex()) const override + { + return _data.size(); + } + + int columnCount(const QModelIndex& parent = QModelIndex()) const override + { + return 3; + } + //--------------------------------------------------------------------------- + void appendRow(const BlueskyPlan& row) + { + int rown = _data.size(); + QModelIndex gIndex = index(rown, 0, QModelIndex()); + beginInsertRows(gIndex, rown, rown); + _data.append(row); + endInsertRows(); + } + + //--------------------------------------------------------------------------- + + void clear() + { + _data.clear(); + } + + //--------------------------------------------------------------------------- + + const BlueskyPlan& item(int row) + { + return _data.at(row); + } + + //--------------------------------------------------------------------------- + + const QString& getNameAtRow(int row) + { + if(_data.size() > row) + { + return _data.at(row).name; + } + return ""; + } + + //--------------------------------------------------------------------------- + + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override + { + if (!index.isValid() || index.row() >= _data.size() || index.column() >= 4) + { + return QVariant(); + } + + const BlueskyPlan& rowData = _data[index.row()]; + + if (role == Qt::DisplayRole) + { + switch(index.column()) + { + case 0: + return rowData.name; + case 1: + return rowData.user; + case 2: + return rowData.uuid; + }; + } + return QVariant(); + } + //--------------------------------------------------------------------------- + QVariant headerData(int section, Qt::Orientation orientation, int role) const + { + // Check this is DisplayRole + if (role != Qt::DisplayRole) return QVariant(); + + // Horizontal headers + if (orientation == Qt::Horizontal) + { + if(section > 3) + { + return QVariant(); + } + else + { + return _headers[section]; + } + } + + // Return empty data + return QVariant(); + } + + //--------------------------------------------------------------------------- + + Qt::ItemFlags flags(const QModelIndex &index) const + { + if (!index.isValid()) + { + return Qt::NoItemFlags; + } + + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } + + //--------------------------------------------------------------------------- + + void setAllData(std::vector& scans) + { + beginResetModel(); + _data.clear(); + for(auto itr : scans) + { + _data.append(itr); + } + endResetModel(); + } + + //--------------------------------------------------------------------------- + + bool setData(const QModelIndex& index, const QVariant& value, int role) + { + if (role == Qt::EditRole && index.isValid()) + { + if( index.row() < _data.size() && index.column() == 1) + { + _data[index.row()].user = value.toString(); + return true; + } + return false; + } + return false; + + } + //--------------------------------------------------------------------------- + +private: + QList _data; + + QString _headers[3]; +}; + + +//--------------------------------------------------------------------------- + +#endif /* ScanQueueTableModel.h */ + +//--------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/mvc/ScanQueueWidget.cpp b/src/mvc/ScanQueueWidget.cpp index 1e53c49..0102cfb 100644 --- a/src/mvc/ScanQueueWidget.cpp +++ b/src/mvc/ScanQueueWidget.cpp @@ -33,9 +33,22 @@ void ScanQueueWidget::_createLayout() QVBoxLayout* layout = new QVBoxLayout(); - _scan_table_view = new QTableView(); + _scan_running_table_model = new ScanQueueTableModel(); + _scan_running_table_view = new QTableView(); + _scan_running_table_view->setFixedHeight(100); + _scan_running_table_view->setModel(_scan_running_table_model); + + _scan_queue_table_model = new ScanQueueTableModel(); + _scan_queue_table_view = new QTableView(); + _scan_queue_table_view->setModel(_scan_queue_table_model); + + + layout->addWidget(new QLabel("Running Scan")); + layout->addWidget(_scan_running_table_view); + layout->addWidget(new QLabel("Scan Queue")); - layout->addWidget(_scan_table_view); + layout->addWidget(_scan_queue_table_view); + _te_qs_console = new QTextEdit(this); _te_qs_console->scrollBarWidgets(Qt::AlignRight); @@ -48,9 +61,32 @@ void ScanQueueWidget::_createLayout() //--------------------------------------------------------------------------- +void ScanQueueWidget::updateQueuedItems( std::vector &queued_plans, BlueskyPlan &running_plan) +{ + _scan_queue_table_model->setAllData(queued_plans); + std::vector runlist; + if(running_plan.uuid.length() > 0) + { + runlist.push_back(running_plan); + } + _scan_running_table_model->setAllData(runlist); +} + +//--------------------------------------------------------------------------- + void ScanQueueWidget::newDataArrived(const QString& data) { _te_qs_console->append(data); + if (data.count("Item added: success=True item_type='plan'") > 0 + || data.count("Plan failed:") > 0 + || data.count("The plan was exited") > 0 + || data.count("Removing item from the queue") > 0 + || data.count("Starting the plan") > 0 + || data.count("Queue is empty") > 0) + { + emit queueNeedsToBeUpdated(); + } + // if ERROR:bluesky:Run aborted } //--------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/mvc/ScanQueueWidget.h b/src/mvc/ScanQueueWidget.h index 5bf75e2..4bb32f5 100644 --- a/src/mvc/ScanQueueWidget.h +++ b/src/mvc/ScanQueueWidget.h @@ -11,6 +11,8 @@ #include #include #include +#include "mvc/BlueskyPlan.h" +#include "mvc/ScanQueueTableModel.h" //--------------------------------------------------------------------------- @@ -32,6 +34,11 @@ class ScanQueueWidget : public QWidget */ ~ScanQueueWidget(); + void updateQueuedItems( std::vector &queued_plans, BlueskyPlan &running_plan); + +signals: + void queueNeedsToBeUpdated(); + public slots: void newDataArrived(const QString &); @@ -45,7 +52,14 @@ public slots: QTextEdit *_te_qs_console; - QTableView* _scan_table_view; + QTableView* _scan_queue_table_view; + + ScanQueueTableModel* _scan_queue_table_model; + + QTableView* _scan_running_table_view; + + ScanQueueTableModel* _scan_running_table_model; + }; diff --git a/src/mvc/ScanRegionDialog.cpp b/src/mvc/ScanRegionDialog.cpp index 6f84d54..86fe9fc 100644 --- a/src/mvc/ScanRegionDialog.cpp +++ b/src/mvc/ScanRegionDialog.cpp @@ -77,7 +77,7 @@ void ScanRegionDialog::_createLayout() //--------------------------------------------------------------------------- -void ScanRegionDialog::setAvailScans(std::unordered_map * avail_scans) +void ScanRegionDialog::setAvailScans(std::map * avail_scans) { _avail_scans = avail_scans; int i=0; diff --git a/src/mvc/ScanRegionDialog.h b/src/mvc/ScanRegionDialog.h index 2ef912a..7aa5a48 100644 --- a/src/mvc/ScanRegionDialog.h +++ b/src/mvc/ScanRegionDialog.h @@ -43,7 +43,7 @@ class ScanRegionDialog : public QDialog QString getScanName() { return _scan_name->text(); } - void setAvailScans(std::unordered_map * avail_scans); + void setAvailScans(std::map * avail_scans); signals: void ScanUpdated(); @@ -75,7 +75,7 @@ public slots: ScanTableModel *_scan_table_model; - std::unordered_map *_avail_scans; + std::map *_avail_scans; }; diff --git a/src/mvc/ScanTableModel.h b/src/mvc/ScanTableModel.h index 8577446..aa21af0 100644 --- a/src/mvc/ScanTableModel.h +++ b/src/mvc/ScanTableModel.h @@ -33,7 +33,7 @@ class ScanTableModel : public QAbstractTableModel return 3; } //--------------------------------------------------------------------------- - void appendRow(const BlueSkyParam& row) + void appendRow(const BlueskyParam& row) { int rown = _data.size(); QModelIndex gIndex = index(rown, 0, QModelIndex()); @@ -51,7 +51,7 @@ class ScanTableModel : public QAbstractTableModel //--------------------------------------------------------------------------- - const BlueSkyParam& item(int row) + const BlueskyParam& item(int row) { return _data.at(row); } @@ -76,7 +76,7 @@ class ScanTableModel : public QAbstractTableModel return QVariant(); } - const BlueSkyParam& rowData = _data[index.row()]; + const BlueskyParam& rowData = _data[index.row()]; if (role == Qt::DisplayRole) { @@ -138,14 +138,13 @@ class ScanTableModel : public QAbstractTableModel void setAllData(BlueskyPlan& scan) { - QModelIndex gIndex = index(0, 0, QModelIndex()); - beginInsertRows(gIndex, 0, scan.parameters.size()); + beginResetModel(); _data.clear(); for(auto itr : scan.parameters) { _data.append(itr.second); } - endInsertRows(); + endResetModel(); } //--------------------------------------------------------------------------- @@ -167,7 +166,7 @@ class ScanTableModel : public QAbstractTableModel //--------------------------------------------------------------------------- private: - QList _data; + QList _data; QString _headers[3]; }; diff --git a/src/mvc/VLM_Widget.h b/src/mvc/VLM_Widget.h index 26b27d8..c5f1b95 100644 --- a/src/mvc/VLM_Widget.h +++ b/src/mvc/VLM_Widget.h @@ -160,7 +160,7 @@ class VLM_Widget void addMicroProbeRegion(gstar::UProbeRegionGraphicsItem* annotation); // TODO: make sure to update all ScansRegionGraphicsItems with new pointer - void setAvailScans(std::unordered_map * avail_scans) { _avail_scans = avail_scans;} + void setAvailScans(std::map * avail_scans) { _avail_scans = avail_scans;} public slots: /** @@ -662,7 +662,7 @@ protected slots: */ QMap m_actionMap; - std::unordered_map *_avail_scans; + std::map *_avail_scans; }; From af8183995ef7502004be428fd784ead464f41987 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Tue, 6 Aug 2024 11:12:43 -0500 Subject: [PATCH 5/9] added new icon images --- images/chip_off.png | Bin 0 -> 362 bytes images/chip_on.png | Bin 0 -> 381 bytes images/refresh.png | Bin 0 -> 14229 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 images/chip_off.png create mode 100644 images/chip_on.png create mode 100644 images/refresh.png diff --git a/images/chip_off.png b/images/chip_off.png new file mode 100644 index 0000000000000000000000000000000000000000..61c209b4f54b04d44d225b305939b089fe57b42c GIT binary patch literal 362 zcmV-w0hRuVP)MYxcUpfF1J$@F=hz9Ws%7Jvt(!wvIH%0N@7TwK%0xF#{M)P2OB95I|O3I6`KV zd_Z}Qi_Umco9T#Kj|fQwxpYKZrgBcq2>q#zOzm9=Q9g+^Kw@_6s3Z4?U+o{$a)ofs z9(x2Sc5B6Y{X&GO*qeut^jRcA{E?2>v}|_Wix3ri^AN-%E=Wg89-400?7EksQElWo zZEhbxNNg39bk@oVi4Zi{5zRDvPAKKAl@m&NYvqK*?C7K;vq}8?WGT(b)G~3B#{?rt zXq-7h1|#O%nUXOX5v-q~-9sy;OT8W)5mH-6^vYO}dL6sq4N68VDdzwN9{>OV07*qo IM6N<$f^`X!CjbBd literal 0 HcmV?d00001 diff --git a/images/chip_on.png b/images/chip_on.png new file mode 100644 index 0000000000000000000000000000000000000000..ed36ef128ba8a52b41b9896c21fc6725b4c824c7 GIT binary patch literal 381 zcmV-@0fPRCP)1>U|9L5wlg!{o8$4td zX~@#`JD}7b`IA5K7OJ6zXFm!mz0(hD18(NSi^uOYEWEP~glLNe(nk`&E)dJ%(2UO@14kBmP{o6~tSGxZIn2IVXT4K7EV04}>TZ19oHyG>L6MaT&h> zgZq&mY(W{#fWZyhz^lP$ZQ(P*>{pBJ;!*j)of5l))*$Uv!=p+2l~iOfb25D;KsU{|(izT?m~s7F9RK;7^w>h@%B!8r2yG{fb~OtN_m za4jGpAO%(=-|^>Oxrr{NWgMMZaBy(0+{13blqsWE1~wH?P*4~g0g};r*6kNJs8|Pw zJCxCf&+6Ptv1z;FLn)$3SGIN;~x5k;?XX1s@_*q90@4e=R>V%Dn$&r z;kY?w6x8g?0V)zhNdm{(2*l=%HAo0Hg(RZR6Svn6i>M9V@T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%E23=n@H z$5dHjAhL1(J97Ma24)|WB8pG`~gh72+&9Y*fK3_%k&Za|3pLJXZR?C zj-o(=FUMF~)-%)nN7et?lY#ObM??VE!m&P(zz^1_m}?7boz4O+NC73y0QL;{z|8Ut zyq+OWW(dC6;O>nUeHk}^f1%x8Sc8N6G?GF}fQH}QDgQ$Fb7w|)=kzav0v9-_J48Xc zw$}N7`&N&eI1q)W^aXMPgtUbvtjLW`5oyUbqm_`Ym2d-v*GfS}gT)25BAq2~4T_c& zNfe0_gf0yQT@H|Hqnu&id*gp>Cu|ll$$oGEjkY>s)DDUg^Juc_Txw&w8KY3d^L>InkXv3XoHxmq4vMi+5hd| z|2I@Xx_Cer%2fU%2NKAqMhwy*pv8eBow=S1k|*fe=A5erj}`bV6OM>I78!%_eqKmB z=D)TXNGI2nk8xr(K_8$Uw+)BbL*sC$a0Y&K(k)#aSy*r{=!P=U^E3qDxTXpI8dX(^ zqPy$N@^35sm;6?YxW5d_9OYO6VFM?UAb>8KZW3Q=i4&fQz0R%R0T==XX=<`2_)`j? z>dK?q<&W%425dLThJkcD!-7b1CoVrWfIK?o+=0gF08W+#FWs^n-82R5@E`$9-GQ4H zv3CLq9HTj+0c)`WxChAot+adl7lnazayJu|juC_g+NcQ}9Ki>;IToIT-`9Zr9n%RU z5V|!-Ez*(b?1R&~6s2>wdS0^|W${%IclF544&>vMsR1wPs}NCA2L z;RS6SbUj3^=mx}Zhf|2 zbn_3mj&sv}rgg{GdB%0>ud4G@YFOLJjR~IiKs}uU{PCh_><+6E`bE=} z+$9)6NjjhqVGslgOs|%1;jn#HH55w#B22~)kpl`fNIKwQJaJ0~tRDTcTo8V1p3I;9 zG6M(^{O9@PzI-H`RTVwyMYxOQe13Ct^Oz?72$$yb<-&b=gdVFj`qE~&->iF|RUboX zYZ$TvL1!E6JM54!=>J>x{Q)~XbUx Date: Tue, 6 Aug 2024 11:13:18 -0500 Subject: [PATCH 6/9] Added open,close env. Started working on queeing scan but need to change parasm from map to vector --- .../Annotation/ScanRegionGraphicsItem.cpp | 3 +- src/gstar/Annotation/ScanRegionGraphicsItem.h | 6 +- src/mvc/BlueskyComm.h | 123 ++++++++++++++++++ src/mvc/LiveMapsElementsWidget.cpp | 92 +++++++++++++ src/mvc/LiveMapsElementsWidget.h | 11 ++ src/mvc/ScanQueueWidget.cpp | 59 +++++++-- src/mvc/ScanQueueWidget.h | 19 ++- src/mvc/ScanRegionDialog.cpp | 7 +- src/mvc/ScanRegionDialog.h | 2 +- src/mvc/ScanTableModel.h | 10 ++ src/mvc/VLM_Widget.cpp | 2 + src/mvc/VLM_Widget.h | 5 + uProbeX.qrc | 3 + 13 files changed, 327 insertions(+), 15 deletions(-) diff --git a/src/gstar/Annotation/ScanRegionGraphicsItem.cpp b/src/gstar/Annotation/ScanRegionGraphicsItem.cpp index d82e222..3751e9e 100644 --- a/src/gstar/Annotation/ScanRegionGraphicsItem.cpp +++ b/src/gstar/Annotation/ScanRegionGraphicsItem.cpp @@ -143,10 +143,11 @@ QDialog* ScanRegionGraphicsItem::get_custom_dialog() //--------------------------------------------------------------------------- -void ScanRegionGraphicsItem::onScanUpdated() +void ScanRegionGraphicsItem::onScanUpdated(const BlueskyPlan& plan) { setPropertyValue(DEF_STR_DISPLAY_NAME, _scan_dialog.getScanName()); + emit scanUpdated(plan); } /* diff --git a/src/gstar/Annotation/ScanRegionGraphicsItem.h b/src/gstar/Annotation/ScanRegionGraphicsItem.h index 823b2e9..6104538 100644 --- a/src/gstar/Annotation/ScanRegionGraphicsItem.h +++ b/src/gstar/Annotation/ScanRegionGraphicsItem.h @@ -149,9 +149,13 @@ Q_OBJECT void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); */ +signals: + + void scanUpdated(const BlueskyPlan &plan); + public slots: - void onScanUpdated(); + void onScanUpdated(const BlueskyPlan &plan); private: ScanRegionDialog _scan_dialog; diff --git a/src/mvc/BlueskyComm.h b/src/mvc/BlueskyComm.h index ae13c4a..5925414 100644 --- a/src/mvc/BlueskyComm.h +++ b/src/mvc/BlueskyComm.h @@ -92,6 +92,47 @@ class BlueskyComm : public QThread //--------------------------------------------------------------------------- + QByteArray gen_send_mesg2(QString method, QJsonObject ¶ms) + { + QJsonDocument doc; + QJsonObject obj; + obj["method"] = method; + obj["params"] = params; + doc.setObject(obj); + return doc.toJson(); + } + + //--------------------------------------------------------------------------- + + QJsonObject plan_to_json_item(const BlueskyPlan& plan) + { + /* + {'name': 'count', + 'args': [['det1', 'det2']], + 'kwargs': {'num': 10, 'delay': 1}, + 'item_type': 'plan', + 'user': 'qserver-cli', + 'user_group': 'primary', + 'item_uid': 'f66d959f-12e2-43a5-a67d-01b3d40b4f43'} + */ + + QJsonObject item; + + item["name"] = plan.name; + item["item_type"] = "plan"; + + QJsonObject kwargs; + for(auto itr: plan.parameters) + { + kwargs[itr.first] = itr.second.default_val; + } + item["kwargs"] = kwargs; + + return item; + } + + //--------------------------------------------------------------------------- + bool open_env(QString &msg) { // @@ -141,6 +182,88 @@ class BlueskyComm : public QThread } return ret; } + + //--------------------------------------------------------------------------- + + bool start_queue(QString &msg) + { + // + bool ret = false; + zmq::message_t message; + QByteArray msg_arr = gen_send_mesg("queue_start", nullptr); + _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); + + _zmq_comm_socket->recv(&message); + QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); + if(reply.contains("success")) + { + if(reply["success"].toString() == "true") + { + ret = true; + } + } + if(reply.contains("msg")) + { + msg = reply["msg"].toString(); + } + return ret; + } + + //--------------------------------------------------------------------------- + + bool stop_queue(QString &msg) + { + // + bool ret = false; + zmq::message_t message; + QByteArray msg_arr = gen_send_mesg("queue_stop", nullptr); + _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); + + _zmq_comm_socket->recv(&message); + QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); + if(reply.contains("success")) + { + if(reply["success"].toString() == "true") + { + ret = true; + } + } + if(reply.contains("msg")) + { + msg = reply["msg"].toString(); + } + return ret; + } + + //--------------------------------------------------------------------------- + + bool queue_plan(QString &msg, const BlueskyPlan& plan) + { + bool ret = false; + zmq::message_t message; + + QJsonObject params; + params["item"] = plan_to_json_item(plan); + params["user"] = "uProbeX"; + params["user_group"] = "primary"; + QByteArray msg_arr = gen_send_mesg2("queue_item_add", params); + _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); + + _zmq_comm_socket->recv(&message); + QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); + if(reply.contains("success")) + { + if(reply["success"].toString() == "true") + { + ret = true; + } + } + if(reply.contains("msg")) + { + msg = reply["msg"].toString(); + } + return ret; + } //--------------------------------------------------------------------------- diff --git a/src/mvc/LiveMapsElementsWidget.cpp b/src/mvc/LiveMapsElementsWidget.cpp index c587596..d2e3137 100644 --- a/src/mvc/LiveMapsElementsWidget.cpp +++ b/src/mvc/LiveMapsElementsWidget.cpp @@ -127,9 +127,14 @@ void LiveMapsElementsWidget::createLayout() _vlm_widget = new VLM_Widget(); _vlm_widget->setAvailScans(&_avail_scans); + connect(_vlm_widget, &VLM_Widget::onScanUpdated, this, &LiveMapsElementsWidget::queueScan); _scan_queue_widget = new ScanQueueWidget(); connect(_scan_queue_widget, &ScanQueueWidget::queueNeedsToBeUpdated, this, &LiveMapsElementsWidget::getQueuedScans); + connect(_scan_queue_widget, &ScanQueueWidget::onOpenEnv, this, &LiveMapsElementsWidget::callOpenEnv); + connect(_scan_queue_widget, &ScanQueueWidget::onCloseEnv, this, &LiveMapsElementsWidget::callCloseEnv); + connect(_scan_queue_widget, &ScanQueueWidget::onStartQueue, this, &LiveMapsElementsWidget::callStartQueue); + connect(_scan_queue_widget, &ScanQueueWidget::onStopQueue, this, &LiveMapsElementsWidget::callStopQueue); _tab_widget = new QTabWidget(); _tab_widget->addTab(_mapsElementsWidget, "Counts"); @@ -179,6 +184,7 @@ void LiveMapsElementsWidget::updateIp() updateScansAvailable(); getQueuedScans(); + callOpenEnv(); } //--------------------------------------------------------------------------- @@ -304,4 +310,90 @@ void LiveMapsElementsWidget::getQueuedScans() } } +//--------------------------------------------------------------------------- + +void LiveMapsElementsWidget::callOpenEnv() +{ + QString msg; + if (false == _qserverComm->open_env(msg)) + { + //_scan_queue_widget->newDataArrived( msg ); + } + else + { + //_scan_queue_widget->updateQueuedItems(_queued_scans, _running_scan); + } + + _scan_queue_widget->newDataArrived( msg ); +} + +//--------------------------------------------------------------------------- + +void LiveMapsElementsWidget::callCloseEnv() +{ + QString msg; + if (false == _qserverComm->close_env(msg)) + { + //_scan_queue_widget->newDataArrived( msg ); + } + else + { + //_scan_queue_widget->updateQueuedItems(_queued_scans, _running_scan); + } + + _scan_queue_widget->newDataArrived( msg ); +} + +//--------------------------------------------------------------------------- + +void LiveMapsElementsWidget::callStartQueue() +{ + QString msg; + if (false == _qserverComm->start_queue(msg)) + { + //_scan_queue_widget->newDataArrived( msg ); + } + else + { + //_scan_queue_widget->updateQueuedItems(_queued_scans, _running_scan); + } + + _scan_queue_widget->newDataArrived( msg ); +} + +//--------------------------------------------------------------------------- + +void LiveMapsElementsWidget::callStopQueue() +{ + QString msg; + if (false == _qserverComm->stop_queue(msg)) + { + //_scan_queue_widget->newDataArrived( msg ); + } + else + { + //_scan_queue_widget->updateQueuedItems(_queued_scans, _running_scan); + } + + _scan_queue_widget->newDataArrived( msg ); +} + +//--------------------------------------------------------------------------- + +void LiveMapsElementsWidget::queueScan(const BlueskyPlan& plan) +{ + QString msg; + if (false == _qserverComm->queue_plan(msg, plan)) + { + + } + else + { + + } + + _scan_queue_widget->newDataArrived( msg ); + getQueuedScans(); +} + //--------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/mvc/LiveMapsElementsWidget.h b/src/mvc/LiveMapsElementsWidget.h index 8df3f11..804ad3b 100644 --- a/src/mvc/LiveMapsElementsWidget.h +++ b/src/mvc/LiveMapsElementsWidget.h @@ -56,6 +56,17 @@ public slots: void updateScansAvailable(); void getQueuedScans(); + + void callOpenEnv(); + + void callCloseEnv(); + + void callStartQueue(); + + void callStopQueue(); + + void queueScan(const BlueskyPlan& plan); + protected: /** diff --git a/src/mvc/ScanQueueWidget.cpp b/src/mvc/ScanQueueWidget.cpp index 0102cfb..43f2de1 100644 --- a/src/mvc/ScanQueueWidget.cpp +++ b/src/mvc/ScanQueueWidget.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "core/defines.h" //--------------------------------------------------------------------------- @@ -42,19 +43,59 @@ void ScanQueueWidget::_createLayout() _scan_queue_table_view = new QTableView(); _scan_queue_table_view->setModel(_scan_queue_table_model); + QSize btn_size(33,33); - layout->addWidget(new QLabel("Running Scan")); - layout->addWidget(_scan_running_table_view); + _btn_play = new QPushButton(); + _btn_play->setFixedSize(btn_size); + _btn_play->setIcon(QIcon(":images/start.png")); + _btn_play->setToolTip("Start Queue"); + connect(_btn_play, &QPushButton::pressed, this, &ScanQueueWidget::onStartQueue); - layout->addWidget(new QLabel("Scan Queue")); - layout->addWidget(_scan_queue_table_view); - + _btn_stop = new QPushButton(); + _btn_stop->setIcon(QIcon(":images/stop.png")); + _btn_stop->setFixedSize(btn_size); + _btn_stop->setToolTip("Stop Queue"); + connect(_btn_stop, &QPushButton::pressed, this, &ScanQueueWidget::onStopQueue); + + _btn_refresh = new QPushButton(); + _btn_refresh->setIcon(QIcon(":images/refresh.png")); + _btn_refresh->setFixedSize(btn_size); + _btn_refresh->setToolTip("Manual Refresh Queue"); + connect(_btn_refresh, &QPushButton::pressed, this, &ScanQueueWidget::queueNeedsToBeUpdated); + + _btn_open_env = new QPushButton("Open Env"); + _btn_open_env->setToolTip("Open Environment"); + connect(_btn_open_env, &QPushButton::pressed, this, &ScanQueueWidget::onOpenEnv); + + _btn_close_env = new QPushButton("Close Env"); + _btn_close_env->setToolTip("Close Environment"); + connect(_btn_close_env, &QPushButton::pressed, this, &ScanQueueWidget::onCloseEnv); + + QGridLayout *grid = new QGridLayout(); + grid->addWidget(_btn_play, 0,0); + grid->addWidget(_btn_stop,0,1); + grid->addWidget(_btn_refresh,0,2); + grid->addWidget(_btn_open_env,0,3); + grid->addWidget(_btn_close_env,0,4); + grid->addItem(new QSpacerItem(999,10), 0,6); + + layout->addItem(grid); _te_qs_console = new QTextEdit(this); _te_qs_console->scrollBarWidgets(Qt::AlignRight); - - layout->addWidget(new QLabel("QServer Log")); - layout->addWidget(_te_qs_console); + + QDockWidget *dock_running = new QDockWidget("Running Scan", this); + dock_running->setWidget(_scan_running_table_view); + layout->addWidget(dock_running); + + QDockWidget *dock_queue = new QDockWidget("Scan Queue", this); + dock_queue->setWidget(_scan_queue_table_view); + layout->addWidget(dock_queue); + + QDockWidget *dock_log = new QDockWidget("QServer Log", this); + dock_log->setWidget(_te_qs_console); + layout->addWidget(dock_log); + setLayout(layout); } @@ -89,4 +130,4 @@ void ScanQueueWidget::newDataArrived(const QString& data) // if ERROR:bluesky:Run aborted } -//--------------------------------------------------------------------------- \ No newline at end of file +//--------------------------------------------------------------------------- diff --git a/src/mvc/ScanQueueWidget.h b/src/mvc/ScanQueueWidget.h index 4bb32f5..eca156c 100644 --- a/src/mvc/ScanQueueWidget.h +++ b/src/mvc/ScanQueueWidget.h @@ -11,6 +11,7 @@ #include #include #include +#include #include "mvc/BlueskyPlan.h" #include "mvc/ScanQueueTableModel.h" @@ -39,8 +40,15 @@ class ScanQueueWidget : public QWidget signals: void queueNeedsToBeUpdated(); -public slots: + void onOpenEnv(); + + void onCloseEnv(); + + void onStartQueue(); + + void onStopQueue(); +public slots: void newDataArrived(const QString &); protected: @@ -60,7 +68,16 @@ public slots: ScanQueueTableModel* _scan_running_table_model; + QPushButton* _btn_play; + + QPushButton* _btn_stop; + + QPushButton* _btn_refresh; + + QPushButton* _btn_open_env; + QPushButton* _btn_close_env; + }; diff --git a/src/mvc/ScanRegionDialog.cpp b/src/mvc/ScanRegionDialog.cpp index 86fe9fc..fb83709 100644 --- a/src/mvc/ScanRegionDialog.cpp +++ b/src/mvc/ScanRegionDialog.cpp @@ -106,7 +106,7 @@ void ScanRegionDialog::updateProps(QList &anno_list) void ScanRegionDialog::onUpdate() { - emit ScanUpdated(); + //emit ScanUpdated(); close(); } @@ -114,7 +114,10 @@ void ScanRegionDialog::onUpdate() void ScanRegionDialog::onUpdateAndQueue() { - emit ScanUpdated(); + BlueskyPlan plan; + plan.name = _scan_type->currentText(); + _scan_table_model->getCurrentParams(plan); + emit ScanUpdated(plan); close(); } diff --git a/src/mvc/ScanRegionDialog.h b/src/mvc/ScanRegionDialog.h index 7aa5a48..84499c1 100644 --- a/src/mvc/ScanRegionDialog.h +++ b/src/mvc/ScanRegionDialog.h @@ -46,7 +46,7 @@ class ScanRegionDialog : public QDialog void setAvailScans(std::map * avail_scans); signals: - void ScanUpdated(); + void ScanUpdated(const BlueskyPlan& plan); public slots: diff --git a/src/mvc/ScanTableModel.h b/src/mvc/ScanTableModel.h index aa21af0..c1f5e12 100644 --- a/src/mvc/ScanTableModel.h +++ b/src/mvc/ScanTableModel.h @@ -67,6 +67,16 @@ class ScanTableModel : public QAbstractTableModel return ""; } + //--------------------------------------------------------------------------- + + void getCurrentParams(BlueskyPlan& plan) + { + for(auto itr : _data) + { + plan.parameters[itr.name] = itr; + } + } + //--------------------------------------------------------------------------- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override diff --git a/src/mvc/VLM_Widget.cpp b/src/mvc/VLM_Widget.cpp index 1749817..158db6f 100644 --- a/src/mvc/VLM_Widget.cpp +++ b/src/mvc/VLM_Widget.cpp @@ -240,6 +240,8 @@ void VLM_Widget::addMicroProbeRegion() annotation->setMouseOverPixelCoordModel(m_coordinateModel); annotation->setLightToMicroCoordModel(m_lightToMicroCoordModel); + connect(annotation, &ScanRegionGraphicsItem::scanUpdated, this, &VLM_Widget::onScanUpdated); + insertAndSelectAnnotation(m_mpTreeModel, m_mpAnnoTreeView, m_mpSelectionModel, diff --git a/src/mvc/VLM_Widget.h b/src/mvc/VLM_Widget.h index c5f1b95..c23e2be 100644 --- a/src/mvc/VLM_Widget.h +++ b/src/mvc/VLM_Widget.h @@ -161,6 +161,9 @@ class VLM_Widget // TODO: make sure to update all ScansRegionGraphicsItems with new pointer void setAvailScans(std::map * avail_scans) { _avail_scans = avail_scans;} + + + public slots: /** @@ -398,6 +401,8 @@ protected slots: void onLinkRegionToDataset(QString, QString, QImage); + void onScanUpdated(const BlueskyPlan &plan); + private: /** diff --git a/uProbeX.qrc b/uProbeX.qrc index 7ca2e5a..c5f4244 100644 --- a/uProbeX.qrc +++ b/uProbeX.qrc @@ -32,5 +32,8 @@ images/gear.png images/compose.png images/editing.png + images/refresh.png + images/chip_on.png + images/chip_off.png From fa4d9a5cbfa5e7bd5dc4956595b9117b03ba6f76 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Fri, 9 Aug 2024 10:02:57 -0500 Subject: [PATCH 7/9] Fixed but where log10 was performed on fit element counts when it should not be --- src/mvc/FitElementsTableModel.cpp | 43 ++++++++++++++----------- src/mvc/SpectraWidget.cpp | 52 ++++++++++++++++--------------- 2 files changed, 52 insertions(+), 43 deletions(-) diff --git a/src/mvc/FitElementsTableModel.cpp b/src/mvc/FitElementsTableModel.cpp index 079bb04..38bd35d 100644 --- a/src/mvc/FitElementsTableModel.cpp +++ b/src/mvc/FitElementsTableModel.cpp @@ -5,6 +5,7 @@ #include "FitElementsTableModel.h" #include +#include "preferences/Preferences.h" //--------------------------------------------------------------------------- @@ -22,7 +23,7 @@ FitElementsTableModel::FitElementsTableModel(std::string detector_element, QObje FitElementsTableModel::~FitElementsTableModel() { - _is_log10 = true; + _is_log10 = Preferences::inst()->getValue(STR_PFR_LOG_10).toBool(); for(auto& itr : _nodes) { delete itr.second; @@ -66,28 +67,34 @@ void FitElementsTableModel::setDisplayHeaderMinMax(bool val) void FitElementsTableModel::update_counts_log10(bool is_log10) { - - for (auto& itr : _nodes) + if(_is_log10 != is_log10) { - TreeItem* node = itr.second; _is_log10 = is_log10; - if (is_log10) - { - double val = node->itemData[COUNTS].toDouble(); - node->itemData[COUNTS] = std::log10(val); - m_headers[HEADERS::COUNTS] = tr("Counts (10^Cnts)"); - } - else + for (auto& itr : _nodes) { - double val = node->itemData[COUNTS].toDouble(); - node->itemData[COUNTS] = std::pow(10, val); - m_headers[HEADERS::COUNTS] = tr("Counts"); + TreeItem* node = itr.second; + + if (is_log10) + { + double val = node->itemData[COUNTS].toDouble(); + if (val != 0) + { + node->itemData[COUNTS] = std::log10(val); + } + m_headers[HEADERS::COUNTS] = tr("Counts (10^Cnts)"); + } + else + { + double val = node->itemData[COUNTS].toDouble(); + node->itemData[COUNTS] = std::pow(10, val); + m_headers[HEADERS::COUNTS] = tr("Counts"); + } } + QModelIndex topLeft = index(0, 0); + QModelIndex bottomRight = index(_row_indicies.size() - 1, NUM_PROPS - 1); + emit dataChanged(topLeft, bottomRight); + emit layoutChanged(); } - QModelIndex topLeft = index(0, 0); - QModelIndex bottomRight = index(_row_indicies.size() - 1, NUM_PROPS - 1); - emit dataChanged(topLeft, bottomRight); - emit layoutChanged(); } //--------------------------------------------------------------------------- diff --git a/src/mvc/SpectraWidget.cpp b/src/mvc/SpectraWidget.cpp index 51a63d8..ea336df 100644 --- a/src/mvc/SpectraWidget.cpp +++ b/src/mvc/SpectraWidget.cpp @@ -565,39 +565,41 @@ void SpectraWidget::ShowContextMenu(const QPoint &pos) void SpectraWidget::set_log10(bool val) { - QList series = _chart->series(); - - for(QAbstractSeries* ser : _element_lines) + if(_display_log10 != val) { - series.removeOne(ser); - } + QList series = _chart->series(); - for(QAbstractSeries* ser : series) - { - ser->detachAxis(_currentYAxis); - } - _chart->removeAxis(_currentYAxis); + for(QAbstractSeries* ser : _element_lines) + { + series.removeOne(ser); + } - _display_log10 = val; + for(QAbstractSeries* ser : series) + { + ser->detachAxis(_currentYAxis); + } + _chart->removeAxis(_currentYAxis); - if(_display_log10) //if current one is log10, set to normal - { - _currentYAxis = _axisYLog10; - } - else - { - _currentYAxis = _axisY; - } + _display_log10 = val; - _chart->addAxis(_currentYAxis, Qt::AlignLeft); + if(_display_log10) //if current one is log10, set to normal + { + _currentYAxis = _axisYLog10; + } + else + { + _currentYAxis = _axisY; + } - for(QAbstractSeries* ser : series) - { - ser->attachAxis(_currentYAxis); - } + _chart->addAxis(_currentYAxis, Qt::AlignLeft); - emit(y_axis_changed(_display_log10)); + for(QAbstractSeries* ser : series) + { + ser->attachAxis(_currentYAxis); + } + emit(y_axis_changed(_display_log10)); + } } //--------------------------------------------------------------------------- From 3aa420a61e2f0db2d01b7ca2f8b5fa74614fc63f Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Fri, 9 Aug 2024 11:04:49 -0500 Subject: [PATCH 8/9] Fixed header stretch in fitting dialog --- src/mvc/FitSpectraWidget.cpp | 1 + src/mvc/FittingDialog.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mvc/FitSpectraWidget.cpp b/src/mvc/FitSpectraWidget.cpp index 6b041c8..7565a3d 100644 --- a/src/mvc/FitSpectraWidget.cpp +++ b/src/mvc/FitSpectraWidget.cpp @@ -144,6 +144,7 @@ void FitSpectraWidget::createLayout() _fit_params_table->setItemDelegateForColumn(4, npDelegate); _fit_params_table->setItemDelegateForColumn(5, npDelegate); _fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); + //_fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); _fit_params_table->setContextMenuPolicy(Qt::CustomContextMenu); connect(_fit_params_table, SIGNAL(customContextMenuRequested(QPoint)), diff --git a/src/mvc/FittingDialog.cpp b/src/mvc/FittingDialog.cpp index 8746dd8..5599683 100644 --- a/src/mvc/FittingDialog.cpp +++ b/src/mvc/FittingDialog.cpp @@ -75,13 +75,13 @@ void FittingDialog::_createLayout() _fit_params_table->setItemDelegateForColumn(3, npDelegate); _fit_params_table->setItemDelegateForColumn(4, npDelegate); _fit_params_table->setItemDelegateForColumn(5, npDelegate); - _fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); + _fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); _new_fit_params_table = new QTableView(); _new_fit_params_table->setModel(_new_fit_params_table_model); _new_fit_params_table->sortByColumn(0, Qt::AscendingOrder); _new_fit_params_table->setItemDelegateForColumn(2, cbDelegate); - _new_fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); + _new_fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); connect(_new_fit_params_table->verticalScrollBar(), &QAbstractSlider::valueChanged, _fit_params_table->verticalScrollBar(), &QAbstractSlider::setValue); From 7100d762320ea06ff772ca9ea3092a522fe380d7 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Mon, 12 Aug 2024 10:31:15 -0500 Subject: [PATCH 9/9] Use meta data for bluesky plans as scan name --- .../Annotation/ScanRegionGraphicsItem.cpp | 9 ++++- src/mvc/BatchRoiFitWidget.cpp | 2 +- src/mvc/BlueskyComm.h | 38 +++++++++++++++++-- src/mvc/BlueskyPlan.h | 1 + src/mvc/LiveMapsElementsWidget.cpp | 28 ++++++++++++++ src/mvc/ScanQueueTableModel.h | 17 +++++---- src/mvc/ScanQueueWidget.cpp | 8 ++++ src/mvc/ScanRegionDialog.cpp | 2 +- 8 files changed, 92 insertions(+), 13 deletions(-) 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();