|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 3 b$ F) J! q2 `6 _) }
- k% z6 k$ M" a8 o/ n
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
H0 B( J% u% O M以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.5 r. `8 N: \6 m6 k7 ^; {9 L E
swarm.SignatureNotFoundException
4 j: Y, ^, B) t1 C5 ^/ n at swarm.Selector.<init>(Selector.java:76)9 M6 w9 r; `( u# g
at ActionGroupDemo.<init>(ActionGroupDemo.java:37) P6 m$ `# b" S* o. B7 _
at ActionGroupDemo.main(ActionGroupDemo.java:67)- x* s. o* @2 e% ~& `, m
0 L0 X( v+ X" E/ c" U
0 u2 \" J: ~; u4 j. Oimport swarm.objectbase.SwarmImpl;
' y9 ?* _' {/ ~2 K+ `/ Gimport swarm.objectbase.Swarm;3 Z9 O$ q3 g; N: u$ Y, g+ A
import swarm.activity.ScheduleImpl;0 y$ m, f; X* p3 g# l
import swarm.activity.Activity;
1 g' Y1 V- k: G3 mimport swarm.activity.ActionGroupImpl;" N' L' r% Y; e/ T& K
import swarm.collections.ListImpl;
* [, A) d9 F4 V" M5 t) Qimport swarm.defobj.Zone;
& F* c2 _2 {7 Limport swarm.Globals;
2 c: ]2 ?1 u9 a! _, G. q) himport swarm.Selector;
& o4 \, s/ e w) ^; Dimport swarm.activity.ActionGroup;
& a: a+ W) W5 O& gclass Agent {
( e& V+ L) t: d L* Z, r char id;
9 v9 D5 |$ {: v7 i/ f0 |4 ]% ^: G
Agent(char id) {& | E3 b! O& [& r4 C1 B* k( g
this.id = id;$ k M( `1 Q/ w- B4 k' n9 F- d
}
$ X+ m; p% X1 [) n1 B' Q }" c: J/ \+ Z# Z" @
public void agentStep() {- p- D/ d( m B* |6 N
System.out.println(id + ":" + Globals.env.getCurrentTime());
4 W* X) t- U, f6 q8 s }' F$ r5 h; l! t1 D& y0 q
}- E8 h! y. x4 b- `1 q! U" j. m/ M
3 e, ]8 B& b% j* a* tpublic class ActionGroupDemo extends SwarmImpl {
) e G; q" B; f/ w2 I1 f9 h5 N ScheduleImpl schedule;
$ B7 H3 P- _1 C& ]: h ActionGroupImpl actionGroup;' Q) f+ q6 f# f0 B
ListImpl list;" v" ^9 I6 ]2 n9 B4 \7 i$ V
char Id = 'a';- p' p" J6 w/ [; D+ b2 R
7 P5 S) j8 v0 A: ?
ActionGroupDemo(Zone aZone) {
) G% Q* Z8 Q$ i2 j( w+ f super(aZone);
8 Z) D. F! H @ list = new ListImpl(aZone);
' q: N% Q& I3 L) p swarmSetp();3 P6 d7 [$ u, X( w9 C* L
actionGroup = new ActionGroupImpl(aZone);2 p. M6 R6 U+ q! t
schedule = new ScheduleImpl(aZone);5 l/ [; w+ s9 ~6 z/ ^) U
try {
& @7 {( Q7 g, |# w Selector agentSel = new Selector(Agent.class, "agentStep", false);: a& q& N3 P/ _, F
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行5 s8 ?5 w! N6 `2 @# u0 U
/ z3 a( Y$ N- W# T actionGroup.createActionForEach$message(list, agentSel);& }% i9 ?. T5 k( H% v* t* G; G
actionGroup.createActionTo$message(this, swarmSel);9 I @8 d, S0 D% R
schedule.at$createAction(0, actionGroup);
9 \$ k# [8 ?% } schedule.at$createAction(1, actionGroup);
! \* }: e, K } g1 i4 X% s' } schedule.at$createAction(2, actionGroup);
+ g( O% i" s$ q. t( B4 y1 B- i0 L* g: A: X4 T
} catch (Exception e) {; b/ d9 I6 ?8 N( g& _6 x: S
e.printStackTrace(System.err);
- W+ f: j6 k- {4 x% f6 ^) z+ N5 ^ //System.out.println(e);1 o5 f; K, V8 d: V
System.exit(1);/ Y) G- e3 {8 B! f! H+ J
}
! K e: d9 x; r$ X- s
x+ w6 [; k! I; j- O0 S2 l9 T8 e( h7 C3 o; s e
}
. K0 T" \* S5 |/ [3 U1 i& m
. n# c6 i* V# u7 G2 N5 v- S private void swarmSetp() {, y+ i+ h$ ]6 L
list.addLast(new Agent(Id));8 n# u/ {; w4 k7 w# q( ^: Y# l
Id++;* o# C, ~; l( q
}
2 v! M# e3 t0 _' f+ N M, E/ f r+ a3 x
public Activity activateIn(Swarm context) {
8 T/ j1 e7 A6 `( f. a( ~ super.activateIn(context);
; v0 \; ~0 z" d+ ~# y, [5 z- N6 H schedule.activateIn(this);
5 r* G3 o2 c, @) A! b0 A4 S0 A return getActivity();
$ S8 e. T9 Z3 y# K f4 S }# @6 W7 q4 X3 ?/ n% ?
$ J. z6 r7 ~' f- k
public static void main(String[] args) {$ ]9 p4 K8 J$ r9 F4 _6 j( f9 Y; ]
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
% r( V/ F% Y5 r# y: Y8 g3 F Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);3 i! g# W5 _2 U/ p7 \5 I/ P
swarms.buildObjects();7 B& s5 J- ~1 C9 M5 v5 M9 u6 g
swarms.buildActions();* k. B; i& t; X/ S* i/ P' ?
swarms.activateIn(null).run();
; C+ Y8 y6 }7 s( F! p4 J% a: f% A }
9 C8 H& Y R0 v" a8 @
: O3 R; Z" ^7 a4 u" t- B B# c} |
|