|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 : q4 I) y$ w0 N1 O, @" ^8 y) S
& H( N$ r+ K# t3 L2 m% X# a
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
2 m( T3 s1 s1 V. I7 q以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激." _7 X- p* N v- u. J, x/ q3 J
swarm.SignatureNotFoundException. x L4 v! [6 M/ M" m
at swarm.Selector.<init>(Selector.java:76)
7 V! E2 i1 D: {( d at ActionGroupDemo.<init>(ActionGroupDemo.java:37)7 e: `9 i+ j9 [4 q# L( @
at ActionGroupDemo.main(ActionGroupDemo.java:67)
+ x# a6 O# i4 n
* p! \0 L" y# B" ]
* L k1 {8 e* l: \- P7 Q, Yimport swarm.objectbase.SwarmImpl;! y4 Q4 z5 A2 Q L/ S
import swarm.objectbase.Swarm;
8 \) D2 |& H5 w9 C7 \$ r' O' gimport swarm.activity.ScheduleImpl;1 H3 z' L, Y7 x" C1 D' s! D
import swarm.activity.Activity;. s/ j0 q+ J' r9 Y
import swarm.activity.ActionGroupImpl;
/ G. z' h$ H$ I& O8 }$ s/ m( [% Zimport swarm.collections.ListImpl;
" `: z; ]. f( ^, ?4 k Oimport swarm.defobj.Zone; % k) I2 r3 `+ n! r
import swarm.Globals;
& ~' c7 I! Z/ Qimport swarm.Selector;
x t+ ^+ Z4 B9 [2 Nimport swarm.activity.ActionGroup;
3 v2 |3 y- [4 D& f. I8 {, ]; gclass Agent {) j, F L$ f7 B: a; y) E, a1 z" e
char id;
8 n, V8 W# e8 ^8 {0 C; V, L2 ~, w
$ x3 z1 r. t7 {8 m3 ` Agent(char id) {- ^3 T9 n2 A; C7 f
this.id = id;
% g6 l9 G, a$ ^8 P }) r6 Y0 t" P4 D6 ~/ X; V, t
1 g/ _' T3 E' o; A3 ?. g" S# A
public void agentStep() {0 z" K. v1 q/ I' y* `- C; U% `
System.out.println(id + ":" + Globals.env.getCurrentTime());5 R; D5 L1 M& C
}
6 S: I7 [8 X. `( r* Q- r. u" R}
, K2 f% s7 i( D$ S0 i3 ^4 j0 w _3 u2 t" I& ^
public class ActionGroupDemo extends SwarmImpl {( l ^) d1 v' j* N, ?0 E% P7 I
ScheduleImpl schedule;- j& |, m6 [4 X! l* _7 H) v2 I( j1 \
ActionGroupImpl actionGroup;
9 N7 u1 a" F% H" z* w- h) A, H ListImpl list;
) ]; T+ v: M+ U char Id = 'a';
6 [6 w( ^0 Z: d. i8 o: ?& m* _. d. h% T9 F; Y1 G8 l& t
ActionGroupDemo(Zone aZone) {' R& ^( z" |8 ]. e6 n: Y. K3 J9 I
super(aZone);
: e" I( }; {1 ]- Z/ J& Z list = new ListImpl(aZone);% {7 D3 {! R5 f: Q7 J! D' W3 r; p
swarmSetp();/ z3 [. M) o1 b; q0 K6 t9 W4 z* x
actionGroup = new ActionGroupImpl(aZone);( [/ _, i/ t/ q k) p
schedule = new ScheduleImpl(aZone);3 B( X9 x; M; L. d5 d
try {
" a2 C8 ]6 l6 o4 M- C7 h5 L Selector agentSel = new Selector(Agent.class, "agentStep", false);! C6 A, m) W+ @% W7 y9 O7 v' f
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
! C+ m+ S# d$ F n8 [, B! n
0 `6 f8 g: i8 a* y* P5 l actionGroup.createActionForEach$message(list, agentSel);
& q6 p0 v, Z. R; U5 a# g actionGroup.createActionTo$message(this, swarmSel);
6 {/ x& q$ ]% M9 c: _ schedule.at$createAction(0, actionGroup);, Q( @' D% X1 @" q
schedule.at$createAction(1, actionGroup);- B. Y/ s+ O/ C) |& K6 R3 Q2 i3 C4 c
schedule.at$createAction(2, actionGroup);
( O7 ]8 z1 n0 f2 `& R: i
. W. ]+ w, d! d/ n1 T4 Z) E } catch (Exception e) {
; ^, {& C( p; t. a. ~! D& _ ] e.printStackTrace(System.err);! B4 X' ~! Y+ O' T6 x# w
//System.out.println(e);
1 C/ o X" J. E" l System.exit(1);
1 B6 z! J. b% f8 m }
4 j @# f3 O$ z$ M9 M9 b5 p) p1 O" }( B7 g' y
9 \, m* G, L/ b; k: N }, T$ o, b8 R: Q) b
" C* l, f6 Z, L9 W
private void swarmSetp() {0 ?! b6 m# R: [8 L e% G+ S: T1 k
list.addLast(new Agent(Id));/ q1 T- a" e' }$ F& i. ~( v
Id++;
! |( Y) n' y0 J$ c }& \) z4 a+ D6 d! }5 j7 t" U1 ^/ A
$ h4 }4 L4 ?/ O! M" y; o" P public Activity activateIn(Swarm context) {
- U7 N& M9 `# x- n# K super.activateIn(context);
3 u9 b$ I& K3 t4 Z# n schedule.activateIn(this);
9 d- y5 U! }5 ?) S1 i, c return getActivity();
" D$ \8 x4 L- i' z ? } } w! `% E m
9 V4 W; n3 p: T3 U/ E) u public static void main(String[] args) {2 |7 A+ D9 Z7 Y {, g K9 C
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
2 g6 y: t. A X1 \& y Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
* ]% p- ?6 ?- X$ `. \ swarms.buildObjects();/ V- A0 q4 O7 u. G3 V: w
swarms.buildActions();
8 u) w7 Z1 B5 b) O& ^( E# f0 G. S" v( H swarms.activateIn(null).run();4 d' \5 i4 ]0 {
}
+ E4 s2 j* W# Y2 @+ x# v1 R: _5 |- p- T" B9 u- ]
} |
|