Add .ranges() method to Channel class.
authorW. Trevor King <wking@drexel.edu>
Mon, 19 Mar 2012 13:09:30 +0000 (09:09 -0400)
committerW. Trevor King <wking@drexel.edu>
Mon, 19 Mar 2012 13:09:30 +0000 (09:09 -0400)
pycomedi/channel.pyx

index b743731581f17f55a5995a1114cd21a081f4f4d8..76bb5eba9496ccf1fe7741c95bd594fa762afc34 100644 (file)
@@ -119,6 +119,15 @@ cdef class Channel (object):
         """
         return self.get_range(self._find_range(unit, min, max))
 
+    def ranges(self, **kwargs):
+        "Iterate through all available ranges."
+        ret = []
+        for i in range(self.get_n_ranges()):
+            #yield self.subdevice(i, **kwargs)
+            # Generators are not supported in Cython 0.14.1
+            ret.append(self.get_range(i, **kwargs))
+        return ret
+
 
 cdef class DigitalChannel (Channel):
     """Channel configured for reading or writing digital data.