Ejemplo n.º 1
0
    def setUp(self):
        self.src = component()
        self.dst = component()
        self.dst2 = TestComponent()
        self.controller = component()
        self.split = Splitter()
        self.runner = self.split.main()
        self.linkin = linkage(self.src, self.split)
        self.linkcont = linkage(self.controller,
                                self.split,
                                sinkbox="configuration")
        self.links = [self.linkin, self.linkcont]
        #      self.linkout1 = linkage(self.split,self.dst)
        #      self.linkout2 = linkage(self.split,self.dst2, sourcebox="out2")

        #
        # -- NEW STUFF ------
        #
        Axon.Scheduler.scheduler.run = Axon.Scheduler.scheduler()
        self.execute = Axon.Scheduler.scheduler.run.main()

        self.S = Splitter().activate()
        self.D = component().activate()
        self.D2 = TestComponent().activate()
        self.W = component().activate()
        self.W.link((self.W, "outbox"), (self.S, "configuration"))
Ejemplo n.º 2
0
 def setUp(self):
     self.testerA = component()
     self.testerB = component()
     self.Comparator = Comparator()
     self.Comparator.activate()
     self.pm = postman()
     #pipewidth = 1 implies 2 items in the linkage.  One in outbox and one in sourcebox.  Need to change this code if these semantics change.
     self.pm.registerlinkage(
         linkage(source=self.testerA,
                 sink=self.Comparator,
                 sourcebox="outbox",
                 sinkbox="inA"))
     self.pm.registerlinkage(
         linkage(source=self.testerB,
                 sink=self.Comparator,
                 sourcebox="outbox",
                 sinkbox="inB"))
     self.pm.registerlinkage(
         linkage(source=self.testerA,
                 sink=self.Comparator,
                 sourcebox="signal",
                 sinkbox="control"))
     self.pm.registerlinkage(
         linkage(source=self.Comparator,
                 sink=self.testerA,
                 sourcebox="outbox",
                 sinkbox="inbox"))
     self.pm.registerlinkage(
         linkage(source=self.Comparator,
                 sink=self.testerA,
                 sourcebox="signal",
                 sinkbox="control"))
Ejemplo n.º 3
0
 def setUp(self):
     self.tester = component()
     self.connector = testedclass()
     self.connector.activate()
     self.pm = postman()
     #pipewidth = 1 implies 2 items in the linkage.  One in outbox and one in sourcebox.  Need to change this code if these semantics change.
     self.pm.registerlinkage(linkage(source = self.tester, sink = self.connector, sourcebox = "outbox", sinkbox = "inbox"))
     self.pm.registerlinkage(linkage(source = self.tester, sink = self.connector, sourcebox = "signal", sinkbox = "control"))
     self.pm.registerlinkage(linkage(source = self.connector, sink = self.tester, sourcebox = "outbox", sinkbox = "inbox", pipewidth = 1))
Ejemplo n.º 4
0
 def link(self, source, sink, *optionalargs, **kwoptionalargs):
     """\
    link((component,boxname),(component,boxname),**otherargs) -> new linkage
    
    Creates a linkage from a named box on one component to a named box on
    another. See linkage class for meanings of other arguments. A linkage
    object is returned as a handle representing the linkage created.
    
    The linkage is registered with this postoffice.
    
    Throws Axon.AxonExceptions.BoxAlreadyLinkedToDestination if the source
    is already linked to somewhere else (Axon does not permit one-to-many).
    """
     (sourcecomp, sourcebox) = source
     (sinkcomp, sinkbox) = sink
     thelink = linkage(sourcecomp, sinkcomp, sourcebox, sinkbox,
                       *optionalargs, **kwoptionalargs)
     #       try:
     #           thelink.getSinkbox().addsource( thelink.getSourcebox() )
     #       except BoxAlreadyLinkedToDestination, e:
     #           raise e
     thelink.getSinkbox().addsource(thelink.getSourcebox(
     ))  # Cease  rethrowing messages from here - also python 2/3 fix
     self.linkages.append(thelink)
     return thelink
Ejemplo n.º 5
0
 def test_addSinkInboxes_passthrough(self):
     """mainBody - addsink->configurations - Adds a whole set of sinks and checks
   they all receive expected messages.  Complicated by setting the sink to
   passthrough and to be to an inbox."""
     boxes = 10
     boxlist = []
     for x in xrange(boxes):
         c = component()
         boxlist.append(c)
         self.links.append(
             linkage(source=c,
                     sourcebox="outbox",
                     sink=c,
                     sinkbox="control"))
         self.controller.send(addsink(c, "outbox", 2))
         self.deliverhelper()
         runrepeat(self.runner)
     for i in xrange(20):
         self.src.send(i)
         self.deliverhelper()
         runrepeat(self.runner)
         self.deliverhelper()
         self.deliverhelper()
         for comp in boxlist:
             self.failUnless(comp.dataReady("control"))
             self.failUnless(comp.recv("control") == i)
 def setUp(self):
     self.tester = component()
     self.trcomp = TestResult()
     self.trcomp.activate()
     self.pm = postman()
     self.pm.activate()
     self.tester.activate()
     #pipewidth = 1 implies 2 items in the linkage.  One in outbox and one in sourcebox.  Need to change this code if these semantics change.
     self.pm.registerlinkage(
         linkage(source=self.tester,
                 sink=self.trcomp,
                 sourcebox="outbox",
                 sinkbox="inbox"))
     self.pm.registerlinkage(
         linkage(source=self.tester,
                 sink=self.trcomp,
                 sourcebox="signal",
                 sinkbox="control"))
