|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.cougaar.util.GenericStateModelAdapter
org.cougaar.core.blackboard.BlackboardClientComponent
org.cougaar.core.plugin.ComponentPlugin
org.cougaar.pizza.plugin.PlaceOrderPlugin
This plugin orders the pizza for a pizza party. It subscribes to a PizzaPreferences object
published by the InvitePlugin when it knows how much of what kind of pizza to order.
On receiving the PizzaPreferences, it creates and publishes a Task with the Verb "Order" and a Direct Object of type Pizza (Asset). Next, it expands the Order Task into a workflow of two subtasks, one subtask per type of pizza with a quantity Preference for the number of servings needed. To place the order, it allocates the subtasks to its pizza provider, Joes Local Pizza Shack. This customer/provider relationship is defined in the XML configuration files and is established when the agents start up. See PizzaNode1.xml and PizzaNode2.xml for details.
In this example, the plugin cannot successfully complete the pizza order because Joe's Local Pizza Shack doesn't make veggie pizzas. The final result is a failed Expansion on the parent order Task due to the failed Allocation of the veggie pizza subtask.
| Nested Class Summary |
| Nested classes inherited from class org.cougaar.core.blackboard.BlackboardClient |
org.cougaar.core.blackboard.BlackboardClient.Local |
| Field Summary | |
protected static org.cougaar.util.UnaryPredicate |
ALLOCATION_PRED
This predicate matches Allocations on "Order" tasks. |
protected org.cougaar.core.blackboard.IncrementalSubscription |
allocationSub
|
protected org.cougaar.core.service.DomainService |
domainService
|
protected static org.cougaar.util.UnaryPredicate |
EXPANSION_PRED
This predicate matches Expansions on "Order" tasks. |
protected org.cougaar.core.blackboard.IncrementalSubscription |
expansionSub
|
protected org.cougaar.core.service.LoggingService |
logger
|
protected static org.cougaar.util.UnaryPredicate |
PIZZA_PREF_PRED
This predicate matches PizzaPreferences objects. |
protected org.cougaar.core.blackboard.IncrementalSubscription |
pizzaPrefSub
|
protected org.cougaar.planning.ldm.PlanningFactory |
planningFactory
|
protected static org.cougaar.util.UnaryPredicate |
SELF_PRED
This predicate matches the Entity object of the agent. |
protected org.cougaar.core.blackboard.IncrementalSubscription |
selfSub
|
| Fields inherited from class org.cougaar.core.blackboard.BlackboardClientComponent |
agentId, agentIdentificationService, alarmService, blackboard, blackboardClientName |
| Fields inherited from interface org.cougaar.core.plugin.PluginBase |
INSERTION_POINT |
| Fields inherited from interface org.cougaar.util.GenericStateModel |
ACTIVE, IDLE, LOADED, UNINITIALIZED, UNLOADED |
| Fields inherited from interface org.cougaar.core.blackboard.BlackboardClient |
current |
| Constructor Summary | |
PlaceOrderPlugin()
|
|
| Method Summary | |
protected void |
allocateSubtasks(java.util.Collection subtasks,
org.cougaar.planning.ldm.asset.Entity provider)
Creates and publishes Allocations for each subtask in the collection. |
protected org.cougaar.planning.ldm.plan.Task |
createOrderTask()
Returns a Task for ordering pizza. |
protected java.util.Collection |
createPizzaSubtasks(PizzaPreferences pizzaPrefs,
org.cougaar.planning.ldm.plan.Task parentTask)
Returns a Collection of subtasks for ordering meat and veggie pizzas. |
protected void |
execute()
When there are changes to the plugins's subscriptions, we: 1) When the PizzaPreferences arrives, create the root Order Task, and expand it by the types of pizza. |
protected org.cougaar.planning.ldm.plan.Expansion |
getChangedExpansion()
Returns the Expansion that was changed (the one and only typically). |
protected PizzaPreferences |
getPizzaPreferences()
Returns any added PizzaPreferences object from the PizzaPreferences Subscription. |
protected org.cougaar.planning.ldm.asset.Entity |
getProvider()
Returns a pizza provider for this agent. |
protected org.cougaar.planning.ldm.asset.Entity |
getSelfEntity()
Returns the Entity representing the agent. |
void |
load()
Loads services used by the plugin. |
protected void |
logExpansionResults(org.cougaar.planning.ldm.plan.Expansion exp)
Log (at SHOUT) the results of the given Expansion, showing what was ordered, how much, from whom, and with what success. |
protected void |
makeExpansion(org.cougaar.planning.ldm.plan.Task parentTask,
java.util.Collection subtasks)
Creates and adds an Expansion on a Task and publishes it to the blackboard. |
protected PizzaAsset |
makePizzaAsset(java.lang.String assetType)
Creates an instance of a PizzaAsset of the specified asset type. |
protected org.cougaar.planning.ldm.plan.Preference |
makeQuantityPreference(int value)
Returns a quantity Preference, representing the number of servings of pizza to order. |
protected org.cougaar.planning.ldm.plan.NewTask |
makeTask(org.cougaar.planning.ldm.plan.Verb verb,
org.cougaar.planning.ldm.asset.Asset directObject)
Returns a NewTask. |
protected java.lang.String |
printAllocationResults(org.cougaar.planning.ldm.plan.PlanElement pe)
|
protected java.lang.String |
printExpansionResults(org.cougaar.planning.ldm.plan.Expansion exp)
|
void |
setDomainService(org.cougaar.core.service.DomainService aDomainService)
Services that are absolutely required by the plugin can be loaded via introspection by the binding utility instead of explicitly getting each service from the ServiceBroker in load(). |
protected void |
setupSubscriptions()
Initialize the subcriptions the plugin is interested in: self Entity, the PizzaPreferences, and existing Allocations or Expansions or Order Tasks. |
protected void |
updateOrderAllocationResults()
Updates the estimated AllocationResults with reported AllocationResults. |
| Methods inherited from class org.cougaar.core.plugin.ComponentPlugin |
getConfigFinder |
| Methods inherited from class org.cougaar.core.blackboard.BlackboardClientComponent |
currentTimeMillis, cycle, getAgentIdentifier, getAlarmService, getBindingSite, getBlackboardClientName, getBlackboardService, getMessageAddress, getParameter, getParameters, getServiceBroker, halt, precycle, requestCycle, resume, setAgentIdentificationService, setAlarmService, setBindingSite, setBlackboardService, setParameter, setSchedulerService, setServiceBroker, setSuicideService, shouldExecute, start, stop, suspend, toString, unload, wasAwakened |
| Methods inherited from class org.cougaar.util.GenericStateModelAdapter |
getModelState, initialize, transitState |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.cougaar.util.GenericStateModel |
getModelState, halt, initialize, resume, start, stop, suspend, unload |
| Field Detail |
protected org.cougaar.core.service.LoggingService logger
protected org.cougaar.core.service.DomainService domainService
protected org.cougaar.planning.ldm.PlanningFactory planningFactory
protected org.cougaar.core.blackboard.IncrementalSubscription selfSub
protected org.cougaar.core.blackboard.IncrementalSubscription pizzaPrefSub
protected org.cougaar.core.blackboard.IncrementalSubscription allocationSub
protected org.cougaar.core.blackboard.IncrementalSubscription expansionSub
protected static final org.cougaar.util.UnaryPredicate SELF_PRED
protected static final org.cougaar.util.UnaryPredicate PIZZA_PREF_PRED
protected static final org.cougaar.util.UnaryPredicate ALLOCATION_PRED
protected static final org.cougaar.util.UnaryPredicate EXPANSION_PRED
| Constructor Detail |
public PlaceOrderPlugin()
| Method Detail |
public void setDomainService(org.cougaar.core.service.DomainService aDomainService)
public void load()
protected void setupSubscriptions()
protected void execute()
protected void logExpansionResults(org.cougaar.planning.ldm.plan.Expansion exp)
exp - The Expansion of the root Order task, whose details we printprotected PizzaPreferences getPizzaPreferences()
Note that since we only check the Added list, this method will only return an object once in our application. This keeps the plugin from publishing the Order Tasks each time the plugin runs.
protected org.cougaar.planning.ldm.plan.Task createOrderTask()
protected java.util.Collection createPizzaSubtasks(PizzaPreferences pizzaPrefs,
org.cougaar.planning.ldm.plan.Task parentTask)
pizzaPrefs - contains the number of people requesting meat or veggie pizzasparentTask - the parent of the subtasks
protected void makeExpansion(org.cougaar.planning.ldm.plan.Task parentTask,
java.util.Collection subtasks)
parentTask - the parent task to be expandedsubtasks - the collection of subtasks to be added to the Workflow of Expansion
protected void allocateSubtasks(java.util.Collection subtasks,
org.cougaar.planning.ldm.asset.Entity provider)
subtasks - a collection of subtasks to be allocatedprovider - the provider to which the subtasks are allocatedprotected void updateOrderAllocationResults()
Remember that the infrastructure sets the ReportedResult for you (in this case, by copying it from the provider agent when the provider settles the Task), but you must copy that up typically.
Checks the changed collection on the Allocation subscription. If the collection is not empty, it retrieves the Allocation PlanElement from the subscription. If the reported AllocationResults have changed, the results are udpated and a publish change is called on the PlanElement. The reported AllocationResults are changed by the provider assigned to the task.
protected org.cougaar.planning.ldm.plan.Expansion getChangedExpansion()
Checks the changed collection on the Subscription. If the collection is not empty, it returns the first element. If empty it returns null.
protected org.cougaar.planning.ldm.plan.NewTask makeTask(org.cougaar.planning.ldm.plan.Verb verb,
org.cougaar.planning.ldm.asset.Asset directObject)
verb - the verb of the newtaskdirectObject - asset that this Task is acting on
protected PizzaAsset makePizzaAsset(java.lang.String assetType)
assetType - the name of the type of asset (veg/meat)
protected org.cougaar.planning.ldm.plan.Preference makeQuantityPreference(int value)
Creates a Preference with a Strictly-at ScoringFunction and a quantity AspectType from the specified value. In other words, says I want this many, and you get 0 credit for any more or less.
value - the number required
protected org.cougaar.planning.ldm.asset.Entity getProvider()
protected org.cougaar.planning.ldm.asset.Entity getSelfEntity()
protected java.lang.String printExpansionResults(org.cougaar.planning.ldm.plan.Expansion exp)
protected java.lang.String printAllocationResults(org.cougaar.planning.ldm.plan.PlanElement pe)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||