|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 2 F8 k9 M! u" ~6 a5 k
5 L9 w; V! D. r+ N* V8 _
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
0 t/ D5 h5 o" J, k以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.1 Q0 r4 I) @5 w Y0 `
swarm.SignatureNotFoundException
' x. R+ e$ ^) U) K; ~$ P1 T at swarm.Selector.<init>(Selector.java:76)# J1 x+ _# f0 o, ?! c. E* w4 _
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)' [2 _3 n& t) S% k$ Q" g) ?6 x
at ActionGroupDemo.main(ActionGroupDemo.java:67)
- M' Y3 [0 x5 q0 [
! T8 s6 r0 x1 m. Y- J$ Q( m- @
( u1 N2 U. ^# `5 w- Iimport swarm.objectbase.SwarmImpl;
2 }6 I6 F+ E: Q. H K. m* I% P, ?: W, ^import swarm.objectbase.Swarm;2 b! W4 P/ T [) z* c7 j6 W
import swarm.activity.ScheduleImpl;" K+ M" ~" T; e5 {
import swarm.activity.Activity;6 ^! v) G2 I+ x& B9 p) ?
import swarm.activity.ActionGroupImpl;
0 E, i3 A5 V8 ^8 I' Jimport swarm.collections.ListImpl;
/ n3 b- ?; ]2 v" z; s. @! o4 fimport swarm.defobj.Zone;
! Y" P" U, b4 _/ K7 @import swarm.Globals;& |# Y; T: k7 n; }/ s6 Q
import swarm.Selector;3 g& B2 C' R& `: L. I" a
import swarm.activity.ActionGroup; + G- z* v' U8 _% d2 l% S6 Z4 k
class Agent {
9 I7 s! E( r# a" p# j- P% l char id;6 t: B. `: d8 O8 h$ O
% m- G5 [5 u4 ~: e1 D. Z* ^
Agent(char id) {3 D+ l* M( m; ^3 b6 c! N
this.id = id;+ o0 I+ Q1 B' `+ q4 ~# |- S* w
}6 _, c+ S, p% ?% ~
3 S$ C" o$ T8 N5 @7 x/ g public void agentStep() {
3 V" m9 \, G, u8 A System.out.println(id + ":" + Globals.env.getCurrentTime());
" A u+ K# Q9 c9 z }( e+ E$ C; r! i- Z) o3 @6 c
} ?( l! k0 b: M/ u7 q
) i- ^& i% ]# Q' n+ }public class ActionGroupDemo extends SwarmImpl {
( x' a% b* C i( V- U5 o' H" G! t ScheduleImpl schedule;
0 `- k( e- ?) l ActionGroupImpl actionGroup;
' B* J8 w9 b; s7 Z: Q- R% H( s ListImpl list;
3 j" N; [4 ~5 V char Id = 'a';
% ?- P f# G0 S9 Y6 s" E- }' s2 W! Q
ActionGroupDemo(Zone aZone) {
" E8 g& I" w8 G, e super(aZone);
( P. l! t. P- \( v" k+ p& j list = new ListImpl(aZone);
. i+ K% x: Q0 N9 [ swarmSetp();
& n1 W6 d Q) D actionGroup = new ActionGroupImpl(aZone);
8 K9 m( Y: r! R/ n7 y( h) R schedule = new ScheduleImpl(aZone);+ k1 _0 A3 h7 x$ j- l
try {' I- X g6 G5 J/ C" E$ b. J
Selector agentSel = new Selector(Agent.class, "agentStep", false);
# }, \0 O1 _: O4 ]0 I" E Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
' y1 c6 l7 x" Q% }/ Z( Q, I; j) e
8 j a1 }$ B% J7 H actionGroup.createActionForEach$message(list, agentSel);
4 g9 k+ l) s6 y4 p( R actionGroup.createActionTo$message(this, swarmSel);8 [. K* e$ y" M1 H! W& o- \5 |
schedule.at$createAction(0, actionGroup);" O l* E( T2 w( W& w( H2 a5 h
schedule.at$createAction(1, actionGroup);
9 l$ t" H- ?; z1 g( V schedule.at$createAction(2, actionGroup);
8 K5 K2 C# M6 C' c& Q- M
# v- O8 e, ~2 N" A } catch (Exception e) {
; v$ B# f( T3 p e.printStackTrace(System.err);
: |0 s7 d; D& T; Y& W4 \" e' m //System.out.println(e);! e/ n+ l$ t' V r5 `& }# u4 c
System.exit(1);- |1 B+ I6 q u/ W
}
/ x. \* i2 o2 B: V
1 a) | @/ Q% R d' h6 |
. k" R8 F# z- c3 o: e }
6 I, @/ s5 n @- m# N! _
8 i* ~: w9 `5 {" w* u1 H7 W private void swarmSetp() {. b" J/ w: m1 m& x1 I- H
list.addLast(new Agent(Id));
9 a5 q* ?2 P+ f Id++;( P) J8 H3 S! J9 B, N1 @2 Q
}
; Q! U# }2 D" _, x/ u$ M- m; D \: q# H
public Activity activateIn(Swarm context) {- I' h& L0 w4 d/ S% w3 l
super.activateIn(context);
9 R9 E8 n1 ~$ d8 i+ ?6 {( A, O schedule.activateIn(this);" J9 t) b( r& L ~
return getActivity();, N: S/ e8 e/ ^: _( e
}
1 K& _0 o. K0 F0 r! t* P8 H
" L0 v2 m) n7 N7 D- I public static void main(String[] args) {3 F: M$ i a6 w2 s
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
0 H+ \; i5 p/ p" k5 b; T8 Y) G Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);/ e; n: a" o# M
swarms.buildObjects();
a# i$ `* |: f* E) ? swarms.buildActions();
/ X* w$ _. _7 Z3 e9 _5 T6 [7 a3 I swarms.activateIn(null).run();& `! \( U6 Y0 G9 J
}
! g0 x2 _! E/ R$ B+ G! j: e
+ @8 O" D; d5 Q" F# [& |0 C6 b" i} |
|