1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package zeus.generator.code;
25
26 import zeus.util.*;
27 /***
28 * used to generate the script that runs the facilitator
29 * Change log
30 * ----------
31 * 26/06/01 removed java from command line
32 */
33 public class FacilitatorInfo extends GenerationInfo {
34 protected static int count = 0;
35 static final String DEFAULT_PERIOD =
36 SystemProps.getProperty("facilitator.period.default");
37
38 public boolean has_gui = false;
39 public String zeus_external = null;
40 public String period = DEFAULT_PERIOD;
41 public String dns_file = NameserverInfo.DEFAULT_DNS;
42 public String ontology_file = null;
43
44 public FacilitatorInfo(String file) {
45 name = FACILITATOR + (count++);
46 ontology_file = file;
47 }
48 public FacilitatorInfo(String name, String file) {
49 this.name = name;
50 ontology_file = file;
51 }
52
53 public String[] summarize() {
54 String[] out = new String[4];
55 out[NAME] = name;
56 out[TYPE] = FACILITATOR;
57 out[ID] = id;
58
59 out[COMMAND] = "zeus.agents.Facilitator " + name +
60 " -o " + ontology_file + " -s " + dns_file +
61 " -t " + period;
62 if ( has_gui )
63 out[COMMAND] += " -gui zeus.agentviewer.BasicViewer";
64 if ( zeus_external != null )
65 out[COMMAND] += " -e " + zeus_external;
66
67 return out;
68 }
69 public String isValid() {
70 String error = null;
71 if ( dns_file == null )
72 error = "Facilitator " + name + ": domain nameserver file not specified\n";
73
74 return error;
75 }
76
77 public String toString() {
78 double p = (Double.valueOf(period)).doubleValue();
79 String p_str = Misc.decimalPlaces(p,2);
80
81 String s = "";
82 s += "(:name " + name;
83 s += " :period " + p_str;
84 s += " :has_gui " + has_gui;
85 if ( host != null && !host.equals(LOCALHOST) )
86 s += " :host \"" + Misc.escape(host) + "\"";
87 if ( zeus_external != null )
88 s += " :zeus_external \"" + Misc.escape(zeus_external) + "\"";
89 if ( dns_file != null )
90 s += " :dns_file \"" + Misc.escape(dns_file) + "\"";
91 s += ")";
92 return s;
93 }
94
95 public String pprint(int sp) {
96 String tabs = Misc.spaces(sp);
97 String eol = "\n" + tabs;
98 double p = (Double.valueOf(period)).doubleValue();
99 String p_str = Misc.decimalPlaces(p,2);
100
101 String s = tabs;
102 s += "(:name " + name + eol;
103 s += " :period " + p_str + eol;
104 s += " :has_gui " + has_gui + eol;
105 if ( host != null && !host.equals(LOCALHOST) )
106 s += " :host \"" + Misc.escape(host) + "\"" + eol;
107 if ( zeus_external != null )
108 s += " :zeus_external \"" + Misc.escape(zeus_external) + "\"" + eol;
109 if ( dns_file != null )
110 s += " :dns_file \"" + Misc.escape(dns_file) + "\"" + eol;
111 s += ")";
112 return s;
113 }
114 }