[snip of handy summary] > http://www.kamaelia.org/MiniAxon > > It takes you through how to build a really simple Axon/Kamaelia system of > your own - thereby showing you what is actually going on. > Thank you! > > When a system written using Kamaelia wants to, for example, connect, as a > client, to a TCP port on a server; then we write a component that knows > how to send and receive data on sockets. We write it such that any data it > receives on its inbox will get sent across the TCP socket connection; and > any data it receives will get sent out of its outbox. It just so happens > we've already written one of those - Kamaelia.Internet.TCPClient > > Similarly for a server, we write the logic of a server as a component (or > collection of components). In this case > Kamaelia.Chassis.ConnectedServer.ServerCore > I get it now. The encapsulated, reusable "thing" I should be writing is almost always a component. And your use of the word "protocol" in this context is the correct English usage, but not the geek interpretation of the word "protocol": the language spoken directly to a driver/filter. I get it, finally! :) Woo! > >> Let's say I need to interface directly with a device, say a serial port >> for example. How do I properly encapsulate this in Kamaelia? Where does >> the driver code get "registered"? >> > > You would write some python code that can send and receive data from a > serial port. You would then make that code into a Kamaelia component, such > that data it receives from the serial port gets sent out of its "outbox" > outbox; and anything that it receives on its "inbox" inbox should get sent > to the serial port. > > The component that does this doesn't need to be registered anywhere. > > When we talk about "protocols" in Kamaelia - we're talking in the most > abstract sense - a protocol being a behaviour: when we receive X and our > state is Y we send out Z in reply. Your chat protocol you were looking at > before was like this - it doesn't know where the data goes to or comes > from, or how. > > The point at which we make that decision (TCP, UDP, serial port, etc) is > when we then come to use that component. Want to make it a protocol used > to handle clients who connect via TCP? We create an instance of > ServerCore, using your chat protocol component as the 'protocol' for it: > > ServerCore(protocol=ChatProtocol, port=1501).run() > > or: > class ChatProtocolServer(ServerCore): > protocol=ChatProtocol > > ChatProtocolServer(port=1501).run() > > Want to make a single instance that talks over the serial port? We'd wire > it up to the inboxes and outboxes of our hypothetical serial port handling > component: > > class SerialPortTransciever(component): > .... > > Graphline( > CHAT = ChatProtocol(), > TXRX = SerialPortTransciever(), > linkages = { > ("CHAT", "oubox") : ("TXRX", "inbox"), > ("TXRX", "oubox") : ("CHAT", "inbox"), > } > ).run() > > This is cool. I understand why you chose a Graphline. This is great. > >> Sorry if my questions are fuzzy. I am trying to stop thinking in twistd, >> where I had to do some very raw protocol handling in various spots of my >> interface. >> Because of my development history, I am so used to dealing with protocol >> directly that it took me a while to do this paradigm shift. >> > > Its no problem. It is a rather different way to write code to what many > people are used to. I'm really glad you've stuck with it and kept asking > questions - rather than never asking anything and moving onto something > else! > Thanks for taking the time and energy to answer my questions. Not many Open Source online groups have members which will take the time to answer these questions without RTFM-ing a person. I greatly appreciate this.
Gloria --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "kamaelia" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/kamaelia?hl=en -~----------~----~----~----~------~----~------~--~---
