]> sigrok.org Git - sigrok-meter.git/commitdiff
Import the sigrok module under a different name.
authorJens Steinhauser <redacted>
Wed, 12 Nov 2014 04:01:49 +0000 (05:01 +0100)
committerJens Steinhauser <redacted>
Wed, 12 Nov 2014 13:05:31 +0000 (14:05 +0100)
sigrok-meter

index fcf5eb4f10c2202c778c44f3ff06817f780fee11..4c74e7323ee77743e207f5eb30481c7a3fd9631e 100755 (executable)
 
 from multiprocessing import Process, Queue
 from gi.repository import Gtk, GObject
-from sigrok.core import *
+import sigrok.core as sr
 
 def init_and_run(queue):
     def datafeed_in(device, packet):
-        if packet.type == PacketType.ANALOG:
+        if packet.type == sr.PacketType.ANALOG:
             data = packet.payload.data
             unit, unit_str = packet.payload.unit, ""
-            if unit == Unit.VOLT:
+            if unit == sr.Unit.VOLT:
                 unit_str = " V"
-            elif unit == Unit.OHM:
+            elif unit == sr.Unit.OHM:
                 unit_str = " Ohm"
-            elif unit == Unit.AMPERE:
+            elif unit == sr.Unit.AMPERE:
                 unit_str = " A"
             mqflags, mqflags_str = packet.payload.mq_flags, ""
-            if QuantityFlag.AC in mqflags:
+            if sr.QuantityFlag.AC in mqflags:
                 mqflags_str = " AC"
-            elif QuantityFlag.DC in mqflags:
+            elif sr.QuantityFlag.DC in mqflags:
                 mqflags_str = " DC"
             for i in range(packet.payload.num_samples):
                 dev = "%s %s" % (device.vendor, device.model)
                 val = "%f%s%s" % (data[0][i], unit_str, mqflags_str)
                 queue.put((dev, val))
 
-    context = Context_create()
-    context.log_level = LogLevel.SPEW
+    context = sr.Context_create()
+    context.log_level = sr.LogLevel.SPEW
     drivers_to_use = ['tecpel-dmm-8061-ser']
     drivers = [context.drivers[d] for d in drivers_to_use]
     devices = [d.scan(conn="/dev/ttyUSB0")[0] for d in drivers]
@@ -88,7 +88,7 @@ class SigrokMeter:
 
     def on_about(self, action):
         about = self.builder.get_object("aboutdialog")
-        context = Context_create()
+        context = sr.Context_create()
         sr_pkg = context.package_version
         sr_lib = context.lib_version
         s = "Using libsigrok %s (lib version %s)." % (sr_pkg, sr_lib)