|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 0 w1 Z& G1 j9 \5 F
6 N% F r) r2 f Y3 ~本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21& K8 c; b$ U# M p$ s. c* L. i
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
8 L4 K- G$ {. j7 x9 |$ {swarm.SignatureNotFoundException: @; I% w( E3 r
at swarm.Selector.<init>(Selector.java:76), V1 D3 ?1 D: d) v+ z
at ActionGroupDemo.<init>(ActionGroupDemo.java:37). s8 B7 L9 E" ^- Q* H7 l/ P9 u( ?
at ActionGroupDemo.main(ActionGroupDemo.java:67)
! I$ ~/ i5 l. _5 b% t# i ~. e5 f! _9 B6 q
- v; k7 T' \0 R% Q/ i- b% _9 uimport swarm.objectbase.SwarmImpl;* Y. E& Y) d, i; C) h; w" _
import swarm.objectbase.Swarm;
$ ^ U$ G6 m9 b7 Iimport swarm.activity.ScheduleImpl;
8 Y0 b; B& R- z* {7 |! Oimport swarm.activity.Activity;, r: l* d. z1 Z* P* J
import swarm.activity.ActionGroupImpl;1 ?$ \7 E M# Q5 U4 J
import swarm.collections.ListImpl;
8 _/ n/ m2 d4 P7 W2 T% m8 K! uimport swarm.defobj.Zone; 9 A e9 Q S8 R# V. b5 ~
import swarm.Globals;; w% e! N2 b; g) h5 @, z: b
import swarm.Selector;
- c, D( ~7 v2 A1 `7 R- Jimport swarm.activity.ActionGroup; * _8 J/ e. k4 G( E2 J
class Agent {
) ^2 m0 {* T2 X7 Q+ \" d6 w char id;
0 |5 i" ?( M6 r4 T
: ^, A9 Y$ l0 x2 l' @3 i# K Agent(char id) {5 m, }6 i q, t8 D9 I* @- D
this.id = id;; K+ O( z, C& Q# a+ R+ {3 \. H4 W$ o4 P
}
L# P9 K7 \; g7 u7 F4 j
8 K, R1 N8 M! C% z% ~$ ] public void agentStep() {
% Q; i x. n% [. t9 s, h/ l# P6 Z l System.out.println(id + ":" + Globals.env.getCurrentTime());+ b( p6 }2 o6 P" J) D% C
}
- b% l& ^2 s) q, F# U+ R}+ N* f! S( n( K! n4 c: u
8 B7 m8 f( E+ J: r% Cpublic class ActionGroupDemo extends SwarmImpl {7 i: j& O; B4 I$ P+ J% d6 d
ScheduleImpl schedule;
: j) h0 L! K8 z/ H+ I) e ActionGroupImpl actionGroup;
; Z: C \8 O3 { r1 W+ I ListImpl list;
3 g, Q* p8 I/ n+ l5 {( t1 l& B char Id = 'a';
$ w1 t" [) Z2 d
% y; Q" I8 v9 B d ActionGroupDemo(Zone aZone) {8 @. b/ r( V$ P" ^' ~
super(aZone);1 B/ C0 P6 y" G' n; `
list = new ListImpl(aZone);" }0 K w) U J" A5 t
swarmSetp();
& l7 a3 X) a' t9 H% f* M actionGroup = new ActionGroupImpl(aZone);- ]9 P. W: W2 {1 ? t$ d( }5 W. D g" B% [
schedule = new ScheduleImpl(aZone);1 i( b$ O& o# r; V4 J4 w
try {
, y- G Q3 V: O3 A: W Selector agentSel = new Selector(Agent.class, "agentStep", false);" [+ p; @( U9 `- C) R0 y3 F
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
, E. Q. W1 d, _; f . g2 F9 G; y6 D2 ~
actionGroup.createActionForEach$message(list, agentSel);4 ]/ Q8 B( Q+ X( Q
actionGroup.createActionTo$message(this, swarmSel);) A0 D L1 q$ c: g5 x: o
schedule.at$createAction(0, actionGroup); k" L/ I3 \* a1 x O4 l, t6 Z
schedule.at$createAction(1, actionGroup);7 j# }" c, {! o0 q- \% x
schedule.at$createAction(2, actionGroup);
6 \1 r5 g" v! T* b; ~: ^# M, p
$ |" \$ x0 [, [2 U* Q# L: R6 Z- W } catch (Exception e) {
2 A4 r/ s; ^5 ~/ k7 G e.printStackTrace(System.err);
! O, w, i$ ?/ e1 Z //System.out.println(e);
( \3 f' T8 R7 e, t" ` System.exit(1);
. B( W- o" n& l) X }3 Y5 F0 q7 W8 c, ^4 Y
c7 `4 n7 c7 P5 A1 O( A
6 I0 y9 _/ @/ Z8 J, x+ }/ V2 Q }
6 X, M7 X0 S! T( j! ?: P
. ^( A5 p/ J# t. A9 w# _ private void swarmSetp() {
; g! V' N' d% f6 f, x2 `! P5 g list.addLast(new Agent(Id));5 o" k$ R& I# F2 P' L
Id++;9 s4 V" ]) C9 I4 ?0 Q7 V( t* L
}
7 y$ u" p" c/ L' v! j0 {$ G6 t9 N9 l, W: ?- |1 d# k, A0 }: [
public Activity activateIn(Swarm context) {4 P; h4 E2 ?2 H. b
super.activateIn(context);! r' k" V [, J" @* q, i
schedule.activateIn(this);" S! W. f' A0 A! T* t+ `; t
return getActivity();- l! F5 M4 n' F6 W2 N- w2 j
}+ G+ a D j2 l! R" @2 ^
7 e. a t4 C# z7 p
public static void main(String[] args) {
3 J6 q; O8 S" ~5 ]& J9 m6 G Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
$ c2 t$ h; h% d- O( |1 g Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
. |" Y! ^# @; z, Y swarms.buildObjects();
W' f3 d; E& S6 q swarms.buildActions();! _1 T# a1 {6 w% M- l
swarms.activateIn(null).run();
! i( ^7 p( G: [2 G- j }3 ~$ O: G) a# G9 ?* g
) E& u" G9 U, L! O3 c' n} |
|