|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 5 P- l, W9 r. u/ T; |# c: s
; g: U5 ]; V0 p本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
7 N! H# ^" J2 M: {以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.$ g d9 Z& i/ n6 o
swarm.SignatureNotFoundException
" I9 A8 q* ]5 G" t at swarm.Selector.<init>(Selector.java:76)+ Y$ n0 {! d, Z; }# B5 x5 B
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
$ {. g6 D7 R5 v' i at ActionGroupDemo.main(ActionGroupDemo.java:67)
+ S/ C6 _8 |! {' @0 Q& b* j1 y. w1 l( s! h$ q
/ E1 e3 D2 z3 ~import swarm.objectbase.SwarmImpl;; |) b$ ^3 o% B
import swarm.objectbase.Swarm;
5 ^% M+ ~8 r& }import swarm.activity.ScheduleImpl;
5 j" c, e) I. E8 e% uimport swarm.activity.Activity;
9 F6 `; Q z, C) s! p7 Ximport swarm.activity.ActionGroupImpl;
3 W' i; W; M. P! _7 jimport swarm.collections.ListImpl;/ L8 e9 I. V" G& ?2 L
import swarm.defobj.Zone;
* [- M3 F2 z% O, |: Y0 Simport swarm.Globals;. a6 {; S( k4 M0 K5 M
import swarm.Selector;
" W# I( O! P" n2 eimport swarm.activity.ActionGroup;
/ d8 s* C7 |& o, M2 n+ Pclass Agent {2 s* ] z$ U, v: ?# G
char id;
3 p* P" N o- o4 r2 _. b
% R+ y J- O2 T( @( f) P Agent(char id) {% P9 L+ `9 _" m
this.id = id;; ^* {+ J- G& J# S* J
}
* f! H2 O7 [: A. G
, d t8 R; y: r/ G) m8 j* R public void agentStep() {0 h" q+ b5 d2 R, N. v5 f+ [7 X
System.out.println(id + ":" + Globals.env.getCurrentTime());
1 Q. d# q1 h# x9 X } [* j; _3 Q4 Y- s2 Z
}
) r3 v7 P5 {: Q* T1 b% c3 ~- d2 u! ^$ `
public class ActionGroupDemo extends SwarmImpl {# I9 K& E: n3 g- q4 Z3 {/ H5 ~8 i
ScheduleImpl schedule;
& p7 O/ U5 V' z* q4 }* k ActionGroupImpl actionGroup;1 {9 n5 r- G$ n- X& \
ListImpl list;/ k, \5 N1 d# F( i) c
char Id = 'a';9 [0 G' a+ e/ q6 p2 L
* ]" s0 [4 B/ B' ~ l% Z2 J ActionGroupDemo(Zone aZone) {9 m0 m- K- B C |
super(aZone);: |8 P( M& N) M# i
list = new ListImpl(aZone);
( q/ c; B. I7 u) M1 b swarmSetp();
+ e& U1 [! v$ R/ ^) t: a actionGroup = new ActionGroupImpl(aZone);
9 r H U7 M% P$ O+ O) l; s schedule = new ScheduleImpl(aZone);' V( h2 h- F2 Z. S5 s
try {
- t$ H- P/ e" ?6 d. \3 V Selector agentSel = new Selector(Agent.class, "agentStep", false);
" L9 E0 P) {. f0 I Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行( P" O; d! S8 X4 |' g8 g
7 \5 a) A5 @3 Y* V8 K4 x- \: @
actionGroup.createActionForEach$message(list, agentSel);
9 |- i4 c0 F8 a actionGroup.createActionTo$message(this, swarmSel);9 P- {3 \6 g1 K& `
schedule.at$createAction(0, actionGroup);
# T' x8 F! |- x schedule.at$createAction(1, actionGroup);
! W5 Z o/ m- N! Y5 g0 e schedule.at$createAction(2, actionGroup);
$ S5 z! m9 \3 G f. c( c6 R$ V, {0 w) p/ }* S
} catch (Exception e) {# K& B/ F2 c5 h) O
e.printStackTrace(System.err);2 k! ]7 s3 B; O+ S/ t7 J k2 y0 u u
//System.out.println(e);
8 L" A# B% d8 W0 l- O7 Z4 b System.exit(1);* x! u2 f! ?0 Z$ @2 I: q* `
}
* M2 p; K4 w. R) O5 Q& d
8 g- r0 l. B' L: W5 `6 f, A# E% T9 A! z$ y/ L% v0 c+ L
}: I* [) W+ h& |$ l3 C9 Z# R* m
8 g) {/ M( w- `% s8 O( R1 `: q private void swarmSetp() {6 `/ Y9 `2 P1 z
list.addLast(new Agent(Id));
( w+ ~ R1 ]- @8 K- ]8 F Id++;- T- b+ w0 Q& \( i5 x& B
}5 x/ M6 G6 G$ L6 M# w w
3 I) S$ A: x& g: J public Activity activateIn(Swarm context) {; c' ~8 @" |# B P: z1 ?
super.activateIn(context);: S- @) _5 u7 ?. a; B) H
schedule.activateIn(this);
; X- `3 A; S9 `# c3 f+ i return getActivity(); s! z3 ]- \7 r
}% E" x; @: h6 M, B: m- ]5 y8 K
6 \" L$ @8 g3 T/ W$ d3 R. H( |1 y public static void main(String[] args) {
& D6 R0 ]3 ~& R! ~+ d; y X z Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);5 A- q. Q& k$ C8 `+ [% K
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);: b3 v9 e# ]4 _) ^ f
swarms.buildObjects();5 f" T2 }/ L) U# D9 j' o7 n
swarms.buildActions();. ]) c* k: \( m4 d+ r
swarms.activateIn(null).run();) p' N1 Q$ b1 }7 p0 v
}
& @ y9 T' u" d" C; U, Y& Z S0 D! H. D
} |
|