|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 # H0 t# S5 ?0 D! ^6 u( `
" @0 O% D3 \4 s! Y5 w% X
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21" G b9 i8 J% i* ~' l. Z6 z) z9 t
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.- B+ Y9 b3 f: g2 e
swarm.SignatureNotFoundException
/ J8 ^# G! B8 M1 Y/ | d$ j- K; U at swarm.Selector.<init>(Selector.java:76)
8 R. n+ z+ ~/ C- [1 E+ @ at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
. c- i. ^4 Y* i# o* } at ActionGroupDemo.main(ActionGroupDemo.java:67)3 h" ?) E1 `) u8 V, W
( }/ l8 q& S/ ^+ Y7 }
1 `9 |& k' @& h9 T- D7 Wimport swarm.objectbase.SwarmImpl;
3 }; {: V0 f1 a* {import swarm.objectbase.Swarm;5 q+ B. D* D5 S1 S! P
import swarm.activity.ScheduleImpl;
8 d: g/ x/ b" q# Oimport swarm.activity.Activity;
0 M4 V: b, }+ @: ? O: Uimport swarm.activity.ActionGroupImpl;
+ V7 Z5 C7 [! ^1 o! X& I* rimport swarm.collections.ListImpl;
: ~1 T/ L% y3 e9 r' ]% ]5 iimport swarm.defobj.Zone;
4 H3 i' E) E) _! v) ^4 ]import swarm.Globals;
5 l o8 M- t7 |3 T2 Iimport swarm.Selector;
+ G4 H: h$ i& X/ O$ D$ d; I iimport swarm.activity.ActionGroup;
( } j% ^5 W* qclass Agent {
# F+ L. J0 G9 u char id;( T% K, ^8 E2 A
; J# F* @; d$ z
Agent(char id) {
+ @, S8 c# P# X3 {9 y& b0 r& H this.id = id;6 P! S7 j6 h5 r# Q! \- i+ N% Q
}
0 l* M+ @+ R% p8 ^' B( u" A2 Y- g7 Y7 {4 A% [
public void agentStep() {1 W0 f6 m9 X$ U0 c
System.out.println(id + ":" + Globals.env.getCurrentTime());
* ]/ ~" f* [& _& P1 s/ ?# u }
+ J5 H" g& x( Z}4 t6 D4 f; d n9 W
3 L8 d9 P3 l9 [6 e8 q
public class ActionGroupDemo extends SwarmImpl {
: s0 q2 v9 V# z1 b( D g ScheduleImpl schedule;1 {! m) r7 O1 T% S
ActionGroupImpl actionGroup;6 H. G; c1 n5 U
ListImpl list;
; P( D, I3 M6 r% X char Id = 'a';9 J( W/ _8 V5 x2 @1 r4 B: M( } |
) A. c/ H g) V# Z6 i# S4 G; M
ActionGroupDemo(Zone aZone) {4 ~/ f+ F7 z7 _; X) j" l% @
super(aZone);
8 l4 D4 R6 U3 H list = new ListImpl(aZone);9 `0 [- N5 W$ p. Y) T
swarmSetp();
8 F3 s* b" k; v! r actionGroup = new ActionGroupImpl(aZone);
1 D- n( }( a6 l- d7 j2 y) d schedule = new ScheduleImpl(aZone);3 n1 e( {3 w, L& ~1 I/ u
try {; j1 L- L, K: U! S3 y. t5 s7 l( K. s
Selector agentSel = new Selector(Agent.class, "agentStep", false);, H5 x- s2 U3 @# c
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行* M. o- N( ]4 b
( `" T: m* {! X/ L& L
actionGroup.createActionForEach$message(list, agentSel);
) E8 z3 d, q% i actionGroup.createActionTo$message(this, swarmSel);
& M1 t3 @: l6 q. k2 Z schedule.at$createAction(0, actionGroup);
; A% p& V/ G( h. W0 e0 e% e" A7 h1 \! x schedule.at$createAction(1, actionGroup);
2 G$ B" D( U- s( A- P schedule.at$createAction(2, actionGroup);: z- Y$ d5 J5 n
' x. ^! J& L- Z, G0 g/ \- d$ k# ] } catch (Exception e) {
) `6 D2 e% e2 g e.printStackTrace(System.err);- z! i Q5 ]# V# E
//System.out.println(e);
, R, \6 r. G" l+ d2 O, Y System.exit(1);
1 h! c C$ L" `7 W8 e }. G; X# C8 c( W( s
4 m, d0 ]7 n1 M: `; Y' ?, v& Y/ r+ i
}
' m4 t# t2 G8 E& `0 X: S X# @8 v- C- [6 y! k; Y, H, V
private void swarmSetp() {
5 W8 a) u+ V7 K+ f3 r list.addLast(new Agent(Id));- Q7 D( o3 u4 c2 |, `4 ^4 q
Id++;
# W& x: t2 h/ a }
6 U4 e/ f# l m2 Q" s+ f: P
* O2 O: }" M) _1 H; P public Activity activateIn(Swarm context) {8 p# L5 E$ b8 L) D% n+ w3 I$ g, @7 @
super.activateIn(context);
' j/ F% x, x8 V1 x schedule.activateIn(this);& u4 H- c1 ]0 D3 o0 t# P! n
return getActivity();
/ }! _5 A# F; h& l/ D }9 e. M6 M0 L! g4 _# H- U3 m6 X
' S) W* ]2 z9 ?: Y3 V* S% W public static void main(String[] args) {
Z; A% V* G: y8 D7 K" j Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
' Y4 A. T a% T Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
4 m$ Z, U2 {! F! }, d; ? swarms.buildObjects();/ t( `* }7 r. ^( j/ v
swarms.buildActions();
; T1 m; I) z6 r2 ] swarms.activateIn(null).run();* ]5 l7 e8 y9 {# L1 g+ G8 x, t
}( s1 ]; \: L [& N
; m6 k" s) T! \
} |
|