|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 ) Y R& z6 ^9 P3 O9 k! Y
' @& i0 Q L& Z% g& f+ L本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21" o/ s* P; P1 C2 m) Q" a
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
# ~% ]! n) g0 g( i9 |$ f- Qswarm.SignatureNotFoundException
2 P# J3 X! J/ C& a6 X at swarm.Selector.<init>(Selector.java:76)
x& y \" S. K+ r4 h1 Z at ActionGroupDemo.<init>(ActionGroupDemo.java:37)! v# r) ?) }# O, Z; {
at ActionGroupDemo.main(ActionGroupDemo.java:67)" R6 T* w( T4 ^0 `& f- o0 X
4 a: l4 n9 U) N: b% f: g3 @* d. t5 f$ I n5 z6 ~5 u
import swarm.objectbase.SwarmImpl;
3 f# E! | O/ Zimport swarm.objectbase.Swarm;
; c$ o0 t( j7 j& y; {" L; r( _import swarm.activity.ScheduleImpl;' j% p+ ~9 e( h c) j4 }% ^+ V+ K4 `5 R
import swarm.activity.Activity;
4 P% Z+ S m! F; a6 _! Vimport swarm.activity.ActionGroupImpl;
) k6 @/ o: P( w' S7 v" fimport swarm.collections.ListImpl;
% \. ?8 g+ G' M% \& w5 Dimport swarm.defobj.Zone; ) c' O" n3 h3 G( J; r, z2 \; V- A: G6 o
import swarm.Globals;, o/ j, ?& q# x9 E+ i
import swarm.Selector;
( h2 e3 c& y$ U' Cimport swarm.activity.ActionGroup; 4 R1 \# _; v) c7 @' k5 Y& w
class Agent {4 W$ g3 ?: J* M% U( g7 i
char id;3 t7 z6 |# k h# p3 e" u3 Y
+ _% X- c$ R. ~0 T4 @( F& O
Agent(char id) {
* x- \6 d; f @4 _ this.id = id;
1 d0 f |& `0 V }
. H+ y2 h3 |+ U+ x# s4 T7 K7 n- c
# n! u% r$ g# v7 ]- G) z* B public void agentStep() {* d( H) N& t y3 \
System.out.println(id + ":" + Globals.env.getCurrentTime());9 _, c$ {* A, E1 B
}
8 |# H' n l- ^* `7 P}: V& q/ r `: c- p$ C0 A8 n4 b
) @5 ]+ x, \8 r. {9 k7 x
public class ActionGroupDemo extends SwarmImpl {
* k% H; V* b8 E( {7 ]1 M0 ~ ScheduleImpl schedule;
2 r, C8 l$ r+ h ActionGroupImpl actionGroup;
5 r4 W8 m2 J. j- _' p4 {& @! J; o ListImpl list;3 }' M0 I, S9 u2 V( g- x- X; M
char Id = 'a';
; _9 a; _$ j- e: g" N* g- O! X; g2 v
ActionGroupDemo(Zone aZone) {: w( C* |# F% m( `) X# s
super(aZone);+ z% Y2 ?9 V" M
list = new ListImpl(aZone);
$ R/ H9 q6 M& q0 z% O swarmSetp();, W0 O9 _9 ?2 t7 ]
actionGroup = new ActionGroupImpl(aZone);6 P$ t% Z. y3 F0 r* S4 W
schedule = new ScheduleImpl(aZone);
9 l: \4 E+ z) h+ Z& X- A try {
2 W' _7 n# v& Q% K4 x/ V0 h Selector agentSel = new Selector(Agent.class, "agentStep", false);
p+ W b2 w3 G6 W5 ]" j Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行' w R( E1 m" z- i
B) @5 n* P9 m9 `; t actionGroup.createActionForEach$message(list, agentSel);4 g! w( E) Q8 ]1 \
actionGroup.createActionTo$message(this, swarmSel);
% l4 ]9 [. y! e: P schedule.at$createAction(0, actionGroup);
" u) V* X# d- s% {4 R1 n! z- ~ schedule.at$createAction(1, actionGroup);
4 I8 e6 B+ ^7 r- A9 p! G2 l9 \' O schedule.at$createAction(2, actionGroup);- A& O) l! t3 Y; d6 n* R( r
" w3 u N; j! [3 n& F5 q1 M3 W* ] } catch (Exception e) {! ~' m& ~4 V [9 h, g+ X
e.printStackTrace(System.err);
) X4 ~2 |; s0 k8 N# B3 v4 F //System.out.println(e);
) \9 J4 g4 E0 I5 H: M: V System.exit(1);6 H3 }3 a; G6 T2 Y
}
) g+ U* c! m9 h( z B+ ?
6 ~4 j8 _, Q. D- |8 G- _7 N7 p2 U3 u9 W
}* i9 T( c. \/ J0 e% p1 Z, O. x5 U: K
4 e1 G1 ?9 B4 y; P) \$ x9 H! H8 g4 b) o
private void swarmSetp() { R# |7 A) l3 {6 o* V# T+ |
list.addLast(new Agent(Id));
- y- | G1 g1 t. w2 K' k t Id++;
7 F4 `7 W. W4 t" d }
/ q, b# s1 Q; p/ M, J; C) l% w, h. n
0 D% ]- t- ], l; R. S public Activity activateIn(Swarm context) {. D9 O, Q9 _% S3 t' \
super.activateIn(context);
$ i4 d8 O, C5 O+ M9 I schedule.activateIn(this);
o6 U. e, e) ] return getActivity();! K. ]" o6 [4 J+ s3 Q
}7 t- D$ f% T4 \0 O
/ _: U# f' G% C" [, {! R; R public static void main(String[] args) {
: H9 c( E0 Y2 B" f2 G% N# h Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);% y4 c2 Q6 I* q0 B, P9 T% \- v8 J4 B3 s
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
* b; I/ F. f$ W% z. ^+ W1 Q swarms.buildObjects();* {, f0 ^ \9 \9 `% g" p! \
swarms.buildActions();
, @ p+ q# f, W5 Y: m6 H5 H# ` swarms.activateIn(null).run();9 g7 S/ J% K: e- U
}
# S6 y/ G4 A; Q) s/ ^+ _5 l
2 P8 _! X; O6 Y O} |
|