Commit b36ce0ff authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

porting to cumbia and hdb plugin

parent 8380a954
# build
> qmake
> cuuimake
> make -j9
# Test
./bin/vacuumcond l03/vacuum/sip75_l03.05/Pressure l03/vacuum/sip75_l03.06/Pressure l03/vacuum/sip300_l03.03/Pressure l03/vacuum/sip300_l03.04/Pressure l03/vacuum/sip75_l03.07/Pressure l03/vacuum/sip75_l03.08/Pressure ACCBT_L03.02 K09
#include "MyPlot.h"
#include <qwt_plot_grid.h>
MyPlot::MyPlot(QWidget *v, CumbiaPool *cup, const CuControlsFactoryPool &fp) :
QuTrendPlot(v, cup, fp) {}
QuTrendPlot(v, cup, fp) {
QwtPlotGrid *grid = new QwtPlotGrid();
grid->enableX(true);
grid->enableY(true);
grid->enableYMin(true);
QColor color("#a0a0a0");
QPen pen(QBrush(color), 1);
grid->setMajorPen(pen);
color.setNamedColor("#e0e0e0");
QPen minpen(QBrush(color), 1);
grid->setMinorPen(minpen);
grid->attach(this);
setAxisMaxMinor(QwtPlot::yLeft,10);
}
......@@ -69,9 +69,32 @@ vacuumcond::vacuumcond(CumbiaPool *cumbia_pool, QWidget *parent) : QWidget(paren
// cumbia
CuModuleLoader mloader(cumbia_pool, &m_ctrl_factory_pool, &m_log_impl);
cu_pool = cumbia_pool;
QString db_profile;
CuPluginLoader pl;
QObject *o;
CuHdbPlugin_I *hdb_p = pl.get<CuHdbPlugin_I>("cuhdb-qt-plugin.so", &o);
if(hdb_p) {
cu_pool->registerCumbiaImpl("hdb", hdb_p->getCumbia());
cu_pool->setSrcPatterns("hdb", hdb_p->getSrcPatterns());
m_ctrl_factory_pool.registerImpl("hdb", *hdb_p->getReaderFactory());
}
else
perr("vacuumcond: failed to load hdb plugin");
// use cumbia hdb profiles managed by the hdb-db-profile-manager utility
if(!db_profile.isEmpty())
hdb_p->setDbProfile(db_profile);
else
printf("\e[1;33m* \e[0musing \e[1;33mdefault\e[0m database profile, if available\n");
const QStringList& args = qApp->arguments();
QStringList srcs;
for(int i = 1; i < args.size(); i++)
if(args[i].count('/') > 2)
srcs << args[i];
ui = new Ui::vacuumcond;
ui->setupUi(this, cu_pool, m_ctrl_factory_pool);
printf("1\n");
// mloader.modules() to get the list of loaded modules
// cumbia
......@@ -87,196 +110,83 @@ vacuumcond::vacuumcond(CumbiaPool *cumbia_pool, QWidget *parent) : QWidget(paren
imgpath = imgpath + "/";
}
printf("2\n");
QString db_profile;
CuPluginLoader pl;
QObject *o;
CuHdbPlugin_I *hdb_p = pl.get<CuHdbPlugin_I>("cuhdb-qt-plugin.so", &o);
if(hdb_p) {
printf("\e[1;32m*\e[0m hdb plugin loaded\n");
cu_pool->registerCumbiaImpl("hdb", hdb_p->getCumbia());
cu_pool->setSrcPatterns("hdb", hdb_p->getSrcPatterns());
m_ctrl_factory_pool.registerImpl("hdb", *hdb_p->getReaderFactory());
}
// use cumbia hdb profiles managed by the hdb-db-profile-manager utility
if(!db_profile.isEmpty())
hdb_p->setDbProfile(db_profile);
else
printf("\e[1;33m* \e[0musing \e[1;33mdefault\e[0m database profile, if available\n");
printf("3\n");
connect(ui->mainplot, SIGNAL(curveAdded(QuPlotCurve*)), this, SLOT(newCurve(QuPlotCurve *)));
ui->mainplot->setYAxisLogScale(true);
ui->mainplot->setYAxisAutoscaleEnabled(false);
ui->mainplot->setYUpperBound(0.000001);
ui->mainplot->setYLowerBound(0.000000001);
argsize = qApp->arguments().size();
argsize = args.size();
bool getHDB = true;
if (qApp->arguments()[argsize-1].contains("noHDB")) {
if (args[argsize-1].contains("noHDB")) {
getHDB = false;
argsize--;
}
if (!qApp->arguments()[argsize-1].contains("/")) {
ui->MDK_Label->setText(qApp->arguments()[argsize-1]);
if (!args[argsize-1].contains("/")) {
ui->MDK_Label->setText(args[argsize-1]);
argsize--;
}
else {
ui->MDK_Label->hide();
}
if (!qApp->arguments()[argsize-1].contains("/")) {
ui->section_label->setText(qApp->arguments()[argsize-1]);
if (!args[argsize-1].contains("/")) {
ui->section_label->setText(args[argsize-1]);
argsize--;
}
else {
ui->section_label->hide();
}
QStringList psrcs;
// plot and hdb sources
QString now = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
QString before = QDateTime::currentDateTime().addSecs(-3600 * 8).toString("yyyy-MM-dd hh:mm:ss");
for(int i = 1; i < qApp->arguments().size(); i++) {
psrcs.append(qApp->arguments().at(i));
psrcs.append(QString("hdb://%1(%2,%3)").arg(psrcs.last()).arg(before).arg(now));
ui->mainplot->setSources(srcs);
// take ui->mainplot->sources not psrcs to make sure hdb and live data are
// on the same curve
const QStringList &psrcs = ui->mainplot->sources();
for(int i = 0; i < psrcs.size() && getHDB; i++){
const QString& src = psrcs[i];
printf("i = %d source %s\n", i, qstoc(src));
ui->mainplot->addSource(QString("hdb://%1(%2,%3)").arg(src).arg(before).arg(now));
}
printf("5\n");
ui->mainplot->setSources(psrcs);
printf("6\n");
ui->mainplot->setAxisMaxMinor(QwtPlot::yLeft,10);
ui->mainplot->setDataBufferSize(480*60);
QwtPlotGrid *grid = new QwtPlotGrid();
grid->enableX(true);
grid->enableY(true);
grid->enableYMin(true);
QColor color("#a0a0a0");
QPen pen(QBrush(color), 1);
#if QWT_VERSION >= 0x060000
grid->setMajorPen(pen);
#else
grid->setMajPen(pen);
#endif
color.setNamedColor("#e0e0e0");
QPen minpen(QBrush(color), 1);
#if QWT_VERSION >= 0x060000
grid->setMinorPen(minpen);
#else
grid->setMinPen(minpen);
#endif
grid->attach(ui->mainplot);
if (argsize>1) {
ui->value_1->setSource(qApp->arguments()[1]);
ui->value_1->setProperty("forceNoUnit", true);
ui->label_1->setText(qApp->arguments()[1].split("/").at(2));
ui->InfoButton_1->setIcon(QPixmap(imgpath+"/info.png"));
connect(ui->InfoButton_1, SIGNAL(clicked()), this, SLOT(open_info_1()));
}
else {
ui->value_1->hide();
ui->label_1->hide();
ui->color_1->hide();
ui->InfoButton_1->hide();
}
if (argsize>2) {
ui->value_2->setSource(qApp->arguments()[2]);
ui->value_2->setProperty("forceNoUnit", true);
ui->label_2->setText(qApp->arguments()[2].split("/").at(2));
ui->InfoButton_2->setIcon(QPixmap(imgpath+"/info.png"));
connect(ui->InfoButton_2, SIGNAL(clicked()), this, SLOT(open_info_2()));
}
else {
ui->value_2->hide();
ui->label_2->hide();
ui->color_2->hide();
ui->InfoButton_2->hide();
}
if (argsize>3) {
ui->value_3->setSource(qApp->arguments()[3]);
ui->value_3->setProperty("forceNoUnit", true);
ui->label_3->setText(qApp->arguments()[3].split("/").at(2));
ui->InfoButton_3->setIcon(QPixmap(imgpath+"/info.png"));
connect(ui->InfoButton_3, SIGNAL(clicked()), this, SLOT(open_info_3()));
}
else {
ui->value_3->hide();
ui->label_3->hide();
ui->color_3->hide();
ui->InfoButton_3->hide();
for(int i = 0; i < srcs.size(); i++) {
printf("finding label %s\n", qstoc(QString("value_%1").arg(i+1)));
QuLabel *value_x = findChild<QuLabel *>(QString("value_%1").arg(i+1));
value_x->setSource(srcs[i]);
value_x->setProperty("forceNoUnit", true);
findChild<QLabel *>(QString("label_%1").arg(i+1))->setText(srcs[i].split('/')[2]);
findChild<QPushButton *>(QString("InfoButton_%1").arg(i+1))->setIcon(QPixmap(imgpath+"/info.png"));
connect(findChild<QPushButton *>(QString("InfoButton_%1").arg(i+1)), SIGNAL(clicked()), this, SLOT(open_info()));
}
if (argsize>4) {
ui->value_4->setSource(qApp->arguments()[4]);
ui->value_4->setProperty("forceNoUnit", true);
ui->label_4->setText(qApp->arguments()[4].split("/").at(2));
ui->InfoButton_4->setIcon(QPixmap(imgpath+"/info.png"));
connect(ui->InfoButton_4, SIGNAL(clicked()), this, SLOT(open_info_4()));
}
else {
ui->value_4->hide();
ui->label_4->hide();
ui->color_4->hide();
ui->InfoButton_4->hide();
}
if (argsize>5) {
ui->value_5->setSource(qApp->arguments()[5]);
ui->value_5->setProperty("forceNoUnit", true);
ui->label_5->setText(qApp->arguments()[5].split("/").at(2));
ui->InfoButton_5->setIcon(QPixmap(imgpath+"/info.png"));
connect(ui->InfoButton_5, SIGNAL(clicked()), this, SLOT(open_info_5()));
}
else {
ui->value_5->hide();
ui->label_5->hide();
ui->color_5->hide();
ui->InfoButton_5->hide();
}
if (argsize>6) {
ui->value_6->setSource(qApp->arguments()[6]);
ui->value_6->setProperty("forceNoUnit", true);
ui->label_6->setText(qApp->arguments()[6].split("/").at(2));
ui->InfoButton_6->setIcon(QPixmap(imgpath+"/info.png"));
connect(ui->InfoButton_6, SIGNAL(clicked()), this, SLOT(open_info_6()));
}
else {
ui->value_6->hide();
ui->label_6->hide();
ui->color_6->hide();
ui->InfoButton_6->hide();
const QStringList &objs {"value_%1", "label_%1", "color_%1", "InfoButton_%1" };
for(int i = 1; i < 7; i++) {
foreach(const QString& o, objs) {
findChild<QWidget *>(QString(o).arg(i))->setVisible(i <= srcs.size());
}
}
ui->label_logo->setPixmap(QPixmap(imgpath+"logo_fermi.png"));
info_process = new QProcess(this);
printf("8\n");
ui->mainplot->setYUpperBound(0.000001);
ui->mainplot->setYLowerBound(0.000000001);
}
vacuumcond::~vacuumcond()
{
}
void vacuumcond::open_info_1() { open_info(1);}
void vacuumcond::open_info_2() { open_info(2);}
void vacuumcond::open_info_3() { open_info(3);}
void vacuumcond::open_info_4() { open_info(4);}
void vacuumcond::open_info_5() { open_info(5);}
void vacuumcond::open_info_6() { open_info(6);}
void vacuumcond::open_info(int i) {
void vacuumcond::open_info() {
const QString& on = sender()->objectName();
bool ok;
int i = QString(on.at(on.size() - 1)).toInt(&ok);
if (info_process->state() == QProcess::Running) {
info_process->kill();
info_process->waitForFinished(3000);
}
info_process->start("sip "+qApp->arguments()[i].split("/").at(0)+"/"+qApp->arguments()[i].split("/").at(1)+"/"+qApp->arguments()[i].split("/").at(2));
if(ok)
info_process->start("sip " , QStringList() << qApp->arguments()[i].section('/', 0, 2));
// info_process->start("sip "+qApp->arguments()[i].split("/").at(0)+"/"+qApp->arguments()[i].split("/").at(1)+"/"+qApp->arguments()[i].split("/").at(2));
}
......@@ -46,24 +46,19 @@ class vacuumcond: public QWidget
public:
vacuumcond(CumbiaPool *cu_p, QWidget * =NULL);
~vacuumcond();
int argsize;
~vacuumcond();
int argsize;
public slots:
void newCurve(QuPlotCurve *c);
void open_info_1();
void open_info_2();
void open_info_3();
void open_info_4();
void open_info_5();
void open_info_6();
private slots:
void open_info();
private:
Ui::vacuumcond * ui;
QTimer *timer;
QString imgpath;
void open_info(int i);
QString imgpath;
QProcess *info_process;
QVector<double > new_x;
QVector<double > new_y;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment