|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 , L/ e1 j6 \0 Q0 n
2 M2 |! ]# I5 f) {本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21" S; {1 o) c4 h; j) {- k! t
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.0 Q- m* b% x. o2 f' [! `6 f6 F3 e
swarm.SignatureNotFoundException% y" o; u9 L2 n7 X/ f- c5 u- `
at swarm.Selector.<init>(Selector.java:76)* @; F: f, D" q; Z
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)' M% x8 \. x# y' _: O& z
at ActionGroupDemo.main(ActionGroupDemo.java:67)1 p# ?0 g9 }& r6 Z
$ s& O, [/ T. ~$ i- k- F
/ v( y1 Y$ h8 g- v0 Bimport swarm.objectbase.SwarmImpl;
6 y1 Q7 o# F1 k! j8 Bimport swarm.objectbase.Swarm;8 n( F' ?( S# S
import swarm.activity.ScheduleImpl;5 U e4 Q# H, Y
import swarm.activity.Activity; c& [/ {6 r% W+ d
import swarm.activity.ActionGroupImpl;! R1 B+ k. n2 e8 e7 B- x: f
import swarm.collections.ListImpl;
- |+ v/ K" p: i) w: ?0 bimport swarm.defobj.Zone; 6 O% x7 t0 R9 V" D2 K
import swarm.Globals;
3 }6 f& b; n1 f2 A6 J/ X9 pimport swarm.Selector;: a& ~! `( J& I! X3 Z
import swarm.activity.ActionGroup; 2 @6 r/ u2 h% W p6 A
class Agent {9 o" a9 M& j! `8 e
char id;( n8 @# b$ }1 I2 M8 }8 s9 T7 E
( J, A- J* C5 _3 Y% @" j
Agent(char id) {2 f5 ]/ J5 w5 M1 o
this.id = id;& [8 d8 B: J& B. I6 l2 Y) g& B
} H/ C/ l9 w% X2 q( S& W2 y g
% g7 h! k$ y) L+ _
public void agentStep() {
6 G% E4 H: _1 Q+ T System.out.println(id + ":" + Globals.env.getCurrentTime());
/ a& m) u, I9 V2 m, h }. ]- @' c& h- l o# p3 ~( s
}( i' l8 ~6 P) X% \1 z9 A/ J6 w
$ q2 d- |3 p% _public class ActionGroupDemo extends SwarmImpl {6 t" Y; Y( P: r! H& ~: z1 _# ?
ScheduleImpl schedule;0 {! R9 m" T/ p& z6 J3 v c
ActionGroupImpl actionGroup;7 j( c4 P) ]; v( ]" _
ListImpl list;
' l1 r8 Y& |, I9 b3 _- N# D char Id = 'a';9 q! p, ~/ ~9 d
' h% V4 T$ j/ r1 F, m5 v
ActionGroupDemo(Zone aZone) {
5 F' l9 x" \% d# ^/ K) f0 A super(aZone);
3 A6 q5 b( c- f: Z list = new ListImpl(aZone);7 ^0 Q2 G( S6 I2 q1 i5 _" c: r# Z5 ]
swarmSetp();; D# l* W% n { ?# }
actionGroup = new ActionGroupImpl(aZone);
1 ^) O8 U, T3 Z8 Y. Y6 a1 Z8 K+ P schedule = new ScheduleImpl(aZone);% N Y/ O T" V6 i
try {, F, _. P5 u% l$ m
Selector agentSel = new Selector(Agent.class, "agentStep", false);
$ |- V4 g* r/ N% t7 _ Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
4 _# T3 Q5 B( E5 L* _! h a - j1 j! D4 T' R% u; N
actionGroup.createActionForEach$message(list, agentSel);
4 O( }% c8 t4 ^+ J actionGroup.createActionTo$message(this, swarmSel);
0 j; v$ A2 x% X5 e( P schedule.at$createAction(0, actionGroup);8 o3 W J1 a7 ?8 C S8 l: V
schedule.at$createAction(1, actionGroup);
3 w4 m7 O2 A o( ?3 x schedule.at$createAction(2, actionGroup);9 k k& H" U- x% g- q h* ~/ S
; V* a& P% S8 x$ |3 }: Z } catch (Exception e) {( c' f# g6 K. W/ a! M1 f5 _, \
e.printStackTrace(System.err);+ }6 m/ X% V6 n3 t4 ^
//System.out.println(e);
3 N7 T# @7 t& j) m# @ System.exit(1);* s6 ^3 D# |. C# i/ o+ y% Z3 K
}# s+ X* {5 E" `! q: m. ]. m8 C
^( k1 [! ] g2 C- e. m$ A/ {
7 k o4 `/ L3 e$ E% r( G- R% F# o
}
- a' F+ P b! }! Y: h( J
1 t( C8 p- `% f& a0 g, U$ m6 u private void swarmSetp() {# F! X+ Y: u3 y9 p, x: r; A& n
list.addLast(new Agent(Id));# u4 h- C) V) ], [) _) f$ t: E* i
Id++;6 v u' Y; r& r- u3 x+ a
}/ l7 P) t8 ~ x8 F' B. i' W
0 B% ~' _" w) [/ P
public Activity activateIn(Swarm context) {) ]+ |6 Q" Q4 }' Y
super.activateIn(context);; M v u' Q0 S- |! G* d* o
schedule.activateIn(this);
8 g- `/ U8 v1 R" d+ \( z return getActivity();
( f; U: ]/ s1 o' ~# b' B0 U }
* P# @$ ^ a* q$ t6 u$ S; h" w h: l
public static void main(String[] args) {8 y) ]& v+ i! e8 m- D/ T
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);8 s! E7 Z* j7 Z) y% M6 a9 \
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
) I: l' W, q: u; Y8 Q: U# @ swarms.buildObjects();1 x* h# I5 R: X0 _: Q! M0 s* f6 F6 @
swarms.buildActions();" ?* [1 q( c; J! m- b4 v3 O
swarms.activateIn(null).run();
8 E1 u( d0 K4 }/ P9 u0 ]$ b: P8 y; \: E }
; X* p' ^; w" r7 h& c8 \
( p/ z# q( ?: d$ ~6 e} |
|