def clientconnector(whiteboardBackplane="WHITEBOARD", audioBackplane="AUDIO", port=1500): return Pipeline( chunks_to_lines(), lines_to_tokenlists(), Graphline( ROUTER=Router(((lambda T: T[0] == "SOUND"), "audio"), ((lambda T: T[0] != "SOUND"), "whiteboard")), WHITEBOARD=FilteringPubsubBackplane(whiteboardBackplane), AUDIO=Pipeline( SimpleDetupler(1), # remove 'SOUND' tag SpeexDecode(3), FilteringPubsubBackplane(audioBackplane, dontRemoveTag=True), RawAudioMixer(), SpeexEncode(3), Entuple(prefix=["SOUND"], postfix=[]), ), linkages={ # incoming messages go to a router ("", "inbox"): ("ROUTER", "inbox"), # distribute messages to appropriate destinations ("ROUTER", "audio"): ("AUDIO", "inbox"), ("ROUTER", "whiteboard"): ("WHITEBOARD", "inbox"), # aggregate all output ("AUDIO", "outbox"): ("", "outbox"), ("WHITEBOARD", "outbox"): ("", "outbox"), # shutdown routing, not sure if this will actually work, but hey! ("", "control"): ("ROUTER", "control"), ("ROUTER", "signal"): ("AUDIO", "control"), ("AUDIO", "signal"): ("WHITEBOARD", "control"), ("WHITEBOARD", "signal"): ("", "signal"), }, ), tokenlists_to_lines(), )
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()
def clientconnector(whiteboardBackplane="WHITEBOARD", audioBackplane="AUDIO", port=1500): return Pipeline( chunks_to_lines(), lines_to_tokenlists(), Graphline( ROUTER = Router( ((lambda T : T[0]=="SOUND"), "audio"), ((lambda T : T[0]!="SOUND"), "whiteboard"), ), WHITEBOARD = FilteringPubsubBackplane(whiteboardBackplane), AUDIO = Pipeline( SimpleDetupler(1), # remove 'SOUND' tag SpeexDecode(3), FilteringPubsubBackplane(audioBackplane, dontRemoveTag=True), RawAudioMixer(), SpeexEncode(3), Entuple(prefix=["SOUND"],postfix=[]), ), linkages = { # incoming messages go to a router ("", "inbox") : ("ROUTER", "inbox"), # distribute messages to appropriate destinations ("ROUTER", "audio") : ("AUDIO", "inbox"), ("ROUTER", "whiteboard") : ("WHITEBOARD", "inbox"), # aggregate all output ("AUDIO", "outbox") : ("", "outbox"), ("WHITEBOARD", "outbox") : ("", "outbox"), # shutdown routing, not sure if this will actually work, but hey! ("", "control") : ("ROUTER", "control"), ("ROUTER", "signal") : ("AUDIO", "control"), ("AUDIO", "signal") : ("WHITEBOARD", "control"), ("WHITEBOARD", "signal") : ("", "signal") }, ), tokenlists_to_lines(), )
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()
def clientconnector(): return Pipeline( chunks_to_lines(), lines_to_tokenlists(), FilterAndTagWrapper( Pipeline( publishTo(backplane), # well, should be to separate pipelines, this is lazier! subscribeTo(backplane), )), tokenlists_to_lines(), )
def clientconnector(): return pipeline( chunks_to_lines(), lines_to_tokenlists(), FilterAndTagWrapper( pipeline( publishTo(backplane), # well, should be to separate pipelines, this is lazier! subscribeTo(backplane), ) ), tokenlists_to_lines(), )
def clientconnector(): return Pipeline( chunks_to_lines(), lines_to_tokenlists(), Graphline( WHITEBOARD=FilterAndTagWrapper( Pipeline( publishTo(whiteboardBackplane), # well, should be to separate pipelines, this is lazier! subscribeTo(whiteboardBackplane), )), AUDIO=Pipeline( SimpleDetupler(1), # remove 'SOUND' tag SpeexDecode(3), FilterAndTagWrapperKeepingTag( Pipeline( publishTo(audioBackplane), # well, should be to separate pipelines, this is lazier! subscribeTo(audioBackplane), ), ), RawAudioMixer(), SpeexEncode(3), Entuple(prefix=["SOUND"], postfix=[]), ), ROUTER=Router( ((lambda tuple: tuple[0] == "SOUND"), "audio"), ((lambda tuple: tuple[0] != "SOUND"), "whiteboard"), ), linkages={ # incoming messages go to a router ("", "inbox"): ("ROUTER", "inbox"), # distribute messages to appropriate destinations ("ROUTER", "audio"): ("AUDIO", "inbox"), ("ROUTER", "whiteboard"): ("WHITEBOARD", "inbox"), # aggregate all output ("AUDIO", "outbox"): ("", "outbox"), ("WHITEBOARD", "outbox"): ("", "outbox"), # shutdown routing, not sure if this will actually work, but hey! ("", "control"): ("ROUTER", "control"), ("ROUTER", "signal"): ("AUDIO", "control"), ("AUDIO", "signal"): ("WHITEBOARD", "control"), ("WHITEBOARD", "signal"): ("", "signal") }, ), tokenlists_to_lines(), )
def clientconnector(): return Pipeline( chunks_to_lines(), lines_to_tokenlists(), Graphline( WHITEBOARD = FilterAndTagWrapper( Pipeline( publishTo(whiteboardBackplane), # well, should be to separate pipelines, this is lazier! subscribeTo(whiteboardBackplane), )), AUDIO = Pipeline( SimpleDetupler(1), # remove 'SOUND' tag SpeexDecode(3), FilterAndTagWrapperKeepingTag( Pipeline( publishTo(audioBackplane), # well, should be to separate pipelines, this is lazier! subscribeTo(audioBackplane), ), ), RawAudioMixer(), SpeexEncode(3), Entuple(prefix=["SOUND"],postfix=[]), ), ROUTER = Router( ((lambda tuple : tuple[0]=="SOUND"), "audio"), ((lambda tuple : tuple[0]!="SOUND"), "whiteboard"), ), linkages = { # incoming messages go to a router ("", "inbox") : ("ROUTER", "inbox"), # distribute messages to appropriate destinations ("ROUTER", "audio") : ("AUDIO", "inbox"), ("ROUTER", "whiteboard") : ("WHITEBOARD", "inbox"), # aggregate all output ("AUDIO", "outbox") : ("", "outbox"), ("WHITEBOARD", "outbox") : ("", "outbox"), # shutdown routing, not sure if this will actually work, but hey! ("", "control") : ("ROUTER", "control"), ("ROUTER", "signal") : ("AUDIO", "control"), ("AUDIO", "signal") : ("WHITEBOARD", "control"), ("WHITEBOARD", "signal") : ("", "signal") }, ), tokenlists_to_lines(), )
def TopologyViewerServer(serverPort = 1500, **dictArgs): """\ TopologyViewerServer([noServer][,serverPort],**args) -> new TopologyViewerServer component. Multiple-clients-at-a-time TCP socket Topology viewer server. Connect on the specified port and send topology change data for display by a TopologyViewer. Keyword arguments: - serverPort -- None, or port number to listen on (default=1500) - args -- all remaining keyword arguments passed onto TopologyViewer """ FastRestartServer(protocol=Users, port=serverPort).activate() # SimpleServer(protocol=Users, port=serverPort).activate() return Pipeline( SubscribeTo("NODEEVENTS"), chunks_to_lines(), lines_to_tokenlists(), TopologyViewer(**dictArgs), ConsoleEchoer() )
assert (mode == "play" or mode == "record") filename = sys.argv[2] rhost = sys.argv[3] rport = int(sys.argv[4]) except: sys.stderr.write( "Usage:\n ./WhiteboardClerk play|record filename host port\n\n") sys.exit(1) if mode == "record": print "Recording..." pipeline( 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"),
def EventServerClients(rhost, rport, whiteboardBackplane="WHITEBOARD", audioBackplane="AUDIO"): # plug a TCPClient into the backplae from Kamaelia.Internet.TCPClient import TCPClient from Kamaelia.Chassis.Carousel import Carousel loadingmsg = "Fetching sketch from server..." failuremsg = "FAILED: Couldn't connect to server:" failuremsg2 = str(rhost) + " on port " + str(rport) return Graphline( NETWORK=Graphline( PIPE=Pipeline( tokenlists_to_lines(), TCPClient(host=rhost, port=rport), chunks_to_lines(), lines_to_tokenlists(), ), SHUTDOWN=TriggeredOneShot(msg=shutdownMicroprocess()), linkages={ ("", "inbox"): ("PIPE", "inbox"), ("PIPE", "outbox"): ("", "outbox"), # shutdown stuff - TCPClient may have caused it, so need to # loop the shutdown message back round to the front of the pipe # as well as propagating it onwards ("", "control"): ("PIPE", "control"), ("PIPE", "signal"): ("SHUTDOWN", "inbox"), ("SHUTDOWN", "outbox"): ("PIPE", "control"), ("SHUTDOWN", "signal"): ("", "signal"), }), ROUTER=Router( ((lambda tuple: tuple[0] == "SOUND"), "audio"), ((lambda tuple: tuple[0] != "SOUND"), "whiteboard"), ), WHITEBOARD=FilterAndTagWrapper( Pipeline( publishTo(whiteboardBackplane), # subscribeTo(whiteboardBackplane), )), AUDIO=Pipeline( SimpleDetupler(1), # remove 'SOUND' tag SpeexDecode(3), FilterAndTagWrapperKeepingTag( Pipeline( publishTo(audioBackplane), # subscribeTo(audioBackplane), ), ), RawAudioMixer(), SpeexEncode(3), Entuple(prefix=["SOUND"], postfix=[]), ), GETIMG=OneShot(msg=[["GETIMG"]]), BLACKOUT=OneShot( msg=[["CLEAR", 0, 0, 0], ["WRITE", 100, 100, 24, 255, 255, 255, loadingmsg]]), FAILURE=TriggeredOneShot( msg=[["WRITE", 100, 200, 32, 255, 96, 96, failuremsg], ["WRITE", 100, 232, 24, 255, 160, 160, failuremsg2]]), linkages={ # incoming messages from network connection go to a router ("NETWORK", "outbox"): ("ROUTER", "inbox"), # distribute messages to appropriate destinations ("ROUTER", "audio"): ("AUDIO", "inbox"), ("ROUTER", "whiteboard"): ("WHITEBOARD", "inbox"), # aggregate all output, and send across the network connection ("AUDIO", "outbox"): ("NETWORK", "inbox"), ("WHITEBOARD", "outbox"): ("NETWORK", "inbox"), # initial messages sent to the server, and the local whiteboard ("GETIMG", "outbox"): ("NETWORK", "inbox"), ("BLACKOUT", "outbox"): ("WHITEBOARD", "inbox"), # shutdown routing, not sure if this will actually work, but hey! ("NETWORK", "signal"): ("FAILURE", "inbox"), ("FAILURE", "outbox"): ("WHITEBOARD", "inbox"), ("FAILURE", "signal"): ("ROUTER", "control"), ("ROUTER", "signal"): ("AUDIO", "control"), ("AUDIO", "signal"): ("WHITEBOARD", "control"), ("WHITEBOARD", "signal"): ("", "signal"), })
def text_to_token_lists(): return Pipeline( chunks_to_lines(), lines_to_tokenlists() )
if __name__=="__main__": from Kamaelia.Internet.TCPClient import TCPClient from Kamaelia.File.Reading import PromptedFileReader from Kamaelia.File.Writing import SimpleFileWriter from Kamaelia.Apps.Whiteboard.SingleShot import OneShot try: if "--help" in sys.argv: sys.stderr.write("Usage:\n ./WhiteboardRecorder.py filename host port\n\n") sys.exit(0) filename = sys.argv[1] rhost = sys.argv[2] rport = int(sys.argv[3]) except: sys.stderr.write("Usage:\n ./WhiteboardRecorder.py filename host port\n\n") sys.exit(1) print "Recording..." Pipeline( OneShot(msg=[["GETIMG"]]), tokenlists_to_lines(), TCPClient(host=rhost, port=rport), chunks_to_lines(), Timestamp(), IntersperseNewlines(), SimpleFileWriter(filename), ).run()
"outbox" : PPostbox.Outbox } from Kamaelia.UI.PygameDisplay import PygameDisplay pgd = PygameDisplay(width=800,height=600).activate() PygameDisplay.setDisplayService(pgd) TVC = TopologyViewerComponent(position=(0,48), laws = AxonLaws(), particleTypes=particleTypes) SANDBOX = Sandbox() 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 = {
def text_to_token_lists(): return Pipeline(chunks_to_lines(), lines_to_tokenlists())
def TextControlledTopologyViewer(**dictArgs): return Pipeline( chunks_to_lines(), lines_to_tokenlists(), TopologyViewer(**dictArgs), ConsoleEchoer() )
def EventServerClients(rhost, rport, whiteboardBackplane="WHITEBOARD", audioBackplane="AUDIO"): # plug a TCPClient into the backplae from Kamaelia.Internet.TCPClient import TCPClient from Kamaelia.Chassis.Carousel import Carousel loadingmsg = "Fetching sketch from server..." failuremsg = "FAILED: Couldn't connect to server:" failuremsg2 = str(rhost)+" on port "+str(rport) return Graphline( NETWORK = Graphline( PIPE = Pipeline( tokenlists_to_lines(), TCPClient(host=rhost,port=rport), chunks_to_lines(), lines_to_tokenlists(), ), SHUTDOWN = TriggeredOneShot(msg=shutdownMicroprocess()), linkages = { ("", "inbox") : ("PIPE", "inbox"), ("PIPE", "outbox") : ("", "outbox"), # shutdown stuff - TCPClient may have caused it, so need to # loop the shutdown message back round to the front of the pipe # as well as propagating it onwards ("", "control") : ("PIPE", "control"), ("PIPE", "signal") : ("SHUTDOWN", "inbox"), ("SHUTDOWN", "outbox") : ("PIPE", "control"), ("SHUTDOWN", "signal") : ("", "signal"), } ), ROUTER = Router( ((lambda tuple : tuple[0]=="SOUND"), "audio"), ((lambda tuple : tuple[0]!="SOUND"), "whiteboard"), ), WHITEBOARD = FilterAndTagWrapper( Pipeline( publishTo(whiteboardBackplane), # subscribeTo(whiteboardBackplane), ) ), AUDIO = Pipeline( SimpleDetupler(1), # remove 'SOUND' tag SpeexDecode(3), FilterAndTagWrapperKeepingTag( Pipeline( publishTo(audioBackplane), # subscribeTo(audioBackplane), ), ), RawAudioMixer(), SpeexEncode(3), Entuple(prefix=["SOUND"],postfix=[]), ), GETIMG = OneShot(msg=[["GETIMG"]]), BLACKOUT = OneShot(msg=[["CLEAR",0,0,0],["WRITE",100,100,24,255,255,255,loadingmsg]]), FAILURE = TriggeredOneShot(msg=[["WRITE", 100,200, 32, 255, 96, 96, failuremsg], ["WRITE", 100,232, 24, 255,160,160, failuremsg2]]), linkages = { # incoming messages from network connection go to a router ("NETWORK", "outbox") : ("ROUTER", "inbox"), # distribute messages to appropriate destinations ("ROUTER", "audio") : ("AUDIO", "inbox"), ("ROUTER", "whiteboard") : ("WHITEBOARD", "inbox"), # aggregate all output, and send across the network connection ("AUDIO", "outbox") : ("NETWORK", "inbox"), ("WHITEBOARD", "outbox") : ("NETWORK", "inbox"), # initial messages sent to the server, and the local whiteboard ("GETIMG", "outbox") : ("NETWORK", "inbox"), ("BLACKOUT", "outbox") : ("WHITEBOARD", "inbox"), # shutdown routing, not sure if this will actually work, but hey! ("NETWORK", "signal") : ("FAILURE", "inbox"), ("FAILURE", "outbox") : ("WHITEBOARD", "inbox"), ("FAILURE", "signal") : ("ROUTER", "control"), ("ROUTER", "signal") : ("AUDIO", "control"), ("AUDIO", "signal") : ("WHITEBOARD", "control"), ("WHITEBOARD", "signal") : ("", "signal"), } )
} from Kamaelia.UI.PygameDisplay import PygameDisplay pgd = PygameDisplay(width=800, height=600).activate() PygameDisplay.setDisplayService(pgd) TVC = TopologyViewerComponent(position=(0, 48), laws=AxonLaws(), particleTypes=particleTypes) SANDBOX = Sandbox() 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)),