|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
/ j* p N2 p/ _) b- f! O4 T3 v8 N
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update210 q9 i- l" M' ~# Z/ I. N6 H5 b
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.* P- W+ u. a4 W
swarm.SignatureNotFoundException% ~$ _) [5 G& E/ b0 {( J
at swarm.Selector.<init>(Selector.java:76)$ \: M- B/ c3 ?2 w
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
$ v& }7 D3 n$ \ at ActionGroupDemo.main(ActionGroupDemo.java:67)8 L+ a. V/ a# ]" u3 t, b @) a
# Z. a2 L) a/ v" [0 D
. ~: ~* q/ ^9 Timport swarm.objectbase.SwarmImpl;) S: L7 ?! A9 o' f
import swarm.objectbase.Swarm;
d Q. D1 M* `! S4 Simport swarm.activity.ScheduleImpl;" Z7 ^) N$ w P7 |$ N: e
import swarm.activity.Activity;
( f0 X" R- q4 R$ _6 @( W4 G, w( u4 Simport swarm.activity.ActionGroupImpl;+ h, f5 P- o0 \
import swarm.collections.ListImpl;' ]$ l" o" K* @0 @" T- N6 d
import swarm.defobj.Zone; & u" ?, g7 n6 j2 B% g8 x: x S& a
import swarm.Globals;
0 I5 B; H& B- f' _' D3 `5 B# ximport swarm.Selector;
2 v9 ^+ I8 [# Pimport swarm.activity.ActionGroup;
4 W" q: s( P) {' w1 ]class Agent {, V5 s; E& M9 [" ~, Y7 A
char id;
& j* t0 @) q( Y$ L* B0 g& \% M }3 z- Y: L$ r. h7 X' a
Agent(char id) {& W+ a: ]3 S- l3 G I9 b9 `9 I
this.id = id;
8 _+ v& B N4 I/ b$ _. B }, w! T% B z+ M0 k: I
! h; I- T- O& p& j public void agentStep() {6 V* D6 G4 V, X! d1 N9 t2 [0 G" x1 j% X
System.out.println(id + ":" + Globals.env.getCurrentTime());
" x, Y" O9 m$ H) i4 J" k9 z% I2 ^" B }
" G+ d; @! [& j( z" R}
0 d; C# P+ M$ g& j3 x6 p# R2 S& G t6 T! B% k0 s* V
public class ActionGroupDemo extends SwarmImpl {
" `2 ^% B/ }/ J) X ScheduleImpl schedule;, ~% U& W9 I# B5 a7 q
ActionGroupImpl actionGroup;
: P( u/ s' G" Z, `% Z- L. p5 L9 k6 s( ^ ListImpl list;) h5 r0 K7 z8 g! I5 b1 @$ J& t5 V
char Id = 'a';" h' P) R0 y! d& }" _) m
5 K; y4 q* A n7 @# ? ActionGroupDemo(Zone aZone) {, e$ i& k P( [9 @
super(aZone);
7 |2 S9 w8 u3 o y- [8 o- ^7 A- y list = new ListImpl(aZone);4 g/ C% n. r, h' N
swarmSetp();( V3 t. o) K7 P2 C9 h, M
actionGroup = new ActionGroupImpl(aZone);
# l2 E- {8 p# R5 A9 I5 O schedule = new ScheduleImpl(aZone);
$ z/ D5 V% r& M/ C7 f5 Y) D try {
7 E7 {" v1 U7 @7 I$ B6 u; O& q Selector agentSel = new Selector(Agent.class, "agentStep", false);; P5 j6 V+ T% I7 {& ?' |0 C
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行* p. Y* z' b9 }7 y. \' o% D
, d$ ?- P, a5 A( x1 [$ G% `
actionGroup.createActionForEach$message(list, agentSel);: i9 T, A" i; h1 f, C, U5 o
actionGroup.createActionTo$message(this, swarmSel);" U% m6 \# J. _ u: B2 E! [- q
schedule.at$createAction(0, actionGroup);
; V# L* j0 D( P& M, J0 }/ K schedule.at$createAction(1, actionGroup);
7 W- L1 Q- U3 |7 Y4 s$ U schedule.at$createAction(2, actionGroup);" W y$ O* \1 \5 w! _, v
$ N; C, M8 w6 [7 F) M4 x
} catch (Exception e) {
; u$ f* [2 A9 w9 S% F2 ] e.printStackTrace(System.err);2 l; X0 r, A _8 K+ m
//System.out.println(e);
w$ |# g. Z4 L3 J% H: } System.exit(1);
0 M0 D* I6 y, K, _/ Z }
- A; G+ Z2 q) V) S6 K
" t- }- G% V1 U4 y( {. `! ~ c) |0 o4 V$ l# X
}
# Z1 [4 ?* k. \/ l3 L0 F: x$ y, z* W' v M0 C( J4 B @1 u& A
private void swarmSetp() {
( O7 S: ?5 j# H% H) V1 ?5 D# G list.addLast(new Agent(Id));, [* @ n# r/ o& M, U% ]/ Z8 R4 ]
Id++;3 i& N" O' w; ^& _6 d
}. X& Q3 O8 {# k/ u
, G7 y# d" P I1 G2 b; @& I public Activity activateIn(Swarm context) {
# i1 f* `- ]. s( e R. B( Y& v super.activateIn(context);
& |( a$ s& o6 |' y4 P5 e schedule.activateIn(this);3 }" ?9 U: l* I) e" \
return getActivity();
. [" \9 Q- v6 R }
1 `& W0 R7 K3 V# {1 @% K1 E1 V( A& e" f
public static void main(String[] args) {
+ b8 r4 i& W, F; g2 F f7 c# F" b Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);8 d- c. b- o2 z/ k* n& l
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
; u+ M% q8 Q+ ]- I9 } swarms.buildObjects();9 B4 r B& i$ C0 M9 `3 a) K' ]. E
swarms.buildActions();5 q3 Z5 x$ j7 x! i' q
swarms.activateIn(null).run();+ T* [. l3 q3 ]/ q# g
}
: Y( j4 B y/ n& X9 y2 _/ q& Y1 O; `1 t9 C4 C
} |
|