|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
! M' W- N" {; ~' H5 M6 r
+ J# J' t; r$ I6 }% q# W% V本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21, }4 ]' q- y. _. K/ S( ^
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.7 o7 H- q# G9 v# s% }
swarm.SignatureNotFoundException
2 X2 N+ p7 K0 }2 S( N at swarm.Selector.<init>(Selector.java:76)
, A3 a1 R% p6 g# z# k1 V at ActionGroupDemo.<init>(ActionGroupDemo.java:37)8 y% c8 @6 c/ R/ ^- \4 b/ s
at ActionGroupDemo.main(ActionGroupDemo.java:67)
; k F7 t/ p& P3 b( {* U
6 h7 z8 v& k: c9 I, N7 T2 r
: _1 q" ?3 @" l+ H! Simport swarm.objectbase.SwarmImpl;
0 x/ t- T+ b' e g7 {6 ]import swarm.objectbase.Swarm;8 c- j' R% B$ ?7 ~) M1 z
import swarm.activity.ScheduleImpl;
9 y/ B5 ]! x. e$ t, M& k. timport swarm.activity.Activity;5 R. v1 }, D+ K; E N- N r9 `
import swarm.activity.ActionGroupImpl;
% Z1 Z9 _5 }& Z+ M2 gimport swarm.collections.ListImpl;: ]% R A( g5 S: t2 {7 K- D3 X
import swarm.defobj.Zone; * ^6 x& N& o0 i% @/ Z
import swarm.Globals;
$ T Q4 P( t& z |9 ?import swarm.Selector;
# V$ [. r$ I, |: \- nimport swarm.activity.ActionGroup; ( N2 a( T; S' c7 Y% i j8 y
class Agent {
( y8 J0 @- P# k. Q' _; s) W char id;
3 K1 I V1 I8 U1 I: ^9 L+ c$ ] p* w7 q. N# | q
Agent(char id) {: B4 ` y# Z9 g: ]9 u. X
this.id = id; t" ~# w5 P( H! ]; l, H: J
}1 J0 Y# B6 X: Y$ d9 ^' u
4 a& W* J2 G1 \* k% `( x public void agentStep() {
! i; ~0 }" m3 r D6 s; Z& z& t1 U; } B( m System.out.println(id + ":" + Globals.env.getCurrentTime());( l, ]1 [. w3 {( l
}% a/ p0 \. z0 S' K) a& z. O2 J
}
! ]+ c. x% B9 P+ p& ~- m' |3 Z( T
# Q; c" t; d+ Cpublic class ActionGroupDemo extends SwarmImpl {" V! L( t, \" {$ d
ScheduleImpl schedule;; t9 K) ?# e+ [( F% ?% D! k
ActionGroupImpl actionGroup;
5 r9 T: Y+ G) V f$ a K ListImpl list;
; n3 @' Y2 _) j# U9 d4 x char Id = 'a';
1 G- t1 s5 p& P1 g3 I" w4 y4 c4 x$ |
# ]! g" u$ T4 r. v ActionGroupDemo(Zone aZone) {- S+ ~& }5 y' Q9 F ^
super(aZone);/ Z8 i- L l$ H1 n
list = new ListImpl(aZone); f& }% e6 D" K/ x) d9 o
swarmSetp();, k$ m, `0 u/ A* ?( o0 x! P
actionGroup = new ActionGroupImpl(aZone);
! z+ X- A* V5 l8 M# D* i) t7 Y schedule = new ScheduleImpl(aZone);
& W2 G- c! ~- [7 e, _4 j. x try {
2 k$ ~8 `/ k7 p9 @ Selector agentSel = new Selector(Agent.class, "agentStep", false);
- ]5 j2 H( w) S" z Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
! E3 j( n+ o6 G% W! _
3 x; Y3 p- f. p actionGroup.createActionForEach$message(list, agentSel);+ L- S' v: Z8 X9 c# h2 T
actionGroup.createActionTo$message(this, swarmSel);' I2 Y" O! k0 n8 t9 z) B/ o7 N1 k$ A. |
schedule.at$createAction(0, actionGroup);8 D e6 d* C6 L& T) h, ]
schedule.at$createAction(1, actionGroup);) S O# \. _2 Z5 i
schedule.at$createAction(2, actionGroup);
. H1 Q( h( h4 j5 }, I h s9 s
0 G4 c1 I* u! N2 Q } catch (Exception e) {
: A5 n) H2 c. y* N; b" O* ]8 n) V e.printStackTrace(System.err);
9 E) w1 N! r+ `! @9 G! b! i3 u //System.out.println(e);8 W: c: h# D) h2 p$ f' h- k. q
System.exit(1);
# a7 ]6 ^* J' r: n/ ]% h }
- }) }1 |6 r# B) N# D
- `6 E5 U3 @% `; {* `' m5 |
. ^, [7 E6 T/ [" b1 K) p }
+ N/ [2 D6 B" t( s% `5 f4 m# h" i" P3 }- E; W9 m! G
private void swarmSetp() {$ M5 R' N1 Q: L0 r2 n7 b
list.addLast(new Agent(Id));
6 A0 d! |2 o- B; _. \ Id++; ]' O8 ?! a3 t9 i# L
}
8 g$ H. B# |! y2 _ f7 t! ]. N3 R' f9 G9 {! d. A$ p& k) I
public Activity activateIn(Swarm context) {# m) \4 z2 `1 }" v' U! ~; N
super.activateIn(context);, {% ^! }2 D0 |6 \7 X! a0 q
schedule.activateIn(this);5 y3 l7 h" f1 r* B
return getActivity();1 A3 M( O1 E. i( D: J$ P* H
}
Q, h$ U, Z$ ?; I6 }5 }$ H7 Z' r% E, N- _( i1 L3 w# |1 J
public static void main(String[] args) {
& Z% W, }' P* K G! h2 X; _# s Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
5 h2 X# M" M0 @4 g* O7 s Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
# l- \) A8 B% U, {2 }( Y" ^ swarms.buildObjects();
3 Q" j/ e# t# U% B, b swarms.buildActions();7 M, X% F) {8 r
swarms.activateIn(null).run();9 [) U9 t9 T" v* |3 h* }8 I
}1 o( R% \( l/ x7 r/ A* M
* U* ~( `: H5 O W
} |
|