Example #1
0
def EventServerClients(rhost, rport, backplane="WHITEBOARD"):
        # plug a TCPClient into the backplae
        from Kamaelia.Internet.TCPClient import TCPClient

        loadingmsg = "Fetching sketch from server..."

        return pipeline( subscribeTo(backplane),
                         TagAndFilterWrapper(
                         Graphline( GETIMG = OneShot(msg=[["GETIMG"]]),
                                    PIPE = pipeline(
                                            tokenlists_to_lines(),
                                            TCPClient(host=rhost,port=rport),
                                            chunks_to_lines(),
                                            lines_to_tokenlists(),
                                        ),
                                    BLACKOUT = OneShot(msg=[["CLEAR",0,0,0],["WRITE",100,100,24,255,255,255,loadingmsg]]),
                                    linkages = { ("self","inbox") : ("PIPE","inbox"),
                                                 ("self","control") : ("PIPE","control"),
                                                 ("PIPE","outbox") : ("self","outbox"),
                                                 ("PIPE","signal") : ("self","signal"),
                                                 ("GETIMG","outbox") : ("PIPE","inbox"),
                                                 ("BLACKOUT","outbox") : ("self","outbox"),
                                               },
                                  )
                         ),
                         publishTo(backplane),
                       ) #.activate()
Example #2
0
def FilterAndTagWrapper(target, dontRemoveTag=False):
    """\
    Returns a component that wraps a target component, tagging all traffic
    going into its inbox; and filtering outany traffic coming out of its outbox
    with the same unique id.
    """
    if dontRemoveTag:
        Filter = FilterButKeepTag
    else:
        Filter = FilterTag

    return Graphline( TAGGER = UidTagger(),
                      FILTER = Filter(),
                      TARGET = target,
                      linkages = {
                          ("TARGET", "outbox") : ("FILTER", "inbox"),    # filter data coming from target
                          ("FILTER", "outbox") : ("self", "outbox"),

                          ("TAGGER", "uid")    : ("FILTER", "uid"),      # ensure filter uses right uid

                          ("self", "inbox")    : ("TAGGER", "inbox"),    # tag data going to target
                          ("TAGGER", "outbox") : ("TARGET", "inbox"),

                          ("self", "control")  : ("TARGET", "control"),  # shutdown signalling path
                          ("TARGET", "signal") : ("TAGGER", "control"),
                          ("TAGGER", "signal") : ("FILTER", "control"),
                          ("FILTER", "signal") : ("self", "signal"),
                      },
                    )
Example #3
0
def JoinChooserToCarousel(chooser, carousel):  # CHASSIS
    """Combines a Chooser with a Carousel
           chooser = A Chooser component, or any with similar behaviour and interfaces.
           carousel = A Carousel component, or any with similar behaviour and interfaces.
       This component encapsulates and connects together a Chooser and a Carousel component.
       
       The chooser must have an inbox that accepts 'next' style commands, and an outbox for outputting
       the next file information.
       
       The carousel must have a 'next' inbox for receiving next file info, and a 'requestNext'
       outbox for outputting 'next' style messages.
    """

    return Graphline(CHOOSER = chooser,
                     CAROUSEL = carousel,
                     linkages = { 
                         ("CHOOSER", "outbox")        : ("CAROUSEL", "next"),
                         ("CHOOSER", "signal")        : ("CAROUSEL", "control"),
                         ("self", "inbox")            : ("CAROUSEL", "inbox"),
                         ("self", "control")          : ("CHOOSER", "control"),
                         ("CAROUSEL", "requestNext") : ("CHOOSER", "inbox"),
                         ("CAROUSEL", "outbox")      : ("self", "outbox"),
                         ("CAROUSEL", "signal")      : ("self", "signal")
                     }
    )
Example #4
0
def buildPalette(cols, order, topleft=(0,0), size=32):
    buttons = {}
    links = {}
    pos = topleft
    i=0
    # Interesting/neat trick MPS
    for col in order:
        buttons[col] = Button(caption="", position=pos, size=(size,size), bgcolour=cols[col], msg=cols[col])
        links[ (col,"outbox") ] = ("self","outbox")
        pos = (pos[0] + size, pos[1])
        i=i+1
    return Graphline( linkages = links,  **buttons )
