|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
+ t% ]( C. \2 o. n
4 ]' V+ s, N- E& N本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21; l$ {+ u# I* I
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
* q/ D' I1 D% z3 b8 Nswarm.SignatureNotFoundException
0 j' x! v0 u) F/ F1 s5 J9 Z8 Y9 g2 ^0 L at swarm.Selector.<init>(Selector.java:76)% u7 O( b$ R+ B/ s! L
at ActionGroupDemo.<init>(ActionGroupDemo.java:37): a2 i9 B* K1 j3 Y/ ^
at ActionGroupDemo.main(ActionGroupDemo.java:67)
7 I( s; R1 V+ ~
8 }' R8 U) s7 P0 z" p" Y6 {5 @9 e) H- @; i' o- Z* y1 }; g: d
import swarm.objectbase.SwarmImpl;
/ |" r" V6 L/ z2 M6 `! fimport swarm.objectbase.Swarm;, G* R, u" T5 b/ m6 B0 C* o, M
import swarm.activity.ScheduleImpl;: u, d9 v. S' t( n l
import swarm.activity.Activity;
, k( D; k+ ?2 u- i( v6 Kimport swarm.activity.ActionGroupImpl;
; s6 J& p4 p) y% S' Mimport swarm.collections.ListImpl;
) ` {3 j' o! L+ Vimport swarm.defobj.Zone; # H' W$ }, b: s0 E, m% n
import swarm.Globals;
& V& m- g. q, K: _, Pimport swarm.Selector;
' L0 M- r$ \ ^, G7 s: ]import swarm.activity.ActionGroup; ' g6 N/ m3 G0 J( j
class Agent {
w( [4 W- A4 J) S7 p char id;
- f0 @" a' g+ {8 g* h. i
% V( g: z+ @; J) w4 d+ z w Agent(char id) {
* E' g0 O3 g7 O4 o; S- q/ `8 M/ i this.id = id;
% K: B9 b# X$ I' C* c7 y }2 @" z& i8 v2 ~: u5 l6 Q3 R
% l( D. j+ h# q6 ?9 q5 N
public void agentStep() {( R: r. N+ _( c/ t% E
System.out.println(id + ":" + Globals.env.getCurrentTime());
' ^1 C2 A" v' @4 l; H }
7 Y$ f, Z3 K, |}+ H* [2 A% G+ _. B( h
; e4 V/ j2 U% O# y9 t# V
public class ActionGroupDemo extends SwarmImpl {
; n8 T# W. J1 \2 K4 E ScheduleImpl schedule;
9 }) u1 O3 D( H- c- } ActionGroupImpl actionGroup;
1 q% D/ M/ W2 v3 {) t8 W9 f ListImpl list;
" O+ G( g2 u8 f7 Y+ Q% m" n char Id = 'a';, u; U8 d b' D& }# d t
9 N* I, k( v' Y
ActionGroupDemo(Zone aZone) {" Y. ]; Z& i4 F1 U( z/ Y, D/ k
super(aZone);& g6 Y# Z& s$ `; J, ?+ k
list = new ListImpl(aZone);
7 u8 K6 S! Y$ I+ p swarmSetp();; A0 f3 S! ~; F; M
actionGroup = new ActionGroupImpl(aZone);
7 ~; ^; o+ R( ?! v schedule = new ScheduleImpl(aZone);
2 r5 }& P; d+ P# |$ g- ^* @ try {
" N- H m( x8 Z/ J7 v, n Selector agentSel = new Selector(Agent.class, "agentStep", false);8 e, M1 ]4 @* P; ]2 v& F F
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行* f+ A. C+ i8 V8 h7 l1 m( m& E' l) Z
/ A2 I9 \ U' k- `, m2 I4 [/ j1 G
actionGroup.createActionForEach$message(list, agentSel);
4 J0 J8 Z' _3 I# C actionGroup.createActionTo$message(this, swarmSel);. u: N- Z3 V, u5 u5 T
schedule.at$createAction(0, actionGroup);
5 u# b8 q% w' R- Z; o schedule.at$createAction(1, actionGroup);
# x5 Y! m8 `6 S3 }( c4 {- E" F schedule.at$createAction(2, actionGroup);, i- _3 x: v) H Q' Y. ?
" }6 `9 W C% p/ i2 l } catch (Exception e) {7 Q |" A( u+ [/ t
e.printStackTrace(System.err);/ ?2 o4 Q: l3 G. G3 O# k
//System.out.println(e);
; {2 u p/ g, Q; G6 s System.exit(1);7 k: s1 h, a5 t. J9 D
}9 o" M1 s6 X9 c) C( u# Z. v
9 k0 e' i1 B w
- s Z- p. z0 ~" n. a: A
}5 K3 y7 V6 d# v7 T
5 _3 Y$ H, U9 I1 b/ i9 R! Y
private void swarmSetp() {
% F( I" y8 Y/ ?# s list.addLast(new Agent(Id));; j$ }% ?2 T0 w! |" p4 }/ H# h
Id++;7 r" `5 n$ J/ v# E+ }) l: ^
}0 j# i K5 o6 G' ~4 t6 t8 i
4 `* l7 A6 N- Q
public Activity activateIn(Swarm context) {* r7 S1 T. i* \/ ^ u1 v2 Z" ]$ r
super.activateIn(context);
/ H7 e( l0 u3 Z schedule.activateIn(this);# y- e; u; K- }& Y
return getActivity();4 W+ |6 I$ X& j4 z
}
( B* { Z0 @1 Q" q. b- r) s# f4 e
3 u% t* T5 S+ ` public static void main(String[] args) {
4 Q; o* ~& _6 F Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);% d1 {1 ]: R8 q6 Y" E- \8 S
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
* q/ u& u# U1 U2 |8 G swarms.buildObjects();
4 ]& i5 m3 r) L" n swarms.buildActions();6 \) Y5 S Y- b$ e3 i' U: _. I
swarms.activateIn(null).run();
& j5 R+ d0 T* p }9 w) @) `2 t5 z7 u- I
, U6 H; n0 _1 q3 `1 }, q4 w} |
|