|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
: t& { `! M4 Z% y
* C [& D3 m* l' y# O; H% l5 T本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21$ [5 s1 _' y) [& \- a" J8 D. Q
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.( R# ]9 L% I" c' t
swarm.SignatureNotFoundException- [2 Y; J7 Y/ y
at swarm.Selector.<init>(Selector.java:76)
/ L$ H, o1 N# t2 b' P3 H9 U. v4 ~, \ at ActionGroupDemo.<init>(ActionGroupDemo.java:37)6 G/ _9 n1 A, \9 }
at ActionGroupDemo.main(ActionGroupDemo.java:67)
/ h6 V, }' v% F& i, B4 \) x
; \/ @3 ~, v. m0 W
4 d7 `3 E: g6 `import swarm.objectbase.SwarmImpl;* c' I% s! Q( @- j
import swarm.objectbase.Swarm;3 ]' h. L, [' i% ~; f- ]
import swarm.activity.ScheduleImpl;8 L0 U5 Z7 c+ c+ ]& c# Z+ D0 J
import swarm.activity.Activity;
8 q# f0 e* ~) Simport swarm.activity.ActionGroupImpl;. X/ t+ R. J# _! V: r2 b7 U. F
import swarm.collections.ListImpl;* C5 p" ~2 B7 ^
import swarm.defobj.Zone;
; n- v! R- j6 h1 x) u% u' t' b. zimport swarm.Globals;
: ~6 \, f6 a8 e. k8 E2 h9 @import swarm.Selector;
4 ]$ K# Z4 w V8 i x. @' }2 N8 y6 Mimport swarm.activity.ActionGroup; # V4 f! [7 K1 a7 B
class Agent {" x& i8 h; K- v9 l- A: }" e% p
char id;
1 [" G! T' ]0 Z0 n" v, O g; b0 B- r; A O/ D* ~! d3 B5 C
Agent(char id) {) ?7 f7 C1 ?7 x$ _$ I
this.id = id;) {5 A0 l% i# }$ N8 Z6 _
}# v# p8 \" z# ]7 v0 r
) ~7 @& R Y b" D7 }4 G' A public void agentStep() {
. }, a7 x9 d" w$ n9 @) u, w System.out.println(id + ":" + Globals.env.getCurrentTime());3 H8 c9 }: B3 O7 J
}* [8 A0 R1 V' O/ @8 a( ^& E: w3 U
}+ I) T1 x- R& \ F7 k
( G7 b3 c' ?8 d" M- hpublic class ActionGroupDemo extends SwarmImpl {
& G% ~( F9 k4 ~& ^! r ScheduleImpl schedule;
+ ~( z1 g( q# }, s+ c2 Q# y ActionGroupImpl actionGroup;- W r$ }: _( ]
ListImpl list;
' }$ f2 g3 w" ?3 q( H1 | char Id = 'a';
- b+ x" R' ]( n$ D$ e: S
3 y1 s5 N1 q/ H. {7 E+ w* m ActionGroupDemo(Zone aZone) {
6 E' Y+ o8 R* C7 ` super(aZone);
0 i2 n* q! A: M list = new ListImpl(aZone);, P# M7 O) [: \1 c! T- o- T9 O. ~
swarmSetp();
, Y' p" t7 s9 `8 _) [ actionGroup = new ActionGroupImpl(aZone);' {- h# h8 Y# D! s& l
schedule = new ScheduleImpl(aZone);# O1 A. J+ ~' y" g& @' D1 w7 ?
try {
7 e2 ^) b b ~! a Selector agentSel = new Selector(Agent.class, "agentStep", false);# P( R$ K0 E, Z' b& z
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
/ U: B- }. E: U* R+ E2 \' @4 l - ] K- |; H8 X- R+ p3 _4 Z
actionGroup.createActionForEach$message(list, agentSel);& \' g4 i9 l* v% L& Z
actionGroup.createActionTo$message(this, swarmSel);
( j7 Q4 g$ r z9 d+ c2 x! g schedule.at$createAction(0, actionGroup);9 A) F1 r ^8 i1 U5 G! H+ t
schedule.at$createAction(1, actionGroup);' ]2 ]* k* G) |% Z2 j$ Z" K
schedule.at$createAction(2, actionGroup);
$ V9 h) i9 Z, S5 [4 X6 ?! i! h4 K* H' Y5 c. X; a) Q3 Q# J
} catch (Exception e) {* w% ~4 y* s9 e' t) |- s" C
e.printStackTrace(System.err);/ N. q: t! _6 O. W) Z
//System.out.println(e);
. O2 e8 V- @8 X3 ~$ O System.exit(1);
5 { T+ J) W% i% ~ }/ m* o3 _/ L( Z, A9 y
/ Y8 i0 U6 D* K ^/ Z) ]0 I1 P( D9 G' G6 e1 @ Z) P6 V* N3 s
}7 \4 T0 W. g- X1 ~' S
& o/ g/ c7 m0 ~
private void swarmSetp() {: L( j3 ]8 q6 m+ ]4 ^
list.addLast(new Agent(Id));: T C/ E+ @' w
Id++;
, J7 ]9 E. U% ? }
6 E( u% E4 H3 z
1 B' O" B8 d- q9 k$ ]/ Q; W public Activity activateIn(Swarm context) {
8 O1 u7 b) A. C/ D( L7 t super.activateIn(context);
5 s2 u! M+ M3 `3 R( h. y schedule.activateIn(this);
- k1 Z% Q! f r8 t return getActivity();
* B) `" B8 {+ z# [, z& X% b8 P }
4 [1 V \; q; G/ O3 n
' o6 d& j/ @) ?% r public static void main(String[] args) {2 P3 P c4 H' Q4 w
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
' }3 Q. i1 E+ S$ U% x! j/ x Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);! H2 Q" S, U/ S2 g4 [. [. c) J
swarms.buildObjects();$ x: x$ h' F+ X# \5 T$ V4 X/ i9 \
swarms.buildActions();
2 D/ n4 S8 N) x' V7 {% B5 v swarms.activateIn(null).run();! C6 X7 u. `% D3 }. S! o3 }
}
1 c6 X# `% m& i: U! O0 }9 W* K5 v% u9 C1 d- L
} |
|