Example #5
0
def main(*args): 
    Graphline(
        PALETTE = Palette("Palette","Brush"),
        CONSOLE = ConsoleReader(">>> "),
        LINESTOKENS = lines_to_tokenlists(),
        PAINT = Painter(),
        linkages = {
            ("CONSOLE", "outbox"): ("LINESTOKENS","inbox"),
            ("LINESTOKENS", "outbox"): ("PAINT","inbox"),
            ("PALETTE", "outbox"): ("LINESTOKENS","inbox"),
            ("PAINT", "colour") : ("PALETTE", "colourchange"),
        }
    ).run()
Example #6
0
def RateControlledReadFileAdapter(filename, readmode = "bytes", **rateargs):
    """ReadFileAdapter combined with a RateControl component
       Returns a component encapsulating a RateControl and ReadFileAdapter components.
            filename   = filename
            readmode   = "bytes" or "lines"
            **rateargs = named arguments to be passed to RateControl
        """
    return Graphline(RC  = RateControl(**rateargs),
                     RFA = ReadFileAdapter(filename, readmode),
                     linkages = { ("RC",  "outbox")  : ("RFA", "inbox"),
                                  ("RFA", "outbox")  : ("self", "outbox"),
                                  ("RFA", "signal")  : ("RC",  "control"),
                                  ("RC",  "signal")  : ("self", "signal"),
                                  ("self", "control") : ("RFA", "control")
                                }
    )
Example #7
0
def FixedRate_ReadFileAdapter_Carousel(readmode = "bytes", **rateargs):
    """A file reading carousel, that reads at a fixed rate.
       Takes filenames on its inbox
    """
    return Graphline(RC       = RateControl(**rateargs),
                     CAR      = ReusableFileReader(readmode),
                     linkages = { 
                         ("self", "inbox")      : ("CAR", "next"),
                         ("self", "control")    : ("RC", "control"),
                         ("RC", "outbox")       : ("CAR", "inbox"),
                         ("RC", "signal")       : ("CAR", "control"),
                         ("CAR", "outbox")      : ("self", "outbox"),
                         ("CAR", "signal")      : ("self", "signal"),
                         ("CAR", "requestNext") : ("self", "requestNext"),
                         ("self", "next")       : ("CAR", "next")
                     }
    
    )
Example #8
0
    def main(self):
        import random
        port = self.port

        host = self.host

        #      client = TCPClient(host,port)
        #      clientProtocol = self.IRC_Handler(self.nick, self.nickinfo, self.defaultChannel)

        subsystem = Graphline(SELF=self,
                              CLIENT=TCPClient(host, port),
                              PROTO=self.IRC_Handler(self.nick, self.nickinfo,
                                                     self.defaultChannel),
                              linkages={
                                  ("CLIENT", ""): ("CLIENT", ""),
                                  ("CLIENT", ""): ("PROTO", ""),
                                  ("PROTO", ""): ("CLIENT", ""),
                                  ("PROTO", ""): ("PROTO", ""),
                                  ("CLIENT", "outbox"): ("PROTO", "inbox"),
                                  ("PROTO", "outbox"): ("CLIENT", "inbox"),
                                  ("PROTO", "heard"): ("SELF", "outbox"),
                                  ("SELF", "inbox"): ("PROTO", "talk"),
                                  ("SELF", "topic"): ("PROTO", "topic"),
                                  ("SELF", "control"): ("PROTO", "control"),
                                  ("PROTO", "signal"): ("CLIENT", "control"),
                                  ("CLIENT", "signal"): ("SELF", "signal"),
                              })

        #      self.link((client,"outbox"), (clientProtocol,"inbox"))
        #      self.link((clientProtocol,"outbox"), (client,"inbox"))
        #
        #      self.link((clientProtocol, "heard"), (self, "outbox"), passthrough=2)
        #      self.link((self, "inbox"), (clientProtocol, "talk"), passthrough=1)
        #      self.link((self, "topic"), (clientProtocol, "topic"), passthrough=1)
        #
        #      self.link((self, "control"), (clientProtocol, "control"), passthrough=1)
        #      self.link((clientProtocol, "signal"), (client, "control"))
        #      self.link((client, "signal"), (self, "signal"), passthrough=2)
        #
        self.addChildren(subsystem)
        yield _Axon.Ipc.newComponent(*(self.children))
        while 1:
            self.pause()
            yield 1
