|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
5 ~. Q/ Q: O0 H/ z8 s' `
8 z6 J* |) _* P0 k/ f本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update217 `% T9 _' m! m. [) Q0 E
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
& f8 {+ y6 u6 v3 H7 o! p5 Rswarm.SignatureNotFoundException
' U8 _- m2 L: ~. N& X& ^+ F at swarm.Selector.<init>(Selector.java:76)
; m, b& w+ u( W at ActionGroupDemo.<init>(ActionGroupDemo.java:37). c* w0 T0 X7 c( d) |
at ActionGroupDemo.main(ActionGroupDemo.java:67)3 c" Q4 z/ S/ Z) K8 J
/ i- K& [( `& ^$ G
, w7 H. a& }2 s3 z- @0 j
import swarm.objectbase.SwarmImpl;
& D+ W. H% m' dimport swarm.objectbase.Swarm;5 t4 O& ]2 j8 J, Q. g: K8 k
import swarm.activity.ScheduleImpl;5 ^# t0 J. z% [- m/ a1 }
import swarm.activity.Activity;( Y8 Q: M# c( z+ f; y& o
import swarm.activity.ActionGroupImpl;
. V7 M8 x: v3 F6 C2 o1 e0 s' t# `0 ^9 gimport swarm.collections.ListImpl;
+ L E# h& i! F1 v$ P kimport swarm.defobj.Zone;
/ q; M7 j9 z6 o7 u- Limport swarm.Globals;
6 t& j2 C9 ]) t! ?import swarm.Selector;
& `, B. K; y3 qimport swarm.activity.ActionGroup; . Z1 B3 \3 f+ r4 C( E5 J; {/ Z+ v
class Agent { h8 ?, V% v3 t& `, n5 [- b9 a/ l( j
char id;
0 w b& h& F3 w" f% Z. ?$ Y# w; N/ r! E& ?- J
Agent(char id) {; W- S1 H* L* G7 P! N/ C& m1 V
this.id = id;4 H5 D/ ]) }+ [% E
}
) m) X! @2 R2 D
4 O% x, }% R$ L+ t, O$ e0 q$ ]! w& c public void agentStep() {6 `4 ]+ V. b) M1 R3 R7 e2 S) S
System.out.println(id + ":" + Globals.env.getCurrentTime());
4 ?6 _8 a: Q. d( V8 V% Y" ] }' f! u) b8 L& C7 N; D. t
}- |) B q4 n r2 R- W6 w. H( x `
3 B0 _* @ ]- c1 u1 P9 J& {( F/ i
public class ActionGroupDemo extends SwarmImpl {
; E: {1 a9 R4 v: U ScheduleImpl schedule;# ~, {) }+ j& P" Y# i7 h5 H6 Y
ActionGroupImpl actionGroup;3 Z$ }$ ]+ |; w- W) z
ListImpl list;
7 T$ U; t$ l1 b5 K1 ^ char Id = 'a'; d8 O7 y1 ^1 Z( H! U
) s& {) i, v- C% K
ActionGroupDemo(Zone aZone) {! e& [+ `5 T; P9 o5 I! r0 m% U
super(aZone);
, a7 t& M, P) G1 y list = new ListImpl(aZone);
h" b* T4 |4 c; g2 T! i swarmSetp();, Q; v& G" d6 h1 P7 l. N
actionGroup = new ActionGroupImpl(aZone);5 u- P7 V: P* k
schedule = new ScheduleImpl(aZone);9 a, \& ^ x4 g' R5 r; C( t9 Q
try {
; `8 T; E4 N" [( x8 f Selector agentSel = new Selector(Agent.class, "agentStep", false);+ g. D" W1 P. Q' \6 }9 \
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
/ V; Z4 N2 Z$ E5 u' U # X5 g7 A. u3 n5 |
actionGroup.createActionForEach$message(list, agentSel);
0 {) o- N* H3 c( a actionGroup.createActionTo$message(this, swarmSel);
7 b8 H# ]% s4 M3 k( j" G" F schedule.at$createAction(0, actionGroup);- t6 E& t) z' B. M: A* ~9 d2 i
schedule.at$createAction(1, actionGroup);3 P. w. f; F5 t$ }6 y& X/ ?4 H
schedule.at$createAction(2, actionGroup);
3 r3 V, J P0 ]9 S' \
2 A: F8 ^. y3 z$ [ } catch (Exception e) {* ]8 ~: n( t( `/ }
e.printStackTrace(System.err);; Z4 r6 I* W" L" b. o9 {& D
//System.out.println(e);
) T" v z$ p8 J System.exit(1);
: I3 ^* H' y8 D& u }
/ @/ ?. {9 e; k+ K) g
' X6 E9 w# I- Y% w1 j# p# n- ?8 N- A& C P( D# I, r4 I7 X
}
+ s/ n' Y) D9 s# ]( N+ Z& G; f& j! e+ ~) @% F
private void swarmSetp() {4 F* B" ^- U6 L. f+ p9 D7 h
list.addLast(new Agent(Id));
2 M* N& G) E' h' z) p- }& [ Id++;/ |2 V! h7 w3 [6 @, h4 M+ T2 w
}0 \' C2 V. \7 E4 t( x( B
) i% |( i8 e& P public Activity activateIn(Swarm context) {
$ ~+ u- Y% L. J' P super.activateIn(context);
* E/ ]3 i1 d7 @. I' a# W schedule.activateIn(this);" p6 j, y% Y) K$ U
return getActivity();. X R* e6 M9 l" g, P
}
4 j7 @& I4 |# K" j/ |$ }, ~6 h, ]* \
public static void main(String[] args) {
1 e3 F; ~9 V* `; s, d Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);2 t1 e9 Q( b' q( g; M
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);" w! @" o9 E9 W9 `. a+ R5 Y8 y
swarms.buildObjects();, P; f0 s& g0 E6 x
swarms.buildActions();' A6 a0 @# L3 h0 g0 }6 E
swarms.activateIn(null).run();0 ]6 c# M3 h4 w9 S% n7 h
}8 a q8 V4 X% x) C; _) _
1 o" J9 R1 s# W3 i& u4 |
} |
|