def add_device(self, device): """Adds child devices. This is automatically called by the labscript compiler. Args: device (:class:`_PrawnBlasterPseudoclock` or :class:`_PrawnBlasterDummyPseudoclock`): Instance to attach to the device. Only the allowed children can be attached. """ if len(self.child_devices) < ( self.num_pseudoclocks + self.use_wait_monitor) and isinstance( device, (_PrawnBlasterPseudoclock, _PrawnBlasterDummyPseudoclock)): PseudoclockDevice.add_device(self, device) elif isinstance(device, _PrawnBlasterPseudoclock): raise LabscriptError( f"The {self.description} {self.name} automatically creates the correct number of pseudoclocks." + "Instead of instantiating your own Pseudoclock object, please use the internal" + f" ones stored in {self.name}.pseudoclocks") else: raise LabscriptError( f"You have connected {device.name} (class {device.__class__}) to {self.name}, but {self.name} does not support children with that class." )
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( f'The {self.name} PseudoclockDevice only supports a single Pseudoclock, so it automatically creates one.' + f'Instead of instantiating your own Pseudoclock object, please use the internal one stored in {self.name}.pseudoclock' ) elif isinstance(device, DigitalOut): raise LabscriptError( f'You have connected {device.name} directly to {self.name}, which is not allowed. You should instead specify ' + f'the parent_device of {device.name} as {self.name}.direct_outputs' ) elif isinstance(device, ClockLine): raise LabscriptError( f'You have connected {device.name} directly to {self.name}, which is not allowed. You should instead specify ' + f'the parent_device of {device.name} as {self.name}.pseudoclock' ) else: raise LabscriptError( f'You have connected {device.name} (class {device.__class__}) to {self.name}, but {self.name} does not support children with that class.' )
def add_device(self, device): if len(self.child_devices) < 2 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 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) elif isinstance(device, DDS): #TODO: Defensive programming: device.name may not exist! raise LabscriptError('You have connected %s directly to %s, which is not allowed. You should instead specify the parent_device of %s as %s.direct_outputs'%(device.name, self.name, device.name, 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))