Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        commitlog-requ...@lists.openmoko.org

You can reach the person managing the list at
        commitlog-ow...@lists.openmoko.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r5693 - developers/werner/ahrt/host/tmc/lib
      (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2009-10-16 06:07:21 +0200 (Fri, 16 Oct 2009)
New Revision: 5693

Modified:
   developers/werner/ahrt/host/tmc/lib/meter.py
Log:
- lib/meter.py: added front/rear and scanner channel selection for Picotest
  M3500A



Modified: developers/werner/ahrt/host/tmc/lib/meter.py
===================================================================
--- developers/werner/ahrt/host/tmc/lib/meter.py        2009-10-14 13:59:55 UTC 
(rev 5692)
+++ developers/werner/ahrt/host/tmc/lib/meter.py        2009-10-16 04:07:21 UTC 
(rev 5693)
@@ -2,6 +2,7 @@
 # meter.py - Multimeter control
 #
 # Copyright (C) 2008, 2009 by OpenMoko, Inc.
+# Copyright (C) 2009 by Werner Almesberger
 # Written by Werner Almesberger <wer...@openmoko.org>
 # All Rights Reserved
 # 
@@ -25,7 +26,7 @@
 #
 
 
-from tmc.instrument import instrument, setting
+from tmc.instrument import instrument, setting, settings
 
 
 class meter(instrument):
@@ -71,9 +72,77 @@
        self.send(":SYST:REM")
 
 
+class m3005a_chan(settings):
+
+    def __init__(self, instr):
+       self.curr = None
+       self.front = None
+       self.scanner = None
+       self.instr = instr
+
+    def is_front(self):
+       if self.front is None:
+           term = self.instr.query("ROUT:TERM?")
+           if term == "FRON":
+               self.front = True
+           elif term == "REAR":
+               self.front = False
+           else:
+               raise hell
+       return self.front
+
+    def has_scanner(self):
+       if self.scanner is None:
+           term = self.instr.query("ROUT:STAT?")
+           if term == "1":
+               self.scanner = True
+           elif term == "0":
+               self.scanner = False
+           else:
+               raise hell
+       return self.scanner
+
+    def get(self):
+       if self.curr is None:
+           if self.is_front():
+               self.curr = 0
+           else:
+               if self.has_scanner():
+                   closed = self.instr.query("ROUT:CLOS?")
+                   self.curr = None
+                   n = 1
+                   for ch in closed:
+                       if ch == "1":
+                           if self.curr is not None:
+                               raise hell
+                           self.curr = n
+                       n += 1
+               else:
+                   self.curr = 1
+       return self.curr
+
+    def set(self, value):
+       if self.curr is not None and self.curr == value:
+           return
+       if self.is_front():
+           if value != 0:
+               raise hell
+       else:
+           if value < 1 or value > 10:
+               raise hell
+           if self.has_scanner():
+               self.instr.send("ROUT:OPEN")
+               self.instr.send("ROUT:CLOS "+str(value))
+           else:
+               if value > 1:
+                   raise hell
+       self.curr = value
+
+
 class picotest_m3500a(meter):
 
     def __init__(self):
        meter.__init__(self, "usbtmc", "timeout=2", "retry", "vendor=0x164e",
          "product=0x0dad")
+       self.chan = m3005a_chan(self)
        self.lock_attr()




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to