|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
0 a) Z2 Y+ |; o5 F+ @
! J. Y* t5 z! z/ m3 _本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21* F0 w% ~8 V. C5 D
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.9 X9 b% d4 g% n' ?) Q
swarm.SignatureNotFoundException
$ ]; Z& _5 i# N$ E/ @# l1 p at swarm.Selector.<init>(Selector.java:76)
5 r; M) X K& ~: R. j$ ~ at ActionGroupDemo.<init>(ActionGroupDemo.java:37): H- J7 R& c9 S' j/ n" C
at ActionGroupDemo.main(ActionGroupDemo.java:67)
7 O9 Y, d3 Z: m2 L
3 @- D* J7 d( I5 B2 W
- I9 x9 u. M t! |7 \$ S6 zimport swarm.objectbase.SwarmImpl;* `+ U4 j; N5 S
import swarm.objectbase.Swarm;; I2 R$ @% W P8 x
import swarm.activity.ScheduleImpl;
' ]- f/ }; P+ z# Q/ k0 timport swarm.activity.Activity;8 |- y( o# G: D" f$ {1 |
import swarm.activity.ActionGroupImpl;8 @( n1 C: r ?5 g3 K& O
import swarm.collections.ListImpl; o+ S9 L0 M) F: k" \
import swarm.defobj.Zone;
, p. R9 W: o/ s8 _# U4 S( K% Simport swarm.Globals;
" _! a: M g, U4 F6 M0 bimport swarm.Selector;
6 N. y' J' l; B0 D0 d: zimport swarm.activity.ActionGroup; 9 A3 X4 J8 R7 E% {$ |
class Agent {
9 t! ^( v' \7 U; L5 M char id;1 S3 Z1 @" n9 p8 @$ `
8 W8 c' c# u- R8 G' V# F1 E
Agent(char id) {
: D: b& V" ?: B. n$ O4 `/ ^8 k this.id = id;
0 V: F& |9 [ G% V( P7 G }
. j8 [$ q5 m8 H& |4 j
) [, @( P8 c3 Y* x% r1 A! S3 M public void agentStep() {
; r# i B4 u# F. S4 n# E1 E System.out.println(id + ":" + Globals.env.getCurrentTime());
( M2 P, {6 H/ k4 a, l }
4 ^+ R' G; T! ^% E2 S8 Q( Y}
1 u3 U4 h7 L i! G6 l; `) k# Q; c& t3 E1 n
public class ActionGroupDemo extends SwarmImpl {& H- L$ e! p9 }, o- r8 D& q, Q5 J
ScheduleImpl schedule;9 X: ~% y8 l; |( O$ K( L) T4 V9 B
ActionGroupImpl actionGroup;
2 g* u( ^0 J% n& g" a ListImpl list;
: x2 B9 ], m! k- _/ r6 | char Id = 'a';
. g; n; G9 J3 Z: Z( T9 s6 } q5 P' X& q+ Z
ActionGroupDemo(Zone aZone) {
: Z- P& H) ~& X3 p4 [8 K super(aZone);
: v0 ?7 g* L! q list = new ListImpl(aZone);, ]- P+ x8 A! n: Z
swarmSetp();' B2 z) P0 u- I
actionGroup = new ActionGroupImpl(aZone);) d* b8 }5 U# k( {
schedule = new ScheduleImpl(aZone);7 H! b. n0 f2 g7 r# S! O
try {
2 z" v, _. S* }1 v+ E/ V7 ` Selector agentSel = new Selector(Agent.class, "agentStep", false);' F+ T6 C- t% G5 ~6 c2 U
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
+ O" B& q" {2 x* f, I; I: C' X ; |- h" e2 N g, O8 X, d( C1 a+ [
actionGroup.createActionForEach$message(list, agentSel);
; v' v+ r! `* F4 n3 B actionGroup.createActionTo$message(this, swarmSel);/ s3 z' ? m6 S1 f
schedule.at$createAction(0, actionGroup);( X. E! y; y1 D [3 u; X
schedule.at$createAction(1, actionGroup);, g. [ ?6 }! j2 R
schedule.at$createAction(2, actionGroup);
* l7 n1 d6 C* U2 o. a3 i& W
9 q" p/ r" a" E5 ^( m } catch (Exception e) { O4 n0 F/ d" r
e.printStackTrace(System.err);' G4 p1 T2 k- D0 O1 `3 |) \$ p$ o
//System.out.println(e);6 L; Z T. I [$ x. F8 N" e1 t
System.exit(1);
g, `+ F3 T2 G* o1 O5 x" ^ }
7 z7 n2 K/ q% q0 V: j; ?0 h8 ^0 t, N( L$ _% n- i2 ]
, u3 D( F" G6 r. ~$ A }
; W% X# h# M- b1 }$ \" @: a/ x2 h+ z3 `
private void swarmSetp() {0 P2 E! ?& m8 ?
list.addLast(new Agent(Id));
9 o( b4 w0 P/ N* M2 s% u7 o. R Id++;
- c$ P6 }! Z. l6 p- S N }7 E; K9 A& v0 h' I, c+ T& l9 H7 T5 o
2 S% n# A" r1 u. F4 v public Activity activateIn(Swarm context) {; f) n0 F! e8 H3 G) n5 x8 Y2 f
super.activateIn(context);
/ |- r- Z+ Y" q) C$ F schedule.activateIn(this);
; `* ?) d; z: ^' t! t) ~ return getActivity();; Y, p$ i( T8 J+ N- N* E
}5 g2 W+ N- s+ P3 ^) Q4 f, D. R
" a% V( e& E% Y! b9 p public static void main(String[] args) {! g( i: A' ~" N7 m
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
2 V" m: R) ? u6 H; U b Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);: {0 u7 ?0 J; x7 x! ?- Y, v
swarms.buildObjects();/ C1 g, n9 G- n7 [' f! [, f8 h! d
swarms.buildActions();+ m! r/ a! b! s
swarms.activateIn(null).run();
7 Y1 J2 e3 U; {$ o2 R- w }
6 z( G" X- X6 L# x5 |( U6 j$ m7 F# x; G, Y+ x
} |
|