|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 - N7 W f% g/ A* n# @+ t8 u
% Q. \- |: v; O( m. {# l0 Q6 ~* V. e本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update212 I/ ?# }; [# l" H, _
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.* L% Z2 u$ E, k' L2 l" _
swarm.SignatureNotFoundException/ |' y1 q9 v) g4 d7 s1 W
at swarm.Selector.<init>(Selector.java:76)
* s. q8 d2 b* w# |! N at ActionGroupDemo.<init>(ActionGroupDemo.java:37)6 z) [/ X3 r6 o' u
at ActionGroupDemo.main(ActionGroupDemo.java:67)
/ x6 d% V7 o9 Z' L2 }! _# F& P' m0 E. }
. Y) u2 ?& S6 h3 Nimport swarm.objectbase.SwarmImpl;
% h: H2 ?( H. P; { Himport swarm.objectbase.Swarm;
; |9 c9 D: u3 ]7 ~. L9 A1 ^7 Aimport swarm.activity.ScheduleImpl;/ Q4 T9 {: e6 g4 G6 X8 n1 I( |% P
import swarm.activity.Activity;% O) t8 h1 _0 n' [. l Y' U# W
import swarm.activity.ActionGroupImpl;* l v) I9 P7 K/ J u
import swarm.collections.ListImpl;/ E9 J2 l4 t$ g. A" t1 y
import swarm.defobj.Zone;
, l# F7 l# H( u% n1 }import swarm.Globals;
8 W, F6 X+ a6 o4 g" Timport swarm.Selector;2 \* D2 C: ]- i' x# E
import swarm.activity.ActionGroup;
/ ` n7 P z: y+ Z6 U; {7 }class Agent {
# K% _& h8 Z: x7 a8 g char id;
& k1 I1 p6 L% ]: N$ f+ ?
" D$ a) K0 z* n- z" L L Agent(char id) {
' J8 c# |' Q- r! o this.id = id;8 P' m! P6 ]- g1 L( h7 J* I8 y
}/ o1 F+ v0 J. V3 _. y. i- S. X4 u, @% U
5 x. [' W5 [0 s/ E
public void agentStep() {3 A9 |6 t4 s3 @0 n b3 Q' w
System.out.println(id + ":" + Globals.env.getCurrentTime());
- g( {. i" e) Y1 q; Z- ] }9 l& E% k0 R- z9 }& u( }" Z
}3 X0 G+ _$ W% Y: s9 F- K) y: l6 {# F
0 d& e( Z+ X7 M
public class ActionGroupDemo extends SwarmImpl {
. g. z8 u9 S/ N) o ScheduleImpl schedule;
$ x: k% Q" x9 u. v ActionGroupImpl actionGroup;
8 t# E. ]- m [' `" B9 e* d ListImpl list;
" B% F5 Y+ b. p char Id = 'a';
' J) U& K. }$ V/ q# e
8 e% I; z9 E& o6 c2 K( y& h; W3 ` ActionGroupDemo(Zone aZone) {
! I- P5 b" U5 H! G/ l) K$ ] super(aZone);$ l/ b* |* N1 M
list = new ListImpl(aZone);" A4 N- d% Z& s8 y8 d v
swarmSetp();) u9 w" ^" b& Y9 p' H5 x: x
actionGroup = new ActionGroupImpl(aZone);3 h1 U9 T) s5 \2 n
schedule = new ScheduleImpl(aZone);; u* u/ [0 O5 O8 a5 S+ j2 @: I
try {9 o( F# k7 J0 S3 }: a
Selector agentSel = new Selector(Agent.class, "agentStep", false);
3 D j7 X& J* c* \; r, ]4 @( a& A& w Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行/ ^6 H- d; X9 f3 g
6 C1 d! l7 O E4 r actionGroup.createActionForEach$message(list, agentSel);
/ h0 d; \" C: U2 | actionGroup.createActionTo$message(this, swarmSel);
# k$ S6 f% i+ |+ p6 a schedule.at$createAction(0, actionGroup);1 b2 c# l2 e4 @, o
schedule.at$createAction(1, actionGroup);
( {0 F% n0 I! t( q0 d3 { t schedule.at$createAction(2, actionGroup);# H1 q- O1 t) t- I/ z# _
0 d% E9 c+ O. G+ T/ \/ _4 x' E
} catch (Exception e) {' V" T5 r/ V. G/ _8 @: D+ f, @
e.printStackTrace(System.err);
# c+ x! o/ d5 S: f" {8 O //System.out.println(e);3 F0 }" |8 X$ R5 u" w
System.exit(1);
0 R) y% F$ q, x: J; x. Y }
& q3 q* B; }. f) u, i# i
$ x0 E' E# c. ~; {1 L% T
, P* M7 W5 d6 V }
5 t9 T9 K+ ~/ T% T& |4 i" X* _0 I# E" q4 ]# ]- P$ H) P0 F4 X
private void swarmSetp() {( `+ D2 |0 r7 ^; y
list.addLast(new Agent(Id));" K+ |1 O3 }7 U% r* U" h! M
Id++;, ?( G% y! E1 w
}- b0 n$ C8 g5 }+ \. F% g, i
1 L" J* K# p9 `* q. R; u' [
public Activity activateIn(Swarm context) {
+ r( j0 P; O2 B/ c/ c+ k super.activateIn(context);/ v( J. _4 `1 ^- k0 T
schedule.activateIn(this);
$ O1 R+ P4 o6 g: M return getActivity();
. ?# s& |+ X) d }0 g, t4 u2 }+ S, d# R/ z5 `
" T }: X% D1 J public static void main(String[] args) {
5 i2 K9 [0 M2 [; V Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
( l& C$ \" @' w$ \! ~: f& V! }' K3 x3 Z Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);: q5 o- }9 B0 T
swarms.buildObjects();
1 R& M0 s# {; i4 b# }) c; X swarms.buildActions();
* J" u! N% `4 u9 y' d" w swarms.activateIn(null).run();' g: ~$ U# Z4 I) L
}4 v a. Z$ r' x3 t7 ?( {$ y6 [
- N) j, w" h) {2 k% x, I7 O} |
|