]> sigrok.org Git - pulseview.git/blobdiff - sigsession.cpp
Push data into data model
[pulseview.git] / sigsession.cpp
index e8d129fcdcc6f7f2cdd3d85455d3bcd352988b52..9b9798e0577b65b4b64c0de854a82fb203426539 100644 (file)
 
 #include "sigsession.h"
 
 
 #include "sigsession.h"
 
+#include "logicdata.h"
+#include "logicdatasnapshot.h"
+
 #include <QDebug>
 
 #include <assert.h>
 
 #include <QDebug>
 
 #include <assert.h>
 
+using namespace boost;
+
 // TODO: This should not be necessary
 SigSession* SigSession::session = NULL;
 
 // TODO: This should not be necessary
 SigSession* SigSession::session = NULL;
 
-SigSession::SigSession() :
-       unitSize(0),
-       sigData(NULL)
+SigSession::SigSession()
 {
        // TODO: This should not be necessary
        session = this;
 {
        // TODO: This should not be necessary
        session = this;
@@ -37,8 +40,6 @@ SigSession::SigSession() :
 
 SigSession::~SigSession()
 {
 
 SigSession::~SigSession()
 {
-       g_array_free(sigData, TRUE);
-
        // TODO: This should not be necessary
        session = NULL;
 }
        // TODO: This should not be necessary
        session = NULL;
 }
@@ -61,50 +62,45 @@ void SigSession::dataFeedIn(const struct sr_dev_inst *sdi,
        assert(packet);
 
        switch (packet->type) {
        assert(packet);
 
        switch (packet->type) {
-       case SR_DF_META_LOGIC:
-               {
-                       const sr_datafeed_meta_logic *meta_logic =
-                               (sr_datafeed_meta_logic*)packet->payload;
-                       int num_enabled_probes = 0;
-
-                       for (int i = 0; i < meta_logic->num_probes; i++) {
-                               const sr_probe *probe =
-                                       (sr_probe *)g_slist_nth_data(sdi->probes, i);
-                               if (probe->enabled) {
-                                       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);
-               }
+       case SR_DF_HEADER:
                break;
 
                break;
 
-       case SR_DF_LOGIC:
+       case SR_DF_META_LOGIC:
                {
                {
-                       uint64_t filter_out_len;
-                       uint8_t *filter_out;
+                       assert(packet->payload);
 
 
-                       const struct sr_datafeed_logic *const logic =
-                               (sr_datafeed_logic*)packet->payload;
+                       _logic_data.reset(new LogicData(
+                               *(sr_datafeed_meta_logic*)packet->payload));
 
 
-                       qDebug() << "SR_DF_LOGIC (length =" << logic->length
-                               << ", unitsize = " << logic->unitsize << ")";
+                       assert(_logic_data);
+                       if(!_logic_data)
+                               break;
 
 
-                       if (sr_filter_probes(logic->unitsize, unitSize,
-                               probeList, (uint8_t*)logic->data, logic->length,
-                               &filter_out, &filter_out_len) != SR_OK)
-                               return;
+                       break;
+               }
 
 
-                       assert(sigData);
-                       g_array_append_vals(sigData, filter_out, filter_out_len / unitSize);
+       case SR_DF_LOGIC:
 
 
-                       g_free(filter_out);
+               assert(packet->payload);
+               if(!_cur_logic_snapshot)
+               {
+                       // Create a new data snapshot
+                       _cur_logic_snapshot = shared_ptr<LogicDataSnapshot>(
+                               new LogicDataSnapshot(
+                               *(sr_datafeed_logic*)packet->payload));
+                       _logic_data->push_snapshot(_cur_logic_snapshot);
                }
                }
+               else
+               {
+                       // Append to the existing data snapshot
+                       _cur_logic_snapshot->append_payload(
+                               *(sr_datafeed_logic*)packet->payload);
+               }
+
                break;
 
        case SR_DF_END:
                break;
 
        case SR_DF_END:
+               _cur_logic_snapshot.reset();
                dataUpdated();
                break;
        }
                dataUpdated();
                break;
        }