|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 8 z$ ~9 M9 @4 X& T
& Z% F6 I$ N; B
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update212 P- l8 ?4 N- }4 t
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
1 H( A5 P1 M' n$ J( _, E7 a; }swarm.SignatureNotFoundException
- P2 c/ P* }2 b- b) a6 [' v" ` at swarm.Selector.<init>(Selector.java:76)3 z% y$ b' `: Q @3 Z4 K8 w' ~
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
7 U, T% V6 L3 c! n8 \* s at ActionGroupDemo.main(ActionGroupDemo.java:67)
( u) v8 {3 L. Z" Y
5 a5 ^$ @, v' D% w) F0 L y% h* j! M5 |* t! |
import swarm.objectbase.SwarmImpl;, f1 f* X6 w* L! {; o
import swarm.objectbase.Swarm;
1 i+ D# F* o2 `+ p. z& n' \import swarm.activity.ScheduleImpl;
/ d$ P/ o/ s+ K9 }, h% }+ b1 [( Cimport swarm.activity.Activity;9 t# d4 t! t1 ^8 S! C" y5 u3 f9 f
import swarm.activity.ActionGroupImpl;8 [3 g2 ~6 C4 z8 l. J+ G
import swarm.collections.ListImpl;6 }: a8 ^$ ~" R( }( u
import swarm.defobj.Zone; 9 O& m" q" Y9 _, y
import swarm.Globals;
6 l" L. J' o5 L, x Cimport swarm.Selector;9 o$ ?$ S6 O# M! D+ `* X: M$ b+ f
import swarm.activity.ActionGroup; 6 ^9 s: H0 o+ C* v: ?) B, K
class Agent {4 X- D' j1 M9 g4 H0 c: b
char id;
& s- {# U) w9 s* C% h
8 A- s+ @4 `# a* [: X Agent(char id) {8 C% ?! g* u- s8 b; y b+ t/ N3 w
this.id = id;
5 Z/ T* G7 G+ V- D9 X' K } X) }, E* b: R7 m: ~( b. ~& P9 f
+ L5 G9 {4 O4 \' } public void agentStep() {
# }" C" y5 j) ?; j. T3 J! z System.out.println(id + ":" + Globals.env.getCurrentTime());! c/ b4 T3 N" \$ W0 f
}
# B' A2 g+ Y7 m2 `}3 q8 p3 `, S$ T4 X9 ]
6 m; x# a, [5 A# J) i
public class ActionGroupDemo extends SwarmImpl {
2 q0 o7 z8 l- J+ \ ScheduleImpl schedule;; s3 Y' n, y* i( K
ActionGroupImpl actionGroup;
, m/ s9 H# O$ J( D/ h$ @ ListImpl list;/ h8 R% W. l# h8 }1 R
char Id = 'a';
3 y# v3 c% ~4 Y: j; m; W t, }# ~9 R7 `
ActionGroupDemo(Zone aZone) {) C, J# t9 _. F5 J( ^! e; O
super(aZone);" x& g3 u) Y8 J7 ]% y! s6 ]
list = new ListImpl(aZone);/ \) |# x) q" t3 a" p4 w
swarmSetp();
3 ?; W. [7 D5 O- r. }; w, D" b$ m1 J actionGroup = new ActionGroupImpl(aZone);
8 T4 O7 e% u* q4 X k1 [6 I. f schedule = new ScheduleImpl(aZone);
) ?9 R: E0 @% T$ n" V' V8 t try {
! {+ k; W$ M; ^4 O! B* E" O6 p Selector agentSel = new Selector(Agent.class, "agentStep", false);
. h! c0 y s5 M z Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行2 ~3 F3 t. c& K
% m4 w8 B- q: f) j5 ]# P' H
actionGroup.createActionForEach$message(list, agentSel);
. v: S# p7 P9 O actionGroup.createActionTo$message(this, swarmSel);, Z& W1 N. [3 h* o r: w2 }! g
schedule.at$createAction(0, actionGroup);
8 e$ [9 ]. Z+ T+ | schedule.at$createAction(1, actionGroup);
# C+ ~: d) x4 a2 \ schedule.at$createAction(2, actionGroup);) f6 v- i5 o8 K& Z9 ]8 y& |* [
6 H3 b3 _: b) ]# J# _
} catch (Exception e) {
0 [ b0 o4 k' ?- ~" F' K2 ^6 C e.printStackTrace(System.err);
: m5 Q0 R2 y; b3 n$ W. d //System.out.println(e);
$ F- P7 o' ?8 x* H System.exit(1);) K' f* s' l7 w. P
}
" Z( }1 U7 o( o1 @ ^4 l, ?9 H& L0 \1 i$ `; l8 W& ]
/ O7 P) E+ K- b
}
; o# V @1 f" v& ~# j% Z3 V2 f: t& U$ t- I6 J$ v# @. Q3 |8 b( V+ x
private void swarmSetp() {; S8 X; u" h' `$ {
list.addLast(new Agent(Id));
% m, K9 }- w, p; q" e7 Y Id++;% D" j, X5 h. `- j+ b& Y
}& _1 A+ k) b2 u0 `- J9 k
4 x* R; z: w2 q( e public Activity activateIn(Swarm context) {
& q3 _) `% Z, U* |7 B6 ] j$ z super.activateIn(context);
5 V5 { J, K$ t: ]1 k {% t schedule.activateIn(this);; d8 z: A3 S5 l
return getActivity();7 x( W4 h- R8 j& L0 |$ s4 u4 y9 o9 T& N3 ~
}
, @8 U& k# \- C+ h8 Z! r3 b4 R) T5 M* I* R' z0 ?+ P2 p
public static void main(String[] args) {0 _2 I* y; U! M5 Q7 t
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
5 z: N5 k# S$ | Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);: q; D. Q( U5 `, D4 U0 H" `
swarms.buildObjects();3 J2 U4 |# @' D2 d3 H. N( S
swarms.buildActions();
8 D/ H# L# c+ |) y: i0 d- _9 @! j swarms.activateIn(null).run();: D8 p1 l1 i' i( }: j# `
} K r! e: }; g1 }0 P
2 c }. A' d" O* y' O4 x; Y% T
} |
|