Skip to content

Commit

Permalink
Added so that it displays variables in scan queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Oct 15, 2024
1 parent a1f56e9 commit a43e983
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 22 deletions.
31 changes: 27 additions & 4 deletions src/mvc/BlueskyComm.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class BlueskyComm : public QThread
_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"))
{
Expand Down Expand Up @@ -532,17 +532,40 @@ class BlueskyComm : public QThread
}
if(param.contains("args"))
{
//plan.args = param["args"].toString();
QJsonObject kwargs = param["args"].toObject();
for(auto pitr : kwargs.keys())
{
BlueskyParam bsp;
bsp.name = pitr;
if(kwargs.value(pitr).isDouble())
{
double p = kwargs.value(pitr).toDouble();
bsp.default_val = QString::number(p);
}
else if( kwargs.value(pitr).isString() )
{
bsp.default_val = kwargs.value(pitr).toString();
}
plan.parameters[pitr] = bsp;
}
}
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();

if(kwargs.value(pitr).isDouble())
{
double p = kwargs.value(pitr).toDouble();
bsp.default_val = QString::number(p);
}
else if( kwargs.value(pitr).isString() )
{
bsp.default_val = kwargs.value(pitr).toString();
}
plan.parameters[pitr] = bsp;
}
}
Expand Down
61 changes: 43 additions & 18 deletions src/mvc/ScanQueueTableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ class ScanQueueTableModel : public QAbstractTableModel
public:
ScanQueueTableModel(QObject* parent = nullptr) : QAbstractTableModel(parent)
{
_headers[0] = "name";
_headers[1] = "type";
_headers[2] = "user";
_headers[3] = "uuid";
_headers[0] = "Type";
}
//---------------------------------------------------------------------------
int rowCount(const QModelIndex& parent = QModelIndex()) const override
Expand All @@ -37,7 +34,12 @@ class ScanQueueTableModel : public QAbstractTableModel

int columnCount(const QModelIndex& parent = QModelIndex()) const override
{
return 4;

if(_data.size() > 0)
{
return _data.at(0).parameters.size() + 1;
}
return 10;
}
//---------------------------------------------------------------------------
void appendRow(const BlueskyPlan& row)
Expand Down Expand Up @@ -126,26 +128,35 @@ class ScanQueueTableModel : public QAbstractTableModel

QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override
{
if (!index.isValid() || index.row() >= _data.size() || index.column() >= 4)
if (!index.isValid() || index.row() >= _data.size())
{
return QVariant();
}

const BlueskyPlan& rowData = _data[index.row()];

if(index.column() > rowData.parameters.size() + 1)
{
return QVariant();
}

if (role == Qt::DisplayRole)
{
switch(index.column())
if(index.column() == 0)
{
case 0:
return rowData.name;
case 1:
return rowData.type;
case 2:
return rowData.user;
case 3:
return rowData.uuid;
};
}

int idx = 0;
for( auto itr: rowData.parameters)
{
if(idx == index.column() -1 )
{
return itr.second.default_val;
}
idx++;
}

}
return QVariant();
}
Expand All @@ -158,13 +169,27 @@ class ScanQueueTableModel : public QAbstractTableModel
// Horizontal headers
if (orientation == Qt::Horizontal)
{
if(section > 4)
if(section == 0)
{
return QVariant();
return _headers[section];
}
else
{
return _headers[section];
if(_data.size() > 0)
{
const BlueskyPlan& rowData = _data[0];

int idx = 0;
for( auto itr: rowData.parameters)
{
if(idx == section -1 )
{
return itr.second.name;
}
idx++;
}
}
return QVariant(" ");
}
}

Expand Down

0 comments on commit a43e983

Please sign in to comment.