View Javadoc

1   /*
2    * Licence (L77741), Version 1.0 (the "Licence"); you may not use this file
3    * except in compliance with the Licence. You may obtain a copy of the Licence
4    * from $ZEUS_INSTALL/licence.html or alternatively from
5    * http://www.labs.bt.com/projects/agents/zeus/licence.htm
6    *
7    * Except as stated in Clause 7 of the Licence, software distributed under the
8    * Licence is distributed WITHOUT WARRANTY OF ANY KIND, either express or
9    * implied. See the Licence for the specific language governing rights and
10   * limitations under the Licence.
11   *
12   * The Original Code is within the package zeus.*.
13   * The Initial Developer of the Original Code is British Telecommunications
14   * public limited company, whose registered office is at 81 Newgate Street,
15   * London, EC1A 7AJ, England. Portions created by British Telecommunications
16   * public limited company are Copyright 1996-9. All Rights Reserved.
17   *
18   * THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
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; // MS 160101 v1.05
59      private Fact[] expOutputArgs = null; // MS 160101 v1.05
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          // MS 160101 v1.05
78          public void setExpInputArgs (Fact [] expInputArgs) {
79              this.expInputArgs = expInputArgs;
80          }
81          
82          // MS 160101 v1.05
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 () {   // MS 160101 v1.05
101                 return this.expOutputArgs;
102             }
103             
104             
105             public Fact [] getExpInputArgs () {   // MS 160101 v1.05
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 }