Example #9
0
        ConsoleEchoer(),
    ).activate()
    Graphline(
        streamin=pipeline(
            IcecastClient("http://127.0.0.1:1234/"),  # a stream's address
            IcecastDemux(),
            IcecastStreamRemoveMetadata(),
            Chunkifier(500000),
            ChunkDistributor("./"),
            WholeFileWriter(),
            TorrentMaker("http://192.168.1.5:6969/announce"),
        ),
        split=fanout(["toMetaUploader", "toSharer"]),
        fileupload=pipeline(ChunkDistributor("./torrents/", ".torrent"),
                            WholeFileWriter(),
                            PureTransformer(lambda x: x + "\n"),
                            SimpleFileWriter("filelist.txt")),

        #WholeFileWriter()
        #HTTPMakePostRequest("http://192.168.1.15/torrentupload.php"),
        #SimpleHTTPClient()

        # uploader still to write
        bt=TorrentPatron(),
        linkages={
            ("streamin", "outbox"): ("split", "inbox"),
            ("split", "toMetaUploader"): ("fileupload", "inbox"),
            ("split", "toSharer"): ("bt", "inbox"),
            #("split","toMetaUploader") : ("whatever","inbox"),
        }).run()
Example #10
0
            r = 1.00
            f = 0.01
            while 1:
                yield 1
                if r > 1.0: f -= 0.001
                else: f += 0.001
                r += f

                self.send(Control3D(Control3D.SCALING, Vector(r, r, r)),
                          "outbox")

    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from Kamaelia.Util.Graphline import Graphline

    Graphline(
        PLANE=TexPlane(pos=Vector(0, 0, -6),
                       tex="Kamaelia.png",
                       name="1st Tex Plane"),
        ROTATOR=CubeRotator(),
        #        MOVER = CubeMover(),
        #        BUZZER = CubeBuzzer(),
        ECHO=consoleEchoer(),
        linkages={
            ("PLANE", "outbox"): ("ECHO", "inbox"),
            #            ("ROTATOR", "outbox") : ("PLANE", "control3d"),
            #            ("MOVER", "outbox") : ("PLANE", "control3d"),
            #            ("BUZZER", "outbox") : ("CUBER", "control3d"),
        }).run()

    Axon.Scheduler.scheduler.run.runThreads()
Example #11
0
    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.File.Writing import SimpleFileWriter
    from Kamaelia.ReadFileAdaptor import ReadFileAdaptor
    from Kamaelia.Util.Graphline import Graphline
    from Kamaelia.Util.Console import ConsoleEchoer

    Graphline(
        #        SOURCE=ReadFileAdaptor("/home/matteh/eit.ts"),
        SOURCE=DVB_Multiplex(505833330.0 / 1000000.0, [18, 20]),
        DEMUX=DVB_Demuxer({
            "18": "_EIT_",
            "20": "_DATETIME_"
        }),
        EIT=pipeline(
            PSIPacketReconstructor(),
            EITPacketParser(),
            NowNextServiceFilter(4164, 4228),  # BBC ONE & BBC TWO
            NowNextChanges(),
            ConsoleEchoer(),
        ),
        DATETIME=pipeline(
            PSIPacketReconstructor(),
            TimeAndDatePacketParser(),
            ConsoleEchoer(),
        ),
        linkages={
            ("SOURCE", "outbox"): ("DEMUX", "inbox"),
            ("DEMUX", "_EIT_"): ("EIT", "inbox"),
            ("DEMUX", "_DATETIME_"): ("DATETIME", "inbox"),
        }).run()
