Exemplo n.º 1
0
 def __plumb_static(self):
     if self.__merge:
         self.__input.correlator.plumb_input(
             self.__signal, 1, piw.pathnull(0), 10,
             policy.Plumber.input_merge, self.__static_data,
             self.__stream_policy.create_converter(False),
             piw.null_filter())
     else:
         self.__input.correlator.plumb_input(
             self.__signal, 1, piw.pathnull(0), -1,
             policy.Plumber.input_input, self.__static_data,
             self.__stream_policy.create_converter(False),
             piw.null_filter())
Exemplo n.º 2
0
 def __init__(self, cdomain, policy=None, functor=None):
     self.__policy = policy or ThrottleStreamPolicy(10)
     f = functor or piw.slowchange(utils.changify(self.__dump))
     self.__backend = piw.functor_backend(1, False)
     self.__backend.set_gfunctor(utils.make_change_nb(f))
     self.__correlator = piw.correlator(cdomain, chr(1), piw.null_filter(),
                                        self.__backend.cookie(), 0, 0)
Exemplo n.º 3
0
    def make_filter(self, stream, slot):
        if logic.is_pred_arity(stream, 'conn', 4, 4):
            if stream.args[0] is not None:
                using = int(stream.args[0])
            else:
                using = 0

            if self.__auto_slot:
                using = using | (slot << 8)

            if stream.args[1] is not None:
                tgt = int(stream.args[1])
            else:
                tgt = 0

            id = stream.args[2]
            path = stream.args[3]

            if path is not None:
                return (id, piw.signal_dsc_filter(using, tgt, path))
            else:
                return (id, piw.signal_cnc_filter(using, tgt))

        print 'cop out of', stream
        return ('', piw.null_filter())
Exemplo n.º 4
0
 def destroy_plumber(self, term, plumber):
     if term and not self.closed():
         self.__input.correlator.plumb_input(
             self.__signal, 1, piw.pathnull(0), -1,
             False, self.__static_data,
             self.__stream_policy.create_converter(False),
             piw.null_filter())
Exemplo n.º 5
0
 def __init__(self,
              cookie,
              clock_domain,
              signals=(),
              filter=None,
              threshold=0,
              poly=0):
     BundleInput.__init__(self, cookie, clock_domain, filter
                          or piw.null_filter(), signals, threshold, poly)
Exemplo n.º 6
0
 def make_ctl_filter(self, stream, slot):
     if logic.is_pred_arity(stream, 'ctl', 2, 2):
         id = stream.args[0]
         path = stream.args[1]
         if path is not None:
             return (id, piw.signal_dsc_filter(slot, 0, path))
         else:
             return (id, piw.signal_cnc_filter(slot, 0))
     print 'cop out of', stream
     return ('', piw.null_filter())
Exemplo n.º 7
0
 def __init__(self, name, address, abs, wav):
     self.__cdomain = piw.clockdomain_ctl()
     self.__backend = piw.capture_backend(name, 1, abs, wav)
     self.__correlator = piw.correlator(self.__cdomain, chr(1),
                                        piw.null_filter(),
                                        self.__backend.cookie(), 0, 0)
     self.__filter = piw.signal_cnc_filter(0, 0)
     self.__plumber = policy.Plumber(self.__correlator, 1, 1, -1,
                                     policy.Plumber.input_input,
                                     policy.AnisoStreamPolicy(), address,
                                     self.__filter, False, self.__connected)
Exemplo n.º 8
0
    def get_data_backend(self, config):
        if self.__backend is None:
            self.__backend = piw.functor_backend(1, True)
            self.__backend.set_gfunctor(utils.make_change_nb(self.__handler))
            self.__correlator = piw.correlator(self.__clock_domain, chr(1),
                                               piw.null_filter(),
                                               self.__backend.cookie(), 0, 0)

        if config.clocked:
            self.__set_clock(self.__backend.get_clock())

        return PlumberBackend(self.__correlator, self.__stream_policy, 1,
                              Plumber.input_input, -1, config.iid)
