|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
5 E; |5 F0 R. g v5 w) o1 `1 y) o! w2 g
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update219 n( ], p- q( q2 O, l7 m- w
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
2 E1 k5 {# D n. J0 fswarm.SignatureNotFoundException
# o4 J3 ?; y) H1 A9 ]/ k at swarm.Selector.<init>(Selector.java:76): z( h) @+ m6 X$ d. I
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
) u# H" B' J9 {# s; f at ActionGroupDemo.main(ActionGroupDemo.java:67)' y' i9 r- o4 E: o+ v
& {4 e. `5 k) j9 S3 i! y6 v. p, y
5 d) U W; u% A5 }9 V1 vimport swarm.objectbase.SwarmImpl;
- k: ?/ S% x) `0 {* |+ `' Y3 y! N# zimport swarm.objectbase.Swarm;
8 s' C3 p4 {6 X0 i3 Vimport swarm.activity.ScheduleImpl;2 I0 e0 e. w1 p; k
import swarm.activity.Activity;% m" {5 `' Z- x# Z% b6 P8 o
import swarm.activity.ActionGroupImpl;
1 y' L, O. k) E" g$ x! V. Vimport swarm.collections.ListImpl;
\9 p8 q0 V2 T4 Zimport swarm.defobj.Zone; + |$ Z5 y( l8 B/ W4 V
import swarm.Globals;. s0 M, g$ n1 @( X. A) [$ `
import swarm.Selector;
, k: R3 `; A9 R) rimport swarm.activity.ActionGroup; 2 z; M& h/ z$ j
class Agent {
% @3 n/ ~9 r/ t+ l: g char id;" {" V7 I2 [- s7 W
6 e; `! t- _' x8 O t Agent(char id) {5 J, u* d- j6 c. O; e3 Z) V& L. z
this.id = id;5 f3 F9 S/ n' P5 O' a. S
}. J$ d( o, ~( A, J Q# c
# P3 c4 j) I1 d* y- w public void agentStep() {
" X8 C( d) l& F# i: o+ V System.out.println(id + ":" + Globals.env.getCurrentTime());; z4 l9 ]1 M! U+ {
}' l4 h$ W- p+ C# D( l+ S2 {% F2 p
}! C4 T p- o; p G" T9 Z
# d- ~ O6 i- A% l) r0 X" I! i. Upublic class ActionGroupDemo extends SwarmImpl {
/ d- ]9 q W* _; M [, R ScheduleImpl schedule;, [6 \+ T, d* c, M6 }1 X: y
ActionGroupImpl actionGroup;- J! ^4 ]! Z: _' [5 ]
ListImpl list;* _* d) W- `: e" l( h; Z
char Id = 'a';
% [9 O* b! W' {" Z+ {
3 @! [; @/ N) S9 g' d: A ActionGroupDemo(Zone aZone) { v- {; \ s0 H9 E! d
super(aZone);
& L. H" P; _8 _' U: J1 h list = new ListImpl(aZone);/ E' ^6 G9 L1 x% x1 e3 F' y) ?- {" Z
swarmSetp();
: ]4 b2 |4 C, ]2 A0 |) N$ z9 H actionGroup = new ActionGroupImpl(aZone);
2 P1 Q7 t( F) v: I0 P8 W schedule = new ScheduleImpl(aZone);
: K3 A* k9 I4 l; V l1 r2 K1 ? try {
" g( P3 L2 A! m5 O8 p Selector agentSel = new Selector(Agent.class, "agentStep", false);6 ?8 t& p& l" H2 P2 M
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
" X; H' j) b( a" l) `/ f5 Z2 h F9 ~: H& R. n0 z2 G3 D- h
actionGroup.createActionForEach$message(list, agentSel);
% {5 c7 h& P. S! h% m actionGroup.createActionTo$message(this, swarmSel);% R2 d3 x! [& u7 H/ u9 J4 N+ c
schedule.at$createAction(0, actionGroup);: m6 y* ]# |* d9 e7 ~+ P0 R2 v/ {
schedule.at$createAction(1, actionGroup);
1 S4 o0 E: f9 G1 G8 g8 \ _ schedule.at$createAction(2, actionGroup);7 [8 X) C6 D, i, [- ?) z
5 H3 P8 a( ]8 i5 ~# \
} catch (Exception e) {
. a9 U; m) Y! [- J$ v; { e.printStackTrace(System.err);3 o3 Q$ I V- h% |
//System.out.println(e);
/ G$ p1 l' r5 R& \ System.exit(1);3 I8 S0 V: d! J5 f
}( N5 i O5 T. j% C
! b: y6 f1 n2 W
8 S/ O* H' [7 x% r' u- c& L! s
}5 P$ i# z' P( K7 N1 e n
$ s% s( F4 X& Z private void swarmSetp() {6 D+ K3 T5 {* d3 B4 \0 K
list.addLast(new Agent(Id));
- K. i3 U4 u; J) s/ K Id++;0 Z1 p5 s2 k; O' D, p
}
4 k; q) _" N8 o4 a3 n* @7 T: @. l$ |
public Activity activateIn(Swarm context) {
9 S. s; a8 n! [) V5 I super.activateIn(context);
: b6 n; H/ X4 P+ T+ _ schedule.activateIn(this);$ Q9 L9 f: g" P3 j
return getActivity();2 \- u3 v# \6 W6 t9 ?8 a! K
}
8 H, M) ]* K( |- E7 l! t4 O& H1 K
public static void main(String[] args) {
. h( L% n- P/ { Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);' o+ T& ^/ [+ Q/ K8 P
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
) f+ J% g1 p3 u3 e7 R swarms.buildObjects();" M H3 E& p; o# @
swarms.buildActions();7 c5 i! ]$ R* f+ {
swarms.activateIn(null).run();# P# r' |$ L# T
}
4 W6 [* C& d i* O0 ^, v* a' P1 ^% V7 ^. o# Q2 \! `1 F8 J/ S
} |
|