Example #12
0
    Graphline(CUBE=SimpleCube(pos=Vector(3, 3, -15)),
              PLANE=TexPlane(pos=Vector(-3, 0, -10),
                             tex="Kamaelia.png",
                             name="1st Tex Plane"),
              BUTTON1=Button(caption="Press SPACE or click", key=K_SPACE),
              BUTTON2=Button(caption="Reverse colours",
                             fgcolour=(255, 255, 255),
                             bgcolour=(0, 0, 0)),
              BUTTON3=Button(caption="Mary...",
                             msg="Mary had a little lamb",
                             position=(200, 100)),
              ROTATOR=CubeRotator(),
              MOVER=CubeMover(),
              BUZZER=CubeBuzzer(),
              ECHO=consoleEchoer(),
              TICKER=Ticker(position=(400, 300),
                            render_left=0,
                            render_right=350,
                            render_top=0,
                            render_bottom=257),
              TEXT=datasource(),
              linkages={
                  ("PLANE", "outbox"): ("ECHO", "inbox"),
                  ("ROTATOR", "outbox"): ("PLANE", "control3d"),
                  ("BUTTON1", "outbox"): ("ECHO", "inbox"),
                  ("BUTTON2", "outbox"): ("ECHO", "inbox"),
                  ("BUTTON3", "outbox"): ("TICKER", "inbox"),
                  ("TEXT", "outbox"): ("TICKER", "inbox"),
                  ("MOVER", "outbox"): ("CUBE", "control3d"),
              }).run()
Example #13
0
                        readmode="bitrate",
                        bitrate=datarate),
        TCPClient("127.0.0.1", musicport),
    ).activate()

if networkserve:
    audiencemix = SingleServer(port=mockserverport)
else:
    audiencemix = printer()  # SimpleFileWriter("bingle.raw")

if livecontrol:
    Graphline(CONTROL=SingleServer(port=controlport),
              TOKENISER=lines_to_tokenlists(),
              MIXER=MatrixMixer(),
              AUDIENCEMIX=audiencemix,
              linkages={
                  ("CONTROL", "outbox"): ("TOKENISER", "inbox"),
                  ("TOKENISER", "outbox"): ("MIXER", "mixcontrol"),
                  ("MIXER", "mixcontrolresponse"): ("CONTROL", "inbox"),
                  ("MIXER", "outbox"): ("AUDIENCEMIX", "inbox"),
              }).run()
