|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
, w6 f e: [ |" K- u
% f* Q( p# O% i3 |/ i本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21# l% s7 h; r7 O) Q( A
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
# P5 D C4 Z5 M" b/ I B1 Bswarm.SignatureNotFoundException8 _: z7 `: F n# Z
at swarm.Selector.<init>(Selector.java:76)+ w- J1 [" t5 w" ?6 G
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)/ ^# s1 q6 q9 e' j: Q# D& a
at ActionGroupDemo.main(ActionGroupDemo.java:67)+ b+ F3 v+ }) S5 A4 q7 ~
, ?6 [# A( R& r
& F9 g+ f% |2 W( O+ D4 j
import swarm.objectbase.SwarmImpl;
2 u- @: I) ~, }* I0 nimport swarm.objectbase.Swarm;
. N+ V9 Y8 M% ]0 q$ _import swarm.activity.ScheduleImpl;6 |7 ?$ R3 ?) [! ]2 y5 g
import swarm.activity.Activity;
8 T( X" L/ s" D+ Himport swarm.activity.ActionGroupImpl;
) Q$ l) c. r5 _3 |import swarm.collections.ListImpl;
/ n1 ~- U+ f' y* y3 u- nimport swarm.defobj.Zone; 8 H& `( } l( T0 u( B* d- D4 g
import swarm.Globals;
0 b6 n/ j+ C4 P+ ~- T" Oimport swarm.Selector;
' [8 S" U) T9 Z, W; Z) r9 z* @import swarm.activity.ActionGroup; ' |6 i( F) v$ n" C" {
class Agent {( N" r/ X) X3 [2 i5 y- D. u
char id;: L$ D: U7 W" S |0 n3 z
5 [- d! x! h8 e0 y$ [
Agent(char id) {
$ R5 d# ^' W6 ?, x5 q this.id = id;2 P% [8 I! a0 x) d
}
% ?4 t1 O' F6 ~+ n7 }
* M& [2 P: B2 \ public void agentStep() {
0 ^+ v' d/ E* _3 d: e( l! L System.out.println(id + ":" + Globals.env.getCurrentTime());2 [3 g$ X4 I; K6 z
}4 _0 ]2 m# r) l) D" K" e7 P
}
5 j/ H5 _0 p" O# }5 Q/ R. T6 R- w e& ^1 K2 k3 s- D# O5 s" ^
public class ActionGroupDemo extends SwarmImpl {2 I$ \( ?$ J: t* @' I9 ^: e
ScheduleImpl schedule;
$ w4 i' M9 w( ^' x: `5 p7 w ActionGroupImpl actionGroup;
; g A. D6 `; i3 S ListImpl list;5 y3 h% W) x0 f& L/ H# G6 Y" Z6 P" _
char Id = 'a';
% f( C9 q+ `* f3 n+ U6 R% F, m3 v+ L2 k k9 J9 K H; f
ActionGroupDemo(Zone aZone) {
! y5 L! D& F6 [5 M: L super(aZone);
) g% G' f! X$ Q& f2 m. L* N3 E# D list = new ListImpl(aZone);
7 I3 \( E0 c/ N0 W swarmSetp();" b5 U% }* s; W
actionGroup = new ActionGroupImpl(aZone);, |5 X8 h% _( z2 j
schedule = new ScheduleImpl(aZone);, F9 Z# Y. [3 d4 b& d
try {) u5 H7 m- t5 c2 v
Selector agentSel = new Selector(Agent.class, "agentStep", false);4 i% l# ]* K3 [
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
* R/ H/ y! r3 P0 P" ^ 1 |# i6 Z+ J2 |3 b5 I1 d/ Z. s y( O
actionGroup.createActionForEach$message(list, agentSel);/ ]/ f6 s( y) X
actionGroup.createActionTo$message(this, swarmSel);' `0 X$ N% Y5 M$ z7 [% r
schedule.at$createAction(0, actionGroup);
, K# ]6 X+ ?6 Q9 ]2 ?4 | schedule.at$createAction(1, actionGroup);
( C& n0 I9 W: e0 b schedule.at$createAction(2, actionGroup);
2 [0 ]- E2 o. o! v# t' A$ F% x% B0 i' P9 ?6 R6 w) R$ _
} catch (Exception e) {
: {8 s) d4 [! n. M3 ] e.printStackTrace(System.err);
, d6 @- j* i0 a2 j2 U. d( T$ l //System.out.println(e);! D: `. o2 `, x( {2 c1 J
System.exit(1);% c. ~3 p3 Y" A
}$ W/ P$ {) j- V( D: d) |) L! y) \* V0 a
! z: @+ e* @% a$ ~1 V# l
' v$ @6 `9 d( Q }
7 V( @8 I- a( K- s$ W) R
* m, b7 r0 p' Y8 i4 {4 U. S private void swarmSetp() {
! ^5 M0 w: r* |; a9 v list.addLast(new Agent(Id));- w4 C9 S. \, U. V9 n9 c" Y
Id++;: X' m# w. x& ^6 T, y# E/ P/ T; y
}: a; f7 _* Z, a5 V6 I# d1 d
2 z: P4 F$ T- G6 s- v; u5 z. w
public Activity activateIn(Swarm context) {
' B L1 e. t3 @' y0 v& ]: j super.activateIn(context);# k) v; d& E) @& j2 o) B2 `2 v
schedule.activateIn(this);
& f* E. k/ \ |( J5 w9 g6 t return getActivity();
9 C0 B5 x! r8 ]6 D& k4 p3 V* V2 d }
' i& B+ F* f _3 Y9 B. [* ~! ?/ V6 p2 K; V1 [3 x0 q+ g
public static void main(String[] args) {
3 P x4 e2 f% s/ ` Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);, j% E5 y, a: o3 s7 r( [
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
0 E" H4 t$ `6 |5 H5 V$ \ swarms.buildObjects();
. ^( f: n; y8 J( P0 e5 j& X swarms.buildActions();
/ F- V: e( C1 t" h swarms.activateIn(null).run(); A5 h, \3 k" G1 t0 Z7 j. q
}. V2 o- n" X$ o) B
1 I8 y7 T8 {8 J+ T; u* g. H" d9 }
} |
|