def __init__(self): """ Creates a new sixjet server. backend is the instance of backends.Backend that will be used to write jets. service_extra is an optionally-empty set of values that will be added to the Autobus 2's service info dictionary. (Keys such as type will be added automatically, but such keys present in service_extra will override the ones added automatically.) bus is the Autobus bus to use. You can usually just use: from autobus2 import Bus with Bus() as bus: server = SixjetServer(..., bus, ...) ... and things will work. """ PyServiceProvider.__init__(self, True) ComplexProvider.__init__(self) self.flash_time = 0.25 self.fixed_provider = atomically(FixedProvider) atomically(lambda: self.provider_list.append(self.fixed_provider))
def __init__(self, backend, bus, service_extra={}): """ Creates a new sixjet server. backend is the instance of backends.Backend that will be used to write jets. service_extra is an optionally-empty set of values that will be added to the Autobus 2's service info dictionary. (Keys such as type will be added automatically, but such keys present in service_extra will override the ones added automatically.) bus is the Autobus bus to use. You can usually just use: from autobus2 import Bus with Bus() as bus: server = SixjetServer(..., bus, ...) ... and things will work. """ PyServiceProvider.__init__(self, True) service_extra = service_extra.copy() service_extra.update(type="sixjet") self.backend = backend self.bus = bus # The event loop used by this server. self.loop = eventloop.EventLoop() # The current states of all of the jets. This must only be read and # modified from the event thread. self.states = [False] * 16 # True to shut down the server. This shouldn't be modified; instead, # stop() should be called, which will post an event that sets this to # True. self.shut_down = False self.service = self.bus.create_service(service_extra, self) # Flush the jets to turn all of them off, but do it on the event loop self.loop.queue(Partial(self.flush)) # Set a default flash time self.flash_time = 0.25