KamaeliaNuts & Bolts | Components | Tools | Cookbook | Systems
wiki:( guest302925, Dev Console, Index, Recent, Edit )
Axon forms the core of Kamaelia. There are two possible introductions you may wish to follow:
It is highly recommend to do the former, and to read the latter :-). If you are pushed for time, reading the latter is recommended.
There is comprehensive reference documentation for Axon. This includes detailed explanations and simple examples and is useful both if you are writing components and also if you want to gain a deeper understanding of Axon.
This documentation is regularly automatically rebuilt from our latest code in the repository.
The following text is adapted from the README bundle that accompanies Axon's separate download...
Axon is the core of Kamaelia. The contents of this directory must be installed before the rest of Kamaelia can be used. It can also be used independently of Kamaelia.
The install procedure is python's usual dance:
python setup.py install
Documentation is held in two places: (until this section is complete)
Sample producer/consumber & wrapper component system:
/-- testComponent -----------------------------------------------\
| |
| +-- Producer ----+ +-- Consumer ----+ |
| | >outbox> --> >inbox> >outbox> --> >_input>|
| +----------------+ +----------------+ |
| |
\----------------------------------------------------------------/
The testComponent creates 2 subcomponents, creates the links in place, and takes the output from the consumer and links it to its own private/internal _input inbox. When it recieves a value from the consumer, it reports this fact and ceases operation.
(It's probably worth noting that an introspection system would be possible to write/nice to see that would be able to derive the above diagram from the running system)
Example code:
from Axon.Component import component
class Producer(component):
Inboxes={
"inbox" : "default inbox - not used by producer",
"control" : "default control inbox - we should really be looking for shutdown messages here",
}
Outboxes= {
"outbox" : "This is where we send our bulk data to",
"signal" : "We should probably be sending producerFinished messages here",
}
def __init__(self):
super(Producer, self).__init__()
def main(self):
i = 100
while(i):
i = i -1
self.send("hello", "outbox")
yield 1
class Consumer(component):
Inboxes={
"inbox" : "This is where we get messges to consume",
"control" : "default control inbox - we should really be looking for shutdown messages here",
}
Outboxes= {
"outbox" : "default outbox - unused",
"signal" : "It would be nice if we forwarded any shutdown message we recieved here",
}
def __init__(self):
super(Consumer, self).__init__()
self.count = 0
self.i = 30
def doSomething(self):
print self.name, "Woo",self.i
if self.dataReady("inbox"):
self.recv("inbox")
self.count = self.count +1
self.send(self.count, "outbox")
def main(self):
yield 1
while(self.i):
self.i = self.i -1
self.doSomething()
yield 1
class testComponent(component):
Inboxes=["_input"]
Outboxes=[]
def __init__(self):
super(testComponent, self).__init__()
self.producer = Producer().activate() # This is a change to the way we used to do things self.consumer = Consumer().activate() # This is a change to the way we used to do things
self.addChildren(self.producer, self.consumer)
self.link((self.producer, "outbox"), (self.consumer, "inbox"))
self.link((self.consumer,"outbox"), (self,"_input") )
def childComponents(self):
return [self.producer, self.consumer]
def mainBody(self):
while len(self.inboxes["_input"]) < 1:
yield 1
result = self.recv("_input")
print "Consumer finished with result:", result, "!"
p = testComponent()
p.run()
from Kamaelia.Chassis.Pipeline import Pipeline
Pipeline(
Producer(),
Consumer(),
).run()
Versions: current , 1 , 2 , 3 , 4 , 5 , 6 , 7
(C) 2005 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved,
This is an ongoing community based development site. As a result the
contents of this page is the opinions of the contributors of the pages
involved not the organisations involved. Specificially, this page
may contain personal views which are not the views of the BBC.