Examples
LighTS comes with a minimal number of examples that
are meant to test the correct functionality of the tuple space and the adapters. They are found under the directory
examples
of the
distribution (follow the links to see the source files):
We plan to add fancier examples as LighTS gets used for teaching and research purposes and, hopefully, as the base of users grows.
lime.util
and, at the same time, provides for a useful tool for debugging Lime
applications. The interactive agent just displays a graphical console that
can be used to perform operations on a Lime tuple space.
InteractiveAgent
:
java lime.LimeServer -tspaces -load InteractiveAgent
>java lime.LimeServer -tspaces -load InteractiveAgent Lime: TSServer activated. Lime: Lime server activated on port 1968 Lime: Listening for agents Lime: Agent InteractiveAgent loaded and started.After a short delay, the window with the console will appear. For details about how to use the console see this description. For details about how to use the Lime console from within your agents, please consult the API documentation of
lime.util.LimeConsole
.
InteractiveAgent
is really small:
public class InteractiveAgent extends Agent { protected LimeTupleSpace lts = null; protected LimeConsole c; public InteractiveAgent() { try { lts = new LimeTupleSpace(this); } catch (LimeException le) { le.printStackTrace(); } c = new LimeConsole(lts); } public void run() { while(true) c.performQueuedOp(); } }The constructor takes care of creating a Lime tuple space with the default name, and creating a Lime console that allows interaction with it. These two objects are stored in two
protected
fields, such that they can be
accessed by subclasses of InteractiveAgent
. The
run()
method of the agent is trivial, in that it continuously
picks the next operation in the queue maintained by the Lime console, and
requests its execution. Remember that the method performQueuedOp
blocks if the queue is empty, which simplifies the code for the agent.