r10 - 29 Jun 2005 - 15:19:06 - LisaDusseaultYou are here: OSAF >  Journal Web  >  DevelopmentHome > AgentFramework2004 > AgentFrameworkAPI2004
The agent framework stuff has been removed from Chandler and instead replaced by less ambitious tools.

The Agent Framework

An early release of the agent framework is included in the .3 release of Chandler. This initial implementation has machinery to load agents from an xml file, persist them in the Chandler repository, and run them in their own threads. They execute instructions containing conditions and actions. There is no user interface yet, but that will come eventually.

Agent Framework Overview

Agents are loaded from parcel xml files and persisted as items in the Chandler repository. All of the agent framework classes that require persistent data derive from the repository 'Item' class.

There are two different classes that are used to represent an agent, one to hold its persistent data, and the other to represent its dynamic state. The persistent class is called 'AgentItem' to distinguish it from the transient 'Agent' class. The Agent Manager maintains a dictionary making getting an Agent from its AgentItem easy.

An Agent instance is created by passing in the associated AgentItem. When initialized, it's registered with the AgentManager which creates subscriptions to the notifications referenced by its conditions. After initialization, an agent is in the suspended state; it starts executing in its main loop when the AgentManager invokes its Resume method.

In an agent's main loop it, sleeps until it either receives a notification that matches an instruction's condition or an instruction's schedule tells it that it should wake up and execure the instruction's actions.

Actions are usually executed on the agent's thread, so they don't block the main program. But sometimes actions need to make wxWindows calls, in order to put up a dialog or otherwise interact with the user. wxWindows calls can only be made by the application's main loop, so there is a simple mechanism for deferring actions to be executed by the main thread at idle time.

The most important classes that comprise the agent framework are AgentManager, AgentThread, Agent, Scheduler, AgentItem, Instruction, Condition and Action. They are described in detail below.

Agent Framework Base classes

AgentManager

At Chandler start-up, it launches agents for each AgentItem in the repository, maintaining a mapping between each agent and its persistent counterpart.

Agent

Represents the dynamic state of an agent and controls the agent's thread.

AgentThread

The thread run by an Agent. It has a main loop and handles things like receiving notifications and scheduling them in its scheduler.

Scheduler

Used by the AgentThread as its main loop. It supports scheduling of events to fire at specific times and repeating events. It is threadsafe and could be used by other parts of the application, but is currently only used by agents.

AgentItem

The persistent item holding references to its instructions.

Instruction

An Instruction is the basic unit of execution, which references a condition and a list of actions. When the instruction is executed, it evaluates the condition, and, if true, queues the actions to be executed. Instructions are executed when a relevent conditions arrives; instructions can also arrange to be executed periodically independent of any notification so their conditions can poll the outside world.

Instructions have an 'enabled' flag. The are not executed unless their enable flag is set to True.

Condition

Conditions are what they sound like. They contain some expression that must be matched in order for an instruction to fire its actions.

Action

The class used to execute code. Actions are the piece that does something, like fetch email or fetch an rss feed.

more coming soon....

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r10 < r9 < r8 < r7 < r6 | More topic actions
 
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.