Commit 80c81681 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

fixes to time X scale and enabled wlen and wlen wei writings

parent 6363c318
No preview for this file type
......@@ -11,6 +11,7 @@
#include <quwatcher.h>
#include <qulineedit.h>
#include <qustring.h>
#include <quwriter.h>
#include "checkablecomboboxmodel.h"
......@@ -52,6 +53,7 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
connect(ui->pbApplyWlenWei, SIGNAL(clicked()), this, SLOT(applyWavelenX()));
// qu-line edit for wavelen / wavelen weights
ui->quleWlens->setTarget(QString("$2/FEL0%1_IOM_wavelengths").arg(m_fel0x));
ui->quleWlenWei->setTarget(QString("$2/FEL0%1_IOM_wavelength_weights").arg(m_fel0x));
// label
......@@ -84,7 +86,7 @@ void I0mapmon::onNamesReady(const QStringList &n) {
ui->qucby->clear();
ui->qucby->insertItems(0, n);
if(n.size()) {
// onYChanged(n.first());
// onYChanged(n.first());
// X combo box
connect(ui->qucby, SIGNAL(currentTextChanged(QString)), this, SLOT(onYChanged(QString)));
}
......@@ -99,7 +101,13 @@ void I0mapmon::applyWavelenX() {
if(v.toDouble(&ok) && ok) vals.push_back(v.toDouble());
sender()->objectName() == "pbApplyWlens" ? tgt = QString("$2/FEL0%1_IOM_wavelengths").arg(m_fel0x) :
tgt = QString("$2/FEL0%1_IOM_wavelength_weights").arg(m_fel0x);
qDebug() << __PRETTY_FUNCTION__ << "*WOULD WRITE ON* target" << tgt << "values" << vals;
if(vals.size() > 0) {
QuWriter *w = new QuWriter(this, cu_pool, m_ctrl_factory_pool);
w->setAutoDestroy(true);
w->setTarget(tgt);
w->execute(vals);
qDebug() << __PRETTY_FUNCTION__ << "*WOULD WRITE ON* target" << w->target() << "values" << vals;
}
}
void I0mapmon::onYChanged(const QString &y) {
......@@ -125,8 +133,8 @@ void I0mapmon::onWlenSelectionChanged(const QString& , bool ) {
if(it->data(Qt::CheckStateRole).toBool())
wlens.append(it->text());
}
ui->quleWlens->setText(wlens.join(","));
ui->qucblambda->setItemText(0, ui->quleWlens->text());
ui->labelleWlens->setText(wlens.join(","));
ui->qucblambda->setItemText(0, ui->labelleWlens->text());
}
void I0mapmon::m_setup_x_list() {
......@@ -138,7 +146,7 @@ void I0mapmon::m_setup_x_list() {
// "PM2a OLD Photocurrent" srv-tf-srf:20000/ec-tf-esa-01/v1720/1000000 None GetArea4
// "PRESTO Intensity" pos/pesp/ccd-pesp_pos.01 Intensity None
// "TARDI Intensity" pos_mag/pesp/ccd-pesp_pos_mag.01 Intensity None
// "DPI Photodiode (Beamline Transmission)" pos/diagnostics/pico_pos.01 None GetIc
// "DPI Photodiode (Beamline Transmission)" pos/diagnostics/pico_pos.01 None GetIc
// "LDM Photodiode (Beamline Transmission)" pos/diagnostics/pico_pos.01 None GetId
ui->qucbx->insertItem(ui->qucbx->count(), "PM2a Ni Photocurrent (a.u.)");
......
......@@ -14,65 +14,7 @@
<string>I0mapmon</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Wavelengths:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="5">
<widget class="QPushButton" name="pbApplyWlenWei">
<property name="text">
<string>APPLY</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QuLabel" name="qulWlenWei"/>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Wavelen weights:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1" colspan="5">
<widget class="QLabel" name="lTitle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Real time</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QuLineEdit" name="quleWlenWei"/>
</item>
<item row="4" column="2">
<widget class="QuLabel" name="qulWlens"/>
</item>
<item row="2" column="0" colspan="6">
<item row="2" column="0" colspan="9">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
......@@ -135,7 +77,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="quleWlens">
<widget class="QLabel" name="labelleWlens">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
......@@ -173,7 +115,33 @@
</item>
</layout>
</item>
<item row="1" column="0" colspan="6">
<item row="4" column="6">
<widget class="QuLabel" name="qulWlenWei"/>
</item>
<item row="4" column="8">
<widget class="QPushButton" name="pbApplyWlenWei">
<property name="text">
<string>APPLY</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QuLineEdit" name="quleWlens"/>
</item>
<item row="4" column="1">
<widget class="QuLabel" name="qulWlens"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Wavelengths:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" colspan="9">
<widget class="I0MMonPlot" name="plot" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
......@@ -183,6 +151,48 @@
</property>
</widget>
</item>
<item row="4" column="7">
<widget class="QuLineEdit" name="quleWlenWei"/>
</item>
<item row="4" column="4">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Wavelen weights:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="4" colspan="5">
<widget class="QLabel" name="lTitle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Real time</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QPushButton" name="pbApplyWlens">
<property name="text">
<string>APPLY</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
......
......@@ -45,6 +45,19 @@ bool I0MMonPlot::pluginLoaded() const {
void I0MMonPlot::onDataReady(const QList<CuData> &dl) {
qDebug() << __PRETTY_FUNCTION__ << "data szi" << dl.size();
double x;
foreach(QwtPlotCurve *c, curves()) {
if(c->style() != QwtPlotCurve::Dots) {
c->setStyle(QwtPlotCurve::Dots);
QPen p = c->pen();
p.setWidthF(2.0f);
c->setPen(p);
}
#if CUMBIA_QTCONTROLS_VERSION > 0x010202
c->setMaxDataSizeForSymbol(0); // disable first points symbol
#endif
if(!c->symbol() || c->symbol()->style() != QwtSymbol::XCross)
c->setSymbol(new QwtSymbol(QwtSymbol::XCross, c->brush(), c->pen(), QSize(10, 10)));
}
if(dl.size() == 2) { // correlate
QVector<double> yv, xv;
const CuData& xd = dl[0];
......@@ -71,17 +84,7 @@ void I0MMonPlot::onDataReady(const QList<CuData> &dl) {
}
QuPlotCurve * c = curve(m_curvenames.first());
if(c) {
if(c->style() != QwtPlotCurve::Dots) {
c->setStyle(QwtPlotCurve::Dots);
QPen p = c->pen();
p.setWidthF(2.0f);
c->setPen(p);
}
#if CUMBIA_QTCONTROLS_VERSION > 0x010202
c->setMaxDataSizeForSymbol(0); // disable first points symbol
#endif
if(!c->symbol() || c->symbol()->style() != QwtSymbol::XCross)
c->setSymbol(new QwtSymbol(QwtSymbol::XCross, c->brush(), c->pen(), QSize(10, 10)));
printf("\e[1;32mI0MMonPlot::onDataReady: curve: %s { ", qstoc(c->title().text()));
for(int i = 0; i < xv.size(); i++)
printf("(%.2f, %.2f), ", xv[i], yv[i]);
......@@ -91,16 +94,20 @@ void I0MMonPlot::onDataReady(const QList<CuData> &dl) {
}
}
else if(dl.size() == 1) { // trend
const CuData &da = dl[0];
const std::vector<double> &yv = da["value"].toDoubleVector();
CuVariant ts = da["timestamp_ms"];
ts.getType() == CuVariant::LongInt ? x = static_cast<qint64>(ts.toLongInt()) : x = ts.toDouble();
const std::vector<double> &ystdv = da["value"].toDoubleVector();
const QVector<double> xv(m_lambda_idxs.begin(), m_lambda_idxs.end());
const QVector<double> yv(ystdv.begin(), ystdv.end());
// CuVariant ts = da["timestamp_ms"];
// ts.getType() == CuVariant::LongInt ? x = static_cast<qint64>(ts.toLongInt()) : x = ts.toDouble();
printf("\e[0;33mdata %s -- timestamp %f\e[0m\n", datos(da), x);
for(int i = 0; i < m_lambda_idxs.size(); i++) {
const QString curveName = QString("lambda %1").arg(m_lambda_idxs[i]);
if(m_lambda_idxs[i] < static_cast<int>(yv.size()) ) {
qDebug() << __PRETTY_FUNCTION__ << "APPENDING" << QDateTime::fromMSecsSinceEpoch(x) << yv[m_lambda_idxs[i]];
appendData(curveName, x, yv[m_lambda_idxs[i]]);
m_set_bounds(xv, yv, curve(curveName)->dataSize());
appendData(curveName, m_lambda_idxs[i], yv[m_lambda_idxs[i]]);
}
}
refresh();
......@@ -112,19 +119,25 @@ void I0MMonPlot::setSources(const QString &x, const QString &y, const QList<int>
qDebug() << __PRETTY_FUNCTION__ << x << y << lambda_idxs;
QuPlotBase::clearPlot();
m_multiread_plu_i->unsetSources();
m_curvenames.clear();
m_numsamples = nsamples;
m_lambda_idxs = lambda_idxs;
m_reset_scales();
if(x == "time") {
m_set_x_trend_scale();
// m_set_x_trend_scale();
foreach(int l, lambda_idxs) {
addCurve(QString("lambda %1").arg(l));
QString cuna = QString("lambda %1").arg(l);
QuPlotCurve *crv = curve(cuna);
if(!crv) {
crv = new QuPlotCurve(cuna);
addCurve(cuna, crv);
}
m_curvenames = QStringList() << QString("lambda %1").arg(l);
}
if(m_multiread_plu_i)
m_multiread_plu_i->insertSource(y, 0);
}
else {
m_reset_scales();
addCurve(y);
m_curvenames = QStringList() << y;
if(m_multiread_plu_i ) {
......@@ -154,9 +167,9 @@ void I0MMonPlot::m_set_bounds(const QVector<double> &xv, const QVector<double> &
if(xub <= *xM)
xub = (*xM + 0.5);
} else {
if(xlb > *xm)
if(xlb >= *xm)
xlb = (*xm - 0.05 * (*xM - *xm));
if(xub < *xM)
if(xub <= *xM)
xub = (*xM + 0.05 * (*xM - *xm));
}
if(*yM == *ym) {
......@@ -165,9 +178,9 @@ void I0MMonPlot::m_set_bounds(const QVector<double> &xv, const QVector<double> &
if(yub <= *yM)
yub = (*yM + 0.5);
} else {
if(ylb > *ym)
if(ylb >= *ym)
ylb = (*ym - 0.05 * (*yM - *ym));
if(yub < *yM)
if(yub <= *yM)
yub = (*yM + 0.05 * (*yM - *ym));
}
if(xlb != xLowerBound())
......
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