|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 ; r- ^/ w e5 k/ r. w! ]1 j9 s% E
+ A) |6 W6 m; \4 W本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21/ v2 L! W( u2 ^4 {( G
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.. M) m- M7 r! ~4 |( A9 ~/ p
swarm.SignatureNotFoundException
& F" |( W2 t8 o, i5 S0 ^; @ at swarm.Selector.<init>(Selector.java:76)2 I, ~8 D6 ~: Z. k4 [9 F
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
. I! l, g% e& } at ActionGroupDemo.main(ActionGroupDemo.java:67)$ F0 ?6 d: _ b# l
3 l, Z2 q. m5 J4 T6 \7 s/ {
a1 m! L& K& W0 i) x4 gimport swarm.objectbase.SwarmImpl;: f) D! D E6 V; a2 r
import swarm.objectbase.Swarm;
7 d( y7 I7 P6 b3 `1 Ximport swarm.activity.ScheduleImpl;
8 U$ ^: \& E' i" s. |import swarm.activity.Activity;7 u4 }; t& h0 a- K( ^7 P7 i
import swarm.activity.ActionGroupImpl;
R! t+ u7 T3 H" \import swarm.collections.ListImpl;
. r f" J! h2 y5 \# simport swarm.defobj.Zone; ) u N# Q$ m& V6 k0 D! C
import swarm.Globals;
0 m {5 p; A2 W# oimport swarm.Selector;
* q% a$ Y, W* R' himport swarm.activity.ActionGroup; ( x2 Z9 r, ^/ t. O
class Agent {
3 Y" ~/ S( h; t& x; R8 \ char id;
8 m" k, g8 F2 e8 R; d" h
s$ h# e6 ~, q) ~* R. u. j2 W3 l Agent(char id) {
2 s& `2 e: { K, c this.id = id;" ?0 |* Q# i( `8 U& C. a& {
}" [; F. H3 B# r9 K- _ I( c
4 l$ W! E6 V& ~
public void agentStep() {
: o* q, T* ]" e1 h4 }+ J. l/ ? System.out.println(id + ":" + Globals.env.getCurrentTime());
4 r0 Z9 N4 t( X( a }
% \6 Y* t4 a0 U1 b, ^3 r( q) d. |}9 q" w% a# d$ w' ^$ C( H% f
4 K# s, J" ~, e" I/ T# [: A
public class ActionGroupDemo extends SwarmImpl {. q" F7 D. q/ F
ScheduleImpl schedule;
! o# ~0 P! b. @: O1 B5 ~ ActionGroupImpl actionGroup;" x# K; U, \6 V- v, [
ListImpl list;* r( m; }/ z0 g& o7 a4 F" }/ L
char Id = 'a';# S0 H* J& ^' f' U( i
2 C: G6 c! d) V, v8 t7 o* e( k ActionGroupDemo(Zone aZone) {: v; i) |! \7 W
super(aZone);' ~ b8 q. R! U# _
list = new ListImpl(aZone);
% e) ^1 S, w" c. b. @ swarmSetp();2 o3 n h+ a7 f7 \8 [
actionGroup = new ActionGroupImpl(aZone);! P* ?# v+ h; g9 s
schedule = new ScheduleImpl(aZone);
7 R1 s" z( z# j/ c( o& p8 q try {4 `# e* D+ }( Q) Q: I
Selector agentSel = new Selector(Agent.class, "agentStep", false);8 X; y7 q0 w/ q6 f' h5 R1 t
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
$ |$ s6 B9 s+ r h8 B7 u+ L) ^ 3 l4 ]$ ^ @& u$ b
actionGroup.createActionForEach$message(list, agentSel);. \: ^$ m+ w/ ?6 A
actionGroup.createActionTo$message(this, swarmSel);( i. s+ k8 n: h6 C
schedule.at$createAction(0, actionGroup);, `( ?! A$ M _. ~; b6 M' ?0 R x
schedule.at$createAction(1, actionGroup);3 z9 S; Z: w, |
schedule.at$createAction(2, actionGroup);0 j9 _2 m1 f# _9 _
- M( U, | V9 P, r9 _- c } catch (Exception e) { ?6 W0 Y* }/ S" l; P
e.printStackTrace(System.err);
2 W L. g5 i0 J //System.out.println(e);/ v$ M2 F. L- s" |
System.exit(1);
: Q$ |: W( s. [( Z0 Z }4 ^0 P; O* z4 H4 K! g! Q% K: W
; N: v0 T. Y, M6 U) H# p) F0 b
! C& d0 c4 ~# x7 b$ V& m
}6 ^( g) M8 ?3 Y6 @6 Z2 Y$ D% v: `* ?
2 @+ C t$ m' c' ?; O" l private void swarmSetp() { U1 B! p% ^" r% t
list.addLast(new Agent(Id));9 f0 {" k( ~, E2 |& H
Id++;
" e8 c/ P) S! T& c2 C: j }$ L% B0 d* S. \3 R
9 p& O1 t: Z! V4 D! W' ~1 C# R public Activity activateIn(Swarm context) {
# N( Z* \6 T' w9 E( Q% R super.activateIn(context);
& l1 k! A. M* L schedule.activateIn(this);
7 n d! L/ D, m0 O. C return getActivity();
f/ t t" J! N1 X3 i c }
$ {; k6 o% h1 g% _* ~: y) f% o- ~3 m0 c. J4 t
public static void main(String[] args) {# m% u- U# f0 N+ W, \
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);( x0 P* U- J( [2 N9 o" ~. E% \
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
1 l3 d$ Y4 Q( ~1 \0 X2 r9 c swarms.buildObjects();% Y& w. H9 E: R/ c6 V% {% }
swarms.buildActions();
l- b1 m6 ?+ q' _' g- C7 z swarms.activateIn(null).run();
; F/ N$ h" I% j2 x' v. O9 Z }
8 y2 S# Q7 l( c C6 W
* k5 r8 l9 E2 w) Y} |
|