|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 7 A3 c" k$ W0 O- f
' `. k0 S8 a& }; A
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21, q' g* Z M# B
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.2 i" n E+ E$ ?; R
swarm.SignatureNotFoundException, N! m7 H' m3 [# K: i2 W
at swarm.Selector.<init>(Selector.java:76)4 g9 n+ ]6 W d/ u% a; U6 r
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)4 ?- n \ r& M: j/ F
at ActionGroupDemo.main(ActionGroupDemo.java:67)
' z" I/ m9 F. _2 Z8 o$ K+ ?1 k) W! u# h4 O4 K, g
$ N/ j5 {9 n1 E4 `) K3 A$ Timport swarm.objectbase.SwarmImpl;$ s! h& s) [* d K- l
import swarm.objectbase.Swarm;
; E9 ~! f" C) G2 N- F7 pimport swarm.activity.ScheduleImpl;
* _0 D1 Y8 `* Timport swarm.activity.Activity;
v [% L4 s* ~% B1 @import swarm.activity.ActionGroupImpl;
" x$ ?# q; z7 wimport swarm.collections.ListImpl;
% c, J& d& k4 L" cimport swarm.defobj.Zone; , I2 G- I, i3 s& k* A% x- S$ N9 @" m
import swarm.Globals;
( c: ~% c+ H2 n8 U. u- oimport swarm.Selector;: e4 @' s6 |+ H# {9 S" ?- }
import swarm.activity.ActionGroup;
2 B5 A' v) ?, R! n# w( p) |class Agent {9 E# ~: P5 ]1 G( X' X
char id;7 H4 P9 B+ k8 N6 z2 g
1 P3 F; V B; O0 _
Agent(char id) {! Z9 [3 F t# @2 e; L& j
this.id = id;" Z$ H" j, x2 K; I
}
1 \1 l: C- v7 A5 q$ s3 {5 k' l' f1 j% L" h. |& g
public void agentStep() {5 j% n- b+ }+ V" w6 ?# x1 Q2 ^
System.out.println(id + ":" + Globals.env.getCurrentTime());
) V6 y' ]5 l$ g# n }
. e, d4 j4 z' ?9 g}
8 O4 ~( T0 {1 Q+ V
3 e& g% ]: M3 f" e( Rpublic class ActionGroupDemo extends SwarmImpl {
% y! z6 k/ }$ ~1 {9 [8 R( O. F2 K7 ]6 F ScheduleImpl schedule;2 ]! P+ ]1 r: q8 U4 v8 V) V
ActionGroupImpl actionGroup;
5 z ~, h: W q: U$ G ListImpl list;
2 M7 K! r/ F" M5 X3 C' G( ` char Id = 'a';8 r: a8 P6 M. q- U
5 s& \1 P! n6 _& ?: u- e% Z! k, q- K ActionGroupDemo(Zone aZone) {, q' V* k4 C2 Y( t+ C. I6 L
super(aZone);3 ?) Q" n2 x7 ~9 F4 D- w0 L1 @! ?$ [
list = new ListImpl(aZone);
8 G- {( }9 G' C- w2 u swarmSetp();+ l" C r% @5 c3 e% N9 @8 K+ _
actionGroup = new ActionGroupImpl(aZone);
1 ] h* N. m' E+ g% d schedule = new ScheduleImpl(aZone);/ {+ o& c$ D7 v- w) S
try {$ m3 Q+ {7 U# q/ |3 `
Selector agentSel = new Selector(Agent.class, "agentStep", false);( n! g# z" i! E# h9 g$ H# ]
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行' _/ s0 F; n4 N! Q3 J1 E
S- j) _5 x) \( |, f- O actionGroup.createActionForEach$message(list, agentSel);) U3 n( t& D. q3 G) Q5 O# ]
actionGroup.createActionTo$message(this, swarmSel);; z1 t' k% W' D$ F9 E
schedule.at$createAction(0, actionGroup);' O+ h, U- h) R1 X
schedule.at$createAction(1, actionGroup);; L& Q5 j; G4 V5 g1 s8 ^$ ~
schedule.at$createAction(2, actionGroup);
0 P6 ^ i2 d$ p2 q* a8 |, B& ~% i% Z9 ^9 [& R5 r3 E- z
} catch (Exception e) {
7 A) t0 n @ N1 e S e.printStackTrace(System.err);" S( p( i. T X' o' h! j
//System.out.println(e);& e4 ^6 U5 R" Z2 }7 M
System.exit(1);+ f/ j2 Y- c2 T1 x# \
}
: H0 Y2 R, M. E- ]& B6 P+ W7 ~0 Z
/ D1 q x. M- f) o! e }
: j1 n5 U) M& _- f8 b9 Q8 R3 n2 d( l* L9 \3 s1 @. d6 J* d
private void swarmSetp() {
3 v: y: o1 d b" ]* H' ^ list.addLast(new Agent(Id));
( Q" M) e% m p: A* }8 d" j Id++;
. }$ X% r# E$ H" T6 x0 U }8 ]% A; a4 k( e+ c4 D2 S
3 q9 F' l8 \7 P; O/ v) W3 a( g- |
public Activity activateIn(Swarm context) {
% E( a: U0 L/ f" t super.activateIn(context);
) Q4 |" `0 x( ]4 W: ^ schedule.activateIn(this);0 z; a, g& p# B( N g- W6 y3 T
return getActivity();$ N' _" @& f U( X+ Y, s3 \; c+ j
}3 N" T" J3 d! ^- N: i
+ `4 ^( l5 f) ^4 L$ P3 ~
public static void main(String[] args) {
' X! s* M/ k# Z9 d4 `2 i( a' _ Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);' L' c7 Z/ ]. k* c" [
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
4 r5 C4 \/ r. f- S0 Y' t$ i& ]4 m1 C swarms.buildObjects();8 j# [0 P4 K- Q5 g* E0 H
swarms.buildActions();
% _. J- H) r( o+ z swarms.activateIn(null).run();
' C; g) [' M! M+ o0 w }
: F0 |8 @: t: P. C- |3 M) U8 |1 Z# B7 w- b, \) i) U4 T9 q
} |
|