]> sigrok.org Git - pulseview.git/commitdiff
Implemented initial data model
authorJoel Holdsworth <redacted>
Sat, 26 May 2012 13:43:58 +0000 (14:43 +0100)
committerJoel Holdsworth <redacted>
Mon, 3 Sep 2012 12:49:39 +0000 (13:49 +0100)
mainwindow.cpp
mainwindow.h
mainwindow.ui
sigsession.cpp
sigsession.h
sigview.cpp
sigview.h

index d85c0a40e46e0604690cb62ab6ea5eefec04d11a..10ef301388536f8668de1deddc3d24d33c5f7864 100644 (file)
@@ -28,6 +28,7 @@ extern "C" {
 
 #include "mainwindow.h"
 #include "ui_mainwindow.h"
+#include "sigview.h"
 
 extern "C" {
 /* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */
@@ -44,6 +45,9 @@ MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::MainWindow)
 {
        ui->setupUi(this);
+
+       view = new SigView(session, this);
+       ui->verticalLayout->addWidget(view);
 }
 
 MainWindow::~MainWindow()
index 34fb1b92e969e120a5ae6f1ed18364e52be3e487..1ba4c8e9d11bddc925cd5093cb0c34f395de46a1 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "sigsession.h"
 
+class SigView;
+
 namespace Ui {
 class MainWindow;
 }
@@ -40,6 +42,7 @@ public:
 private:
        Ui::MainWindow *ui;
        SigSession session;
+       SigView *view;
 
 private slots:
 
index 5cf32c6dfe889ec52445244586edb12513aa0b54..1e17f1155c5b6506d1ccd4b847924503eaac55c8 100644 (file)
@@ -46,9 +46,6 @@
     <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>
index 2df6a151c31e972651f84cc8b157862741ed5204..e8d129fcdcc6f7f2cdd3d85455d3bcd352988b52 100644 (file)
 
 #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;
@@ -33,6 +37,8 @@ SigSession::SigSession()
 
 SigSession::~SigSession()
 {
+       g_array_free(sigData, TRUE);
+
        // TODO: This should not be necessary
        session = NULL;
 }
@@ -68,10 +74,38 @@ void SigSession::dataFeedIn(const struct sr_dev_inst *sdi,
                                        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;
        }
 }
index 47f37a10fa8e5680a9a61bde5d448d9fc07c95ac..92c048bddc1bcf5e25d357d204f312f4fda17919 100644 (file)
 #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();
 
@@ -44,7 +48,12 @@ private:
                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
index c83ea7917064d4dbfc1c8c148df97b9826c267ba..b682cce950cd22ddff85f4b6df8860e7a025979e 100644 (file)
 
 #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);
 }
 
@@ -50,3 +56,9 @@ void SigView::paintGL()
 {
        glClear(GL_COLOR_BUFFER_BIT);
 }
+
+void SigView::dataUpdated()
+{
+       printf("Data Updated\n");
+}
+
index d2bdbe4d1839402219dc42a3e8a397aa923b8029..780d765ae5ecbfbc04f40b7a2a55adb3b631de49 100644 (file)
--- a/sigview.h
+++ b/sigview.h
 #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:
 
@@ -38,10 +40,11 @@ protected:
 
        void paintGL();
 
-signals:
-       
-public slots:
-       
+private slots:
+       void dataUpdated();
+
+private:
+       SigSession &_session;
 };
 
 #endif // SIGVIEW_H