]> sigrok.org Git - sigrok-meter.git/commitdiff
Timestamp measurements as early as possible.
authorJens Steinhauser <redacted>
Sun, 4 Oct 2015 03:39:43 +0000 (05:39 +0200)
committerJens Steinhauser <redacted>
Sun, 4 Oct 2015 13:09:24 +0000 (15:09 +0200)
datamodel.py
samplingthread.py

index 53c70bc46bc635c3f47102b13c6598bdbfcf7b9e..6ce91581bbed334e51d3ba2feda120af8a0eaa3d 100644 (file)
@@ -22,7 +22,6 @@ import collections
 import itertools
 import qtcompat
 import sigrok.core as sr
 import itertools
 import qtcompat
 import sigrok.core as sr
-import time
 import util
 
 try:
 import util
 
 try:
@@ -143,8 +142,8 @@ class MeasurementDataModel(QtGui.QStandardItemModel):
         self.sort(0)
         return item
 
         self.sort(0)
         return item
 
-    @QtCore.Slot(object, object, object)
-    def update(self, device, channel, data):
+    @QtCore.Slot(float, sr.classes.Device, sr.classes.Channel, tuple)
+    def update(self, timestamp, device, channel, data):
         '''Update the data for the device (+channel) with the most recent
         measurement from the given payload.'''
 
         '''Update the data for the device (+channel) with the most recent
         measurement from the given payload.'''
 
@@ -161,7 +160,7 @@ class MeasurementDataModel(QtGui.QStandardItemModel):
 
         # The samples role is a dictionary that contains the old samples for each unit.
         # Should be trimmed periodically, otherwise it grows larger and larger.
 
         # The samples role is a dictionary that contains the old samples for each unit.
         # Should be trimmed periodically, otherwise it grows larger and larger.
-        sample = (time.time(), value)
+        sample = (timestamp, value)
         traces = item.data(MeasurementDataModel.tracesRole)
         traces[unit].append(sample)
 
         traces = item.data(MeasurementDataModel.tracesRole)
         traces[unit].append(sample)
 
index 017f895a7a25c8471a028e58bde6fb2db8398b03..fa95f424c43d5bcaef3f5cbefa7e332a7fc9bcb9 100644 (file)
@@ -22,6 +22,7 @@
 import qtcompat
 import re
 import sigrok.core as sr
 import qtcompat
 import re
 import sigrok.core as sr
+import time
 
 QtCore = qtcompat.QtCore
 QtGui = qtcompat.QtGui
 
 QtCore = qtcompat.QtCore
 QtGui = qtcompat.QtGui
@@ -33,7 +34,7 @@ class SamplingThread(QtCore.QObject):
         '''Helper class that does the actual work in another thread.'''
 
         '''Signal emitted when new data arrived.'''
         '''Helper class that does the actual work in another thread.'''
 
         '''Signal emitted when new data arrived.'''
-        measured = QtCore.Signal(object, object, object)
+        measured = QtCore.Signal(float, sr.classes.Device, sr.classes.Channel, tuple)
 
         '''Signal emmited in case of an error.'''
         error = QtCore.Signal(str)
 
         '''Signal emmited in case of an error.'''
         error = QtCore.Signal(str)
@@ -142,6 +143,8 @@ class SamplingThread(QtCore.QObject):
                 self.session.stop()
 
         def callback(self, device, packet):
                 self.session.stop()
 
         def callback(self, device, packet):
+            now = time.time()
+
             if not sr:
                 # In rare cases it can happen that the callback fires while
                 # the interpreter is shutting down. Then the sigrok module
             if not sr:
                 # In rare cases it can happen that the callback fires while
                 # the interpreter is shutting down. Then the sigrok module
@@ -160,7 +163,7 @@ class SamplingThread(QtCore.QObject):
             # The most recent value.
             value = packet.payload.data[0][-1]
 
             # The most recent value.
             value = packet.payload.data[0][-1]
 
-            self.measured.emit(device, channel,
+            self.measured.emit(now, device, channel,
                     (value, packet.payload.unit, packet.payload.mq_flags))
 
     # Signal used to start the worker across threads.
                     (value, packet.payload.unit, packet.payload.mq_flags))
 
     # Signal used to start the worker across threads.