|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 , W3 m5 v6 ~( `3 j H
) G- H2 T1 W! N, G; s( ?: g+ R本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21' U+ o k7 y! x, q
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激./ B1 y8 X8 O7 |
swarm.SignatureNotFoundException
; J A, a' F v: O/ ]! {& t at swarm.Selector.<init>(Selector.java:76)# @2 D; Y* {' R9 U" k
at ActionGroupDemo.<init>(ActionGroupDemo.java:37), r* `/ e0 ?; {" O8 q. i' G( Y
at ActionGroupDemo.main(ActionGroupDemo.java:67)& H; A, `: z4 i4 T5 ~) V2 y2 N
/ _! M% ]: E3 T: M9 L+ y3 Z
1 O* w3 ]) C8 @3 N4 |5 e: S
import swarm.objectbase.SwarmImpl;
; [( }9 s6 K) t" _ m% b! N" Dimport swarm.objectbase.Swarm;! V* Q- `4 |# w }7 h4 [
import swarm.activity.ScheduleImpl;) q) z7 K% [- t
import swarm.activity.Activity;
9 T# x$ F2 w9 x: [) F6 wimport swarm.activity.ActionGroupImpl;& `1 }/ i$ \1 Q! ]; N) W0 Y) J
import swarm.collections.ListImpl;
! ] e; v8 G3 u; ?/ ?import swarm.defobj.Zone; - P$ Y2 f% _4 V2 ?4 z. N! @
import swarm.Globals;
9 [& n4 b z0 e* Q, P2 v2 Oimport swarm.Selector;
* q( R, M2 S7 f& W, X6 Uimport swarm.activity.ActionGroup;
: ^* }! {; m, H2 y1 nclass Agent {5 o) A; q+ g( u) O) H1 `" W
char id;4 W) _6 Z2 T" p! N6 G9 J
/ E+ j+ r6 }4 W3 n' ]: J
Agent(char id) {# Z; w4 I# b M5 J6 ^
this.id = id;4 @% T4 F S0 r! ~, U- k
}
6 B6 B6 m$ _6 C/ a" U0 a; _5 D/ R9 z3 J' D; X
public void agentStep() {
1 t' M/ l( Y: n2 p) ^ System.out.println(id + ":" + Globals.env.getCurrentTime());
. ?' \% E, n# X" K0 C& s9 }; u }) h7 j* l: s6 i& P
}
) O8 m$ c0 f, T% B4 l6 g% U6 z
$ \9 f0 p N1 {% ~public class ActionGroupDemo extends SwarmImpl {
, j* K" n1 }( v0 X ScheduleImpl schedule;: W4 _1 C3 k, }
ActionGroupImpl actionGroup;
/ l8 o0 g( Z! A0 k8 W) o ListImpl list;
- N& [9 @0 e9 W1 e char Id = 'a';0 k1 N7 i9 e' ]0 u" S! F5 T
' A) R; T5 P) r! C- O# j: F ActionGroupDemo(Zone aZone) {
* h2 k$ E. g: l/ U super(aZone);
1 G2 w1 u2 t" \& Z- U, L list = new ListImpl(aZone);
& m+ y& J4 q5 j4 F. z4 y! @7 m swarmSetp();+ \7 _1 J4 H! h' f: B
actionGroup = new ActionGroupImpl(aZone);
f0 n- D2 }5 {* Y$ R schedule = new ScheduleImpl(aZone);
7 }8 M2 @. z' X* x, Y; I+ C try {- H8 C+ V2 q$ V: \
Selector agentSel = new Selector(Agent.class, "agentStep", false);1 A( c+ H1 f7 g! k" |& j: Z$ W7 @
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
8 c' T* M: o- e' Q( [ : I- k9 s! e$ M9 o: L
actionGroup.createActionForEach$message(list, agentSel);
1 t. s" ], n! p6 L; j( V/ ` actionGroup.createActionTo$message(this, swarmSel);$ h5 |, ^. E, t8 u# q* _( Z c8 T
schedule.at$createAction(0, actionGroup);
# T! ?" v$ D# h4 {+ s schedule.at$createAction(1, actionGroup);! n) \# V% m+ \$ b: w6 P5 f3 ?
schedule.at$createAction(2, actionGroup);0 ~6 L; r' r( k. _7 g5 \# [9 O
% b* _* K1 _# @1 ]' h0 {' c
} catch (Exception e) {
9 V3 O6 k5 L3 S. M% y9 Y e.printStackTrace(System.err);
8 S: K% r/ Y* U$ A //System.out.println(e);
- }+ V3 d5 w' M. \% f System.exit(1);8 ^) f! I5 B4 b
}
: U8 [) S$ j: ?
+ v1 m7 b0 t/ @
% ^3 r$ g! F6 D }
. O2 x4 W# F' p8 S8 j0 f: E
& m0 C. U1 e: u: q private void swarmSetp() {: e; V( K. g0 p/ Z+ J. @
list.addLast(new Agent(Id));0 r7 o( q3 ^% b; M& E
Id++;
& N/ g+ [2 I% G: v% t }! N: w; q: e" l2 [6 [
& g& C8 ?+ ]" g4 a9 M public Activity activateIn(Swarm context) {
) L9 n/ \, s, D- T super.activateIn(context);9 m4 u9 ]) G; R) D4 Y$ i/ T
schedule.activateIn(this);- d2 H" p$ s" V0 P. ~- H
return getActivity();
6 s7 l; U# J( {3 ^% V }! h& c- m0 |! V' K8 Y( @
7 L5 h# n1 q( i# R* c- k
public static void main(String[] args) {
: E$ [1 i4 _2 b8 I* h$ T! N Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);; u$ B0 K, s) J8 [, \; r
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
9 ?- u U1 c+ `) R) J" m6 h: ~ swarms.buildObjects();
; U! h, S$ v! k, w swarms.buildActions();
/ B' i! ^, N/ d: ^+ t, E+ a) S/ B swarms.activateIn(null).run();
4 m& z/ o2 N: L) K5 | }# l9 h1 }9 i5 j- Z1 V
3 f1 F: N$ ~' g} |
|