Exemplo n.º 9
0
 def __init__(self, atom, data_domain, init, transient, input, signal,
              stream_policy, clocked, callback):
     self.__stream_policy = stream_policy
     self.__input = input
     self.__signal = signal
     self.__static_data = FastSender()
     self.__callback = callback
     policy.ConnectablePolicyImpl.__init__(self, atom, data_domain, init,
                                           clocked,
                                           node.Server(transient=transient),
                                           False)
     self.data_node().set_change_handler(self.__change)
     self.__input.correlator.plumb_input(
         self.__signal, 1, piw.pathnull(0), -1, False, self.__static_data,
         self.__stream_policy.create_converter(False), piw.null_filter())
Exemplo n.º 10
0
    def make_filter(self, stream, slot):
        if logic.is_pred_arity(stream, 'conn', 5, 5):
            if stream.args[0] is not None:
                using = int(stream.args[0])
            else:
                using = 0

            if stream.args[1] is not None:
                tgt = int(stream.args[1])
            else:
                tgt = 0

            id = paths.to_absolute(stream.args[2], self.__scope)
            path = stream.args[3]

            ctl = True if stream.args[4] == 'ctl' else False

            if path is not None:
                return (id, piw.signal_dsc_filter(using, tgt, path), ctl)
            else:
                return (id, piw.signal_cnc_filter(using, tgt), ctl)

        return ('', piw.null_filter(), False)
Exemplo n.º 11
0
 def destroy_plumber(self,plumber):
     if self.count_connections()==0:
         if not self.closed():
             self.__input.correlator.plumb_input(self.__signal,1,piw.pathnull(0),-1,False,self.__static_data,self.__stream_policy.create_converter(False),piw.null_filter())
         self.__ctrl = None
Exemplo n.º 12
0
 def __init__(self,atom,data_domain,init,transient,input,signal,stream_policy,clocked,callback,auto_slot):
     self.__stream_policy = stream_policy
     self.__input = input
     self.__signal = signal
     self.__callback = callback
     self.__ctrl = None
     self.__static_data = FastSender()
     policy.ConnectablePolicyImpl.__init__(self,atom,data_domain,init,clocked,node.Server(transient=transient),auto_slot)
     self.data_node().set_change_handler(self.__change)
     self.__input.correlator.plumb_input(self.__signal,255,piw.pathnull(0),10,policy.Plumber.input_merge,self.__static_data,self.__stream_policy.create_converter(False),piw.null_filter())
