|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 . b3 M. Z# w1 U" n) l. M l; }. Q
. D" Q! j& I# f. M/ M
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update218 s! Z: s3 ]9 W) n% w+ J
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
7 H8 M4 |2 p2 u% o/ iswarm.SignatureNotFoundException4 v; N' G% z3 Q& |8 w8 }
at swarm.Selector.<init>(Selector.java:76)6 U, e" G' y' P) x' l* w
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
# w t; o* ~2 T% Y/ z at ActionGroupDemo.main(ActionGroupDemo.java:67)
2 P0 H' G5 k0 f7 I6 r4 k: g
" m2 r1 s2 u. Q7 `4 a2 \+ F
* ~4 {1 V( p7 Y6 ~import swarm.objectbase.SwarmImpl;
, L% @4 m; h6 U1 K; K8 K: jimport swarm.objectbase.Swarm;9 t! V h5 }7 [( L
import swarm.activity.ScheduleImpl;
9 s; ]% U$ L) L3 ]! J, l% A9 ximport swarm.activity.Activity;, G3 G2 H" V- y O9 K0 ?9 t8 B/ a
import swarm.activity.ActionGroupImpl;
. c1 R" ^* E4 {+ m* vimport swarm.collections.ListImpl;6 g4 u C5 r0 P _7 w
import swarm.defobj.Zone;
9 f) w7 y+ U0 I% N) d: Wimport swarm.Globals;0 {6 E( d2 A$ P' A& P' _+ W1 G
import swarm.Selector;
: ^1 @) o0 [ @! `) iimport swarm.activity.ActionGroup;
( n3 k* j, B) q4 [" s0 iclass Agent {
$ S' k d; o: n0 j" R4 j/ \4 r& a' O char id;
! U a2 K% ^& n# M. X5 w2 a! J+ t! q# s8 |. G# @" o
Agent(char id) {% f9 E* U, m2 Y) |+ s
this.id = id;
4 w0 h- Y, M& i7 F! U }8 V3 h$ J- o, m! ?( O: X
7 X$ O: |3 c8 c& s6 g& j
public void agentStep() {) D( Z1 {7 s7 ~6 u9 @
System.out.println(id + ":" + Globals.env.getCurrentTime());: i6 i) R7 e4 @1 [
}. s) B5 L- B0 i5 P
}
8 G- ]7 c( t0 |7 I2 w
6 S# t. e* K! b) @' ~public class ActionGroupDemo extends SwarmImpl {
1 A* T8 n* m0 j# z5 Q% Y& f ScheduleImpl schedule;
/ P. G! z7 d# G+ f ActionGroupImpl actionGroup;) J7 s8 H1 j3 F' l) ~' P2 C
ListImpl list;( `. X5 h' X4 K5 [+ m0 a7 L5 G8 \
char Id = 'a';4 C. z5 Z: [2 q. ?# w
* r" Q- d. F% L; I ActionGroupDemo(Zone aZone) {% f' j6 g( K; L( k
super(aZone);
6 u% J8 J$ F9 A6 I0 } list = new ListImpl(aZone);) z9 ]. m" I6 c/ \( d( Z
swarmSetp();
, E0 I! [/ q$ e3 W- J; | actionGroup = new ActionGroupImpl(aZone);& V" t# [4 a9 e; L( }
schedule = new ScheduleImpl(aZone);
% ^, F2 r0 [9 h l4 |. l. p: {6 h try {, Q9 f0 M2 I6 q. u( R& F4 B8 q Q$ `9 z
Selector agentSel = new Selector(Agent.class, "agentStep", false);; I# ~2 d. L+ u4 u4 k7 i; n
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行- s, @" M) m# d+ { t- a
/ X @8 K/ j! x6 U7 J3 ]# N actionGroup.createActionForEach$message(list, agentSel);
, ]' [/ |' S; F f- F* }! I actionGroup.createActionTo$message(this, swarmSel);
/ |4 i+ L, S5 W$ i& {2 U" A) r schedule.at$createAction(0, actionGroup);% l( Y- h0 L; b) z B; Q! }
schedule.at$createAction(1, actionGroup);' |& S5 U \6 l3 Z& u# ~7 r
schedule.at$createAction(2, actionGroup);3 p8 s" {: U* x- J! p
; f3 V" T0 q' r1 k t$ h6 P( n+ ? } catch (Exception e) {
z' U2 b' q: H$ F7 ]( P/ { e.printStackTrace(System.err);
$ G% x1 a- r; ^ a. m( Y //System.out.println(e);
# Y; Q* B6 m* a' ?" e. F- k System.exit(1);8 r9 Y/ q8 i: }8 T" I
} e: ?7 m5 F8 w! g. q
) a% K( @; [- L# a4 k' d% D
# t& t P( }$ c9 s- w6 _ }* Q% W4 J D9 O$ P! ~# H" y% J, `7 r
. t6 J$ Y2 u1 h
private void swarmSetp() {
, @ R9 i8 C1 c: w3 d/ ~ list.addLast(new Agent(Id));
) ~" c* e7 i ~4 k Id++;
6 U$ O9 ^; H7 A+ \, |3 x; x }% ]6 p) f$ g7 S) D. b
6 _8 ?! v6 X1 ~5 b3 Y
public Activity activateIn(Swarm context) {
, [% G7 f+ x) M S( ~$ d9 {/ k. A super.activateIn(context);
6 @; b" i% y# ~ schedule.activateIn(this);
% r5 K3 g3 r1 h1 p return getActivity();5 y1 |! Z) i, \
}
4 c! F* X% X, x# |4 g/ R4 { Q
1 m$ q7 W; W- |+ [ ] k public static void main(String[] args) {1 L0 y; p* }1 T; l; n$ U
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);* W' R1 u% y, j, L: G9 X: f
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);4 w: e2 j b p% E
swarms.buildObjects();( u, X5 {% R1 [: k8 s' }0 S6 M
swarms.buildActions();
/ Z% n+ W5 M1 ]& Z+ @ swarms.activateIn(null).run();
7 a5 f! X, L6 T+ S }
! J& Z: U/ C- B
' k* t& m7 a2 `} |
|