|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
+ P$ H) M1 S- Z c
' \# @* z& R' d. m本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21' W( c! m0 i6 q. W, g& v$ N
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
\" d5 G' p# N5 e6 vswarm.SignatureNotFoundException
* n6 u2 T0 q4 u8 |1 R$ t at swarm.Selector.<init>(Selector.java:76)
5 G# E, n8 s0 p3 E+ a, ^1 h. n at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
6 C& z/ n; N$ b4 m2 N# I/ e at ActionGroupDemo.main(ActionGroupDemo.java:67)
7 Z$ e" t% x! ~9 i ~9 t' Z. \/ z* f% m: E* ]' i- y9 D, P5 r) c
2 }9 R# X; [ {3 @# i" J/ |3 ximport swarm.objectbase.SwarmImpl;
3 j" H& y+ Z8 g# g2 ]7 gimport swarm.objectbase.Swarm;
( M7 I9 q0 Y; L$ I* y* kimport swarm.activity.ScheduleImpl;
$ X2 N* u$ [2 t! Rimport swarm.activity.Activity;: ~" {) K$ }0 `. b, U2 F; I6 a; w
import swarm.activity.ActionGroupImpl;4 y" h9 F, [" w
import swarm.collections.ListImpl;
1 Q \% }5 q4 }4 o- u. z7 himport swarm.defobj.Zone; ( ?% f" Y2 R* @! N
import swarm.Globals;
: A) h! h& C6 c; E& Pimport swarm.Selector;8 E n1 H1 E# ]- Q' M, u5 \- r i
import swarm.activity.ActionGroup; : K( ?( V, W" Q, z6 i3 N
class Agent {2 [2 L# c: q* H" S5 x$ s
char id;$ J7 V: c) U0 I' p/ B( x1 S
9 [) n( F" B* h* [' r+ R Agent(char id) {
$ x6 e% A! N2 g this.id = id;# F# T) K$ S$ i4 h0 F" e
}
$ I4 g0 L& u7 n" m+ h w1 t4 n; o& d3 G+ g2 P
public void agentStep() {# K9 {3 C Y* M& @# j6 i
System.out.println(id + ":" + Globals.env.getCurrentTime());
& F' Z6 E* O( m# r: q* B7 ~ }, k& b3 F/ s, a2 n
}
: n2 W- @3 m; m5 o2 r' M; V z- D4 s9 w* [
public class ActionGroupDemo extends SwarmImpl {% _9 R2 T* z/ ?( v* X# j K
ScheduleImpl schedule;
3 i3 e5 `6 p& G8 I! q1 | ActionGroupImpl actionGroup;
& ^9 `( m/ n9 c* @) q$ b4 B ListImpl list;
" K) V2 _1 `8 v7 z) | char Id = 'a';
1 c2 R W+ W. |6 N6 B1 ^% l- R- |7 `$ N1 ? p9 O: K) r/ b4 J
ActionGroupDemo(Zone aZone) {
5 K- S4 d- U' |3 ^2 w% P& d super(aZone);2 r; I7 _3 I, U; S# x/ [
list = new ListImpl(aZone);
% M8 b( p$ w3 f7 u9 h3 l9 b e swarmSetp();
/ {# |. t' J' j actionGroup = new ActionGroupImpl(aZone);
8 i5 _. h8 f# T: `# y7 e1 G# Q schedule = new ScheduleImpl(aZone);" u6 h' F- D7 F
try {
5 h% s; r- w+ ?. x8 m* m Selector agentSel = new Selector(Agent.class, "agentStep", false);
; K, v- a3 U3 B0 R Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行+ o/ i/ ]# W3 C: Y) v1 S
6 A8 i5 h/ L7 |/ D. O. i0 E/ c6 s actionGroup.createActionForEach$message(list, agentSel);
+ E; B$ L& N3 l& h actionGroup.createActionTo$message(this, swarmSel);
# j' W4 G* J# }/ V% O schedule.at$createAction(0, actionGroup);
; }, `: T4 N Z" ` j7 ]2 h( N schedule.at$createAction(1, actionGroup);! j, L( h- m7 l- }
schedule.at$createAction(2, actionGroup);# b; Q& ?6 Y: Z
7 C* k, D6 B$ h, n+ |+ S& q- V } catch (Exception e) {1 }$ y# a7 k4 S/ k; w. b( A' G R" n
e.printStackTrace(System.err);" h: ^8 F+ {6 D
//System.out.println(e);0 @1 ` _# m. C$ Q( {; I
System.exit(1);
[* L$ e" X" |' G; {0 n' G }
# }" v. P( K. h! D9 ?: N% G5 g4 a: a v* U& F+ {3 o0 z" q
$ f3 B& J) J6 \6 L" e4 V+ y! B$ a }
% o" [1 J4 B0 |5 F/ \2 y0 d& ]) r& T
private void swarmSetp() {7 e3 Q L1 p3 T, ~
list.addLast(new Agent(Id));
) N' K& ]8 K+ y+ \4 P+ [3 e Id++; L, W8 t8 H9 F) K
}
% M" f% |& W; I" H5 ~% U( E: y/ S8 C5 R$ j
public Activity activateIn(Swarm context) {6 {/ z7 s$ X+ m I+ e
super.activateIn(context);
9 v9 Z7 n" [1 ^ L4 B- G9 O4 r7 K schedule.activateIn(this);
5 O: w: q# c, S; V return getActivity();9 K/ H" R2 \0 d9 j2 ]) l9 W' a
}0 A- w3 j2 b# O' b3 [. r4 l8 B
8 D: ]# m& M: f
public static void main(String[] args) {8 l, ~! z- P N
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);2 `: F0 |# @: b% y
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);! c( v/ h7 g; b t* L
swarms.buildObjects();
" y* {8 Y0 M/ X( |3 M swarms.buildActions();* Q2 j, [" g; R9 `& r
swarms.activateIn(null).run();
( T' @+ ^% E! f1 h/ ~) _ }
6 {3 p, T; V6 t. [
5 x4 K9 k+ ]# h/ \} |
|