|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 R6 G! D9 H+ ~; f( K* @( h! P" Y
, M, G6 N$ k4 s, Y2 w# r* D; P本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21, i6 f" ^* K4 r; n$ M2 p5 Y \1 u5 {
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.1 A0 W7 _% j/ l6 [ Y
swarm.SignatureNotFoundException
5 A5 V: {# Y' ]! `* l. K at swarm.Selector.<init>(Selector.java:76)
7 G% I6 c* g% |5 t0 Z, H* t at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
, T, ~; `6 g- t7 j3 M. F! D; { at ActionGroupDemo.main(ActionGroupDemo.java:67)9 I1 `/ f$ H- k) d+ m: P$ b5 S
8 B. B4 V$ h! ?6 y8 t1 C2 j7 y
, B) h3 s: `3 W* ]7 F" t' K( p& S
import swarm.objectbase.SwarmImpl;4 f$ ~$ t. p, x" U; j7 Q
import swarm.objectbase.Swarm;8 S' Q2 u0 d" z$ {2 j7 l
import swarm.activity.ScheduleImpl;
/ F% V: R* j; g0 D8 nimport swarm.activity.Activity;
" m# z g& H0 B+ _. n) simport swarm.activity.ActionGroupImpl;
: r- H% d* E7 k8 }2 himport swarm.collections.ListImpl;& k/ `8 r8 w% o7 q& [
import swarm.defobj.Zone;
! C7 N- s6 g f: ^& Y- Aimport swarm.Globals;
# P! x5 `0 w: [9 P: q/ n/ c% himport swarm.Selector;* b* e( d4 i, s
import swarm.activity.ActionGroup;
( n9 f2 n+ ^+ B8 P+ x6 fclass Agent { `% ^5 K g( @+ ?
char id;
6 t+ ?+ @/ a& V3 T; I/ ]! o& g0 c0 H3 n* r: M
Agent(char id) {
- m; w0 I. A; E/ C( a0 V' E this.id = id;
) d+ x$ [6 b- _4 z# ` }+ a# U. p& p J9 H
" u/ e* S1 }" U( T- @5 h: W public void agentStep() {
# X! e3 Q7 Z% A1 Z, L. C8 F- o* M System.out.println(id + ":" + Globals.env.getCurrentTime());
# F# t8 {: j! N0 m }
2 n9 l+ q' c/ b! s) @5 G3 w) r}; F5 \9 r1 @9 p% R0 Y/ w+ a* o/ {
; W& h0 L. E9 o1 }( N. Mpublic class ActionGroupDemo extends SwarmImpl {
8 d4 H2 ^" m+ z2 c ScheduleImpl schedule;
1 p8 h1 @4 i+ Y- v& L( w, l% T5 Y' Y ActionGroupImpl actionGroup;
6 X) I# o0 L/ a' M4 o I! @: [7 A ListImpl list;- U7 b& N, w8 Q( j
char Id = 'a';. w2 f. o2 |) J; \$ Y: j5 r
2 C- F- V, l3 w! O% y! r% [ ActionGroupDemo(Zone aZone) {9 v5 `) Y) A2 k3 s$ N5 n
super(aZone);0 c, k! T1 V% `6 w' t7 r
list = new ListImpl(aZone);, _1 I0 R+ y' b8 X7 A
swarmSetp();
7 e( h6 |! `0 m% Y. _$ ? actionGroup = new ActionGroupImpl(aZone);
$ K+ k7 E- `# ?. Z7 S schedule = new ScheduleImpl(aZone);6 Z: f' }: t; ~
try {
' y" X8 y$ D- L1 z V Selector agentSel = new Selector(Agent.class, "agentStep", false);, D8 k; q) H9 p/ C% X
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行- j$ f# x8 Z& m: Q
1 e [' V7 n+ Y/ e& Q
actionGroup.createActionForEach$message(list, agentSel);3 \3 _0 B, V. k' r# K; J: s, _
actionGroup.createActionTo$message(this, swarmSel);
$ K) q) y: o* E: l schedule.at$createAction(0, actionGroup);
6 d( q" x$ ]) M& N schedule.at$createAction(1, actionGroup);4 P. P* N" g4 e+ O3 [( x9 b, Y
schedule.at$createAction(2, actionGroup);1 C7 g4 S* i: C( {! M' W
, g) U0 j" p7 [6 @* E
} catch (Exception e) {
; E3 |* c; v5 W3 O% V9 d e.printStackTrace(System.err);2 l$ ]4 H& t; [" Z' Q$ C2 G4 B$ x
//System.out.println(e);2 g! b2 e* z4 A* a( M) {! U2 [
System.exit(1);
* b% M: z f* O7 }+ f% l4 K }
: X% Z: d% K9 _0 A& L8 E8 X) L% c) T! O0 x
, H O+ O% [/ C6 a# a% C) E ]. H' y }2 c3 l% S, J- S% J9 x- f& a% J
2 n* C* F8 Q$ `. a9 b4 O3 b
private void swarmSetp() {
/ \7 _0 I' r- Q/ x; _7 a list.addLast(new Agent(Id));
( }4 @/ P" ~0 Y4 } Id++;
, T7 h1 n( V" U7 L }% X0 t5 ]4 E( R: x$ u/ u
- z1 X3 L. i8 r% f2 k2 B: b1 x; h
public Activity activateIn(Swarm context) {2 k- v2 H1 I& L- x3 X3 i/ Q6 @
super.activateIn(context);
]) L& ~7 z7 o( F) I' ~; U. ? schedule.activateIn(this);
+ |/ @8 c5 r0 \- R return getActivity();
1 ]: @% F9 v) m% }0 k; p% m3 `3 g% O }
: U4 v+ l9 }! e8 v. O$ n/ u- h# c* N( `3 i2 B1 D& m
public static void main(String[] args) {) a9 U3 r- V7 r4 z
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
5 c- C! v! A1 E0 n* ]7 r Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
) J) w7 w" l9 q6 a) R( A7 x2 K swarms.buildObjects(); y5 F6 G: s; J5 u$ g% W
swarms.buildActions(); _ B4 u6 T0 e5 I0 r
swarms.activateIn(null).run();% e0 B% j# W* E& q3 j2 u
}
5 ~. S5 e- l0 i( N0 w* A
0 T0 Q! g6 v1 K8 q} |
|