|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 3 b% N- G/ d3 p' e" |' {
( }1 R! E1 Q {4 S1 ^4 y/ O5 q9 M本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
, Q- F$ W0 ~2 O7 N) d7 P以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.9 X/ w" J+ L ^" D G' `1 X3 i2 e
swarm.SignatureNotFoundException
2 c# t0 X; ]- q/ c at swarm.Selector.<init>(Selector.java:76)9 G7 @ C* A# ]' c
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)+ ^( R- [. n4 Z1 c2 Y, ?
at ActionGroupDemo.main(ActionGroupDemo.java:67); i, V! _4 F/ k% K7 A- K/ Z
" t. G" E4 V$ [
, @, S u3 X( D, ?& k" @: b0 fimport swarm.objectbase.SwarmImpl;
/ [: _6 y' n% \import swarm.objectbase.Swarm;
& P/ N' O% Z |" H1 ?import swarm.activity.ScheduleImpl;5 V- J/ Y; d4 `( ]
import swarm.activity.Activity;
0 [- _: X) ?5 W0 q; N9 `" [import swarm.activity.ActionGroupImpl;
0 l% K: L b3 {8 {import swarm.collections.ListImpl;
, U4 W- u8 S9 X6 x2 i ^import swarm.defobj.Zone; 2 l& P4 q# e' y
import swarm.Globals;
: p$ ] Y" W: Y' _; Mimport swarm.Selector;
' t3 S4 i) [7 Fimport swarm.activity.ActionGroup;
) Y) M5 A$ A8 Y4 Tclass Agent {
- x' {% X% O5 R; S$ A; c8 p+ o* U char id;
; T, R0 _, h( i/ J3 l/ k' g0 E J* e# H
Agent(char id) {- h5 G9 l& i; {$ F3 j
this.id = id;
/ z, ~& r4 D0 R }/ G& I+ p; ]" V% L
2 ^" h/ x, l4 y3 q# W- [6 \
public void agentStep() {+ q, b- n/ W S+ n7 A) r: b$ ]
System.out.println(id + ":" + Globals.env.getCurrentTime());4 A$ W& {' _, P- r- e8 H) a( D
}/ d% A: }5 ?; \# p4 e
}
4 b) S+ S9 W& J7 ~0 o( |, _% l6 a* L2 V9 m& v3 e( O% Y3 w9 R J
public class ActionGroupDemo extends SwarmImpl {( G' t* t6 o8 s7 S- H) L8 z
ScheduleImpl schedule;7 }7 z/ y! @. c
ActionGroupImpl actionGroup;
# E5 U9 K: w7 P) }! F { ListImpl list;8 i- B2 Z* `+ U* ~. T! r
char Id = 'a';
& w1 N! b6 n6 h1 ~, c+ X2 e2 h+ o: _1 |
ActionGroupDemo(Zone aZone) {
' b# g$ {( f8 G2 t super(aZone);
8 i$ _* B0 P& ]4 q; D0 a list = new ListImpl(aZone);
& W# T7 ?$ s# i" X' ]8 K- ]# W4 w swarmSetp();5 I, h1 }2 S; n/ T6 @
actionGroup = new ActionGroupImpl(aZone);0 O+ g" E, ~- R, u9 e( C
schedule = new ScheduleImpl(aZone);( Y. F4 V) }- v6 B
try {4 Q" n h t7 Y- H I1 c
Selector agentSel = new Selector(Agent.class, "agentStep", false);. l. W/ n6 v, c* {
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
3 u1 d% ^" ^: ]$ N5 C7 T
5 t& f* _$ P% ^# v3 p4 O actionGroup.createActionForEach$message(list, agentSel);! G) u \% j$ k: |- V/ u, e0 u
actionGroup.createActionTo$message(this, swarmSel);
" m$ N+ t9 S( b" ~ schedule.at$createAction(0, actionGroup);1 x$ T& H1 j6 M; v
schedule.at$createAction(1, actionGroup);
4 @: N8 y) P8 h+ H+ @. X7 ^ schedule.at$createAction(2, actionGroup);
2 c* W" s( I4 Y( _3 G& T! j" S) u4 U
} catch (Exception e) {9 x8 D; Z+ Q# B, n# K: f; ^
e.printStackTrace(System.err);8 `) V+ D G3 q) B9 G/ ]- S1 O5 j
//System.out.println(e);
. F5 ~4 v v, o' ]5 [- R; i; \ System.exit(1);
: u3 W& k5 m& p! A p9 e5 Y0 l }! v. g0 S" `" }& }+ u
q; r% _2 `, S3 a) e/ ~* q K
/ m7 x3 u' }3 b1 w
}
8 K! _: T; V1 n9 o
3 t K; y$ s+ m! C1 \ private void swarmSetp() {/ E' _9 C$ q- ?2 S- Q2 x
list.addLast(new Agent(Id));
7 b2 `* J' e6 f2 ^* c Id++;" }4 g* {3 e4 ~
}- n& `1 Y+ S, X9 z' K( @9 ^
$ s4 d" s. u/ p, w8 d8 ~: \$ e
public Activity activateIn(Swarm context) {
2 @3 S' U+ {" `- c super.activateIn(context);
. b8 z1 s* X" l# i, I schedule.activateIn(this);
5 F. p! M$ l/ a% X4 P: p# ]# l" @5 I( J return getActivity();
# o! O6 L: m; M% ^9 j }
8 V/ ~0 V. t7 Q W6 ]7 p
, I/ Y# q* e% U9 M5 [* v% C public static void main(String[] args) {% Z8 Z0 U, u- {9 X9 y$ m: I
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);. h6 u! j' k W4 D
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);: o) T$ q4 {( B
swarms.buildObjects();0 e' b3 C0 @" J% K
swarms.buildActions();: G- J- x9 d, o# M0 G7 J
swarms.activateIn(null).run();
; g4 ?8 ^, o4 O }
/ h3 z- W3 S$ r% l) f. P/ o& E
( K: z3 v% l- M' P: s} |
|