#include "mainwindow.h"
#include "ui_mainwindow.h"
+#include "sigview.h"
extern "C" {
/* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */
ui(new Ui::MainWindow)
{
ui->setupUi(this);
+
+ view = new SigView(session, this);
+ ui->verticalLayout->addWidget(view);
}
MainWindow::~MainWindow()
#include "sigsession.h"
+class SigView;
+
namespace Ui {
class MainWindow;
}
private:
Ui::MainWindow *ui;
SigSession session;
+ SigView *view;
private slots:
<property name="margin">
<number>0</number>
</property>
- <item>
- <widget class="SigView" name="sigView" native="true"/>
- </item>
</layout>
</widget>
<widget class="QStatusBar" name="statusBar" />
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
- <customwidgets>
- <customwidget>
- <class>SigView</class>
- <extends>QGLWidget</extends>
- <header>sigview.h</header>
- </customwidget>
- </customwidgets>
<resources/>
<connections/>
</ui>
#include "sigsession.h"
+#include <QDebug>
+
#include <assert.h>
// TODO: This should not be necessary
SigSession* SigSession::session = NULL;
-SigSession::SigSession()
+SigSession::SigSession() :
+ unitSize(0),
+ sigData(NULL)
{
// TODO: This should not be necessary
session = this;
SigSession::~SigSession()
{
+ g_array_free(sigData, TRUE);
+
// TODO: This should not be necessary
session = NULL;
}
probeList[num_enabled_probes++] = probe->index;
}
}
+
+ /* How many bytes we need to store num_enabled_probes bits */
+ unitSize = (num_enabled_probes + 7) / 8;
+ sigData = g_array_new(FALSE, FALSE, unitSize);
+ }
+ break;
+
+ case SR_DF_LOGIC:
+ {
+ uint64_t filter_out_len;
+ uint8_t *filter_out;
+
+ const struct sr_datafeed_logic *const logic =
+ (sr_datafeed_logic*)packet->payload;
+
+ qDebug() << "SR_DF_LOGIC (length =" << logic->length
+ << ", unitsize = " << logic->unitsize << ")";
+
+ if (sr_filter_probes(logic->unitsize, unitSize,
+ probeList, (uint8_t*)logic->data, logic->length,
+ &filter_out, &filter_out_len) != SR_OK)
+ return;
+
+ assert(sigData);
+ g_array_append_vals(sigData, filter_out, filter_out_len / unitSize);
+
+ g_free(filter_out);
}
break;
case SR_DF_END:
+ dataUpdated();
break;
}
}
#ifndef SIGSESSION_H
#define SIGSESSION_H
+#include <QObject>
+
extern "C" {
#include <libsigrok/libsigrok.h>
}
#include <string>
-class SigSession
+class SigSession : public QObject
{
+ Q_OBJECT
+
public:
SigSession();
struct sr_datafeed_packet *packet);
private:
+ int unitSize;
int probeList[SR_MAX_NUM_PROBES + 1];
+ GArray *sigData;
+
+signals:
+ void dataUpdated();
private:
// TODO: This should not be necessary. Multiple concurrent
#include "sigview.h"
-SigView::SigView(QWidget *parent) :
- QGLWidget(parent)
+#include "sigsession.h"
+
+SigView::SigView(SigSession &session, QWidget *parent) :
+ QGLWidget(parent),
+ _session(session)
{
+ connect(&_session, SIGNAL(dataUpdated()),
+ this, SLOT(dataUpdated()));
+
setMouseTracking(true);
}
{
glClear(GL_COLOR_BUFFER_BIT);
}
+
+void SigView::dataUpdated()
+{
+ printf("Data Updated\n");
+}
+
#include <QtOpenGL/QGLWidget>
#include <QTimer>
+class SigSession;
+
class SigView : public QGLWidget
{
Q_OBJECT
public:
- explicit SigView(QWidget *parent = 0);
+ explicit SigView(SigSession &session, QWidget *parent = 0);
protected:
void paintGL();
-signals:
-
-public slots:
-
+private slots:
+ void dataUpdated();
+
+private:
+ SigSession &_session;
};
#endif // SIGVIEW_H