Add optional temperature controller attribute.
authorW. Trevor King <wking@drexel.edu>
Tue, 19 Apr 2011 23:42:17 +0000 (19:42 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 19 Apr 2011 23:42:17 +0000 (19:42 -0400)
pyafm.py

index 6248c564c91274dc0bda4a3d33cf908698db3974..c46e47b7e6f7e9904836da1a87c9e3f0569cb197 100644 (file)
--- a/pyafm.py
+++ b/pyafm.py
@@ -42,12 +42,24 @@ class AFM (object):
         Fine positioning and deflection measurements.
     stepper | stepper.Stepper instance
         Coarse positioning.
+    temperature | temperature.Controller instance or None
+        Optional temperature monitoring and control.
     """
-    def __init__(self, piezo, stepper, axis_name='z'):
+    def __init__(self, piezo, stepper, temperature=None, axis_name='z'):
         self.piezo = piezo
         self.stepper = stepper
+        self.temperature = temperature
         self.axis_name = axis_name
 
+    def get_temperature(self):
+        """Measure the sample temperature.
+
+        Return the sample temperature in Kelvin or `None` if such a
+        measurement is not possible.
+        """
+        if hasattr(self.temperature, 'get'):
+            return self.temperature.get_temperature()
+
     def move_just_onto_surface(self, depth=-50e-9, setpoint=2, far=200):
         """Position the AFM tip close to the surface.