|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 7 T9 ~6 Y* N( w* Z# H4 a
) q1 ]2 q/ g1 v# Y4 u本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
( S( v6 W, z T! P/ X7 C以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
/ x+ G+ i( z2 H. t/ Lswarm.SignatureNotFoundException
7 h4 w$ s6 m/ c2 L' {" F+ ` at swarm.Selector.<init>(Selector.java:76)
9 K6 F; K9 l& {+ [& t0 A! ~4 W at ActionGroupDemo.<init>(ActionGroupDemo.java:37)& E* w- A Y" W
at ActionGroupDemo.main(ActionGroupDemo.java:67)
: W. d1 w1 l9 k9 y5 g0 ?6 |. m9 E/ K; W% |
1 p4 V* N0 v8 t* D0 O) qimport swarm.objectbase.SwarmImpl;; M* U8 F" p& f
import swarm.objectbase.Swarm;7 c; ?$ p& E& |# k; o- s
import swarm.activity.ScheduleImpl;' x. z8 j# U3 o) `/ b( Y' p' E, v
import swarm.activity.Activity;1 t+ U2 T s" p( e* L
import swarm.activity.ActionGroupImpl;
3 N% z5 O5 E8 s cimport swarm.collections.ListImpl;
! |; G8 Q( w2 V: R& S, U/ bimport swarm.defobj.Zone; $ X& `* u( ~3 {& t9 k# b
import swarm.Globals;& |7 l( ]( S. ^% u0 i0 T% x; o1 n
import swarm.Selector;# c: I6 `( n7 p2 E
import swarm.activity.ActionGroup;
8 J6 g) c& a, s5 B+ \& Bclass Agent {
9 t+ a6 w8 Y% R1 J6 r$ w2 v char id;
& t& `; o7 f7 H- W2 ^% B5 R" C5 J
4 i. x% `. B& S0 [* B h' H Agent(char id) {, D4 ?( `! J+ D2 x9 c" b
this.id = id;
2 A9 w* H9 e" J, d }
9 y9 c `* e Z T- P$ |; Q1 M9 i, `: j. Z! g1 Q( \( ]
public void agentStep() {# n$ H& q) {' C& }8 ~4 }
System.out.println(id + ":" + Globals.env.getCurrentTime());' g! H7 f" `5 ?( p( E( @4 J
}- [3 p+ v6 D- W6 M2 Q
}
. l4 L" L2 a: q O8 D* o3 O% g; {5 E
public class ActionGroupDemo extends SwarmImpl {
. {- n6 {( M# e ScheduleImpl schedule;
% I# E6 i/ F& w ActionGroupImpl actionGroup;
! i- d$ r J6 b. a' M& d ListImpl list;
, h4 N4 l3 X/ H4 w% v/ o char Id = 'a';
8 I( C6 O- S" g
: L7 a5 M. L. M3 g5 a9 J9 P0 V ActionGroupDemo(Zone aZone) {, v6 [$ N5 R. u/ O$ b }# i
super(aZone);) S& r- f/ U/ U' h. m3 Y* M
list = new ListImpl(aZone);
) G) V: G. P4 p/ W* Q swarmSetp();0 p. b3 f( z9 _
actionGroup = new ActionGroupImpl(aZone);
& {0 U! U" ?4 L! s. k schedule = new ScheduleImpl(aZone);: X* c8 F0 P; W$ a {6 J$ b+ d3 Z
try {% o; o. l8 m% R* G2 J) q' b) S
Selector agentSel = new Selector(Agent.class, "agentStep", false);" Y) ~5 m. K/ O! m! b3 a
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行* G( I5 k: p2 n6 X4 O
7 N) O j3 I& S4 @1 U9 W; T$ O/ ^
actionGroup.createActionForEach$message(list, agentSel);4 w' O7 ]* {# D
actionGroup.createActionTo$message(this, swarmSel);
8 ~0 s+ w g+ L" N1 U schedule.at$createAction(0, actionGroup);
2 P; g' g) K; d& P/ H/ m* | schedule.at$createAction(1, actionGroup);. @; L9 |- B( F" h8 W
schedule.at$createAction(2, actionGroup);; |$ A" G$ t% t5 h. { P5 A
/ S- M! e7 h2 l } catch (Exception e) {2 `; ?/ y5 m( g/ g: ?5 m
e.printStackTrace(System.err);
$ c4 b! a1 D ]$ S' O //System.out.println(e);
1 V5 F3 J+ ^, ? B- W System.exit(1);
) i& J {, a4 H2 [0 |8 ~ }- T. y" Z' s. h) Q2 F+ a2 V
0 a" \' A5 ^! E; l' x9 w
# i9 K9 p2 z1 q' Z
}* E: [$ g2 S1 Y, |/ ~+ @' `
9 r# h4 W8 c/ d, e private void swarmSetp() {/ ]& v8 U8 z; F/ g$ w! f
list.addLast(new Agent(Id));
4 M5 ] f+ a2 Z2 e Id++;
6 b4 a3 F# R6 r, @7 r1 [ }& {6 Z5 f ]' R& i( K/ T0 K" J
; Q) J4 ]2 S1 g; G2 h* B public Activity activateIn(Swarm context) {5 {% x7 ^% ]. }
super.activateIn(context);' _7 w' c' f# p. L d( s
schedule.activateIn(this);
! X$ V- F$ x- l3 R n% q6 U return getActivity();
# h- L- g5 A5 Y4 i) B% i* w% ] }
- S9 s) q* p, [& g! n
" m6 B/ F4 b J8 w5 f4 S- {# b public static void main(String[] args) {
1 t2 h' i5 X, Y' R Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
& b2 s5 b" T) @# e& v( Q7 u/ E Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);0 [" _* a$ T% T
swarms.buildObjects();8 J, C: x+ g, l5 G# W
swarms.buildActions();
# @( j( _: Z% U+ ?- X swarms.activateIn(null).run();: _' f, K* S7 d
}: a, f! y2 t- f5 m
9 p9 f. A$ P0 l# k
} |
|