|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 . `+ A: S1 ~6 X/ C" {" m1 {1 t; p8 {
6 t) m; x. f& [' O本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21! A" j) |/ y1 g! v- g+ P2 C1 Q" B
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
+ d7 O+ k2 U- x; p2 _5 V" xswarm.SignatureNotFoundException
5 s& t0 ]* a2 C2 t% \; ?9 n: L2 N6 }2 G at swarm.Selector.<init>(Selector.java:76)0 \1 e5 l1 ?0 g0 O
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
) K0 d3 m! \2 c+ U& G4 T at ActionGroupDemo.main(ActionGroupDemo.java:67)
1 q3 [- N- `( P6 h& b; n) `: [9 I0 j- w
; v; F( j6 w/ n5 W- eimport swarm.objectbase.SwarmImpl;0 _# s" q1 a" \* K* N6 U$ N
import swarm.objectbase.Swarm;
) n; @4 k: \" m7 A% c Cimport swarm.activity.ScheduleImpl;
# @. J0 z+ m$ `, mimport swarm.activity.Activity;
4 O5 \6 i" C1 ~4 o( U1 vimport swarm.activity.ActionGroupImpl;
/ |8 R0 N @. [, i. H8 S) p1 cimport swarm.collections.ListImpl;
2 K4 q2 k. Y' cimport swarm.defobj.Zone;
. B( q H' y4 T$ eimport swarm.Globals;
. g u8 L4 Q. T* _8 V( ?/ Bimport swarm.Selector;
8 |* j$ n* t5 T; S) bimport swarm.activity.ActionGroup; " t; ~7 l. P+ e: i
class Agent {" | S2 t7 X$ i2 f6 L8 N
char id;( N7 g& Q3 M: I) D& U. c7 O3 d
7 b% l: J$ S, k; P
Agent(char id) {
6 ^( E% r3 {( } p/ N this.id = id;- i$ m8 r2 i- r0 I; F
}
- T0 z1 ~( \4 s) {
4 J6 v$ Z: }% H0 w, {! R public void agentStep() {
3 h: o) A$ y0 I% z5 m% \ System.out.println(id + ":" + Globals.env.getCurrentTime());' y0 g" \3 T$ O# g% Y1 P
}
4 @" j" _7 V& L' @4 a}
, \! o+ Q( I% M! a. |
4 x& m* g* p* ~4 _+ E* E, Vpublic class ActionGroupDemo extends SwarmImpl {; q" d" ]/ `9 H" s0 h2 L
ScheduleImpl schedule;6 ^9 A; U( y* p% D
ActionGroupImpl actionGroup;
4 v6 v! s# N# G9 h" p' v; w ListImpl list;4 p( B" P/ N7 ]
char Id = 'a';
5 w- p y8 l" T. N) G) e8 ^% T! K/ I) x
ActionGroupDemo(Zone aZone) {# f* C5 g g2 c/ w( l I& v
super(aZone);
5 f/ d. H/ Z7 n6 F$ B list = new ListImpl(aZone);8 b' o& O3 }# _8 D
swarmSetp();
/ Y# U9 `* V( E5 b* f actionGroup = new ActionGroupImpl(aZone);
2 h! h u" ? m) k e7 s: z2 J- S7 s schedule = new ScheduleImpl(aZone);
- ?9 M& J* Q; ^4 ~7 e+ j try {
" U, J- s$ @% u0 j6 H Selector agentSel = new Selector(Agent.class, "agentStep", false);# q6 O3 [1 a7 x9 @' |
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
- x+ D2 A5 }# k- l% C+ {: x $ T$ ~ J! {9 }8 H I/ F: H- [
actionGroup.createActionForEach$message(list, agentSel);
, P, h; t6 I. r) ?. V' k actionGroup.createActionTo$message(this, swarmSel);
9 q& f) Z$ A) U0 V8 J" | schedule.at$createAction(0, actionGroup);% k4 [0 B5 o% { D5 {0 f: ~1 J
schedule.at$createAction(1, actionGroup);
7 [3 X$ E6 @3 `9 M schedule.at$createAction(2, actionGroup);
! Q; k0 K7 x6 o0 u) I8 i9 f& _$ u: Z& T
} catch (Exception e) {- l% l' ]3 s: y' O
e.printStackTrace(System.err);* q+ }3 L. p- u- Q' F) _) ~: q
//System.out.println(e);, [7 d& N, p# P; M3 U" c$ [9 m" D
System.exit(1);
( ]! P8 t. b. q }
" ]; ^* ^9 |: Q9 |% f
/ H# V( g4 X4 }7 g, c
' c9 s6 F7 B0 X& t5 [4 i& P# A }4 R. }* J0 ^/ q6 r% A
X7 h( g. y+ V% V8 o0 o
private void swarmSetp() {
/ ?. ?$ w" P1 X. { list.addLast(new Agent(Id));
7 c* L) A) t+ e0 U% z Id++;1 ?* x" M/ G% P. u' ^3 h6 `/ e
}/ [- G! ` M- l4 n! D' F
' I: q' f B. \- I+ g2 q
public Activity activateIn(Swarm context) {
/ ^6 o4 N) y, W; z8 H0 j super.activateIn(context);
) {* ^! z; C7 C; T: m& t schedule.activateIn(this);
6 R" V) m$ P9 f/ J" [ return getActivity();
0 i5 s( [0 {8 F- V V% l/ V2 Y H, L9 N }# \; v+ z4 u/ d8 X
0 ^3 p0 t, `1 I; {9 Q% C4 k' ^
public static void main(String[] args) {
3 s1 q) ?% [2 v# L3 f Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
5 M% `% o5 x B$ p$ C' ~9 z Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);: z' X! g9 G; u! R. O$ K+ @
swarms.buildObjects();8 F. q+ O/ i+ V M
swarms.buildActions();1 |5 a; H6 F7 S/ f/ n
swarms.activateIn(null).run();% e7 r. ~* F- g+ B6 X1 ?
}5 ~$ `3 s/ @4 R& T9 W& r
, e/ J0 s9 N1 W+ K! w" d& l9 ], T} |
|