Ejemplo n.º 7
0
 def createsink(self, sink, sinkbox="inbox", passthrough=0):
    """\
    Set up a new destination for data.
    
    Creates an outbox, links it to the target (component,inbox) and records
    it in self.outlist.
    """
    name = self.addOutbox(sink.name + '-' + sinkbox)
    lnk = linkage(source = self, sourcebox = name, sink = sink, sinkbox = sinkbox, postoffice = self.postoffice, passthrough=passthrough)
    self.outlist[(sink,sinkbox)] = (name, lnk)
Ejemplo n.º 8
0
   def setUp(self):
      self.src = component()
      self.dst = component()
      self.dst2 = TestComponent()
      self.controller = component()
      self.split = Splitter()
      self.runner = self.split.main()
      self.linkin = linkage(self.src,self.split)
      self.linkcont = linkage(self.controller, self.split, sinkbox="configuration")
      self.links = [self.linkin, self.linkcont]
#      self.linkout1 = linkage(self.split,self.dst)
#      self.linkout2 = linkage(self.split,self.dst2, sourcebox="out2")

      #
      # -- NEW STUFF ------
      #
      Axon.Scheduler.scheduler.run = Axon.Scheduler.scheduler()
      self.execute = Axon.Scheduler.scheduler.run.main()

      self.S = Splitter().activate()
      self.D = component().activate()
      self.D2 = TestComponent().activate()
      self.W = component().activate()
      self.W.link( (self.W, "outbox"), (self.S, "configuration") )
Ejemplo n.º 9
0
 def createsink(self, sink, sinkbox="inbox", passthrough=0):
     """\
   Set up a new destination for data.
   
   Creates an outbox, links it to the target (component,inbox) and records
   it in self.outlist.
   """
     name = self.addOutbox(sink.name + '-' + sinkbox)
     lnk = linkage(source=self,
                   sourcebox=name,
                   sink=sink,
                   sinkbox=sinkbox,
                   postoffice=self.postoffice,
                   passthrough=passthrough)
     self.outlist[(sink, sinkbox)] = (name, lnk)
Ejemplo n.º 10
0
         def __init__(self):
            super(testComponent, self).__init__()

            self.lackofinterestingthingscount = 0
            self.total = 0

            self.producer, self.consumer =Producer(), Consumer()
            self.producer2, self.consumer2 = Producer(), Consumer()

            self.addChildren(self.producer, self.producer2, self.consumer, self.consumer2)

            self.link((self.producer, "result"), (self.consumer, "source"))
            linkage(self.producer2, self.consumer2, "result", "source", self.postoffice)
            linkage(self.consumer,self,"result","_output", self.postoffice)
            linkage(self.consumer2,self,"result","_output", self.postoffice)
Ejemplo n.º 11
0
 def test_addSinkInboxes_passthrough(self):
    """mainBody - addsink->configurations - Adds a whole set of sinks and checks
    they all receive expected messages.  Complicated by setting the sink to
    passthrough and to be to an inbox."""
    boxes = 10
    boxlist = []
    for x in xrange(boxes):
       c=component()
       boxlist.append(c)
       self.links.append(linkage(source=c, sourcebox="outbox", sink=c, sinkbox="control"))
       self.controller.send(addsink(c,"outbox",2))
       self.deliverhelper()
       runrepeat(self.runner)
    for i in xrange(20):
       self.src.send(i)
       self.deliverhelper()
       runrepeat(self.runner)
       self.deliverhelper()
       self.deliverhelper()
       for comp in boxlist:
          self.failUnless(comp.dataReady("control"))
          self.failUnless(comp.recv("control") == i)
Ejemplo n.º 12
0
   def link(self, source, sink, *optionalargs, **kwoptionalargs):
       """\
       link((component,boxname),(component,boxname),**otherargs) -> new linkage
       
       Creates a linkage from a named box on one component to a named box on
       another. See linkage class for meanings of other arguments. A linkage
       object is returned as a handle representing the linkage created.
       
       The linkage is registered with this postoffice.
       
       Throws Axon.AxonExceptions.BoxAlreadyLinkedToDestination if the source
       is already linked to somewhere else (Axon does not permit one-to-many).
       """
       (sourcecomp, sourcebox) = source
       (sinkcomp, sinkbox) = sink
       thelink = linkage(sourcecomp,sinkcomp,sourcebox,sinkbox,*optionalargs,**kwoptionalargs)
#       try:
#           thelink.getSinkbox().addsource( thelink.getSourcebox() )
#       except BoxAlreadyLinkedToDestination, e:
#           raise e
       thelink.getSinkbox().addsource( thelink.getSourcebox() ) # Cease  rethrowing messages from here - also python 2/3 fix
       self.linkages.append(thelink)
       return thelink
Ejemplo n.º 13
0
            def __init__(self):
                super(testComponent, self).__init__()

                self.lackofinterestingthingscount = 0
                self.total = 0

                self.producer, self.consumer = Producer(), Consumer()
                self.producer2, self.consumer2 = Producer(), Consumer()

                self.addChildren(self.producer, self.producer2, self.consumer,
                                 self.consumer2)

                self.link((self.producer, "result"), (self.consumer, "source"))
                linkage(self.producer2, self.consumer2, "result", "source",
                        self.postoffice)
                linkage(self.consumer, self, "result", "_output",
                        self.postoffice)
                linkage(self.consumer2, self, "result", "_output",
                        self.postoffice)