|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
4 I, T3 i) _$ V; \, l7 q6 {$ L: b) ~8 T3 D0 \* T: S6 h( J
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
1 V$ u! L y5 p1 Y" c8 E以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.) ^7 K! x! a% s U7 u* p: H
swarm.SignatureNotFoundException
* ~3 t5 L0 `+ A) ?4 a at swarm.Selector.<init>(Selector.java:76)
0 E1 z9 g! ]' x* _, |9 {0 P at ActionGroupDemo.<init>(ActionGroupDemo.java:37)% A$ a+ a( C5 f! [
at ActionGroupDemo.main(ActionGroupDemo.java:67)
, C, y% u9 v8 w
8 l9 K+ ^- I' f/ s2 B5 o& j0 Q9 h7 B$ Z* Q
import swarm.objectbase.SwarmImpl;3 Y) r0 p, Y$ R7 r
import swarm.objectbase.Swarm;
: Z* J3 u$ {& I1 o3 _8 vimport swarm.activity.ScheduleImpl;" T, r& |' q& ]3 `
import swarm.activity.Activity;8 J* V- I4 u( c% \6 m
import swarm.activity.ActionGroupImpl;" g' \- K# r4 D1 @/ j2 n9 f
import swarm.collections.ListImpl;* \& B* L% |7 d4 |3 c
import swarm.defobj.Zone;
- g; B! d e3 l R6 R6 O5 _import swarm.Globals;
! n6 c2 ^ ?' E) s# P- |import swarm.Selector;4 H& s2 A# ^4 D( D
import swarm.activity.ActionGroup;
. u0 Z; l$ W4 |0 S8 Bclass Agent {; R) k; p1 s; P/ L( y7 |
char id;- P+ M6 u- D( v) Z6 ~0 x, l) {
9 `6 x" w A2 P8 w) S Agent(char id) {
: i& i% M1 h% g0 J this.id = id;
# X& Y# t% t- J }
8 a# p: v4 k0 ]7 A( ?" X# f6 p' i$ B( x0 R* S& y& ]- E
public void agentStep() {
* M M$ m( Q% K- i" S+ A System.out.println(id + ":" + Globals.env.getCurrentTime());
v: }6 _! h2 ]" F$ G& m t. ` }
7 ^* ^4 y) p+ s3 `% P3 j}7 y" j! H0 e) @4 _2 C' N# Q0 F0 s
% O6 ~& T1 d% Q: L+ _5 ?, U7 E4 D5 L
public class ActionGroupDemo extends SwarmImpl {( ~ k3 L+ I, g' |/ G0 O
ScheduleImpl schedule;
: h1 r2 F% }9 M ActionGroupImpl actionGroup;/ o. ~9 s4 u! |0 b) _) A
ListImpl list;
. C! [# E/ _$ ? char Id = 'a';& y- e! c" ~( T" u
3 J: c6 W, b! @$ H3 ?1 V: u ActionGroupDemo(Zone aZone) {( e2 `* r8 ^# O( I
super(aZone);6 X( [" d# ] J/ X+ Q
list = new ListImpl(aZone);
6 _# }7 y, t s/ I0 ~ i, I swarmSetp();
* \- Z1 q0 J1 k, I& j# [ actionGroup = new ActionGroupImpl(aZone);
& T' P1 O; S5 P% X0 R schedule = new ScheduleImpl(aZone);
5 }1 u1 y( b9 m: \7 U try {
, B2 K7 [2 t; F' T: I9 S' _ Selector agentSel = new Selector(Agent.class, "agentStep", false);
2 h1 q* ?; M$ B4 S2 f2 K4 h( F Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
- M3 Q6 p; I9 V1 p+ w, \+ [. H 4 @6 n: _( I! U
actionGroup.createActionForEach$message(list, agentSel);
/ |2 q9 J6 r0 u. h* W actionGroup.createActionTo$message(this, swarmSel);
5 m, x# |9 C/ M& h6 N' M schedule.at$createAction(0, actionGroup);7 L7 i9 T$ V0 { }; S+ w$ ]
schedule.at$createAction(1, actionGroup);
2 X0 z* r# Z/ Q/ T: d schedule.at$createAction(2, actionGroup);+ w# G+ ~$ S8 H* N
& U& c! B3 |" ]1 f {, { } catch (Exception e) { ^4 |8 P5 {# S a# G6 S" `
e.printStackTrace(System.err);
& K& F+ u/ E/ q8 k //System.out.println(e);- Y7 b g" A6 p, i
System.exit(1);+ Q4 o$ [4 `, v8 a4 ^7 ]
}
2 g+ k& [7 m0 W* Y, T" K$ p; m! M* R4 a$ z% `& i. k: o
" D: K. Z( ~& O
}
; \7 l! X5 b- }
) J( J: g) D Y private void swarmSetp() {) Z8 @# W1 x7 `- P( V) ^9 f3 s
list.addLast(new Agent(Id));
Z( G: _! t7 A' I; _( R7 x Id++;
3 Q& ^8 h. y+ N6 V7 w" i: u& z6 l0 _* q }
) t. z- I0 Z2 X- `( }- C O# ~* M% M' `: L, b( k7 B
public Activity activateIn(Swarm context) {
2 {9 T4 B+ d" c9 j0 w# d( w2 O4 r super.activateIn(context);
{+ @1 e6 l9 w1 G2 _( \3 k7 n schedule.activateIn(this);
; b9 a0 ]. C+ p0 S' m4 t return getActivity();
# A/ q) h# b7 ~6 ^9 i }9 L$ F/ G- B1 w
8 d% \( }* C$ @' L1 ]) P) R
public static void main(String[] args) {+ f. ]- {9 B/ {
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);; N% M, ^0 m+ y; t1 b5 K* s: k
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
6 ~/ s! L6 s3 g8 M swarms.buildObjects();
3 f. B* r) I, c1 Q8 V swarms.buildActions();1 m5 A0 n# U4 k' Q
swarms.activateIn(null).run();: ]) I2 L7 M. W0 U7 B* N
}
1 H! z2 o8 ^3 u9 O
3 v: ^7 R6 m# ~4 U8 z$ {2 U} |
|