|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 % m0 w9 |! {. u
" I0 O3 W1 n' Y# z8 W. O" W+ _
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
" c" W( j( L& F以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
9 S0 `+ c' x- S0 l2 Z7 |, tswarm.SignatureNotFoundException
$ p. c7 Z2 l0 M1 q5 c9 b" e$ | at swarm.Selector.<init>(Selector.java:76)
) s. b, B* d( v: s- S" R at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
0 u1 x- w! h8 x1 B: N' t$ N( ?( ~ at ActionGroupDemo.main(ActionGroupDemo.java:67)
) P8 W' ?0 M* e0 J7 O# a! a2 ?
! k0 s W2 d, m1 h, x/ l
import swarm.objectbase.SwarmImpl;! Y( ?4 n) u/ P3 }
import swarm.objectbase.Swarm;
* D3 E0 L F3 c x& G. ]import swarm.activity.ScheduleImpl;
$ y4 f \9 e6 `9 O, z. z1 p2 O( d+ d/ U2 yimport swarm.activity.Activity;
+ n* [, X) C( d9 Pimport swarm.activity.ActionGroupImpl;
7 P+ g; ?$ S. \3 Qimport swarm.collections.ListImpl;. X' `- e* T4 _, n+ n1 X6 G
import swarm.defobj.Zone; . ?& D' z# S- A) z0 y* ?
import swarm.Globals;
+ m2 W# s4 h7 i3 B" \import swarm.Selector;
) \5 o2 j( R/ v7 }( [$ N+ jimport swarm.activity.ActionGroup; " F' F- f6 J' C" r: I
class Agent {
& J2 E l% T1 n. N char id;
" j6 {) T. Q! Q m
) K* C6 h1 @- J) W' @" ^" H Agent(char id) {/ i; m7 g! ?$ \: G
this.id = id;- V M* E# Z3 o
} S, K6 Y, C# t8 U& p! E
- e4 ?! D9 q4 [2 Q# S- ] public void agentStep() {2 [: E9 g6 g6 _( Y/ e
System.out.println(id + ":" + Globals.env.getCurrentTime());3 @3 _1 P9 h( a6 U2 a
}. v+ b8 [2 R+ {& y3 i
}' c0 ~. L; f, M; s
) a" O" b8 V$ l U& l3 x$ i- zpublic class ActionGroupDemo extends SwarmImpl {% C; s+ [& L) S
ScheduleImpl schedule;! L) v/ B8 q+ J! R+ A I, S
ActionGroupImpl actionGroup;) b: B5 F( |+ o. I1 k+ b1 Z
ListImpl list;
( \: `1 e6 i' E7 t1 P( ^4 T1 k char Id = 'a';
4 n& r' L& C% l- `& }8 t8 T' R" F0 Y; d' \
ActionGroupDemo(Zone aZone) {
; U1 s8 l/ i; j& B6 |. h" s' N super(aZone);
. [4 \7 K: Z8 O, N4 N- z0 y list = new ListImpl(aZone);
7 M2 s3 i# O! \ swarmSetp();
. {' N2 A1 E1 V8 p0 m actionGroup = new ActionGroupImpl(aZone);7 i3 y7 I7 Q, O- N
schedule = new ScheduleImpl(aZone);# Y1 \7 @' p$ ^
try {: z# |% R$ ^( B0 y) X
Selector agentSel = new Selector(Agent.class, "agentStep", false);
& h' n! m _' i/ x Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行7 u; g3 |3 U+ {# h7 v, {- l
* P. O& a; O5 b( ]- O
actionGroup.createActionForEach$message(list, agentSel);8 U8 C" ]* t0 U( h: @7 M; L' X7 R
actionGroup.createActionTo$message(this, swarmSel);
1 X- y) R O4 G0 q n2 t* ` schedule.at$createAction(0, actionGroup);" t# g: j" Q. w6 u
schedule.at$createAction(1, actionGroup);1 _) a+ Y% t% J! G0 r6 |4 y
schedule.at$createAction(2, actionGroup);
: l7 F/ Z& g4 r) N
+ o; e$ P7 n2 C2 m8 j } catch (Exception e) {
' O- Z* W q$ I: p0 h7 X e.printStackTrace(System.err);
4 O r6 U. \9 _" D6 x4 r# k //System.out.println(e);: B8 y0 T' i1 G& M2 ^
System.exit(1);
( v) a9 q0 g. A' E }
$ Z" y Z9 \. P! J! w+ Q1 @# @: g ~& r# Z
& Y2 F6 z. O4 \: L5 Z4 x }6 |* ^, _* ?' i/ m! m
L: I/ g1 W5 E private void swarmSetp() {
* }6 o$ a9 `( m- I; \ list.addLast(new Agent(Id));
/ g) w' r2 o# N# Q# v3 c Id++;. S: G3 ?/ ], C5 m
}
6 I/ ]" A0 a2 g
& E3 g2 B" A3 Y8 u9 g+ J public Activity activateIn(Swarm context) {
* e' j8 F# ?5 b: K% `2 k super.activateIn(context);$ K0 ~: e$ s5 m8 m
schedule.activateIn(this);8 j. t1 S' S! R- Q9 @
return getActivity();' B" B6 L% d5 j" S; s
}
0 R* J2 O9 b- }
- f/ t6 _" e' v9 V2 l, @ public static void main(String[] args) {, r( c( \* k8 T U
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);! X0 i. i b4 u7 y
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);" n+ D0 h' v' `1 V: H" j8 W
swarms.buildObjects();5 k0 |- F$ J1 P
swarms.buildActions();
, J) I1 g6 ^ N' U" A swarms.activateIn(null).run();
7 S- N7 ^; Y' T" Q- L) I7 ?3 Q7 R }4 K$ R# B& X( W; ]
' }; f# D/ }: z( z4 p7 _} |
|