else:
    Graphline(CONTROL=ConsoleReader("mixer desk >> "),
              CONTROL_=consoleEchoer(),
              TOKENISER=lines_to_tokenlists(),
              MIXER=MatrixMixer(),
              AUDIENCEMIX=audiencemix,
              linkages={
                  ("CONTROL", "outbox"): ("TOKENISER", "inbox"),
                  ("TOKENISER", "outbox"): ("MIXER", "mixcontrol"),
                  ("MIXER", "mixcontrolresponse"): ("CONTROL_", "inbox"),
                  ("MIXER", "outbox"): ("AUDIENCEMIX", "inbox"),
Example #14
0
                self.recv("linknode")
                if node is not None:
                    linkstart = node
                    linkmode = True


TVC = TopologyViewerComponent(position=(0, 0)).activate()
Graphline(NEW=Button(caption="New Component", msg="NEXT", position=(72, 8)),
          EDIT=Button(caption="Edit Component", msg="NEXT", position=(182, 8)),
          DEL=Button(caption="Delete Component", msg="NEXT",
                     position=(292, 8)),
          LINK=Button(caption="Make Link", msg="NEXT", position=(402, 8)),
          CONSOLEINPUT=pipeline(
              ConsoleReader(">>> "),
              chunks_to_lines(),
              lines_to_tokenlists(),
          ),
          EDITOR_LOGIC=EditorLogic(),
          DEBUG=ConsoleEchoer(),
          TVC=TVC,
          linkages={
              ("CONSOLEINPUT", "outbox"): ("TVC", "inbox"),
              ("NEW", "outbox"): ("EDITOR_LOGIC", "newnode"),
              ("EDIT", "outbox"): ("EDITOR_LOGIC", "editnode"),
              ("DEL", "outbox"): ("EDITOR_LOGIC", "delnode"),
              ("LINK", "outbox"): ("EDITOR_LOGIC", "linknode"),
              ("TVC", "outbox"): ("EDITOR_LOGIC", "itemselect"),
              ("EDITOR_LOGIC", "outbox"): ("DEBUG", "inbox"),
              ("EDITOR_LOGIC", "nodeevents"): ("TVC", "inbox"),
          }).run()
Example #15
0
            OneShot(msg=[["GETIMG"]]),
            tokenlists_to_lines(),
            TCPClient(host=rhost, port=rport),
            chunks_to_lines(),
            Timestamp(),
            IntersperseNewlines(),
            SimpleFileWriter(filename),
        ).run()

    elif mode == "play":
        print "Playing..."
        pipeline(
            Graphline(
                FILEREADER=PromptedFileReader(filename, "lines"),
                DETIMESTAMP=DeTimestamp(),
                linkages={
                    # data from file gets detimestamped and sent on
                    ("FILEREADER", "outbox"): ("DETIMESTAMP", "inbox"),
                    ("DETIMESTAMP", "outbox"): ("", "outbox"),

                    # detimestamper asks for more data to be read from file
                    ("DETIMESTAMP", "next"): ("FILEREADER", "inbox"),

                    # shutdown wiring
                    ("", "control"): ("FILEREADER", "control"),
                    ("FILEREADER", "signal"): ("DETIMESTAMP", "control"),
                    ("DETIMESTAMP", "signal"): ("", "signal"),
                }),
            TCPClient(host=rhost, port=rport),
        ).run()
            glVertex3f(-1.0, 1.0, -1.0)

            glColor3f(0.0, 1.0, 1.0)
            glVertex3f(1.0, 1.0, 1.0)
            glVertex3f(-1.0, 1.0, 1.0)
            glVertex3f(-1.0, 1.0, -1.0)
            glVertex3f(1.0, 1.0, -1.0)

            glColor3f(1.0, 1.0, 0.0)
            glVertex3f(1.0, -1.0, 1.0)
            glVertex3f(-1.0, -1.0, 1.0)
            glVertex3f(-1.0, -1.0, -1.0)
            glVertex3f(1.0, -1.0, -1.0)
            glEnd()

            glPopMatrix()
            glFlush()

            pygame.display.flip()


if __name__ == '__main__':
    from Kamaelia.Util.Graphline import Graphline
    pygame.init()
    Graphline(CUBE=rotatingCube(),
              CUBECONTROL=cubeController(),
              linkages={
                  ("CUBECONTROL", "rotate"): ("CUBE", "angle"),
                  ("CUBECONTROL", "translate"): ("CUBE", "position"),
              }).run()
Example #17
0
Graphline(
     EXIT = ExceptionRaiser("FORCED SYSTEM QUIT"),
     MOUSE = Multiclick(caption="", 
                        position=(0,0), 
                        transparent=True,
                        msgs = [ "", "NEXT", "FIRST", "PREV", "PREV","NEXT" ],
                        size=(1024,768)),
     KEYS = KeyEvent(outboxes = { "slidecontrol" : "Normal place for message",
                                  "shutdown" : "Place to send some shutdown messages",
                                  "trace" : "Place for trace messages to go",
                                },
                     key_events = {112: ("PREV", "slidecontrol"), 
                                   110: ("NEXT","slidecontrol"),
                                   113: ("QUIT", "shutdown"),
                                  }),
     SPLITTER = Splitter(outboxes = {"totimer" : "For sending copies of key events to the timer",
                                     "tochooser" : "This is the primary location for key events",
                                    }),
     TIMER = TimeRepeatMessage("NEXT",0.02),
     FILES = Chooser(items = files, loop=True),
     DISPLAY = Image(size=(1024,768), 
                     position=(0,0), 
                     maxpect=(1024,768) ),
     linkages = {
        ("TIMER", "outbox") : ("FILES", "inbox"),

        ("MOUSE", "outbox") : ("SPLITTER", "inbox"),
        ("KEYS", "slidecontrol") : ("SPLITTER", "inbox"),
        ("SPLITTER", "tochooser") : ("FILES", "inbox"),
        ("SPLITTER", "totimer") : ("TIMER", "reset"),

        ("KEYS", "shutdown") : ("EXIT", "inbox"),
        ("FILES", "outbox") : ("DISPLAY", "inbox"),
     }
).activate()
Example #18
0
Graphline(CONSOLEINPUT=pipeline(
    ConsoleReader(">>> "),
    chunks_to_lines(),
    lines_to_tokenlists(),
),
          DEBUG=ConsoleEchoer(forwarder=True),
          TVC=TVC,
          INTROSPECTOR=pipeline(Introspector(SANDBOX), chunks_to_lines(),
                                lines_to_tokenlists()),
          SANDBOX=SANDBOX,
          NEW=Button(caption="New Component", msg="NEXT", position=(8, 8)),
          CHANGE=Button(caption="Change Component",
                        msg="NEXT",
                        position=(128, 8)),
          DEL=Button(caption="Delete Component", msg="NEXT",
                     position=(256, 8)),
          LINK=Button(caption="Make Link", msg="NEXT", position=(402, 8)),
          UNLINK=Button(caption="Break Link", msg="NEXT", position=(480, 8)),
          GO=Button(caption="Activate!", msg="NEXT", position=(590, 8)),
          EDITOR_LOGIC=EditorLogic(),
          CED=ComponentEditor(classes),
          linkages={
              ("CONSOLEINPUT", "outbox"): ("SANDBOX", "inbox"),
              ("LINK", "outbox"): ("EDITOR_LOGIC", "linknode"),
              ("UNLINK", "outbox"): ("EDITOR_LOGIC", "unlinknode"),
              ("CHANGE", "outbox"): ("EDITOR_LOGIC", "changenode"),
              ("EDITOR_LOGIC", "componentedit"): ("CED", "inbox"),
              ("DEL", "outbox"): ("EDITOR_LOGIC", "delnode"),
              ("INTROSPECTOR", "outbox"): ("TVC", "inbox"),
              ("EDITOR_LOGIC", "outbox"): ("CED", "inbox"),
              ("CED", "topocontrol"): ("TVC", "inbox"),
              ("TVC", "outbox"): ("EDITOR_LOGIC", "inbox"),
              ("CED", "outbox"): ("SANDBOX", "inbox"),
              ("EDITOR_LOGIC", "commands"): ("SANDBOX", "inbox"),
              ("GO", "outbox"): ("EDITOR_LOGIC", "go"),
              ("NEW", "outbox"): ("EDITOR_LOGIC", "newnode"),
          }).run()
Example #19
0
        pipeline(
            DVB_Multiplex(
                754,
                [640, 641, 620, 621, 622, 610, 611, 612, 600, 601, 602, 12]),
            SimpleFileWriter("multiplex_new.data")).run()
    if 1:
        Graphline(SOURCE=ReadFileAdaptor("multiplex.data"),
                  DEMUX=DVB_Demuxer({
                      "640": "NEWS24",
                      "641": "NEWS24",
                      "600": "BBCONE",
                      "601": "BBCONE",
                      "610": "BBCTWO",
                      "611": "BBCTWO",
                      "620": "CBBC",
                      "621": "CBBC",
                  }),
                  NEWS24=SimpleFileWriter("news24.data"),
                  BBCONE=SimpleFileWriter("bbcone.data"),
                  BBCTWO=SimpleFileWriter("bbctwo.data"),
                  CBBC=SimpleFileWriter("cbbc.data"),
                  linkages={
                      ("SOURCE", "outbox"): ("DEMUX", "inbox"),
                      ("DEMUX", "NEWS24"): ("NEWS24", "inbox"),
                      ("DEMUX", "BBCONE"): ("BBCONE", "inbox"),
                      ("DEMUX", "BBCTWO"): ("BBCTWO", "inbox"),
                      ("DEMUX", "CBBC"): ("CBBC", "inbox"),
                  }).run()
#            if not self.outboxes.has_key(pidmap[pid]):
#                self.addOutbox(pidmap[pid])
Example #20
0
#
# (1) Kamaelia Contributors are listed in the AUTHORS file and at
#     http://www.kamaelia.org/AUTHORS - please extend this file,
#     not this notice.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -------------------------------------------------------------------------

from Kamaelia.Util.Graphline import Graphline
from Kamaelia.UI.OpenGL.SimpleCube import SimpleCube

Graphline(CUBEC=SimpleCube(position=(0, 0, -12),
                           rotation=(225, 45, 135),
                           size=(1, 1, 1)).activate(),
          CUBER=SimpleCube(position=(4, 0, -22), size=(2, 2, 2)).activate(),
          CUBEB=SimpleCube(position=(0, -4, -18),
                           rotation=(0, 180, 20),
                           size=(1, 3, 2)).activate(),
          linkages={}).run()
# Licensed to the BBC under a Contributor Agreement: THF
Example #21
0
                x += dx
                y += dy
                z += dz
                if abs(x) > 5: dx = -dx
                if abs(y) > 5: dy = -dy
                if abs(z + 20) > 10: dz = -dz
                print x, y, abs(x), abs(y)

    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from Kamaelia.Util.Graphline import Graphline

    Graphline(CUBEC=Object3D(pos=Vector(0, 0, -12), name="Center cube"),
              CUBET=Object3D(pos=Vector(0, 4, -20), name="Top cube"),
              CUBER=Object3D(pos=Vector(4, 0, -22), name="Right cube"),
              CUBEB=Object3D(pos=Vector(0, -4, -18), name="Bottom cube"),
              CUBEL=Object3D(pos=Vector(-4, 0, -15), name="Left cube"),
              ROTATOR=CubeRotator(),
              MOVER=CubeMover(),
              ECHO=consoleEchoer(),
              linkages={
                  ("CUBEC", "outbox"): ("ECHO", "inbox"),
                  ("CUBET", "outbox"): ("ECHO", "inbox"),
                  ("CUBER", "outbox"): ("ECHO", "inbox"),
                  ("CUBEB", "outbox"): ("ECHO", "inbox"),
                  ("CUBEL", "outbox"): ("ECHO", "inbox"),
                  ("ROTATOR", "outbox"): ("CUBEC", "3dcontrol"),
                  ("MOVER", "outbox"): ("CUBEC", "3dcontrol"),
              }).run()

    Axon.Scheduler.scheduler.run.runThreads()
Example #22
0
NonInteractiveDataTester = Graphline(
    SOURCE=pipeline(
        source(topology),
        LineSplit(),
        lines_to_tokenlists(),
    ),
    CONTROLLER=pipeline(
        source(commands),
        LineSplit(),
        lines_to_tokenlists(),
    ),
    EXPECTED=pipeline(
        source(dataRecorderExpected),
        LineSplit(),
        lines_to_tokenlists(),
    ),
    MUXER=muxTwo(),
    DR=dataRecorder(),
    DISPLAY=consoleEchoer(),
    TRACE=consoleEchoer(forwarder=True),
    RESULT=Comparator(),
    linkages={
        ("SOURCE", "outbox"): ("DR", "inbox"),
        ("CONTROLLER", "outbox"): ("DR", "control"),
        ("DR", "outbox"): ("MUXER", "primary"),
        ("EXPECTED", "outbox"): ("MUXER", "secondary"),
        ("MUXER", "outbox"): ("RESULT", "inbox"),
        ("RESULT", "outbox"): ("DISPLAY", "inbox"),
    })
Example #23
0
display position and a surface size.
"""
    run_simply = False
    if run_simply:
        Painter().run()
    else:
        from Kamaelia.Util.Graphline import Graphline
        from Kamaelia.Util.Console import ConsoleEchoer
        import Axon

        from pprint import saferepr

        class myfilter(Axon.Component.component):
            def mainBody(self):
                if not self.anyReady():
                    self.pause()
                    return 1
                while self.dataReady("inbox"):
                    self.send(saferepr(self.recv()) + "\n", "outbox")
                return 1

        Graphline(
            PAINTER=Painter(size=(800, 600), position=(100, 75)),
            FORMATTER=myfilter(),
            DEBUG=ConsoleEchoer(),
            linkages={
                ("PAINTER", "logging"): ("FORMATTER", "inbox"),
                ("FORMATTER", "outbox"): ("DEBUG", "inbox"),
            },
        ).run()
Example #24
0
def makeBasicSketcher(left=0,top=0,width=1024,height=768):
    return Graphline( CANVAS  = Canvas( position=(left,top+32),
                                        size=(width,height-32),
                                        displayExtra={ "transparency" : (255,255,255) },
                                      ),
                      PAINTER = Painter(),
                      PALETTE = buildPalette( cols=colours, order=colours_order, topleft=(left+64,top), size=32 ),
                      ERASER  = Button(caption="Eraser", size=(64,32), position=(left,top)),

                      PREV  = Button(caption="<<",
                                     size=(63,32), 
                                     position=(left+64+32*len(colours), top),
                                     msg='prev'),
                      NEXT  = Button(caption=">>",
                                     size=(63,32), 
                                     position=(left+(64*2)+32*len(colours), top),
                                     msg='next'),
                      CHECKPOINT  = Button(caption="checkpoint",
                                     size=(63,32),
                                     position=(left+(64*3)+32*len(colours), top),
                                     msg="checkpoint"),
                      CLEAR  = Button(caption="clear",
                                     size=(63,32),
                                     position=(left+(64*4)+32*len(colours), top),
                                     msg=[["clear"]]),
                      NEWPAGE  = Button(caption="new page",
                                     size=(63,32),
                                     position=(left+(64*5)+32*len(colours), top),
                                     msg="new"),

                      REMOTEPREV  = Button(caption="~~<<~~",
                                     size=(63,32), 
                                     position=(left+(64*6)+32*len(colours), top),
                                     msg=[['prev']]),
                      REMOTENEXT  = Button(caption="~~>>~~",
                                     size=(63,32), 
                                     position=(left+(64*7)+32*len(colours), top),
                                     msg=[['next']]),

                      PREFILTER = PreFilter(),

                      HISTORY = CheckpointSequencer(lambda X: [["LOAD", "Scribbles/slide.%d.png" % (X,)]],
                                                    lambda X: [["SAVE", "Scribbles//slide.%d.png" % (X,)]],
                                                    lambda X: [["CLEAR"]],
                                                    initial = 1,
                                                    highest = num_pages,
                                ),

                      SPLIT   = TwoWaySplitter(),
                      SPLIT2  = TwoWaySplitter(),
                      DEBUG   = ConsoleEchoer(),

                      linkages = {
                          ("CANVAS",  "eventsOut") : ("PAINTER", "inbox"),
                          ("PALETTE", "outbox")    : ("PAINTER", "colour"),
                          ("ERASER", "outbox")     : ("PAINTER", "erase"),

                          ("CLEAR","outbox")       : ("CANVAS", "inbox"),
                          ("NEWPAGE","outbox")     : ("HISTORY", "inbox"),

#                          ("REMOTEPREV","outbox")  : ("self", "outbox"),
#                          ("REMOTENEXT","outbox")  : ("self", "outbox"),
                          ("REMOTEPREV","outbox")  : ("SPLIT2", "inbox"),
                          ("REMOTENEXT","outbox")  : ("SPLIT2", "inbox"),

                          ("SPLIT2", "outbox")      : ("PREFILTER", "inbox"),
                          ("SPLIT2", "outbox2")     : ("self", "outbox"), # send to network


                          ("PREV","outbox")        : ("HISTORY", "inbox"),
                          ("NEXT","outbox")        : ("HISTORY", "inbox"),
                          ("CHECKPOINT","outbox")  : ("HISTORY", "inbox"),
                          ("HISTORY","outbox")     : ("CANVAS", "inbox"),

                          ("PAINTER", "outbox")    : ("SPLIT", "inbox"),
                          ("SPLIT", "outbox")      : ("CANVAS", "inbox"),
                          ("SPLIT", "outbox2")     : ("self", "outbox"), # send to network

                          ("self", "inbox")        : ("PREFILTER", "inbox"),
                          ("PREFILTER", "outbox")  : ("CANVAS", "inbox"),
                          ("PREFILTER", "history_event")  : ("HISTORY", "inbox"),
                          ("CANVAS", "outbox")     : ("self", "outbox"),

                          ("CANVAS","surfacechanged") : ("HISTORY", "inbox"),
                          },
                    )
Example #25
0
        ("SOURCE", "outbox") : ("DR", "inbox"),
        ("CONTROLLER", "outbox") : ("DR", "control"),
        ("DR", "outbox") : ("MUXER", "primary"),
        ("EXPECTED", "outbox") : ("MUXER", "secondary"),
        ("MUXER", "outbox") : ("RESULT", "inbox"),
        ("RESULT", "outbox") : ("DISPLAY", "inbox"),
    }
)

InteractiveTester = Graphline(
    SOURCE = pipeline( source(topology),
                   LineSplit(),
                   lines_to_tokenlists(),
             ),
    NEXT = Button(caption="Next", msg=["NEXT"], position=(72,8)),
    PREVIOUS = Button(caption="Previous", msg=["PREV"],position=(8,8)),
    DR = topologyRecorder(),
    TVC = TopologyViewerComponent(transparency = (255,255,255), showGrid = False, position=(0,0)),
    linkages = {
        ("SOURCE", "outbox") : ("DR", "inbox"),
        ("DR", "outbox") : ("TVC", "inbox"),
        ("NEXT", "outbox") : ("DR", "control"),
        ("PREVIOUS", "outbox") : ("DR", "control"),
    }
)

# NonInteractiveDataTester.run()
# NonInteractiveTopologyTester.run()
InteractiveTester.run()