|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
0 k. Z* r+ L6 R/ [" I9 F6 r5 \1 y6 m+ D# \7 e3 ^! a+ i
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
( l. w' ^3 B* {) ]$ ?% e. B+ x以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.' ~5 |) i( ^: Y, R0 R& ?! M2 R
swarm.SignatureNotFoundException
) |! x$ X+ I/ R+ ?0 ]0 P/ K; ]+ K at swarm.Selector.<init>(Selector.java:76)5 t' e) j: r1 H. g1 Y0 _
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)+ {2 `8 Q; \& r3 a& E
at ActionGroupDemo.main(ActionGroupDemo.java:67)
# P# D4 P$ ?2 t- W9 R- ^' `
. I# u7 K: F# j" N, {/ q ?; {1 Z) }9 }5 f5 s0 |4 Z
import swarm.objectbase.SwarmImpl;
# ~* x: ~* l0 T1 z2 |+ T ]import swarm.objectbase.Swarm;
. y$ A1 n. }# \. Yimport swarm.activity.ScheduleImpl;
3 y) D# h8 k$ S- R4 Q; j, Q( |$ Qimport swarm.activity.Activity;- b9 N, _; s2 H" z8 u9 T
import swarm.activity.ActionGroupImpl;) H$ e v. l' {6 q- Q( |7 u
import swarm.collections.ListImpl;
0 X: _# G! b0 C# Gimport swarm.defobj.Zone; 4 u2 u$ D( I6 }/ {+ F! ^
import swarm.Globals;
7 A1 n! D; o( J" R7 K2 C% mimport swarm.Selector;
$ C2 I& c) t) `* r9 ^7 @import swarm.activity.ActionGroup; 1 L: q' u' G4 q# v; Z! M
class Agent {7 T0 [2 e* K, H. `
char id;# o c% w5 a* Q+ l" R& ^
' z0 u/ O3 W# I0 K
Agent(char id) {
0 {1 x) Z* {, N( h- i0 M2 Z/ } this.id = id;- E% L/ y( N1 k: k- K- u6 e
}. p( _: N, }0 L1 f3 ]) F/ h: u! l
% [2 r$ F9 i0 f( S) `
public void agentStep() {* g$ G5 I, u R6 @- s6 K
System.out.println(id + ":" + Globals.env.getCurrentTime());' ^) t( O: g+ o3 H, i4 J
}
- {6 A) j- C% s0 J% y+ O}
" g* Z: ?3 x. j8 S/ t" E( V, |4 o f% ?! y
public class ActionGroupDemo extends SwarmImpl {9 y+ C O# u$ G: k3 [+ P; L
ScheduleImpl schedule;9 } o3 t4 d$ @# X6 k/ O
ActionGroupImpl actionGroup;4 a* |' [; ?0 S, x% N9 V
ListImpl list;
! j, K0 i) V4 O5 A char Id = 'a';
) N: x8 l; I& ^. D! [( {3 w) N' G+ Y/ h$ n
ActionGroupDemo(Zone aZone) {
8 P* J! X) t! _7 j* x' A9 @ super(aZone);
8 h5 g, M% V/ l }0 S8 x list = new ListImpl(aZone);
" d V( b; `% k( `$ A swarmSetp();
* a5 j1 n& H8 @ v, n actionGroup = new ActionGroupImpl(aZone); C3 ~2 P- [7 F* _! H
schedule = new ScheduleImpl(aZone);
6 Y/ r1 }; V4 d try {# d0 f1 a9 z2 \) v* g( `8 J* m
Selector agentSel = new Selector(Agent.class, "agentStep", false);
4 h3 u* _6 }8 Y+ U/ U- Z. h' e Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行# U# k0 k5 p2 y7 [4 O5 A
) C6 z0 w7 A& \6 ~# v' R, V actionGroup.createActionForEach$message(list, agentSel);
" C) d) O. ~2 H7 C0 A" s& H actionGroup.createActionTo$message(this, swarmSel);' x5 s' }' e W0 u
schedule.at$createAction(0, actionGroup);" [, h6 s3 b: z* O, i
schedule.at$createAction(1, actionGroup);
9 _7 i, s0 V9 I5 Q0 R; K. i schedule.at$createAction(2, actionGroup);
8 p+ r% m1 N7 y: B1 l1 Q& E: \+ K2 o) D$ p
} catch (Exception e) {/ m# j& H2 s, D# d
e.printStackTrace(System.err);0 K- z7 s6 I3 [6 I, H6 \: b# U, |: |. u
//System.out.println(e);2 G$ d/ ]& u& l
System.exit(1);/ v$ O8 F+ Q0 Y8 K0 x- N1 J# P8 U6 X( J
}
6 y" Q5 j& w/ X4 g; g8 [
; F- E" D k4 e) w; x$ {& D, I$ g O9 e
}
7 ^5 U. H, q( O8 ~
* L) f) j5 Q2 I0 U# w# u private void swarmSetp() {
/ v k$ c7 T# E* c$ | list.addLast(new Agent(Id));) u$ }+ N8 \0 Z
Id++;) D e! \. J/ y2 a
}: ^: k" [; e, B7 r! b: g0 g
- Q3 Y. z# |( ` public Activity activateIn(Swarm context) {
# `9 g2 a8 L5 m4 W: G) S super.activateIn(context);' R/ ] o- D$ ?' x- D' i+ m. p$ p
schedule.activateIn(this);% k8 M, j) K' t0 Q4 ~
return getActivity();
7 ]' {+ ^5 [) t. N j; w! p5 p }# }: z9 u4 _/ a. ^8 @
6 B; f. y* T2 B& C( T, l public static void main(String[] args) {
$ v& N* |8 f0 @+ H% ^ Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
' k% H. |3 i) }# I Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);; g; L) H: M+ c% j/ F
swarms.buildObjects();7 K# w! @* S! i+ b' {
swarms.buildActions();( o+ M7 O0 P' Q2 O* v* U
swarms.activateIn(null).run();
( j/ C1 t: |: B% X }
3 V" I. l5 Y; q9 H. C! M$ @" P7 X
# w: ^4 u1 ?, V" l( ~3 j0 P} |
|