|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
, C ^6 F( j5 \* b) P3 N4 p" P" f' z) \4 N2 L
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
+ ^* Q/ e. y2 C6 c以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
$ E9 c4 e: h* y% F& A M0 jswarm.SignatureNotFoundException
& X2 ~+ d+ i" x( m at swarm.Selector.<init>(Selector.java:76)8 G1 b5 A- C1 _/ R# Q9 R7 g8 c
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
6 }+ `( l3 T0 w! t. j at ActionGroupDemo.main(ActionGroupDemo.java:67)
& E! p' }- U+ K& D: `
5 ]# a" \# A2 }' K' p2 `, Z( h. K: s2 @5 @' y
import swarm.objectbase.SwarmImpl;+ j/ @6 B0 e; T$ i0 i
import swarm.objectbase.Swarm;
\: a! m ^9 ]0 p, I! z4 {import swarm.activity.ScheduleImpl;
+ J0 j: G' Z% f5 yimport swarm.activity.Activity;
2 {+ _0 p" U* J9 ^; Bimport swarm.activity.ActionGroupImpl;8 w2 C/ Z+ f6 C5 y; H- R1 z
import swarm.collections.ListImpl;
( I# a6 M2 @) `' \import swarm.defobj.Zone; 0 r6 S# |/ c+ _8 q1 V/ j
import swarm.Globals;
4 {- b1 o, e7 g8 bimport swarm.Selector;
- ?' q$ E2 L' X1 C/ p8 m: ^" ]import swarm.activity.ActionGroup; 8 S3 d* ^3 x- R( i M \+ @
class Agent {
S6 X! h, M, d6 a$ w char id;+ e9 ~! P( o# H4 ?( \* l- b+ d
- t% A+ ?% p: r& P; \2 Y5 H5 b! S7 o Agent(char id) {
, q( \0 [ Y" @8 d6 i8 ` this.id = id;
% @- P& g% ]( d$ Q( r }7 m1 P2 x, o! a" P: F
" f4 _, ~& X3 W, B; n8 ]- s7 {) W9 ?
public void agentStep() {
( ~* J) b: t9 l" p: B6 z& k: ` System.out.println(id + ":" + Globals.env.getCurrentTime());
4 {$ ? n7 W5 ?( E }
5 l4 y/ {$ Z9 B% o}
5 z* K6 \, R. H1 M0 L- i! x8 g' o3 P9 @
1 R) q6 I" |7 W. H% S! r& S+ \public class ActionGroupDemo extends SwarmImpl {
; ` F0 Q+ I% @( g+ U% U' n ScheduleImpl schedule;
, j+ a; |0 f" t- m ActionGroupImpl actionGroup;6 k+ o- R! Z! ?- D' t5 h4 `& I0 t; V
ListImpl list;
) N7 l6 d/ S$ v& J- n5 s/ w- {* M* w char Id = 'a';7 H( h: ]3 b; b
# V8 z6 p1 x: n' V ActionGroupDemo(Zone aZone) {' F/ A9 b2 m1 P- T% @; h) F+ [4 `
super(aZone);/ F5 v) m1 ^ V: m
list = new ListImpl(aZone);1 ?$ G+ J+ o* ^ Y0 n/ t" [
swarmSetp();8 B- s- N0 B% D* P
actionGroup = new ActionGroupImpl(aZone);
- Z; L% j7 L9 A9 d schedule = new ScheduleImpl(aZone);0 E! s5 u% ]( j$ ?" \4 @
try {2 x# L9 n1 r; r- a/ h+ @8 i
Selector agentSel = new Selector(Agent.class, "agentStep", false);; |8 e+ c" g. R2 J- d# f) S- T
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行) z, q, x6 F! H' J* N: _
. e0 F8 v" ]5 E7 d
actionGroup.createActionForEach$message(list, agentSel);
" F2 b5 h \- }3 o) z actionGroup.createActionTo$message(this, swarmSel);
5 M, \! C# M* x p# ? schedule.at$createAction(0, actionGroup);, l/ Z# S5 V9 q* @. z& q% [7 C# E
schedule.at$createAction(1, actionGroup);
" n: p0 B# @6 b! U schedule.at$createAction(2, actionGroup);
* ?# K4 K) [ Z8 v% W; ^( K' F4 S6 S: c" O, _* v# W
} catch (Exception e) { ]5 x( B) h8 U9 ]+ H) a
e.printStackTrace(System.err);
/ C$ Q7 D: M) d& c/ E5 C //System.out.println(e);4 J' g1 ~9 X& _
System.exit(1);
. U' P* W* n6 h }4 e: r" q. V; u
7 ]) Z: Z% n4 e/ d
& I. S. {( n4 }) A4 J' q
}8 s! T+ c9 b, a! Y8 `+ \
" V R# P/ n" p$ N4 G" ]) l private void swarmSetp() {
9 N& J o. T5 \- ~ j9 R3 V; k list.addLast(new Agent(Id));
" F9 \* L: k! m) Z Id++;
. r* G& { J! H. Q }
* j$ E5 {* X, w1 C5 R" V8 B# |. c- X9 I
public Activity activateIn(Swarm context) {
+ s* a" r# E" A6 ^) z% t" d: } super.activateIn(context);7 Q& t% w2 |. J# W$ w/ g, ]- n
schedule.activateIn(this);+ T' u2 j$ Q- b. @1 v/ ^4 G
return getActivity();
8 B7 I% _" b0 U0 a }9 z& g8 d2 B. H4 y0 P+ F
9 G5 |0 \. P2 M' P# T public static void main(String[] args) {2 P# X' f! z1 m) t$ E; {, U
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
) n" k, x( }' k+ O Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
& \% u5 `9 M- i9 ?- x swarms.buildObjects();
' D( |0 Z0 n' {% n, U4 V swarms.buildActions();% f7 D \+ d( ^" k4 }8 n4 p* o& w9 S5 Q, i
swarms.activateIn(null).run();+ U& S1 _* l' m/ }) @$ ]
}! E3 {0 \, A) o$ L
1 c% P% l3 s3 a. x* n5 f; ?} |
|