|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
3 q) ^7 _. Y# C8 K2 a6 z3 t8 Z* P: ] }
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update218 ^: P: M( D/ u; o
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
! Y9 _( H5 {5 Q F5 Fswarm.SignatureNotFoundException
. M. r! j; L' S0 R- K at swarm.Selector.<init>(Selector.java:76)
4 B) l% g- a4 G& Z) \ at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
$ f0 R" b9 y9 Q* b [. \8 a8 N at ActionGroupDemo.main(ActionGroupDemo.java:67), O) I3 a) O) t8 j' [% W9 [
$ [( H) H# p+ V# m9 M8 u0 X
. \+ e; ~) O9 ]9 }
import swarm.objectbase.SwarmImpl;
, a/ {* _$ m+ C# \) ?5 z5 himport swarm.objectbase.Swarm;5 b" ]( C" P1 n+ b. W; ~' ?
import swarm.activity.ScheduleImpl;% m. L) X, r* x: D9 b- J( U
import swarm.activity.Activity;
. B1 ?$ t& c# Jimport swarm.activity.ActionGroupImpl;: R" e% l% T& Y |' g$ q
import swarm.collections.ListImpl;
6 H2 E5 z4 A k b0 s7 \' H# B" timport swarm.defobj.Zone; [" [+ z! H! D0 Z9 @& {
import swarm.Globals;
' ~4 [$ X1 o9 ^8 K7 h& p1 a$ jimport swarm.Selector;5 X7 y% }1 x5 Q1 M0 y( X- \
import swarm.activity.ActionGroup;
' N7 z. b- p# g) T+ N x) Q9 s0 jclass Agent {$ m5 @" Q0 S# Q8 R8 e% u; L8 e
char id;
/ X5 _+ r5 D9 m) o
- U* W! K+ s& [) Q* B0 A: w' v% [7 A Agent(char id) {( U9 E, I8 r- L7 g% l) r
this.id = id;# V5 t u) @, \- Z
}
: I5 d$ H5 y5 x$ v2 v3 y
6 [6 z0 Q# ~& x8 P4 I public void agentStep() {
$ @+ E, w/ h3 j System.out.println(id + ":" + Globals.env.getCurrentTime());
0 o9 k, }7 E4 N: w2 \2 j ` }
) `$ h1 _& F3 }6 |}
( E- p `. Y2 z9 o8 R% P4 z1 m; W4 ^2 ?' l; a D' h
public class ActionGroupDemo extends SwarmImpl {- N) v" x" m3 P& A
ScheduleImpl schedule;" Z F6 |# s! R+ J' z. m
ActionGroupImpl actionGroup;
+ p: i& A( t2 g/ e. H& Y ListImpl list;; A& G5 n; E1 |6 P. b; ^
char Id = 'a';
0 p# K2 w4 a9 v8 X. M
# }7 n3 }2 a+ a1 s ActionGroupDemo(Zone aZone) { q0 D3 g3 Y: D8 N5 m2 {- Z
super(aZone);
4 p# |- d) K' w" I6 Y5 a/ m* j list = new ListImpl(aZone);& w5 w+ A5 C0 r
swarmSetp();
9 k2 u, }0 o+ a6 ]1 x( u6 y3 A+ }% m actionGroup = new ActionGroupImpl(aZone);$ u d. t" r7 F' m. [" A
schedule = new ScheduleImpl(aZone);! Z! N" ?# F; @2 y* L1 q/ u9 X( {' I4 }% o
try {
# ?9 i" B: `% F; M4 [; t- v. W- y Selector agentSel = new Selector(Agent.class, "agentStep", false);! |: R" z* y: }! w; I" ]; g
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
$ h; O# j1 U2 k. ^6 F% | r- ~+ D( j5 K) q3 W9 n; f
actionGroup.createActionForEach$message(list, agentSel);
* S$ N2 \* S( b; x2 c1 L& Y actionGroup.createActionTo$message(this, swarmSel);
8 d* E# r# _% p: t schedule.at$createAction(0, actionGroup);. a% _- v8 g! u" g* S. `3 Z) g
schedule.at$createAction(1, actionGroup);% s3 L) X! {0 k6 T9 D
schedule.at$createAction(2, actionGroup);
8 J8 f! P: Y. H3 |/ s4 W2 u2 k4 F k) w* x% ~+ V
} catch (Exception e) {
4 h m: d5 E' N; v e.printStackTrace(System.err);
- U2 x4 l' G, c //System.out.println(e);
/ G- g' G* Y! z! M/ i0 ? ]; R System.exit(1);
+ F- G0 I' e1 n( c1 h# p }
, n6 R6 a& o, u# q R- A- I0 A$ k7 P) m- F
& L! E: u L$ s" m
}- Y3 e( g; x' B/ G3 t7 y9 J% X5 _) C
/ l$ S* b: \' d$ K, p; S \& D
private void swarmSetp() {. x! O5 p6 R% y: F, Y
list.addLast(new Agent(Id));
. \% U+ D! L3 j Id++;
# ~( k! o* K' t }
2 \$ T8 q8 S/ e) Y3 J b, o% W$ n. C% B' ]* P
public Activity activateIn(Swarm context) {" I* t( n8 S8 d8 V
super.activateIn(context);
! C n4 x- g( n; k$ y0 X1 n schedule.activateIn(this);
( ~' e7 m2 m, R% P, @. m; U s2 i' r return getActivity();
' `3 |4 g) a0 c, m }: ^& _5 w% B7 b$ ^9 q/ `) y2 l: z
1 T9 G8 F. C, m9 @# o public static void main(String[] args) {( d N' Q s8 F1 [: }' c
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);7 h( n4 F8 Z% s2 Q
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
+ t6 A. G! f6 R, q3 {3 M swarms.buildObjects();
, W1 s" l& l3 q. ?' D& U$ a swarms.buildActions();
, s) p9 {! |3 H4 k5 H swarms.activateIn(null).run();5 J t' |1 F7 B$ o; H% l
}
: f+ _( Y# _% O+ Z4 ?7 b3 {5 |/ [& o; X+ E( H
} |
|