def initialise(self,frontend,scaffold,cookie,info): self.scaffold = scaffold self.frontend = frontend self.frontend_context = piw.tsd_snapshot() self.garbage_context = self.__create_context('eigend-garbage',None,False) piw.tsd_thing(self.fgthing) self.stdio = (sys.stdout,sys.stderr) if not self.opts.noredirect: sys.stdout = session.Logger() sys.stderr = sys.stdout self.backend_context = self.__create_context('eigend-backend',None,False) def bginit(): self.agent = Agent(self) piw.tsd_thing(self.bgthing) self.collector = GarbageCollector(self.scaffold,self.garbage_context) self.collector.start() self.bugfiler.start(cookie,info) self.run_background(bginit)
def __loadverb(self,subject,t): tag = self.__process_tag(action.abstract_string(t)) path = find_setup(tag) if not path: print 'no such state',tag thing= 'setup %s' %str(tag) return async.success(errors.doesnt_exist(thing,'load')) def deferred_load(): self.__thing.cancel_timer_slow() self.__thing = None snap = self.prepare_file(path,self.uid,version.version) if not snap: print 'no such state' return async.failure('no such state %s' % tag) print 'loading from version',snap.version(),'in',tag self.setups_changed(path) self.__load(snap,tag) self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__thing.set_slow_timer_handler(utils.notify(deferred_load)) self.__thing.timer_slow(500) return async.success()
def __init__(self, address, ordinal): agent.Agent.__init__(self, signature=version, names='alpha manager', protocols='has_subsys', ordinal=ordinal) self.domain = piw.clockdomain_ctl() self.domain.set_source(piw.makestring('*', 0L)) self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__thing.set_slow_dequeue_handler(utils.changify(self.__dequeue)) self.__base = dict() self.__enum = [] lsf = lambda c: picross.make_string_functor( utils.make_locked_callable(c)) self.__enum.append( picross.enumerator(0xbeca, 0x0102, lsf(self.add_alpha2keyboard))) self.__enum.append( picross.enumerator(0xbeca, 0x0103, lsf(self.add_taukeyboard))) self.__enum.append( picross.enumerator(0x2139, 0x0002, lsf(self.download_base_station))) self.__enum.append( picross.enumerator(0x2139, 0x0003, lsf(self.download_psu))) self.__enum.append( picross.enumerator(0x2139, 0x0104, lsf(self.add_base_station), lsf(self.del_base_station))) self.__enum.append( picross.enumerator(0x2139, 0x0105, lsf(self.add_base_station), lsf(self.del_base_station)))
def __init__(self,name): self.__timer = piw.thing() self.__index = piw.index() piw.tsd_index(name,self.__index) piw.tsd_thing(self.__timer) self.__timer.set_slow_timer_handler(utils.notify(self.__timercallback)) self.__timer.timer_slow(8000)
def __init__(self, usbname, agent): self.__usbname = usbname self.__agent = agent self.__thing = piw.thing() self.__device = 0 self.__instrument = 0 self.__kbd = None piw.tsd_thing(self.__thing) self.__thing.set_slow_timer_handler(utils.notify(self.__poll)) self.__counter = itertools.cycle([1] + [0] * 20) self.__thing.timer_slow(1000)
def __init__(self, deferred, timeout, status, *args, **kwds): async .Deferred.__init__(self) self.__original = deferred self.__status = status self.__args = args self.__kwds = kwds self.__thing = None self.__original.setCallback(self.__callback).setErrback(self.__errback) if self.__original.status() is None and timeout > 0: self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__thing.set_slow_timer_handler(utils.notify(self.__timeout)) self.__thing.timer_slow(timeout)
def deferred_call(func, *args, **kwds): r = Deferred() def call(): try: v = func(*args, **kwds) r.succeeded(v) except: utils.log_trace() r.failed('internal error') r.thing = piw.thing() piw.tsd_thing(r.thing) r.thing.set_slow_trigger_handler(utils.notify(call)) r.thing.trigger_slow() return r
def __init__(self, deferred, status, *args, **kwds): async .Deferred.__init__(self) self.__original = deferred self.__status = status self.__args = args self.__kwds = kwds self.__thing = None if self.__original.status() is None: self.__original.setCallback(self.__callback).setErrback( self.__errback) self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__thing.set_slow_timer_handler(utils.notify(self.__timeout)) else: self.completed(self.__original.status(), *self.__original.args(), **self.__original.kwds())
def __loadverb(self, subject, t): tag = self.__process_tag(action.abstract_string(t)) path = find_setup(tag) if not path: print 'no such state', tag thing = 'setup %s' % str(tag) return async .success(errors.doesnt_exist(thing, 'load')) def deferred_load(): self.__thing.cancel_timer_slow() self.__thing = None self.__backend.setups_changed(path) self.__workspace.load_file(path) self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__thing.set_slow_timer_handler(utils.notify(deferred_load)) self.__thing.timer_slow(500) return async .success()
def initialise(self, frontend, scaffold, cookie, info): try: self.scaffold = scaffold self.frontend = frontend self.frontend_context = piw.tsd_snapshot() self.garbage_context = self.__create_context('eigend-garbage') piw.tsd_thing(self.fgthing) self.stdio = (sys.stdout, sys.stderr) if not self.opts.noredirect: sys.stdout = session.Logger() sys.stderr = sys.stdout self.backend_context = self.__create_context('eigend-backend') resource.clean_current_setup() def bginit(): self.agent = agentd.Agent(self, 1) piw.tsd_thing(self.bgthing) self.collector = GarbageCollector(self.scaffold, self.garbage_context) self.collector.start() if os.getenv('PI_NOCHECK') is None: self.latest_release.start(cookie, info) self.run_background(bginit) except: print >> sys.__stdout__, 'Initialisation failure' traceback.print_exc(limit=None, file=sys.__stdout__) raise
def shutdown(self): self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__thing.set_slow_timer_handler(utils.notify(self.__shutdown)) self.__thing.timer_slow(500)
def bginit(): self.agent = Agent(self) piw.tsd_thing(self.bgthing)
def __init__(self, address, ordinal): # self[3] is the verb container agent.Agent.__init__(self, signature=version, names='console mixer', protocols='inputlist has_subsys oldbrowse', ordinal=ordinal) self.clk = piw.clockdomain_ctl() pan_function = pan_laws[default_pan] # make vol and pan tables self.vol = piw.make_f2f_table( -70, 14, 1000, picross.make_f2f_functor(volume_function)) self.pan = piw.make_f2f_table(-1, 1, 1000, picross.make_f2f_functor(pan_function)) self[1] = atom.Atom(names='outputs') self[1][1] = bundles.Output(1, True, names='left audio output') self[1][2] = bundles.Output(2, True, names='right audio output') self.output = bundles.Splitter(self.clk, self[1][1], self[1][2]) self.mixer = piw.consolemixer(self.vol, self.pan, self.clk, self.output.cookie()) self[10] = atom.Atom( names='pan curve', domain=domain.StringEnum(*sorted(pan_laws.keys())), init=default_pan, policy=atom.default_policy(self.__set_pan)) self.master_controls_input = bundles.ScalarInput( self.mixer.master_controls_cookie(), self.clk, signals=(1, 2)) self[2] = atom.Atom(names='master') self[2][1] = atom.Atom(domain=domain.BoundedFloat( -70, 14, hints=(T('stageinc', 0.1), T('inc', 1), T('biginc', 10), T('control', 'updown'), T('distribution', 'tapered'))), init=0, names='master volume', policy=self.master_controls_input.notify_policy( 1, policy.LopassStreamPolicy(100, 0.97), notify=self.changes_pending)) self[2][2] = atom.Atom(domain=domain.BoundedFloat( -1, 1, hints=(T('stageinc', 0.1), T('inc', 0.02), T('biginc', 0.2), T('control', 'updown'))), init=0, names='master pan', policy=self.master_controls_input.policy( 2, policy.LopassStreamPolicy(100, 0.97))) self[3] = ChannelList(self) self[4] = FxChannelList(self) self.channels = self[3] self.fxchannels = self[4] # add channels numbered 1..24, which means effect channels cannot be called 1..24 ... for n in range(0, num_inputs): self.channels.create_channel(n + 1) # verbs # verb to create a named effect channel self.add_verb2( 1, 'create([],None,role(None,[abstract,matches([effect])]), option(called,[abstract]))', self.__create_fx_chan) self.add_verb2( 2, 'create([un],None,role(None,[concrete,singular,partof(~(a)#4)]))', self.__uncreate_fx_chan) self.__timestamp = piw.tsd_time() self.__selected = None self.__pending = True self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__thing.set_slow_timer_handler(utils.notify(self.update)) self.__thing.timer_slow(500)
def __setup(self): piw.tsd_thing(self.__thing)
def __init__(self): self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__queue = set() self.__thing.set_slow_timer_handler(utils.notify(self.__timer)) self.__thing.timer_slow(500)
def bginit(): self.agent = agentd.Agent(self, 1) piw.tsd_thing(self.bgthing)
def server_opened(self): atom.Atom.server_opened(self) self.__timer.close_thing() piw.tsd_thing(self.__timer) self.__timer.timer_slow(5000)
def __init__(self, address, ordinal): # self[3] is the verb container agent.Agent.__init__(self, signature=version, names='console mixer', protocols='inputlist has_subsys browse', icon='plg_synth/mixer.png', container=3, ordinal=ordinal) self.__private = node.Server() self.set_private(self.__private) self.__private[1] = container.PersistentFactory( asserted=self.__inst_asserted, retracted=self.__inst_retracted) self.__private[2] = node.server(value=piw.makestring('testing1', 0)) self.clk = piw.clockdomain_ctl() pan_function = pan_laws[default_pan] # make vol and pan tables self.vol = piw.make_f2f_table( 0, 120, 1000, picross.make_f2f_functor(volume_function)) self.pan = piw.make_f2f_table(-1, 1, 1000, picross.make_f2f_functor(pan_function)) self[1] = atom.Atom() self[1][1] = bundles.Output(1, True, names='left audio output') self[1][2] = bundles.Output(2, True, names='right audio output') self.output = bundles.Splitter(self.clk, self[1][1], self[1][2]) self.mixer = piw.consolemixer(self.vol, self.pan, self.clk, self.output.cookie()) sh = (T('choices', *pan_laws.keys()), T('control', 'selector')) self[10] = atom.Atom(names='pan curve', domain=domain.String(hints=sh), init='default', policy=atom.default_policy(self.__set_pan)) # channel dicts self.channels = {} self.fxchannels = {} # adds subsystems numbered 1..24, which means effect channels cannot be called 1..24 ... for n in range(0, num_inputs): ss = Channel(self, n + 1, self.clk, self.mixer.create_channel(n)) self.add_subsystem(str(n), ss) self.channels[n] = ss self.master_controls_input = bundles.ScalarInput( self.mixer.master_controls_cookie(), self.clk, signals=(1, 2)) self[2] = atom.Atom() self[2][1] = atom.Atom(domain=domain.BoundedFloat( 0, 120, hints=(T('inc', 1), T('biginc', 10), T('control', 'updown'))), init=100, names='master volume', policy=self.master_controls_input.notify_policy( 1, policy.LopassStreamPolicy(100, 0.97), notify=self.volume_changed)) self[2][2] = atom.Atom(domain=domain.BoundedFloat( -1, 1, hints=(T('inc', 0.02), T('biginc', 0.2), T('control', 'updown'))), init=0, names='master pan', policy=self.master_controls_input.policy( 2, policy.LopassStreamPolicy(100, 0.97))) # verbs # verb to create a named effect channel self.add_verb2( 1, 'create([],None,role(None,[abstract,matches([effect])]), role(called,[abstract]))', self.__create_named_fx_chan) self.add_verb2( 2, 'create([un],None,role(None, [abstract,matches([effect])]), role(called,[abstract]))', self.__uncreate_named_fx_chan) self.add_verb2( 3, 'label([],None,role(None,[mass([channel])]),role(to,[abstract]))', self.__label) self.add_verb2(4, 'label([un],None,role(None,[mass([channel])]))', self.__unlabel) self.add_verb2( 5, 'label([],None,role(None,[mass([effect])]),role(to,[abstract]))', self.__labelfx) self.add_verb2(6, 'label([un],None,role(None,[mass([effect])]))', self.__unlabelfx) self.__timestamp = piw.tsd_time() self.__selected = None self.__pending = True self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__thing.set_slow_timer_handler(utils.notify(self.update)) self.__thing.timer_slow(500)