|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
- ~3 C E$ s' r5 o$ B& r. D' R& `; u+ d
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
j* K; o. O) [- I" u以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.. U3 x3 k$ B$ D
swarm.SignatureNotFoundException8 U( T8 l0 S' V( w; `. M
at swarm.Selector.<init>(Selector.java:76)' t) c L U. H9 v4 A% F3 M+ E
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)' |$ L* l: _) u0 r" X& ~+ H1 r6 \' Q
at ActionGroupDemo.main(ActionGroupDemo.java:67)6 I `2 {* e% z u, V& y/ d
) \7 d3 i: D# z V1 w% x
3 \# T/ H8 J$ Y' G$ T5 O) d& }import swarm.objectbase.SwarmImpl;
, { a {% x3 g% L; b- x5 X, Vimport swarm.objectbase.Swarm;
- K5 ^% T9 I7 P1 c) x& Qimport swarm.activity.ScheduleImpl;
/ G: t- n, n* B* ~import swarm.activity.Activity;) U' |0 P( K5 {9 z" y
import swarm.activity.ActionGroupImpl;7 B! u1 N) b5 S. |0 n& ~
import swarm.collections.ListImpl;
z$ @) r5 ^9 \) R( Yimport swarm.defobj.Zone; % o, H! u* c8 T: w e/ f: u; a; |, l4 V
import swarm.Globals;1 }2 w5 h. O$ c1 B
import swarm.Selector;" M* z: s" V4 q3 D
import swarm.activity.ActionGroup;
$ j, L( X7 i3 Fclass Agent {
8 x$ A- L- @+ ]" M: |7 l char id;
) l( o2 t: J' H2 P
3 T$ R* b/ t" X+ \' z- f0 Q% { Agent(char id) {( N/ `8 r) ^( f& P5 R
this.id = id;
3 e+ V5 x4 W0 ]" c }
) K) G5 O3 [9 A8 f; ^
- F' w$ b, x, K \* t6 S public void agentStep() {& T; l, W, f5 P5 g5 i9 ~& N8 A3 t$ m: \: o
System.out.println(id + ":" + Globals.env.getCurrentTime());
( Q, h, |5 ~: A: I+ f }; w, e# x- s& `
}* h4 w0 ?& z& m2 T) S5 V. a/ z! H1 k
} @ l; I8 k) z
public class ActionGroupDemo extends SwarmImpl {
, b9 \1 p4 C& p1 j: |* H ScheduleImpl schedule;$ c; g) z) ^, V# U8 W. M5 {! p
ActionGroupImpl actionGroup;& n4 G* m& r# P% P6 Z
ListImpl list;, A2 C# O8 o$ P' q
char Id = 'a';
$ q9 s2 L! X5 W; X/ |( c" Y! T' S+ P0 K0 v' r3 m7 R
ActionGroupDemo(Zone aZone) {
4 a# |0 w* Q, G j1 g8 J super(aZone);/ }) J( o4 q+ ^8 x* |# L, O% Y
list = new ListImpl(aZone);% E$ R. W4 _* t1 G/ ^) I9 S
swarmSetp();
" K% q. V' r# s* [/ U actionGroup = new ActionGroupImpl(aZone); T7 |2 s! c4 U1 I6 O
schedule = new ScheduleImpl(aZone);
( D; J p) I0 [# K# ^ try {: ^* ^6 Y$ d7 H& i! N/ ~
Selector agentSel = new Selector(Agent.class, "agentStep", false);6 S5 i* T+ R( L f
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行2 i! L' Z6 T; S1 f R$ G
- ^, r' h& x: ?! Z5 Q
actionGroup.createActionForEach$message(list, agentSel);
' G4 y! d4 P' R6 {" ~2 P3 u actionGroup.createActionTo$message(this, swarmSel);
* Y7 K$ y0 e) f$ O& S- A schedule.at$createAction(0, actionGroup);: y. _+ F, u% u# `3 ]2 D
schedule.at$createAction(1, actionGroup);
) ^6 q# c% g' ~: C8 X) i' p schedule.at$createAction(2, actionGroup);: i3 s x6 E6 _) [: P! O* g6 N
" }; r/ b# w: }& l8 F P) z/ t* \ } catch (Exception e) {7 f* |) @+ L) Z) M, E L
e.printStackTrace(System.err);3 [7 l' Z0 r% H( Z; n, ~+ r3 i
//System.out.println(e);
0 R! y6 H8 a9 a& A System.exit(1);$ b* J7 t- D( l
}
3 @' `& h; ]3 t( J0 G7 P; H; Y; u$ @; }
; p- o5 I8 |: a$ G }
1 A; M( z/ ?$ E5 x. e# ^. X: ^2 f
private void swarmSetp() {
9 @# x! o6 S; \2 y list.addLast(new Agent(Id));9 A8 C! T7 m, p% q
Id++;6 ~6 H2 b" @# S4 w- M8 p
}
& t0 x& i p$ z9 |7 q$ c- @2 @& L! t$ z$ W( u! |
public Activity activateIn(Swarm context) {
' c1 U( z- M6 ]1 J super.activateIn(context);
{2 I( r4 Q# F7 H schedule.activateIn(this);3 o( J& Z7 B, Q( N
return getActivity();( K! r: k5 f% B0 P2 w# N
}0 v% q- j* m4 o- ]( K
/ B% T7 _3 J2 }; q( [6 x
public static void main(String[] args) {
/ u% h# T; ?* Z8 T; P Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);9 U+ q2 V) U1 s4 F1 [& F: [; V
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);. Q8 _+ c( h- z8 M
swarms.buildObjects();
! s- c) d- r3 w. ]5 b swarms.buildActions();. K6 V7 i, `; _; R
swarms.activateIn(null).run();
+ E, v4 U2 G+ J3 }& t, [, { }
; m" K1 A) @, i. [" w: a6 z, R/ v
- ?; o; t/ M1 G6 |; Z: A} |
|