|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
) k2 [4 U4 f9 U6 w! a+ ?9 _
' T3 D, w# g* W3 l- |本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update215 H# o3 r5 ?) w- N! \" a5 x
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
+ ?# W- D1 h: ~7 V5 r; `; qswarm.SignatureNotFoundException
9 C/ K ^/ y y$ T) u1 ^ }5 e( @ at swarm.Selector.<init>(Selector.java:76)2 ^: G" x( Z7 t$ F2 ^2 A' D7 o
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)8 I6 v6 I2 K+ x# j1 u0 V2 b4 E
at ActionGroupDemo.main(ActionGroupDemo.java:67)
- i3 f) O" S. U
0 W: _' o7 p, y
: M/ L5 t- S. Y% Q8 Y$ mimport swarm.objectbase.SwarmImpl;
8 J. l |& K7 j/ m+ fimport swarm.objectbase.Swarm;
( i: y1 S7 t* @% ]* l; uimport swarm.activity.ScheduleImpl;
% f: \( L9 n! f0 d) j7 c7 E3 _import swarm.activity.Activity;
' B' r& U+ N d7 J$ p( J. Rimport swarm.activity.ActionGroupImpl;
; ]4 |9 A. s' O" \- j6 qimport swarm.collections.ListImpl;
" g# Z/ ]4 O3 d3 A+ K- O, ^import swarm.defobj.Zone; 1 L+ L: s8 w9 R/ ^" F! {
import swarm.Globals;
( w) j. T& s- U, F. [9 }" y! _* Ximport swarm.Selector;; u# A; w Q) A |% A# g R
import swarm.activity.ActionGroup; " }( {: G& ^7 C$ z1 f
class Agent {
9 q6 Q: Y" F! w/ p5 E, |% o) p char id;
6 e; \ P. O6 x$ y# A# r' S- {: e9 r. r
5 z1 j/ [8 {6 G' W3 ` Agent(char id) {
- M2 @/ V1 Z( i, R this.id = id;
9 P- A4 v( U2 F8 G }6 q/ |& j+ h' k3 f- C. r
; e2 A# V e. C) C. }7 y public void agentStep() {
3 ?8 B& ^1 ^+ z3 b% K; \ System.out.println(id + ":" + Globals.env.getCurrentTime());
0 f& K# h3 H& p/ x0 C: c" h }; K' h- F% X: a! F! H1 k4 b
}
0 E3 `0 M( X; ?: Z/ u
6 H2 r; U% {: f+ Gpublic class ActionGroupDemo extends SwarmImpl {& V6 i. E* v4 Q/ @1 C `2 ?
ScheduleImpl schedule;2 g+ C" v6 u' R: N6 O: h
ActionGroupImpl actionGroup;
( t' b* @! e1 V7 k. f ListImpl list;# U% x- e" v" H+ Q" p
char Id = 'a';
7 f: }( A' J- D A* ]
9 K% Z4 w' i# Q0 l4 n- z: v ActionGroupDemo(Zone aZone) {
9 k6 X7 e8 J H5 y: x4 [ super(aZone);
( [* w5 z; b5 {" b6 C list = new ListImpl(aZone);
: I0 P) i. c# n: z5 x swarmSetp();
6 }# g2 T& ~' K: |. s; y actionGroup = new ActionGroupImpl(aZone);8 G$ @+ A- T7 c/ @! N3 f3 b
schedule = new ScheduleImpl(aZone);9 W: a+ o5 L, ]9 S/ I1 Y
try {; q# }4 q9 T' A5 E
Selector agentSel = new Selector(Agent.class, "agentStep", false);' Q( Y2 g5 _& \: l) b W
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行7 i6 l" Y, `) T
& f/ y# g2 S8 |2 r' f3 i2 b5 n
actionGroup.createActionForEach$message(list, agentSel);8 G ~ x* Z' H- K% N6 w
actionGroup.createActionTo$message(this, swarmSel);. N2 Y4 C1 @3 L5 q8 _& E; M* D, B
schedule.at$createAction(0, actionGroup);
- Q1 e# ?1 R0 @0 S3 r5 u+ S schedule.at$createAction(1, actionGroup);
; F& s% K0 ~8 `5 U schedule.at$createAction(2, actionGroup);
; k$ f# a* c* @4 Y
" f7 F/ w8 |7 b) X! l, `; Q; i } catch (Exception e) {! I9 A0 k/ m! U$ W9 w i
e.printStackTrace(System.err);
: Z5 _; j& C& T2 ^) X; _& C$ ] //System.out.println(e);
# V q% s9 I7 H) W System.exit(1);
# n( |1 `+ u% g% }' B0 {% Z0 e8 r }* I1 b7 \1 I4 V4 S! g* F9 @' {
* [/ M4 @4 j! H2 Z/ X0 U i
( v" B7 K7 \; P N }
; j$ [3 J G9 r, Y. U+ Q' k2 v9 }& z3 w$ a8 w1 _ J
private void swarmSetp() {+ h0 S }4 w( L, b
list.addLast(new Agent(Id));
) V2 w& s/ C4 \! m* T+ w5 j Id++;/ B3 _7 \- Z1 V" q S
}" V0 @4 R V& g9 U0 {- @, y
' i3 j1 @, _0 K" ?( K S public Activity activateIn(Swarm context) {3 q, w4 y7 Z2 }3 E, A- [
super.activateIn(context);
; X% N0 Q5 o+ H! Y, ?, x2 A schedule.activateIn(this);
3 a% X, y, J. D- T' w" a return getActivity();% s' M9 u8 g3 `6 H; `
}2 u3 F' e/ b; y( A3 J
- {+ P2 k' Z4 ?* t6 \3 F
public static void main(String[] args) {
0 c. P7 }4 i: }3 e& z) _/ X z Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);& K) [8 O3 I9 k$ j# J
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
8 {9 X6 E2 ^! F, z swarms.buildObjects();, x' v; j9 \6 F7 k$ w- y2 w
swarms.buildActions();; j8 [8 ?0 |. w2 L7 T6 A3 ]
swarms.activateIn(null).run();
+ k$ ?1 D0 X1 P) J }
& ^5 ?- D5 S' K. i# d) m/ O4 O2 {7 y& d$ n& h# _ i
} |
|