|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
" M+ O. P4 H/ w# O. `( f
& q; y7 [3 P4 d本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21* b% Z* P: E8 {! w: Y" ~
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
9 D& A. {2 u" l( Xswarm.SignatureNotFoundException
6 l+ _: G d% v& f. a+ i! O8 a X% @ at swarm.Selector.<init>(Selector.java:76), R& @7 n' C- t4 Q+ N* l
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)! k n' `# _. s* `# S
at ActionGroupDemo.main(ActionGroupDemo.java:67)
/ [* o. j" ~ _3 E
' u6 P2 j& p9 |, }1 m$ ]+ f N/ [6 O- S K* Y, @
import swarm.objectbase.SwarmImpl;
6 a0 M+ K7 P; T! ~" t: d/ Vimport swarm.objectbase.Swarm;
v' H$ ]( Y# n0 U- P) Mimport swarm.activity.ScheduleImpl;2 j1 }, }% z- S' ^# k$ P4 Z7 B
import swarm.activity.Activity;8 x( o5 U, b$ q0 ?, o
import swarm.activity.ActionGroupImpl;. R: d1 H( A4 e5 T. ?
import swarm.collections.ListImpl;
+ n) P# F% z( A( H' i5 ]' {; gimport swarm.defobj.Zone;
: U0 H& ]1 i$ r* |) L4 `9 N, Eimport swarm.Globals;/ I4 U3 t: v; B/ y0 o
import swarm.Selector;
9 T& N8 S' e7 l* Iimport swarm.activity.ActionGroup;
- d- E5 U, {, n$ }: @4 H8 iclass Agent {2 u# [8 o6 d+ [/ a) j5 ^
char id;, F4 U7 \9 b$ x" H
# t, k( e7 D' A
Agent(char id) {
6 f j. _ f+ L8 R/ I this.id = id;
$ M2 k; H7 ~& j" a! @" A9 W/ a }
+ e2 K, T* @/ m+ ^ ] f# J! Y4 t4 J6 f a. O! t' D3 O/ d2 k. R
public void agentStep() {
: b% J! ~. R6 K System.out.println(id + ":" + Globals.env.getCurrentTime());# R1 w5 n' w; O/ y4 w
}
, C3 Z! y# L, l( w7 ^5 U( m& c! R+ k}, I" e" V$ b' F+ B# i
) p/ n7 F# ~. G/ O2 s' upublic class ActionGroupDemo extends SwarmImpl {
' J7 t* Y; n. T7 `0 N$ N$ v ScheduleImpl schedule;
' t1 O6 @8 g% U! Z ActionGroupImpl actionGroup;- c4 k o" U: e7 X& I
ListImpl list;
5 n E* B1 N6 Y, d% a char Id = 'a';
2 t* Z) F* ?5 E* U' n3 I$ ^5 [, t1 l9 u" |
ActionGroupDemo(Zone aZone) {
) k) l, _. [1 w) Y/ X' M q2 W2 y super(aZone);
0 t1 l3 [9 N' T) p; Z; H3 C list = new ListImpl(aZone);% O: y9 }$ _! ^0 @% [& f( Q) W( A
swarmSetp();
# }# a5 Y3 g& [8 Z" ] actionGroup = new ActionGroupImpl(aZone);
# Y2 |* L" p/ ` schedule = new ScheduleImpl(aZone);& N5 K E7 N. a, m1 u' M
try {% P' |5 R3 _* o/ V0 w! g
Selector agentSel = new Selector(Agent.class, "agentStep", false); t0 o% t# h, [: Z7 ^6 Q" K l
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
# G9 C3 l( y- h, o
0 t# h$ q/ f# y$ P actionGroup.createActionForEach$message(list, agentSel);
- B( X1 N$ p6 z A) k ?; S actionGroup.createActionTo$message(this, swarmSel);
( W6 L0 M. O$ P& o. k. t% p schedule.at$createAction(0, actionGroup);* v S. c! Z" ]
schedule.at$createAction(1, actionGroup);
- u: e/ z: @: T8 {; R- g& A3 g8 m5 } b schedule.at$createAction(2, actionGroup);
* _$ \/ j& j+ Y6 ~' q5 w
+ `' j% b' |6 o: W) r2 ~: s } catch (Exception e) {
. U/ |1 X/ T- E& R1 x% }0 k e.printStackTrace(System.err);
8 E, ^% @& `. v6 ?. M //System.out.println(e); P+ l2 \) p5 Z' J6 y0 J s- w
System.exit(1);+ t* G$ j" H f1 {' P/ T
}9 q) R1 A' T8 `9 y3 h
. f/ D: u- T# G8 W1 I/ P% V
2 l" j4 A Y8 }* a/ R+ b' [ }/ t' a- y9 k* H1 E# O- G
) B6 W( @4 x6 c9 s0 y
private void swarmSetp() {
7 { i, }5 Q& ^& o, T. z list.addLast(new Agent(Id));
]& t+ g" L- j2 }- E Id++;
( h" v* b0 v+ H J }
: a( I# Z$ v2 d1 N R" `. @* K D0 D- |* N
public Activity activateIn(Swarm context) {- T+ s1 Z* k6 d' F
super.activateIn(context);
( J+ v( B$ r! C, ^; K# N schedule.activateIn(this);
8 D! d1 R/ C! }# }/ B4 M return getActivity();
& M9 N) n- a6 y* d }
7 u9 Z5 I1 I7 m) w" ? _3 |% o- u
3 L N& l0 x6 H& I$ h public static void main(String[] args) {. H `/ F3 G" \, E
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);3 G, e, `9 T* |& P% `4 {4 e0 C
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
, w% m) f t, c3 W& s swarms.buildObjects();+ K5 w( I$ ], a% T3 l3 A: N
swarms.buildActions();
- J% K4 ]1 L, ] v6 P$ E& ~ swarms.activateIn(null).run();
( Y* m4 N+ M+ n; t }* S5 a& s2 N6 J. `# t3 ~4 ?* t" \
# o; v' F1 t- `# u$ |$ n
} |
|