Exemple #1
0
    def test_Unplugging(self):
        """Plug will unplug and shutdown when child component dies."""
        Axon.Scheduler.scheduler.run = Axon.Scheduler.scheduler()

        splitter = Splitter()
        splitter.activate()

        target = DummyComponent()
        plug = Plug(splitter, target).activate()

        execute = Axon.Scheduler.scheduler.run.main()

        for i in xrange(1, 100):
            execute.next()

        #send shutdown msg
        msg = producerFinished()
        target._deliver(msg, "control")

        for i in xrange(1, 100):
            execute.next()

        # verify it reached the target
        self.assert_(target.controllog == [msg])

        # verify the plug has shutdown
        self.assert_(plug._isStopped())

        # verify the plug has no linkages
        self.assert_(not plug.postoffice.linkages)

        # verify that splitter only has outboxes "outbox" and "signal" now
        self.assert_(len(splitter.outboxes) == 2)
        self.assert_("outbox" in splitter.outboxes)
        self.assert_("signal" in splitter.outboxes)
Exemple #2
0
    def test_Unplugging(self):
        """Plug will unplug and shutdown when child component dies."""
        Axon.Scheduler.scheduler.run = Axon.Scheduler.scheduler()

        splitter = Splitter()
        splitter.activate()

        target = DummyComponent()
        plug = Plug(splitter, target).activate()

        execute = Axon.Scheduler.scheduler.run.main()

        for i in xrange(1,100):
            execute.next()

        #send shutdown msg
        msg = producerFinished()
        target._deliver(msg, "control")

        for i in xrange(1,100):
            execute.next()

        # verify it reached the target
        self.assert_(target.controllog == [msg])

        # verify the plug has shutdown
        self.assert_(plug._isStopped())

        # verify the plug has no linkages
        self.assert_(not plug.postoffice.linkages)

        # verify that splitter only has outboxes "outbox" and "signal" now
        self.assert_( len(splitter.outboxes) == 2)
        self.assert_( "outbox" in splitter.outboxes)
        self.assert_( "signal" in splitter.outboxes)
Exemple #3
0
 def subscribeToPlugsplitter(self, plugsplitter):
     forwarder = Forwarder()
     plug = Plug(plugsplitter, forwarder)
     plug.activate()
     outsideForwarder = Forwarder()
     plug.link((plug, 'outbox'), (outsideForwarder, 'secondary-inbox'))
     plug.link((plug, 'signal'), (outsideForwarder, 'secondary-control'))
     return outsideForwarder
Exemple #4
0
    def test_PluggingInAndTxfer(self):
        """Plug instantiated with splitter and component and passes data through to component."""
        Axon.Scheduler.scheduler.run = Axon.Scheduler.scheduler()

        splitter = Splitter()
        splitter.activate()

        target = DummyComponent()
        plug = Plug(splitter, target).activate()

        execute = Axon.Scheduler.scheduler.run.main()

        for i in xrange(1, 1000):
            execute.next()

        #pass some data in
        for i in xrange(1, 10):
            splitter._deliver(i, "inbox")
            splitter._deliver(10 + i, "control")
            for i in xrange(1, 100):
                execute.next()

        # verify it reached the target
        self.assert_(target.inboxlog == range(1, 10))
        self.assert_(target.controllog == range(11, 20))
Exemple #5
0
 def main(self):
     cat = CAT.getcat()
     splitter, configbox = cat.retrieveService("Backplane_O_" + self.source)
     Plug(splitter, self).activate()
     while 1:
         while self.dataReady("inbox"):
             d = self.recv("inbox")
             self.send(d, "outbox")
         yield 1
Exemple #6
0
 def subscribeToPlugsplitter(self,  plugsplitter):
     forwarder        = Forwarder()
     plug             = Plug(plugsplitter,  forwarder)
     plug.activate()
     outsideForwarder = Forwarder()
     plug.link((plug, 'outbox'), (outsideForwarder, 'secondary-inbox'))
     plug.link((plug, 'signal'), (outsideForwarder, 'secondary-control'))
     return outsideForwarder
Exemple #7
0
def Tee(*destinations):
    splitter = PlugSplitter()
    plugs = {}
    i = 1
    for dest in destinations:
        plugs[str(i)] = Plug(splitter, dest)
        i = i + 1

    return Graphline(splitter=splitter,
                     linkages={
                         ("", "inbox"): ("splitter", "inbox"),
                         ("", "control"): ("splitter", "control"),
                         ("splitter", "outbox"): ("", "outbox"),
                         ("splitter", "signal"): ("", "signal")
                     },
                     **plugs)
Exemple #8
0
 def main(self):
     """Main loop."""
     cat = CAT.getcat()
     splitter, configbox = cat.retrieveService("Backplane_O_" + self.source)
     p = PassThrough()
     plug = Plug(splitter, p)
     self.link((self, "control"), (plug, "control"), passthrough=1)
     self.link((plug, "outbox"), (self, "outbox"), passthrough=2)
     self.link((plug, "signal"), (self, "signal"), passthrough=2)
     self.addChildren(plug)
     yield newComponent(plug)
     # wait until all child component has terminated
     # FIXME: If we had a way of simply getting this to "exec" a new component in our place,
     # FIXME: then this while loop here would be irrelevent, which would be cool.
     # FIXME: especially if we could exec in such a way that passthrough linkages
     # FIXME: still operated as you'd expect.
     while not self.childrenDone():
         self.pause()
         yield 1
 def linkChildToInternalSplitter(self, child):
     forwarder = Forwarder()
     plug = Plug(self.internalSplitter,  forwarder)
     plug.activate()
     plug.link((plug, 'signal'), (child, 'control'))
     child.link((child, 'signal'), (plug, 'control'))
