aboutsummaryrefslogtreecommitdiff
path: root/acquisition/hardware.py
diff options
context:
space:
mode:
Diffstat (limited to 'acquisition/hardware.py')
-rw-r--r--acquisition/hardware.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/acquisition/hardware.py b/acquisition/hardware.py
new file mode 100644
index 0000000..2d062e2
--- /dev/null
+++ b/acquisition/hardware.py
@@ -0,0 +1,41 @@
+class Hardware(pc.Hardware):
+
+ def __init__(self, *args, **kwargs):
+ pc.Hardware.__init__(self, *args, **kwargs)
+ self.exposed = self.driver.exposed
+ for obj in self.exposed:
+ obj.updated.connect(self.update)
+ self.recorded = self.driver.recorded
+ self.offset = self.driver.offset
+ self.position = self.exposed[0]
+ self.native_units = self.driver.native_units
+ self.destination = pc.Number(units=self.native_units, display=True)
+ self.destination.write(self.position.read(self.native_units),
+ self.native_units)
+ self.limits = self.driver.limits
+ self.driver.initialized_signal.connect(self.on_address_initialized)
+ hardwares.append(self)
+
+ def set_offset(self, offset, input_units=None):
+ if input_units is None:
+ pass
+ else:
+ offset = wt.units.converter(offset, input_units,
+ self.native_units)
+ # do nothing if new offset is same as current offset
+ if offset == self.offset.read(self.native_units):
+ return
+ self.q.push('set_offset', offset)
+
+ def set_position(self, destination, input_units=None, force_send=False):
+ if input_units is None:
+ pass
+ else:
+ destination = wt.units.converter(destination, input_units,
+ self.native_units)
+ # do nothing if new destination is same as current destination
+ if destination == self.destination.read(self.native_units):
+ if not force_send:
+ return
+ self.destination.write(destination, self.native_units)
+ self.q.push('set_position', destination)