|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
1 d: L/ Y- m$ _5 d3 e! {# L6 M+ J
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21/ l" b+ }( j+ R2 z) R" @
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.9 h, k, J' t) e# G% [2 Z
swarm.SignatureNotFoundException$ u p& R" z: l o
at swarm.Selector.<init>(Selector.java:76)
- M6 F2 H+ H3 k4 m6 S. [ at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
; c7 r, v R# j+ [3 b5 @) i0 ] h at ActionGroupDemo.main(ActionGroupDemo.java:67)
4 k- l% T8 N( E- E: D1 r9 X M }- F2 E% e+ p2 J
2 d3 a/ Q& z, i* K$ K% d3 t; L2 Himport swarm.objectbase.SwarmImpl;
6 ^! ?/ K. Q6 [: j) a Dimport swarm.objectbase.Swarm;
6 ^9 z5 _7 x, a7 _5 oimport swarm.activity.ScheduleImpl; j: }0 ~- L0 v
import swarm.activity.Activity;' G# O" y7 i4 G
import swarm.activity.ActionGroupImpl;7 f/ k. g( k3 n
import swarm.collections.ListImpl;
+ a& i9 u9 f; Z3 L4 t) \import swarm.defobj.Zone;
. t! ^! y/ A6 B, R5 o( H0 simport swarm.Globals;
- Y+ P" w R1 Q9 h5 _7 vimport swarm.Selector;
2 a# ?7 r# K2 Timport swarm.activity.ActionGroup;
; i9 }' @, L) m& dclass Agent {. I" R' v% M1 [" a
char id;
2 y9 x$ R2 D' _6 w6 n* I' R( r7 i* M* z* S$ g
Agent(char id) {
% P/ C6 s6 \ k! T9 c this.id = id;
, z& a a6 N9 o: S/ l } U, f3 p1 G& t* }! g
' b' x8 ~; J9 I6 R" z: P9 n4 p
public void agentStep() {
) d$ a/ T: X$ g9 W" e System.out.println(id + ":" + Globals.env.getCurrentTime());0 e) S @0 h: f; H% g" G7 j
}
7 L7 @# A' B" z: S- r4 p}( B: {. C4 M! x0 C
9 G9 o9 A+ \! ^, V4 _# z% r, y S3 H
public class ActionGroupDemo extends SwarmImpl {
9 d& e6 J9 P2 x5 B0 U2 p ScheduleImpl schedule;0 i$ O: _+ ]5 i: [9 V2 p
ActionGroupImpl actionGroup;- m( `+ Z4 S$ i5 ~: c
ListImpl list;
5 Z2 S- x4 i$ {! x) @ char Id = 'a';
8 M/ k& z# c. K1 Z! z3 ?9 ^9 g1 c J. O% k5 H2 \8 `; N
ActionGroupDemo(Zone aZone) {$ Y+ O: I- K) c( A
super(aZone);
6 x, ?% L0 w2 m7 f) O# Z list = new ListImpl(aZone);
g7 S. t" k& d4 L, a( e+ j& l( L swarmSetp();- X* z0 f, ?) @( n F
actionGroup = new ActionGroupImpl(aZone);( i4 F7 M, q6 G# o& K
schedule = new ScheduleImpl(aZone);1 u; U4 @1 N8 J2 F( G2 Q
try {( ?; v7 ]; e# F2 O; s
Selector agentSel = new Selector(Agent.class, "agentStep", false);6 W) V* T2 l Q/ y
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行6 W7 B2 O5 C6 s
/ v' m4 D$ a+ U7 e2 P actionGroup.createActionForEach$message(list, agentSel);9 M* ?1 b+ h# d6 f: Z
actionGroup.createActionTo$message(this, swarmSel);
5 V5 B7 _: B9 z, k: J schedule.at$createAction(0, actionGroup);
N8 r! Y+ y/ ]; V0 \# G& T! s. b schedule.at$createAction(1, actionGroup);9 l9 P5 V+ P( i
schedule.at$createAction(2, actionGroup);& A. X& j4 N* Z; A1 c* S9 r
5 o4 J7 F7 I$ S# Q
} catch (Exception e) {9 j/ D- W: Q% g& W8 b
e.printStackTrace(System.err);
- n+ N! ~ j4 P9 n9 b3 |1 g //System.out.println(e);2 [. s$ L* E, l, h# } b1 @
System.exit(1);7 G; G) o E: S% T3 M* x
}( Q4 A. n/ U3 ~9 [
$ e8 G' V. \; D. f7 V
& \$ A0 s$ b8 C% b1 Q
}" |6 s/ G$ v) |; |
4 ^& G; O- \5 O9 j! ]) E private void swarmSetp() {( v* o0 I* \4 Q: x
list.addLast(new Agent(Id));
( c. h" @; w( f1 |' `* O# D Id++;& w& w& Q( |: V
}
2 B/ D1 Z" r) z: p0 `8 L% {+ [/ P5 R7 f
public Activity activateIn(Swarm context) { S# |7 C2 `7 m' D. B
super.activateIn(context);$ n" F* _. ?1 f, t# H
schedule.activateIn(this);
( X; ]! Q6 g( M' m8 h( V L, | return getActivity();
, C# f9 j( ]1 ^7 r) m }
; r& K$ l, y/ n8 v: b2 E
9 H; f9 I# o: s! X public static void main(String[] args) {
) o5 Q K7 t# ]& e" c& P: S0 G Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
8 Y ]2 ~( e( h7 [ Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);# X+ i2 t; h/ y0 ~+ P: d% @
swarms.buildObjects();; n- ]" }$ e7 S2 ?6 J- z
swarms.buildActions();( L. P4 N' t3 r# J% _
swarms.activateIn(null).run();9 B. g, j" d1 m' C0 p3 m
}
" d, a7 ?, m0 Y* G3 A- y9 X/ l {7 W9 G4 w8 A
} |
|