|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 5 }+ T+ d, G f
. O, t' P6 T* j0 ^6 @% P
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
1 w- d+ {6 {3 f5 z1 E! u& r以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.6 r7 r' o2 c; L& w5 M
swarm.SignatureNotFoundException$ h9 Q( g0 Q, {" D8 V
at swarm.Selector.<init>(Selector.java:76)
{1 y, Q, u& [& q1 f" ?$ U% O4 R at ActionGroupDemo.<init>(ActionGroupDemo.java:37)% x2 ^& _+ M. W5 J9 T
at ActionGroupDemo.main(ActionGroupDemo.java:67)8 `% W% _' j* s2 W4 ?
4 U! K* r" V9 R$ ^- I3 S6 R: A
3 R. K+ `5 E- F. G
import swarm.objectbase.SwarmImpl;
& i) r$ O" t! y! }! k- }/ E- gimport swarm.objectbase.Swarm;
! l2 |& T* `2 } O2 Timport swarm.activity.ScheduleImpl;4 l V; m- j8 X7 f
import swarm.activity.Activity;) }3 i+ o1 M- ~/ g3 J5 a
import swarm.activity.ActionGroupImpl;
: U2 r7 H, ^3 @, N' `& bimport swarm.collections.ListImpl;! p5 d! x( V6 h; P# L
import swarm.defobj.Zone;
3 ~: f+ N4 ]6 ]import swarm.Globals;
) L5 ]8 g) b0 R0 {" oimport swarm.Selector;
0 V1 K( P% {' _. v$ F" _import swarm.activity.ActionGroup; % g7 B/ c4 k& X, H8 X
class Agent {
2 `' E0 I& y) [ char id;) z6 f% w5 `, ]9 i# N1 C, R
( |- p. X3 t" M7 r- U3 ?" r Agent(char id) {& y% ^( t6 O0 }; I: T$ I
this.id = id;
) U: t/ ^$ [8 @) z( L9 l }0 i" u3 A; [6 V8 L
# g5 c7 j4 f9 @9 S, w public void agentStep() {
; W6 e) ^- F/ g1 t: ]7 _ System.out.println(id + ":" + Globals.env.getCurrentTime());
* p2 e$ v8 x" l: R( F% F% U1 A( ~ }6 u7 S) r8 [9 T! ]! s( t, y; e& |
}
. I/ l/ u4 s3 }) I- y2 C" r% m
1 {( b* i/ z- q0 a: a! R; z, {public class ActionGroupDemo extends SwarmImpl {
% E' l" I4 a0 q/ W ScheduleImpl schedule;
6 e) R5 J7 A6 A4 ` ActionGroupImpl actionGroup;
& D* \" k* a# `5 J, f- e& z$ i ListImpl list; E# d; g& P& H+ @" t! @+ z
char Id = 'a';
' n5 j/ S% a& O" O8 Q( F
7 ]; I5 m' O4 @ ActionGroupDemo(Zone aZone) {
- ~9 R5 O; b, n: t super(aZone);
( l+ L9 @, O; l9 R$ r4 ~ list = new ListImpl(aZone); ]% ~ h! @2 ~. d4 I! V
swarmSetp();
! A% l2 k/ @2 n- l6 ^1 J, h actionGroup = new ActionGroupImpl(aZone);# L- n }2 d' j9 F4 I. U
schedule = new ScheduleImpl(aZone);
* z% u6 w( o5 h. y1 w8 b( Z try {, z/ h% I( o! R" ?
Selector agentSel = new Selector(Agent.class, "agentStep", false);
0 I! u2 T" u/ J1 o4 R/ s" [ Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行2 V$ A* Z/ P% L4 h
2 H- a' B9 u5 l( f7 r" _% l; l$ K
actionGroup.createActionForEach$message(list, agentSel);
c. ?# {0 V! b# d0 o9 N! j actionGroup.createActionTo$message(this, swarmSel);
' ~' E% C5 s# S Z* l4 V$ w; B( d schedule.at$createAction(0, actionGroup);8 M) T1 I ?; G9 d3 C
schedule.at$createAction(1, actionGroup);+ o& @9 O' w/ a: d7 n
schedule.at$createAction(2, actionGroup);$ B2 m; N+ I) A: V7 S
! J! e- ?' M% P. |
} catch (Exception e) {
$ }( L1 y, T- \ e.printStackTrace(System.err);
1 u$ k2 d) }! K. @ //System.out.println(e);1 {, c6 Q- C) s8 G' h
System.exit(1);
; l/ Y- {( ~& g* t0 A( e }
: L( _3 m+ N; ~6 z: U% p: q" }
$ ^& Z) F, n# {( p
}0 t. Y( @# B5 p9 U' h2 w
3 s! F# x/ A* Y) K% [# F
private void swarmSetp() {* y2 w3 o+ Y: f
list.addLast(new Agent(Id));2 e+ h7 O7 d$ e8 f' E8 W2 x
Id++;
4 ^$ H7 p' _* k3 v, s: ^ }
" _* ], R6 {0 e1 u. {- m1 ^6 D( Q* L) m, U& m( Y
public Activity activateIn(Swarm context) {6 d) t7 C0 n: b% S" }/ F
super.activateIn(context);
- c5 K" ?0 O2 w2 G schedule.activateIn(this);) r; t% e7 }" R/ z: t# F
return getActivity();, B9 w" D1 t/ R! k( \5 x) J
}" G! ^9 n2 ~: x$ i( `
3 c8 g5 v5 }1 _4 L& h
public static void main(String[] args) {. s& w, {8 E# {% q. }' |
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
- e2 }3 ^: i) Q0 @3 F* g8 m Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);1 a/ L1 k7 y4 ] x5 K4 r
swarms.buildObjects();
; _, Q' a* p H& z" ~8 _ swarms.buildActions();1 [+ l6 s) x$ @+ V$ _
swarms.activateIn(null).run();
! c/ G: U$ l+ J* B2 J }
* E; ^$ U$ s* C* O' ~
8 c% `9 U" y5 I. U) [" T1 V5 r} |
|