Agent Transport

An agent's transport is its connection to the blackboard. As such the transport provides all of the actions that an agent can initiate with the blackboard. The function provided by the agent transport are described in the following sections.

connect(String)

This method attempts to connect to the blackboard using the given string as the agent's name. If successful the method will return the actual name used to identify the agent.

disconnect()

Disconnects the agent from the blackboard.

register(String)

Tells the blackboard that the agent is interested in all mobs of the given type.

unregister(String)

Tells the blackboard the agent is no longer interested in the given type.

getTypeManager()

Requests a type manager that knows the current type hierarchy.

writeMob(Mob)

Writes the given mob to the blackboard.

readMob(String)

Reads the named mob off of the blackboard.

deleteMob(String)

Deletes the named mob from the blackboard.

replaceMob(Mob)

Overwrites the mob with the new values.

mobSearch(String)

This method is used to search the blackboard for all stored mobs that fit a given condition. The parser for the search string is dependant on the actual blackboard being used.

Search Query Language

The default implementation in the Mica distribution includes a blackboard with an SQL back end. Searching this blackboard is done using standard SQL statements with some functional additions applicable to mobs. These functions can be used to restrict the output from the search or to order the returned mobs.

SQL Mob Functions

typeof(mob, 'type')

allows you to check the type of a mob. This method returns a boolean.

hasslot(mob, 'slotName')

allows you to check whether a mob has a particular slot or not.

getslot1(mob, 'slotName')

gets the first value of a slot. It returns a string.

getslot1asdbl(mob, 'slotName')

gets the first value of a slot. It returns a double.

getslot1asint(mob, 'slotName')

gets the first value of a slot. It returns an int.

getslotn(mob, 'slotName', pos)

is a useful method for getting arbitrary information from a multi-valued slot.

contains(mob, 'slotName', 'value')

allows you to check whether a mob has a particular value stored somewhere in a multi-valued slot.

SQL Examples

Here are some example queries to help you on your way.

Getting all mobs on the blackboard

To get all of the mobs currently on the blackboard you can use:

select * from mobs
Getting all mobs of a particular type

To find all mobs of a particular type you could try:

select * from mobs where typeof(mob, 'text')
Ordering mobs

To order the mobs you can try the order by command. This will look like:

select * from mobs where typeof(mob, 'text')
    order by getslot1(mob, 'creationTime')

Appending asc or desc will place the mobs in ascending and descending order respectively.

Getting the first of a list of mobs

To get the most recent mob you could try:

select top 1 * from mobs
    order by getslot1(mob, 'creationTime') desc
Finding mobs with particular properties

To find a mob you have written you could use:

select * from mobs
    where contains(mob, 'creator', 'myAgentName')

As long as only one value is in the creator slot this could also be done by:

select * from mobs
    where getslot1(mob, 'creator') = 'myAgentName'

isConnected()

Checks that the transport is connected to the blackboard.

getAgentName()

Asks the transport for the name the agent is currently connected to the blackboard with.

setMessageHandler(MessageHandler)

This method is used to tell the transport who is to respond to the messages coming from the blackboard. Typically an agent transport's message handler is the agent and is set when the transport is created. So this method is often not required.

synchronizedWriteMob(Mob, long)

An extension of the agent transport is a synchronized transport [3]. This transport allow mobs to be used to perform remote proceedure calls(RPC) over Mica.

This method writes the given mob to the blackboard and waits for a mob to be sent in reply. A reply mob is any mob that the agent is registered for that names the original mob in its 'replyTo' slot.

The method returns an object containing the name of the written mob and the received reply. If no reply mob is received in the given time period then the returned object will have no reply.



[3] The implementation is unsw.cse.mica.sync.SynchronizedTransport which is used by wrapping it around a standard agent transport.