i0mmonplot.cpp 1.62 KB
Newer Older
Giacomo Strangolino's avatar
Giacomo Strangolino committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "i0mmonplot.h"
#include <cumbiapool.h>
#include <cucontrolsfactorypool.h>
#include <quplotcurve.h>

#include <cupluginloader.h>
#include <qumultireaderplugininterface.h>
#include <cumacros.h>

#include <QtDebug>

#ifdef QUMBIA_TANGO_CONTROLS_VERSION
#include <cutreader.h>
#endif

I0MMonPlot::I0MMonPlot(QWidget *parent, CumbiaPool *cup, const CuControlsFactoryPool &fpoo)
    : QuPlotBase(parent) {
    m_ctrl_fpool = fpoo;
    m_cu_poo = cup;
    CuPluginLoader plo;
    QObject *plugin_qob;
    m_multiread_plu_i = plo.get<QuMultiReaderPluginInterface>("libcumbia-multiread-plugin.so", &plugin_qob);
    if(!m_multiread_plu_i)
        perr("I0MMonPlot: failed to load plugin \"libcumbia-multiread-plugin.so\"");
    else {
        int mode = 0;
#ifdef QUMBIA_TANGO_CONTROLS_VERSION
        mode = CuTReader::Manual;
#endif
        m_multiread_plu_i->init(cup, fpoo, mode); // 0 sync mode
        connect(m_multiread_plu_i->get_qobject(), SIGNAL(onSeqReadComplete(const QList<CuData> &)),
                this, SLOT(onDataReady(const QList<CuData> &)));
    }

}

bool I0MMonPlot::pluginLoaded() const {
    return m_multiread_plu_i != nullptr;
}

void I0MMonPlot::onDataReady(const QList<CuData> &dl) {
    foreach(const CuData& d, dl)
        printf("- %s\n", datos(d));
}

void I0MMonPlot::setSources(const QString &x, const QString &y, QList<int> lambda_idxs, int nsamples)
{
    qDebug() << __PRETTY_FUNCTION__ << x << y << lambda_idxs;
    QuPlotBase::clearPlot();

    QuPlotCurve *c = new QuPlotCurve(y);
    if(m_multiread_plu_i ) {
        m_multiread_plu_i->insertSource(x, 0);
        m_multiread_plu_i->insertSource(y, 1);
    }

}