|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
8 \$ T/ c( H, \
6 V2 Q3 q, L3 Q: ~# S! L本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21+ z+ g! r% b3 z3 g( u& i
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.1 E7 D6 d* c; \ n9 v% y, P7 e
swarm.SignatureNotFoundException
, |. X6 x! `5 p. E6 {; E at swarm.Selector.<init>(Selector.java:76)5 B- `/ [7 k5 E6 B
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
. M4 a g. D( p at ActionGroupDemo.main(ActionGroupDemo.java:67)
5 U9 _* h# @8 m% f0 {1 h: U2 |) z% ?, E: ?
/ ]4 B" t; \. D( t E
import swarm.objectbase.SwarmImpl;. n' K3 g9 N+ f ^4 G5 u
import swarm.objectbase.Swarm; k4 n# B/ L2 `3 | v9 B
import swarm.activity.ScheduleImpl;9 \. n# {0 w {1 I/ X
import swarm.activity.Activity;* Z5 a4 y7 p, r7 [6 }5 N3 v) e1 N1 d
import swarm.activity.ActionGroupImpl;* A# |9 f4 ?! G7 ?5 Q$ q. w; c
import swarm.collections.ListImpl;* |( H# p X# I7 \$ x
import swarm.defobj.Zone; + S- D3 |. j6 d8 Z+ X
import swarm.Globals;
2 a+ `* u F# e. i9 f8 h1 A' bimport swarm.Selector;
+ a2 ?/ Y$ v4 J1 b0 Simport swarm.activity.ActionGroup;
) u( M) ^1 n! g' _! D( jclass Agent {- n0 T" N! x, z: i
char id;1 T2 d* Z( [' R7 ~& a
7 W7 I. ]! Y9 Y" ~ Agent(char id) {7 |7 s6 a6 L% m* |$ I- z
this.id = id;
6 q! ~: o t" [% j& f7 G }
1 `) D. O# Z \* j
- E$ b/ Q9 D' A8 [ public void agentStep() {; ?1 X3 {/ h, z9 S) n$ `: g2 w& B7 Y
System.out.println(id + ":" + Globals.env.getCurrentTime());. X: C; x9 y1 T
}9 i6 L! }. o5 y% G& Z3 G! `! q
}) I+ z0 \8 T$ w7 n) ?( J1 U' p
6 Y- ~9 k8 w9 I; `: Y9 }: H
public class ActionGroupDemo extends SwarmImpl {5 L1 Y% ~, C9 {. F* [/ q8 \
ScheduleImpl schedule;
$ Y- T! G2 |. T/ M6 U( J ActionGroupImpl actionGroup;
0 Z- T7 _8 i2 L8 [, P1 A) a ListImpl list;
b( M- X; o6 n6 `; p; Z/ D char Id = 'a';
" O3 B% ?+ |0 m- k/ U! s
0 J# { @- g+ O: F- _: K ActionGroupDemo(Zone aZone) {
: O1 g0 ~$ X. \ super(aZone);0 G/ ?. t( ?. h; r0 K! O2 y
list = new ListImpl(aZone);
7 N. ?! R2 f: T1 X7 C" I& M swarmSetp();
. g) A& p4 }4 z w. ]8 R& @ actionGroup = new ActionGroupImpl(aZone);% A4 q( |: y2 b$ T
schedule = new ScheduleImpl(aZone);
* p* K |3 L# ?$ V+ d try {! f& ^, {: j2 V* C0 u
Selector agentSel = new Selector(Agent.class, "agentStep", false);
9 k9 k: Q4 f2 S# q1 Y Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
e: S+ Z8 ]2 `) B; E% J( O
: j/ h; l. n% I. a$ Y) ^) B0 W actionGroup.createActionForEach$message(list, agentSel);
. w$ q# N0 z' M1 ]5 \0 W. M7 \ actionGroup.createActionTo$message(this, swarmSel);" `6 I4 s& W a, j1 Y. I- ~
schedule.at$createAction(0, actionGroup);
1 ^5 l/ f' P( l7 g$ q schedule.at$createAction(1, actionGroup);
6 F# ^9 k1 {8 l3 i- W schedule.at$createAction(2, actionGroup);9 A: C% d0 {8 x+ l) G& |+ F
; E& w/ Q5 r- m4 \3 I d2 S } catch (Exception e) {
1 J3 k$ R/ z% M0 a! V e.printStackTrace(System.err);6 ]2 @( D% q8 U+ a" w1 r- r
//System.out.println(e);
- z& P# y5 }4 K4 b, b: P System.exit(1);2 n7 S! D- S& M* ^
}
- i8 k! _9 N0 U$ O% M+ q0 m1 [$ ?3 f. e! z. f- T6 n
9 u. ?$ w0 g2 a- F0 V
}
4 g2 m( z. v9 {3 b. `$ i: w
" ?% A% B- D' N7 K private void swarmSetp() {
h6 u5 z& r6 X2 z$ {" X list.addLast(new Agent(Id));, d% q6 d$ m+ q4 R) U
Id++;
4 H6 D. |% |' W( A }, k+ x+ {- o H* Q* `
Y, g. B; S, o3 T* M
public Activity activateIn(Swarm context) {
! l* Y+ D6 G& g( [" d/ R super.activateIn(context);
8 c1 x- I1 L% n# h schedule.activateIn(this);
. ]" M! W' L) @/ I5 ~, l return getActivity();
5 i# J3 }1 z2 p; i S* v1 d* g }8 |& x. b+ X1 n2 u) i3 t: v1 e$ \
& p* S- F8 W9 r5 K+ R/ b2 q7 U. Q
public static void main(String[] args) {
' s7 Z' ~+ M2 B/ o y) T( H Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
7 ?* N$ o# V3 Z: H9 F F Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
0 m3 V/ L1 P6 L swarms.buildObjects();
9 G0 w7 o- y: j" ^ i; v0 i" {3 @$ _0 ^ swarms.buildActions();
& I4 s' V# {" P9 d1 q1 ?1 w swarms.activateIn(null).run();
2 z0 l, a' F& Z/ B }+ v8 Z7 ?( @( G# u- w0 U6 [; K
7 t$ }( T y( E8 L
} |
|