Exemple #10
0
 def linkChildToInternalSplitter(self, child):
     forwarder = Forwarder()
     plug = Plug(self.internalSplitter, forwarder)
     plug.activate()
     plug.link((plug, 'signal'), (child, 'control'))
     child.link((child, 'signal'), (plug, 'control'))
Exemple #11
0
if __name__ == "__main__":

    from Axon.Scheduler import scheduler

    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.Visualisation.PhysicsGraph.TopologyViewerComponent import TopologyViewerComponent

    from Kamaelia.Util.Splitter import PlugSplitter as Splitter
    from Kamaelia.Util.Splitter import Plug

    #    from Filters import FilterSelectMsgs, FilterTopologyMsgs
    from PipeBuild import PipeBuild
    from PipelineWriter import PipelineWriter
    from BuildViewer import BuildViewer
    from GUI import BuilderControlsGUI, TextOutputGUI

    items = list(getAllClasses(COMPONENTS))

    pipegen = Splitter(pipeline(BuilderControlsGUI(items), PipeBuild()))

    viewer = Splitter(BuildViewer())

    Plug(viewer, pipegen).activate()  # feedback loop for 'selected' msgs

    Plug(pipegen, viewer).activate()
    Plug(pipegen, pipeline(PipelineWriter(),
                           TextOutputGUI("Pipeline code"))).activate()

    scheduler.run.runThreads()
Exemple #12
0
 
 Pipeline(
     RateControlledFileReader(TS_FILE, readmode="bytes", rate=1000*1000, chunksize=188),
     DVB_SoftDemuxer( {0x12:["outbox"]} ),
     ReassemblePSITables(),
     ParseEventInformationTable_Subset( \
         actual_presentFollowing = True,
         other_presentFollowing = True,
         actual_schedule = True,
         other_schedule = True,
         ),
     splitter
 ).activate()
 
 Plug(splitter, Pipeline(
     PrettifyEventInformationTable(),
     SimpleFileWriter("original_eit_parsed.text"),
 )).activate()
 
 Plug(splitter, Pipeline(
     CreateEventInformationTable(),
     ParseEventInformationTable_Subset( \
         actual_presentFollowing = True,
         other_presentFollowing = True,
         actual_schedule = True,
         other_schedule = True,
         ),
     PrettifyEventInformationTable(),
     SimpleFileWriter("regenerated_eit_parsed.text"),
 )).run()
 
     
bitrateExtractor = BitRateExtractor()
decoder = AudioDecoder(extn)
output = SoundOutput()

wiringoption = 2

if wiringoption == 1:  #--------------------------------------------------------

    audiosplitter = Splitter()

    decodedAudioSource = pipeline(rateController, fileReader, decoder,
                                  audiosplitter)

    # here we break the encapsulation provided by pipeline
    # - by directly referencing 'audiosplitter'
    bitrateSource = Plug(audiosplitter, bitrateExtractor)

    mainpipe = pipeline(bitrateSource, decodedAudioSource, output).activate()

elif wiringoption == 2:  #------------------------------------------------------

    decodedAudioSource = Splitter(pipeline(rateController, fileReader,
                                           decoder))

    bitrateSource = Plug(decodedAudioSource, bitrateExtractor)

    mainpipe = pipeline(bitrateSource, decodedAudioSource, output).activate()

elif wiringoption == 3:  #------------------------------------------------------
    decodedAudioSource = Splitter(pipeline(rateController, fileReader,
                                           decoder))
Exemple #14
0
if 0:
	producer = Producer()
	mysplitter = PlugSplitter()
	pipe = Pipeline(producer, mysplitter)

	Plug(mysplitter, Consumer("consumerA") ).activate()
	Plug(mysplitter, Consumer("consumerB") ).activate()

	pipe.run()

if 1:
	mysplitter = PlugSplitter()
	pipe = Pipeline( Producer(), mysplitter )

	forwarder1  = Forwarder("forwarder")
	plug1       = Plug(mysplitter,forwarder1)
	plug1.activate()

	forwarder1b = Forwarder("forwarder1b")
	plug1.link((plug1,'outbox'),(forwarder1b,'secondary-inbox'))
	plug1.link((plug1,'signal'),(forwarder1b,'secondary-control'))
	consumer1   = Consumer("consumer1")
	Pipeline( 
			forwarder1b, 
			consumer1
	).activate()

	forwarder2 = Forwarder("forwarder2")
	plug2 = Plug(mysplitter, forwarder2)
	plug2.activate()
Exemple #15
0
                data = self.recv("secondary-control")
                print "From control in secondary-control: %s: %s" % (self.name,
                                                                     data)
                self.send(data, "signal")
                return

            if not self.anyReady():
                self.pause()
            yield 1


if 0:
    mysplitter = PlugSplitter(Producer())
    mysplitter.activate()

    Plug(mysplitter, Consumer("consumerA")).activate()
    Plug(mysplitter, Consumer("consumerB")).activate()

    mysplitter.run()

if 0:
    producer = Producer()
    mysplitter = PlugSplitter()
    pipe = Pipeline(producer, mysplitter)

    Plug(mysplitter, Consumer("consumerA")).activate()
    Plug(mysplitter, Consumer("consumerB")).activate()

    pipe.run()

if 1: