|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 Q# _( T' a7 `& I% c2 s( e
5 T6 W3 j- ]- B& `8 t本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
; R, ?9 ?; m5 S$ [7 L4 D$ _以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
. a1 l, V/ n+ g8 J$ Y% s! bswarm.SignatureNotFoundException
/ R1 E* }9 d+ `0 j8 u9 Y at swarm.Selector.<init>(Selector.java:76)/ i. `& K: E) k
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
9 O/ a3 e% `% J$ O: X# p) e9 D S at ActionGroupDemo.main(ActionGroupDemo.java:67)
9 ~2 r% T& L) P) | X- n+ S* J; C: e" L5 t; a$ N+ \
0 @, j' M3 z' z% N, [import swarm.objectbase.SwarmImpl;
9 [* w$ _7 b$ c# _import swarm.objectbase.Swarm;
/ {2 T8 v9 {0 Rimport swarm.activity.ScheduleImpl; b$ O( a2 i( |* p7 F0 h
import swarm.activity.Activity;
" Q* ~5 m4 t- ]import swarm.activity.ActionGroupImpl;
( @. ?. G6 @5 L, Zimport swarm.collections.ListImpl;
, ?. V, R8 j! T- n! Y- Yimport swarm.defobj.Zone; 9 z. b' Z( s8 Z M1 t
import swarm.Globals;
* c$ i+ j" M. B0 }2 ?import swarm.Selector;( t0 U1 a- A: u, }) F6 {( D
import swarm.activity.ActionGroup; + V# C; R' w0 U) l7 C Q
class Agent {
) W& M! L1 g9 e+ c3 h* H6 v& F* V; n char id;. n: t' B6 x% c' ^2 v8 C
# F8 `$ C8 c; A Agent(char id) {
1 }, @) a, M4 p/ X% } this.id = id;& U' S1 ~: N/ Z; k- |
}
1 H( r. H& M; m( q O8 ]& g$ B" V
4 f4 D, U/ h8 _! h" V public void agentStep() {
3 H3 `) ~+ c: t# g7 x System.out.println(id + ":" + Globals.env.getCurrentTime());& i( _; g; G S; W$ N
} o' o- ?' x6 L* Y% O1 k
}9 Y! B6 r1 Q9 P7 f8 t; r
$ X! H( E% [9 u+ {. D
public class ActionGroupDemo extends SwarmImpl {8 j0 m: Z N1 V
ScheduleImpl schedule;, q0 T4 S0 P* e) x _! S2 Q3 c
ActionGroupImpl actionGroup;
$ u/ O9 z3 M% m. }" e! u! H ListImpl list;! Q6 c; i& `( n/ z0 L
char Id = 'a';
( x# s8 l" ?6 @0 l }0 D7 Q3 ~' z2 H+ k' q) G4 |: P& C
ActionGroupDemo(Zone aZone) {
) B, U& @7 @7 `# k' k, U super(aZone);1 @& \# {) Q2 ~. |6 o f! Q
list = new ListImpl(aZone);1 v. n2 D2 j0 H9 i1 f: @, i% _* H
swarmSetp();
* W; c0 d0 l% d* Y2 d/ ^ actionGroup = new ActionGroupImpl(aZone);
0 A6 H- T# Q: \$ {; O. d8 J( | schedule = new ScheduleImpl(aZone);. g2 j1 W6 s( }; t/ ^6 q
try {8 r! Z' M8 x, I4 A
Selector agentSel = new Selector(Agent.class, "agentStep", false);3 _1 n8 m4 Q3 s/ V( |( l7 l# x2 F
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行4 ]8 i$ j% Z: A$ [9 i
( N9 k& Z; ?, B1 ^ `4 C5 x% d actionGroup.createActionForEach$message(list, agentSel);' i' X/ F2 M' K1 O2 T
actionGroup.createActionTo$message(this, swarmSel);5 B+ p; }, t0 W8 {1 u% L/ {
schedule.at$createAction(0, actionGroup);# P& x" N: B) b4 L8 k) ]+ p
schedule.at$createAction(1, actionGroup);' W+ b8 F; ^: t: k0 H
schedule.at$createAction(2, actionGroup);3 j8 @3 Q4 r) P6 Z7 I
8 |; ]/ m1 r5 ^3 a. H4 p1 O
} catch (Exception e) {
" R- J. S) Z! s/ x5 \1 W' z e.printStackTrace(System.err);
7 m% }2 D; a9 |! w, W7 x. i //System.out.println(e);
0 Q' W. n" O1 y' x0 f; x System.exit(1);1 @% T8 {1 n4 g! |# H" V) k
}8 J% K ~& L' N
- t( e4 c7 U/ a) b6 z/ p
1 n3 ^& ^+ w, ` w }; `# w2 t* A9 Y* R# k
# ^0 ~6 ~0 k0 s! d3 P5 `) @8 L8 u private void swarmSetp() {
1 D0 Q% g* S% f7 H9 ?9 L6 Y list.addLast(new Agent(Id));
* U+ [# Y% |' U9 C0 N z Id++;9 {9 _ i* V9 a/ m6 ^) b' X
}
B, Z! w4 y7 F3 f/ @4 j2 ]
# q$ H- l) f7 U8 x public Activity activateIn(Swarm context) {
% B0 c0 w7 y1 z6 k super.activateIn(context);
, m/ B# l/ c3 K# N; ? schedule.activateIn(this);
3 r" R1 E& ]6 n% W# K return getActivity();
' h0 H0 X) ~/ o- a0 K* D6 r8 X0 J+ H }
4 p( C U) ?( T$ s9 K \% j) V+ Q2 W0 i* D3 Z% v! {/ L) J
public static void main(String[] args) {
! |9 s0 I& h. R) u. {7 k Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
- V% w% o) k9 _* x9 J2 B) q% X Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
) ^! [* ^% @! V2 u2 L0 | swarms.buildObjects();! o0 Q) p) U$ U/ t) W3 I
swarms.buildActions();1 V+ p: t K% E. x8 A! r3 N
swarms.activateIn(null).run();3 u. `! M2 n0 q6 n
}
. c$ a; o) o. [% i" A9 \/ U5 I6 P3 H( a: _1 D7 k* s% F
} |
|