|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
: w) Q( H+ K7 u8 k5 B) Y( W3 i s& f4 K) G' }' e# Z
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
: ? S4 o X. N6 T以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
' S; g% `! @6 K9 `+ R+ |! Vswarm.SignatureNotFoundException0 C$ c r& F2 W
at swarm.Selector.<init>(Selector.java:76)' T/ c4 j0 R0 m2 p( N
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)4 m7 ~( x7 J& X7 d
at ActionGroupDemo.main(ActionGroupDemo.java:67)
& z) l0 k% ~0 L3 E: _& H
2 p! }8 l4 c) H: h
8 b. U: ~0 E* Rimport swarm.objectbase.SwarmImpl;
3 L$ P) R3 R4 _, fimport swarm.objectbase.Swarm;
/ R) R( r5 h; {) zimport swarm.activity.ScheduleImpl;; B9 U/ X" i3 H. K
import swarm.activity.Activity;' m' A' Y; |6 G
import swarm.activity.ActionGroupImpl;, |* O4 |- C* Y w/ G( X0 o
import swarm.collections.ListImpl;
7 B2 L4 F/ x3 `+ q+ Vimport swarm.defobj.Zone;
" t- A D! U8 @! B! N/ q" O+ \9 M' himport swarm.Globals;- l( H9 m v' c3 s5 J8 @
import swarm.Selector;" G( y! v' N4 T- v3 F7 z
import swarm.activity.ActionGroup;
- C8 ?( c9 g+ _9 ^' y" I3 Dclass Agent {5 r$ Q% f" x: h. J
char id;$ v8 [4 H3 f- @2 s& X4 |( O& C
) I" l: ?7 [9 P Agent(char id) {
: S+ Y3 r- u- K9 p, B1 n! V4 J this.id = id;
* ~+ |- P3 t: W( T1 H }- G) x5 \+ g' {' e
2 i& N1 M# N& m public void agentStep() {
) }( \- t9 H& [9 \$ u. a* Q System.out.println(id + ":" + Globals.env.getCurrentTime());, K- X1 P" l) p" D3 ~' i
}7 e7 p2 X( E. l5 f0 q
}9 l5 P! M! |- K
( L0 r/ a6 H; }public class ActionGroupDemo extends SwarmImpl {0 f2 n* P2 }! i# {7 r N% [
ScheduleImpl schedule;
; \' ]; g6 X7 W1 }6 \ ActionGroupImpl actionGroup;5 ]9 [1 A9 W( I0 \
ListImpl list;
3 C7 f& S- G3 ] e9 F- g A char Id = 'a';
' z% v' [7 H% t' j! Q5 }/ K. l6 k" x+ ^
ActionGroupDemo(Zone aZone) {' F3 s- C& Z. I8 ~! {! |% K
super(aZone);
( k" @5 v \$ \7 L8 P8 U+ P list = new ListImpl(aZone);( h( P: g3 n; F; A* F; R, a/ M
swarmSetp();
% x& o R! |) F4 X, ~4 v actionGroup = new ActionGroupImpl(aZone);) k3 W V7 b) s4 v6 m
schedule = new ScheduleImpl(aZone);( f" y4 ?6 P' G! P! I6 k
try {* ` \6 d3 H$ X4 {& ]
Selector agentSel = new Selector(Agent.class, "agentStep", false);! d; L. B- d( J! y! g8 \6 q
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
( b& H7 X: p6 {2 }4 w) H+ U
" m7 M G* N# f# Z, }( b actionGroup.createActionForEach$message(list, agentSel);# [: X0 T( N( T2 }
actionGroup.createActionTo$message(this, swarmSel);3 q2 M3 L7 V2 f
schedule.at$createAction(0, actionGroup);
; v) C$ t) h1 ~6 b schedule.at$createAction(1, actionGroup);
9 c7 N2 H8 a" n1 D schedule.at$createAction(2, actionGroup);
: A9 U3 j+ Z! X6 t
' M, L( y0 y2 D( ]6 I! E } catch (Exception e) {. s, E9 r* M# ^# Q) o% }
e.printStackTrace(System.err);, c4 |) Z3 U) k
//System.out.println(e);
: Q' I' T9 F; U. g3 V System.exit(1);
8 p& @6 A$ t3 V7 A! f) H6 t }+ j4 A/ O3 S+ e! A
# b8 W' x% ?8 d) P6 l
0 i5 L& n. q* f4 }2 c1 R. K }: k4 f7 Z+ T% j* L# d4 w
8 I7 s7 ]4 @- f6 `' P: m2 v2 t, H
private void swarmSetp() {
4 [7 @- [2 g: i' ?: H' P list.addLast(new Agent(Id));1 _6 b% Y$ q; {7 B6 p$ [
Id++;6 h- c: K. X" H2 a ]/ F
}
. m" A p7 q' t8 _/ e& W, ~1 M& b) w' p& d4 K9 v
public Activity activateIn(Swarm context) {, M) h4 O' c" ?0 X
super.activateIn(context);
* Q- z, o% A$ p. i/ o schedule.activateIn(this);
: D; I% Y7 c1 [/ t, |& s" | return getActivity();
( o1 }) |; a$ a( }# U4 H }0 y; R; n5 A( x9 i8 q1 g$ {1 C
1 V& W' n% ?) k1 c( y+ t9 h
public static void main(String[] args) {
8 f5 b& x5 \& F3 n- m Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
7 v. ?6 u" F4 `! |4 s Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
7 S* i+ P9 {" B swarms.buildObjects(); p- v9 ]8 t4 `( M
swarms.buildActions();
: A% H& C- c7 R: ?$ s+ ]. ~8 \1 P! y swarms.activateIn(null).run();. n# N- b+ e7 x7 t$ S- Z. n0 M* Y
}3 [" w; c1 J3 ^8 c8 i- z6 `5 A. ~
' r- }- l# i& |$ K
} |
|