|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 & y1 @& E: d3 C' ~ m3 q U7 @
$ K9 ^; ~% h: C( {, @
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21# v; t7 a1 R' B) P
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激., d6 y% e0 t" H7 L
swarm.SignatureNotFoundException
4 F6 p: f/ v+ `5 H at swarm.Selector.<init>(Selector.java:76) o: w2 V4 o+ J( Z# }; s4 ^
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)) ~$ L/ d E8 u% V
at ActionGroupDemo.main(ActionGroupDemo.java:67)4 t( d6 n1 d0 r1 o
" J- t8 ^8 p% x% B3 ~9 O9 Z9 |) S
4 S* p+ t0 k$ u l9 F" Zimport swarm.objectbase.SwarmImpl;
# d* w' r* A/ C$ gimport swarm.objectbase.Swarm;
* G' C+ s4 v, X! L: @# z+ Fimport swarm.activity.ScheduleImpl;0 }: i* |, t2 m3 i; u4 f8 h6 }" o
import swarm.activity.Activity;
( S& q4 N& h1 W6 N. X/ gimport swarm.activity.ActionGroupImpl;
6 h+ n% D( Z! V; U4 H7 i$ j1 oimport swarm.collections.ListImpl;- X `' @) ]( l: b0 b& q
import swarm.defobj.Zone;
' P, |3 E/ B+ T- q7 E1 C1 T: M, Y3 J1 [import swarm.Globals;' M& L# o0 v q, ^3 j9 n1 r
import swarm.Selector;1 p2 X' c* b, G4 d" m
import swarm.activity.ActionGroup;
0 w0 L4 n& m2 X) R9 ?% hclass Agent {( [* N. Z1 P. Z; J: F
char id; I p& j0 C" W+ p* X" o" M
* H6 P) j7 D4 T2 i; t Agent(char id) {
" c# n3 h, J0 x, M! M7 u) P: F4 ~ this.id = id;3 U8 Q+ Q& b- }7 U
}
& s' G9 c" s6 f! M" L3 n- c9 L) \, p% }7 j
public void agentStep() {
) g7 P6 R t, o; o! Y System.out.println(id + ":" + Globals.env.getCurrentTime());6 ?0 Z |3 s8 @! x( T0 U
}
% E/ {" `6 p- [$ q% R}9 Q: c1 t3 c/ B
- Z( n7 z' B- F" npublic class ActionGroupDemo extends SwarmImpl {5 K# P9 ~ f- L m% J
ScheduleImpl schedule;/ o$ f. [; h5 F
ActionGroupImpl actionGroup;
' y5 S) D; Z5 R R3 _ ListImpl list;
- t. P2 y8 R0 F char Id = 'a';; F0 K7 F. z0 r n: R2 G6 |0 k
9 d8 \/ l" ]8 I3 X$ ?. w# q ActionGroupDemo(Zone aZone) {
8 h @. Z0 E$ k; ^* ^ F super(aZone);/ c* U, \& l: I4 J; x
list = new ListImpl(aZone);
2 {; k, F2 ^6 j2 p swarmSetp();
6 @* E) j) [2 @* X actionGroup = new ActionGroupImpl(aZone);
% z0 W# W% x2 d0 p7 w! q* R schedule = new ScheduleImpl(aZone);
) u+ {: u# P0 O. ~9 {0 h0 a try {: t6 A2 ?' E+ e6 Z$ x9 m% \
Selector agentSel = new Selector(Agent.class, "agentStep", false);2 w0 d# D5 M: t% E# N! Q
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行" P7 M) l3 ^/ z* y% o
" o4 g. b. u+ d# g actionGroup.createActionForEach$message(list, agentSel);
# ~$ A3 l9 ?% ~6 p# x actionGroup.createActionTo$message(this, swarmSel);
O4 n6 [1 Y* p3 j' O+ x- G schedule.at$createAction(0, actionGroup);
, C$ S, y- D& K& y- s. {- b; s! k schedule.at$createAction(1, actionGroup);( ^& M% `, W& Q1 V8 A
schedule.at$createAction(2, actionGroup);5 ?$ [+ m* r& F+ z+ V4 M- g6 O
1 t* }3 u: T0 Y& q
} catch (Exception e) {' z. p* x8 x2 ?( b& G+ ?% ?7 S
e.printStackTrace(System.err);+ R" t6 G9 k3 o6 J9 D
//System.out.println(e);
& u4 _0 K; O9 \3 b System.exit(1);
; M5 d. i% ^+ x+ p, z }4 b( Y9 Q, e1 l2 v' x0 _, \$ z* S! l
4 F( C, k; t5 b
2 G9 \5 C; Y' R$ W2 R
}" R R5 h1 m6 q" {7 [- K4 k; O% y9 [
) U3 }; Z4 Z2 c private void swarmSetp() {8 t( l% o7 I0 g" ]. @% q2 D
list.addLast(new Agent(Id));# h/ `* k0 a( V9 d
Id++;" J$ H. I+ A5 q$ V5 @" }
}
! l9 [: X8 ^0 V3 @
7 j/ F L; n1 A" v public Activity activateIn(Swarm context) {$ a3 E0 ~3 c9 _
super.activateIn(context);1 p! V) ]% V* o; C
schedule.activateIn(this);
t6 T: i4 J# @# B7 e% S* L return getActivity();* E5 |. w/ E( h) e' |( B- I
}( c/ A+ `( z1 a/ }
% }6 J) D$ ?) C/ g
public static void main(String[] args) {( H5 n: U- ~0 X( |: E' Z
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);3 ]$ Q" q5 z* l7 p* R J* \
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);$ V b* J" @* b9 [
swarms.buildObjects();# @0 O! G+ \" ]. ?
swarms.buildActions();. Q* G0 M( M! @$ d. c+ Y
swarms.activateIn(null).run();
& a; P9 t- w" P: l. ]+ I$ n5 ` }
/ y/ z4 I; H# L( }/ h Y* i v4 \' H9 B$ F y& e# \
} |
|