1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package zeus.actors;
21 import zeus.concepts.*;
22 import zeus.agents.*;
23 /***
24 * TaskContext is a API which should make it easy for the agent developer (you!) to
25 * access the parts of the system and agent that you need to develop code which
26 * changes the system state when an agents deliberative engine (it's planner)
27 * decides to execute some code <p>
28 * You use TaskContext is a little like AgentContext in ZeusExternals. However whereas the
29 * AgentContext object is used to store the AgentState, TaskContext is nowhere near as important
30 * to the system - it just acts as a bag of refereneces for you to access and use. These
31 * references are loaded into the class by task generated by TaskWriter when it has a primative
32 * class with a TaskExternal defined.
33 * <p>
34 * Useful methods are : <br>
35 * <li> <i> AgentContext getAgentContext (); </i> which returns the context object for the
36 * agent that is executing this task
37 * <li> <i> Fact [][] getInputArgs (); </i> which returns the input facts (preconditions) for
38 * this task
39 * <li> <i> Fact [][] getOutputArgs (); </i> which gives you the output arguements (postconditions
40 * for this task. Obviously one use of the task exteranl is to change these so that they
41 * are dependent on the decisions that are made by the user code here
42 * <li> <i> ZeusExteranl getExternal (); </i> which gives you a referenece back to the external
43 * program that you have given to the agent - but you will have to cast the reference to the
44 * external manually, which is why we put in...
45 * <li> <i> String getExternalClassName(); </i> which you can use to get the name of the
46 * external in case the task is used by many agents that have different externals.
47 * @see AgentContext
48 * @see zeus.concepts.PrimativeTask
49 * @see zeus.generator.code.TaskWriter;
50 * @author Simon Thompson
51 * @version 1.04
52 */
53 public class TaskContext {
54
55 private AgentContext context = null;
56 private Fact[][] inputArgs = null;
57 private Fact[][] outputArgs = null;
58 private Fact[] expInputArgs = null;
59 private Fact[] expOutputArgs = null;
60
61 public TaskContext() {;}
62
63
64 public void setAgentContext (AgentContext context) {
65 this.context = context; }
66
67
68 public void setInputArgs (Fact [][] inputArgs) {
69 this.inputArgs = inputArgs;
70 }
71
72
73 public void setOutputArgs (Fact [][] outputArgs) {
74 this.outputArgs = outputArgs;
75 }
76
77
78 public void setExpInputArgs (Fact [] expInputArgs) {
79 this.expInputArgs = expInputArgs;
80 }
81
82
83 public void setExpOutputArgs (Fact [] expOutputArgs) {
84 this.expOutputArgs = expOutputArgs;
85 }
86
87 public AgentContext getAgentContext () {
88 return this.context;}
89
90
91 public Fact [][] getOutputArgs () {
92 return this.outputArgs;
93 }
94
95
96 public Fact [][] getInputArgs () {
97 return this.inputArgs;
98 }
99
100 public Fact [] getExpOutputArgs () {
101 return this.expOutputArgs;
102 }
103
104
105 public Fact [] getExpInputArgs () {
106 return this.expInputArgs;
107 }
108
109 public ZeusExternal getZeusExternal () {
110 if (context== null) {
111 return null; }
112 return (context.ZeusExternal());
113 }
114
115
116 public String getExternalClassName () {
117 if (context== null) {
118 return null; }
119 ZeusExternal zExtern = context.ZeusExternal();
120 Class zeClass = zExtern.getClass();
121 return (zeClass.getName());
122 }
123
124
125 }