|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
3 j* J% `# N7 Q9 t! |+ g0 [, s4 l; Q9 R, \+ a% s
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
* {( Q: G: Y% p' @, B5 ~6 _以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
' U4 @; i/ _: F0 i7 aswarm.SignatureNotFoundException/ L+ D0 J4 e4 k, T1 ^
at swarm.Selector.<init>(Selector.java:76)' H ]( n. m- U4 _! Y) m5 w
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)1 p) U" T3 E) T* _% {; h. ~
at ActionGroupDemo.main(ActionGroupDemo.java:67)
# N! Q8 [6 C" T$ u3 n% g# b" U9 B: d! {7 ~9 A, T( `7 d
3 N8 ?4 A( p7 Y z, ?! Fimport swarm.objectbase.SwarmImpl;
( k( t2 P: F- i2 Q$ P. ]3 \import swarm.objectbase.Swarm;$ v! z" p, s/ P6 i% {; T
import swarm.activity.ScheduleImpl;' I d7 c$ |; Z# O8 O- l$ u0 z7 B
import swarm.activity.Activity;: B/ {) _* X+ G4 q6 c P8 X
import swarm.activity.ActionGroupImpl;
3 |4 Z f2 e( J6 z2 o6 z- Qimport swarm.collections.ListImpl;
' B1 p) g- ^/ O% K5 Jimport swarm.defobj.Zone; 9 G" s- o7 V/ }& @6 y5 ~
import swarm.Globals;4 o! g1 o3 R o
import swarm.Selector;
' O) M8 {, O8 F- Mimport swarm.activity.ActionGroup;
% f- \% `% x' x. _; {$ [5 mclass Agent {
& b, l o! L6 G+ @. v- @( v char id;
/ Z: k7 z: i3 j/ ?( Q6 ^4 R4 g1 V- i
1 S: ~& r" E0 e/ E4 Z Agent(char id) {
' D, k! v9 ?9 T _- ?: l# D1 e this.id = id;
4 \8 F( i9 d, k. i4 L }& z& B+ k ]6 v
/ v0 q: I- U! T4 h" U3 e
public void agentStep() {
, |6 L# u, a8 e7 ~! ]9 l System.out.println(id + ":" + Globals.env.getCurrentTime());
' s3 F1 b8 Y5 E }
' S' v5 S( r6 Y; f- T}3 @& J: W- S! `
$ x& o9 e' Q6 B: x& }7 Z
public class ActionGroupDemo extends SwarmImpl {% T# o2 b- k/ U$ Y* h3 Q& H8 _
ScheduleImpl schedule;% Y u$ Z" l; k# Q3 b7 l/ d' d
ActionGroupImpl actionGroup;( Q* ^. ]" O* t! C, ~9 m5 W6 c; V, `
ListImpl list;) T1 f6 }2 x5 v# }# y {) v$ `1 O: j
char Id = 'a';
Q6 l- a, Q+ f1 s7 F5 h/ u
7 [, p& U: ? p5 [0 C, e. g* v ActionGroupDemo(Zone aZone) {
R2 g4 ~) u' } super(aZone);; D8 t7 g' n$ n5 z: B/ u2 n; K2 n
list = new ListImpl(aZone);' [/ c$ \- E1 Y b- n. U
swarmSetp();$ ^3 x, ?& O+ ~
actionGroup = new ActionGroupImpl(aZone);, @% S- a' Y s: p3 U; A
schedule = new ScheduleImpl(aZone);" o# E$ L8 [7 ?
try {& a" t9 U1 D. ~* L
Selector agentSel = new Selector(Agent.class, "agentStep", false);
0 r- e8 y0 u# K Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行6 E# n% Y7 v5 \4 N
, ~ k/ k0 W. {# A" k0 @; Z7 S actionGroup.createActionForEach$message(list, agentSel);/ Z. l" R! [( g& d1 _* |1 W
actionGroup.createActionTo$message(this, swarmSel);
; J) {# t# k# F: j schedule.at$createAction(0, actionGroup);/ q% ` c- n0 {+ C, [4 v% F
schedule.at$createAction(1, actionGroup);3 J& D3 p: q6 a6 i
schedule.at$createAction(2, actionGroup);
8 z/ c" |. x" v% K" m: S' E2 {. C, Z$ ]# N6 V& P
} catch (Exception e) {
' W6 P N- Z" d+ f: p7 j e.printStackTrace(System.err);2 t+ a/ Q4 ~5 m0 _$ t
//System.out.println(e);9 w; g# [- F. \ q5 a
System.exit(1);8 ^/ B- G& J, Y2 Q) R7 K* ^
}
: h5 o6 h# R) ?# {* f' e' @: q$ @4 i X$ H0 K3 x
) y; [5 ~$ U' }) _ }% V4 y+ u+ w# l/ M9 l/ u2 g$ J! ~
/ d9 }& D8 m; |' Z private void swarmSetp() {+ m7 }6 N n/ z# P5 \
list.addLast(new Agent(Id));
6 v; \4 C, Q# h4 _/ L Id++;
9 B: N# ^' Q% i3 M, `2 i }+ m- ~6 G2 T l) L- ]# O
. Q: x, `! J# A& E0 _ public Activity activateIn(Swarm context) {
/ o3 }) }' W$ }6 _ super.activateIn(context);
% n8 E2 a0 H1 h6 Y( i& ~+ `. B schedule.activateIn(this);
) | @6 V+ a/ X$ ?7 F% {0 S9 c return getActivity();+ |' u, ]( u S. i
}
& H4 }7 y: I5 L) \5 a8 t) D* R: n* o* d7 H' p2 b! M& h/ m4 f+ [
public static void main(String[] args) {
! ~& X' p3 H! w Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
8 R9 n& V. u5 O% v: I {+ q Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
( {1 q1 |7 K8 K2 i# V4 J" ] swarms.buildObjects();' ]3 e* R: a! Q" t' J
swarms.buildActions();# m7 h- }, I# e% C( \. H
swarms.activateIn(null).run();
- I8 @2 p9 d$ i. I% j# { }
; S' |8 e$ e. i7 Z% _8 j& M6 ?; W- R4 } J# U& X3 S
} |
|