calibration: support to-physical-only softcal boards.
[pycomedi.git] / pycomedi / constant.pyx
index 1fed075e8e6cbd5dda0f2c5e98e78ba434bd7b9b..196650aef5e36434d53d278e1888af4500bbf282 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2012 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2011-2012 W. Trevor King <wking@tremily.us>
 #
 # This file is part of pycomedi.
 #
@@ -91,10 +91,17 @@ False
 >>> TRIG_SRC.now <= 2
 True
 >>> TRIG_SRC.now < 3
-False
+True
 >>> TRIG_SRC.now > None
 True
 
+The ``UNIT`` constant treats ``RF_EXTERNAL`` as a full-fledged unit:
+
+>>> UNIT.index_by_name('external')
+<_NamedInt external>
+>>> UNIT.index_by_value(_comedi.RF_EXTERNAL)
+<_NamedInt external>
+
 .. [#ops] See `emulating numeric types`_ and `NotImplementedError` in
    `the standard type hierarchy`_.
 
@@ -191,6 +198,9 @@ cdef class BitwiseOperator (object):
         else:
             raise ValueError(op)
 
+    def __reduce__(self):
+        return (BitwiseOperator, (self.value,))
+
 
 class _NamedInt (BitwiseOperator):
     "A flag or enum item."
@@ -205,6 +215,9 @@ class _NamedInt (BitwiseOperator):
     def __repr__(self):
         return '<%s %s>' % (self.__class__.__name__, self.name)
 
+    def __reduce__(self):
+        return (_NamedInt, (self.name, self.value, self.doc))
+
 
 class _Enum (list):
     "An enumerated list"
@@ -256,7 +269,6 @@ class _Enum (list):
         self._value_keys[item.value] = item
         setattr(self, item.name, item)
 
-
     def index_by_name(self, name):
         return self._name_keys[name]
 
@@ -437,6 +449,11 @@ SUPPORT_LEVEL = _Enum('support_level', 'COMEDI_', whitelist=[
 
 UNIT = _Enum('unit', 'UNIT_', translation={'mA':'mA'})
 # The mA translation avoids lowercasing to 'ma'.
+UNIT.append(_NamedInt(
+        name='external',
+        value=_comedi.RF_EXTERNAL,
+        doc=('RF_EXTERNAL (value unit is defined by an external reference '
+             'channel)')))
 
 CALLBACK = _Enum('callback_flags', 'COMEDI_CB_', blacklist=['block', 'eobuf'])
 CALLBACK.eos.doc += ' (end of scan)'