|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 1 K4 K3 M) `4 J
7 [1 X9 d2 w, _( x本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21' X; Q$ C% V0 P6 k3 f& ], F
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
! x. L: l. k( q2 d; b* @4 m0 Yswarm.SignatureNotFoundException4 l+ g3 x' g1 ]8 N: f
at swarm.Selector.<init>(Selector.java:76)2 O/ @7 f& O) _) Z. _8 v
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)6 X3 e' ?- v# \. A" e6 @
at ActionGroupDemo.main(ActionGroupDemo.java:67)* ?: |( F' {* h9 o
) O+ V# W# i1 F6 w3 x
/ L, @! m# M+ [( Limport swarm.objectbase.SwarmImpl;
9 i$ s2 L' \' c% }4 d6 `import swarm.objectbase.Swarm;4 P, i: e" d0 B* ~2 R, L8 p
import swarm.activity.ScheduleImpl;. I8 r2 ]* Z. r- ^
import swarm.activity.Activity;8 r! C8 m% w2 b/ G! c9 m
import swarm.activity.ActionGroupImpl;4 A( w4 s$ I9 M4 n4 U' ~
import swarm.collections.ListImpl;
9 \6 `- a' P y& j' a0 E6 vimport swarm.defobj.Zone; 3 g% z# {2 o! |" E4 A
import swarm.Globals;# x8 A+ [. @" R8 V
import swarm.Selector;. u) Z! A0 U& W# D. \" k
import swarm.activity.ActionGroup;
4 A4 n8 r G% sclass Agent {
& @% Z/ o7 L6 q( q/ \2 }) i char id;
5 w. ^7 D( H6 E4 R7 C: v5 Y
. ^8 \* f9 ^2 H2 g! z: ~3 {1 i Agent(char id) {: ^1 d3 U: B j4 N6 V' K
this.id = id;
+ a5 ^# u. L/ f* p* W }0 i) [3 s g8 @( k: l& i
, G G! M6 N" F3 l; i+ e7 p
public void agentStep() {
- J! l/ L2 z- G' g& I System.out.println(id + ":" + Globals.env.getCurrentTime());
/ |4 B6 w; V/ ^" k: r7 m7 B! W) V6 | }
6 k" e5 [7 o& s" V- q& S}4 \3 \) D2 t2 h1 m
( Q+ O2 Z. @8 B; f# xpublic class ActionGroupDemo extends SwarmImpl {1 b+ }" c" X. x
ScheduleImpl schedule;
. O4 K7 g2 r7 |, D ActionGroupImpl actionGroup;
" O# {# t7 Q# A ListImpl list;( [9 i8 v7 h5 m
char Id = 'a';
3 M; F! u- o3 f2 ]2 q+ K: _5 M9 s* @& f5 a l% ]( q& \. o9 g
ActionGroupDemo(Zone aZone) {
7 v$ Z: E& |' \. ^ Q super(aZone);
/ y( A: n/ a, y. P# F list = new ListImpl(aZone);& I& B& J, N8 n. `/ g4 u z
swarmSetp();
, F* K, X# I0 c) W* X6 a4 E actionGroup = new ActionGroupImpl(aZone);6 f2 o6 N5 _/ q/ }( a' R' h
schedule = new ScheduleImpl(aZone);* ]# d1 B1 e. l# J2 T
try {
8 ]" c; _, z/ @, ^* k) ~2 B) J Selector agentSel = new Selector(Agent.class, "agentStep", false);
) J( x1 F% [- } Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
: y$ y! `/ @ G. ]
/ b9 \/ p w$ |, z3 H- P s actionGroup.createActionForEach$message(list, agentSel);
$ g1 R6 M8 d- \8 R6 B" i' E actionGroup.createActionTo$message(this, swarmSel);
) T# c g3 G- I7 V) e schedule.at$createAction(0, actionGroup);
1 P9 T J% X9 H; o, M schedule.at$createAction(1, actionGroup);
& [8 p" J" \1 \" W, D( N schedule.at$createAction(2, actionGroup);% s; C' r. K2 U/ J/ }- Z3 ?1 B
# c9 ^- {. E5 `! `; K0 Y% I } catch (Exception e) {
4 d" ], X, V8 r L, p e.printStackTrace(System.err);
) _# ~) [/ b. p: e3 t$ J //System.out.println(e);6 `: C" [ y+ |( E: o, c
System.exit(1);$ Z0 h$ S5 `3 C
}, B' v. [ M1 g9 Y# @2 h7 H
) j9 @, A; H- w0 e0 ]8 T% F3 V9 d
- I) D, B Q9 J: C0 s0 R
}
4 E( E) K' u' p1 _. u& I
" Y$ Y& ~! u- ^4 H$ w# K private void swarmSetp() {
* ~ }* v& f1 X$ m) c6 D2 _ list.addLast(new Agent(Id));/ M: k+ m& @- ^- P/ Q- P9 J
Id++;6 f9 }; o c4 ?# r
}1 g. |0 ]- S s: c
+ N' Y9 i: w1 |- E2 Z4 Y6 h: W: a
public Activity activateIn(Swarm context) {
( @ l0 T' ?8 M( e) ~- ` super.activateIn(context);
5 L# Y# c& r# s3 T; `# N# s; n4 L9 I schedule.activateIn(this);4 O8 {; |9 d% O( j& L
return getActivity();
7 P* f$ z+ v; t: g }- |# o7 S$ [! v
% T/ P1 w8 f( R8 E public static void main(String[] args) {
% U. q2 ]1 X' S$ S: { Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
2 a+ K2 e2 j2 { Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
# h9 K0 ]. ^4 f2 ^( } swarms.buildObjects();) {3 M, u2 p$ g
swarms.buildActions();
" _9 P. H, l+ k: h, ]0 r7 u swarms.activateIn(null).run();; r$ [ i. b/ L; C( O* \/ C) e
}* |1 T" h+ L/ b" x
. m6 k7 e: J: E1 [- R Y% t& u$ k
} |
|