|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
$ \( ]- f0 d/ h* D# |9 H& R: c+ h' \+ i+ L! o# x7 c! x' S+ d
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
5 |. K; @" K2 F9 X以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.& s6 ^; e& E8 V" `2 t8 L
swarm.SignatureNotFoundException! a, [; N& ?: ]+ j: Y
at swarm.Selector.<init>(Selector.java:76)
- }; w( W* R- N9 [ at ActionGroupDemo.<init>(ActionGroupDemo.java:37)% k4 {: \0 E: |$ T
at ActionGroupDemo.main(ActionGroupDemo.java:67): D7 F$ Y% l% m) ?4 o7 H; _, C
0 `3 a. ~0 o, j( Z+ Q" |9 A M, }5 b. S+ x
import swarm.objectbase.SwarmImpl;; r, r% C' H) o
import swarm.objectbase.Swarm;
: I6 E7 [7 Q1 A8 S/ m( Q" Q! Jimport swarm.activity.ScheduleImpl;
! |# u. M. } @$ |3 nimport swarm.activity.Activity;
/ l/ c" E; F! oimport swarm.activity.ActionGroupImpl;& G# e+ ^7 [3 s' h3 o' [
import swarm.collections.ListImpl;
, x/ V0 {6 N- himport swarm.defobj.Zone; ; s, q2 M" b* y
import swarm.Globals;
. r+ e/ d: ~# Oimport swarm.Selector;
# ^) ~& {% X1 ximport swarm.activity.ActionGroup;
: |6 H b3 ?8 D4 lclass Agent {
2 N, i& W& W# ? char id;; c% n/ A. ~) J
1 g" H4 Y- Z' C# k) h6 ~ Agent(char id) {
9 i2 a) K+ n1 E7 Z this.id = id;
! S7 X% Q! ?# Z8 \$ S! T }
7 F: @/ T# z% x0 l7 R, L5 D( S; i7 J4 M/ P8 m7 y$ c5 w2 _( H
public void agentStep() {# u1 o# _# K$ U
System.out.println(id + ":" + Globals.env.getCurrentTime());
4 Q" A. z8 }/ ~1 n+ v( N1 c( O+ b }" w9 N, t5 h2 ^% L
}/ O! V: J6 D* _
/ n! ^" F. b. [7 L1 I7 Dpublic class ActionGroupDemo extends SwarmImpl {
, u% y+ J8 {: F! \! c4 \$ C ScheduleImpl schedule;
$ a, |# W* S& ?0 {% O& \8 ~ ActionGroupImpl actionGroup;& ^6 x: l* W3 g1 f1 j) P8 d
ListImpl list;: p* f8 j1 B& A" i
char Id = 'a';* H9 k" I6 D" n2 T q* `( V9 `, F
" M* Y; Y/ m. H2 v6 z
ActionGroupDemo(Zone aZone) {
" ^/ e" [" I+ D6 Q: r$ K# L- h6 Q super(aZone);
. t6 t, f5 r* I4 K* j, U list = new ListImpl(aZone);' w2 W9 d& ?+ ~/ {& e7 g
swarmSetp();
$ w' t3 q- |; A actionGroup = new ActionGroupImpl(aZone);
6 s/ y$ v6 r1 s$ Y* o schedule = new ScheduleImpl(aZone);
) Y6 @9 [% @' c% k1 |9 A* d; z. ?( H try {
; f9 x' ], B; o6 w Selector agentSel = new Selector(Agent.class, "agentStep", false);8 w: j/ ?+ H' T+ `+ c
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行: t" J( [) G' n
* t; X* K9 ]6 U actionGroup.createActionForEach$message(list, agentSel);
9 |2 b' M; F5 d$ S! B actionGroup.createActionTo$message(this, swarmSel);
* T4 r! {( }3 K# J" J' z% f! \, f schedule.at$createAction(0, actionGroup);' |- N; V# ?6 L; y
schedule.at$createAction(1, actionGroup);
+ _" x5 P% V8 e schedule.at$createAction(2, actionGroup);6 Y- c/ s. w( t/ S% W
* z6 Q' u, Z1 b) u) E
} catch (Exception e) {
$ F% G& | z9 k* {* |) a e.printStackTrace(System.err);6 Y8 X/ j$ m# E
//System.out.println(e);( R1 j* _) h. B( I2 E. h2 l8 i
System.exit(1);, S% n0 S: V6 _. }
}
: Y. Y7 ~2 A* p9 `: J
# Z* A) }4 T8 G7 Y
/ G7 Z$ F7 `2 X+ s2 }; ?0 s$ M }- H' d R: L( ]: H* h0 P9 B# R+ }( x1 M
! ?( x. |$ \7 I
private void swarmSetp() {
, S/ D* C% A; b3 J& n( d% _3 K0 P list.addLast(new Agent(Id));6 r* S j& U% V M. |# i5 O; q- k4 E
Id++;
% \: M& m( b( k: H: E }. \; z% \( s- x" f) L
) `" x1 k8 M: R4 Y
public Activity activateIn(Swarm context) {
, \4 v5 N! C! ^+ Z super.activateIn(context);, }$ G3 `9 T4 h& u% j
schedule.activateIn(this);) K3 ?8 J5 K3 b; S* Q9 O# ^
return getActivity();
( u4 Q4 w7 _6 |) s( p }* Y5 s7 j, Y6 S; j7 f
/ E V* `/ h2 E8 S% `" {* h
public static void main(String[] args) {) i! t$ I, A3 V: D9 }- `9 q
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);$ o4 L' A7 J7 t1 L+ U2 x0 S3 ` q, f
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
- U5 b& i! p9 i3 m1 C8 n swarms.buildObjects();
4 C+ | q4 d7 E" l swarms.buildActions();7 C0 E4 Y+ h& ~) ^7 O
swarms.activateIn(null).run();
- o. t- O- K) ^1 e0 u" q% t5 a }1 m5 l% G- |3 j h) t
: z* C0 l2 q! \' J, K& T* k} |
|