Skip to content

Commit

Permalink
Implemented review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
philipstarkey committed Jun 23, 2020
1 parent 4a4096f commit dd195a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
25 changes: 22 additions & 3 deletions labscript_devices/DummyPseudoclock/labscript_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,33 @@
from labscript import PseudoclockDevice, Pseudoclock, ClockLine, config, LabscriptError
import numpy as np

class _DummyPseudoclock(Pseudoclock):
def add_device(self, device):
if isinstance(device, ClockLine):
# only allow one child
if self.child_devices:
raise LabscriptError('The pseudoclock of the DummyPseudoclock %s only supports 1 clockline, which is automatically created. Please use the clockline located at %s.clockline'%(self.parent_device.name, self.parent_device.name))
Pseudoclock.add_device(self, device)
else:
raise LabscriptError('You have connected %s to %s (the Pseudoclock of %s), but %s only supports children that are ClockLines. Please connect your device to %s.clockline instead.'%(device.name, self.name, self.parent_device.name, self.name, self.parent_device.name))


class DummyPseudoclock(PseudoclockDevice):

description = 'Dummy pseudoclock'
clock_limit = 10e6
clock_resolution = 25e-9
clock_type = 'fast clock'
trigger_delay = 350e-9
wait_delay = 2.5e-6
allowed_children = None
allowed_children = [_DummyPseudoclock]
max_instructions = 1e5

def __init__(
self, name='dummy_pseudoclock', BLACS_connection='dummy_connection', **kwargs
):
self.BLACS_connection = BLACS_connection
PseudoclockDevice.__init__(self, name, None, None, **kwargs)
self._pseudoclock = Pseudoclock(
self._pseudoclock = _DummyPseudoclock(
name=f'{name}_pseudoclock',
pseudoclock_device=self,
connection='pseudoclock',
Expand All @@ -54,6 +63,16 @@ def pseudoclock(self):
def clockline(self):
return self._clock_line

def add_device(self, device):
if not self.child_devices and isinstance(device, Pseudoclock):
PseudoclockDevice.add_device(self, device)
elif isinstance(device, Pseudoclock):
raise LabscriptError('The %s %s automatically creates a Pseudoclock because it only supports one. '%(self.description, self.name) +
'Instead of instantiating your own Pseudoclock object, please use the internal' +
' one stored in %s.pseudoclock'%self.name)
else:
raise LabscriptError('You have connected %s (class %s) to %s, but %s does not support children with that class.'%(device.name, device.__class__, self.name, self.name))

def generate_code(self, hdf5_file):
PseudoclockDevice.generate_code(self, hdf5_file)
group = self.init_device_group(hdf5_file)
Expand Down
1 change: 0 additions & 1 deletion labscript_devices/DummyPseudoclock/runviewer_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

class DummyPseudoclockParser(object):
clock_resolution = 25e-9
clock_type = 'fast clock'
trigger_delay = 350e-9
wait_delay = 2.5e-6

Expand Down

0 comments on commit dd195a5

Please sign in to comment.