Exemplo n.º 13
0
    def __init__(self, address, ordinal):
        self.domain = piw.clockdomain_ctl()
        self.domain.set_source(piw.makestring('*', 0))

        agent.Agent.__init__(self,
                             signature=version,
                             names='strummer',
                             protocols='',
                             ordinal=ordinal)

        self[1] = atom.Atom(names='outputs')
        self[1][1] = bundles.Output(1, False, names='key output')
        self[1][2] = bundles.Output(2, False, names='pressure output')
        self[1][3] = bundles.Output(3, False, names='roll output')
        self[1][4] = bundles.Output(4, False, names='yaw output')

        self.output = bundles.Splitter(self.domain, *self[1].values())
        self.strummer = strummer_native.cstrummer(self.output.cookie(),
                                                  self.domain)
        self.aggregator = piw.aggregator(self.strummer.cookie(), self.domain)
        self.strum_input = bundles.VectorInput(
            self.aggregator.get_filtered_output(1, piw.null_filter()),
            self.domain,
            signals=(
                1,
                2,
                3,
                4,
                5,
            ))
        self.data_input = bundles.VectorInput(
            self.aggregator.get_filtered_output(2, piw.null_filter()),
            self.domain,
            signals=(
                1,
                2,
                3,
                4,
            ))

        self[4] = atom.Atom(names='inputs')

        self[4][1] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                               policy=self.strum_input.vector_policy(1, False),
                               names='strum breath input',
                               protocols='nostage')
        self[4][2] = atom.Atom(domain=domain.Aniso(),
                               policy=self.strum_input.vector_policy(2, False),
                               names='strum key input',
                               protocols='nostage')
        self[4][3] = atom.Atom(domain=domain.BoundedFloat(0, 1),
                               policy=self.strum_input.merge_policy(3, False),
                               names='strum pressure input',
                               protocols='nostage')
        self[4][4] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                               policy=self.strum_input.merge_policy(4, False),
                               names='strum roll input',
                               protocols='nostage')
        self[4][5] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                               policy=self.strum_input.merge_policy(5, False),
                               names='strum yaw input',
                               protocols='nostage')

        self[4][6] = atom.Atom(domain=domain.Aniso(),
                               policy=self.data_input.vector_policy(1, False),
                               names='course key input',
                               protocols='nostage')
        self[4][7] = atom.Atom(domain=domain.BoundedFloat(0, 1),
                               policy=self.data_input.merge_policy(2, False),
                               names='course pressure input',
                               protocols='nostage')
        self[4][8] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                               policy=self.data_input.merge_policy(3, False),
                               names='course roll input',
                               protocols='nostage')
        self[4][9] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                               policy=self.data_input.merge_policy(4, False),
                               names='course yaw input',
                               protocols='nostage')

        self[2] = atom.Atom(names='controls')
        self[2][1] = atom.Atom(domain=domain.Bool(),
                               init=True,
                               names='enable',
                               policy=atom.default_policy(self.__enable))
        self[2][2] = atom.Atom(domain=domain.BoundedInt(0, 2000),
                               init=0,
                               names='trigger window',
                               policy=atom.default_policy(
                                   self.__set_trigger_window))
        self[2][3] = atom.Atom(domain=domain.BoundedFloat(0, 10),
                               init=0.0,
                               names='course pressure scale',
                               policy=atom.default_policy(
                                   self.__set_course_pressure_scale))
        self[2][4] = atom.Atom(domain=domain.BoundedFloat(0, 10),
                               init=1.0,
                               names='course roll scale',
                               policy=atom.default_policy(
                                   self.__set_course_roll_scale))
        self[2][5] = atom.Atom(domain=domain.BoundedFloat(0, 10),
                               init=1.0,
                               names='course yaw scale',
                               policy=atom.default_policy(
                                   self.__set_course_yaw_scale))
        self[2][6] = atom.Atom(domain=domain.BoundedFloat(0, 10),
                               init=1.0,
                               names='strum breath scale',
                               policy=atom.default_policy(
                                   self.__set_strum_breath_scale))
        self[2][7] = atom.Atom(domain=domain.BoundedFloat(0, 10),
                               init=1.0,
                               names='strum pressure scale',
                               policy=atom.default_policy(
                                   self.__set_strum_pressure_scale))
        self[2][8] = atom.Atom(domain=domain.BoundedFloat(0, 10),
                               init=0.0,
                               names='strum roll scale',
                               policy=atom.default_policy(
                                   self.__set_strum_roll_scale))
        self[2][9] = atom.Atom(domain=domain.BoundedFloat(0, 10),
                               init=0.0,
                               names='strum yaw scale',
                               policy=atom.default_policy(
                                   self.__set_strum_yaw_scale))
        self[2][10] = atom.Atom(domain=domain.Bool(),
                                init=True,
                                names='strum note end',
                                policy=atom.default_policy(
                                    self.__set_strum_note_end))
        self[2][11] = atom.Atom(domain=domain.Bool(),
                                init=False,
                                names='open course enable',
                                policy=atom.default_policy(
                                    self.__open_course_enable))
        self[2][12] = atom.Atom(domain=domain.BoundedFloat(0, 1),
                                init=0.0,
                                names='open course pressure default',
                                policy=atom.default_policy(
                                    self.__open_course_pressure_default))
        self[2][13] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                                init=0.0,
                                names='open course roll default',
                                policy=atom.default_policy(
                                    self.__open_course_roll_default))
        self[2][14] = atom.Atom(domain=domain.BoundedFloat(-1, 1),
                                init=0.0,
                                names='open course yaw default',
                                policy=atom.default_policy(
                                    self.__open_course_yaw_default))
        self[2][15] = atom.Atom(domain=domain.BoundedFloat(0, 1),
                                init=0.0,
                                names='strum roll pressure mix',
                                policy=atom.default_policy(
                                    self.__set_strum_roll_pressure_mix))
        self[2][16] = atom.Atom(domain=domain.BoundedFloat(0, 1),
                                init=0.0,
                                names='strum yaw pressure mix',
                                policy=atom.default_policy(
                                    self.__set_strum_yaw_pressure_mix))
        self[2][17] = atom.Atom(domain=domain.BoundedFloat(0, 1),
                                init=0.1,
                                names='course mute threshold',
                                policy=atom.default_policy(
                                    self.__set_course_mute_threshold))
        self[2][18] = atom.Atom(domain=domain.BoundedFloat(0, 1),
                                init=0.1,
                                names='strum mute threshold',
                                policy=atom.default_policy(
                                    self.__set_strum_mute_threshold))
        self[2][19] = atom.Atom(domain=domain.BoundedInt(0, 1000),
                                init=20,
                                names='course mute interval',
                                policy=atom.default_policy(
                                    self.__set_course_mute_interval))
        self[2][20] = atom.Atom(domain=domain.BoundedInt(0, 1000),
                                init=20,
                                names='strum mute interval',
                                policy=atom.default_policy(
                                    self.__set_strum_mute_interval))
        self[2][21] = atom.Atom(domain=domain.Bool(),
                                init=True,
                                names='polyphonic courses enable',
                                policy=atom.default_policy(
                                    self.__set_poly_courses_enable))
        self[2][22] = atom.Atom(domain=domain.Bool(),
                                init=True,
                                names='course mute enable',
                                policy=atom.default_policy(
                                    self.__set_course_mute_enable))
        self[2][23] = atom.Atom(domain=domain.Bool(),
                                init=True,
                                names='strum mute enable',
                                policy=atom.default_policy(
                                    self.__set_strum_mute_enable))
        self[2][24] = atom.Atom(domain=domain.BoundedFloat(0, 1),
                                init=0.6,
                                names='pulloff threshold',
                                policy=atom.default_policy(
                                    self.__set_pulloff_threshold))
        self[2][25] = atom.Atom(domain=domain.BoundedInt(0, 1000),
                                init=10,
                                names='pulloff interval',
                                policy=atom.default_policy(
                                    self.__set_pulloff_interval))
        self[2][26] = atom.Atom(domain=domain.Bool(),
                                init=True,
                                names='pulloff enable',
                                policy=atom.default_policy(
                                    self.__set_pulloff_enable))

        self[3] = atom.Atom(domain=domain.String(),
                            init='[]',
                            names='courses',
                            policy=atom.default_policy(self.__set_courses),
                            protocols='course_editor')

        self.add_verb2(
            1,
            'set([],~a,role(None,[matches([breath,modulation])]),role(for,[mass([course])]))',
            callback=self.__set_breath_modulation)
        self.add_verb2(
            2,
            'set([un],~a,role(None,[matches([breath,modulation])]),role(for,[mass([course])]))',
            callback=self.__unset_breath_modulation)
        self.add_verb2(
            3,
            'set([],~a,role(None,[matches([open])]),role(as,[mass([key])]),role(for,[mass([course])]))',
            callback=self.__set_open_course_key)
        self.add_verb2(
            4,
            'set([],~a,role(None,[matches([open])]),role(as,[coord(physical,[column],[row])]),role(for,[mass([course])]))',
            callback=self.__set_open_course_physical)
        self.add_verb2(
            5,
            'add([],~a,role(None,[matches([strum,key])]),role(with,[coord(physical,[column],[row])]),role(for,[mass([course])]))',
            callback=self.__add_strum_key)
        self.add_verb2(
            6,
            'clear([],~a,role(None,[matches([all,strum,key])]),role(for,[mass([course])]))',
            callback=self.__clear_strum_key)

        self.strumconfig = strummer_native.strumconfig()