|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 & ^- ^) \7 A7 g+ k9 @
: m# w9 [) Z% [! Z, A- z本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21. f# V( V7 d4 R( E* T7 J
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.' O! Y7 w+ E( }( Q
swarm.SignatureNotFoundException! H8 w1 _/ r7 v
at swarm.Selector.<init>(Selector.java:76)0 G# ?" C, u6 }' I
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
: i) _/ _% t) {# e at ActionGroupDemo.main(ActionGroupDemo.java:67)
2 d4 v8 b9 z5 ?& U: P. Q& q7 _, h0 H" u4 L
7 U+ X. }( F6 {import swarm.objectbase.SwarmImpl;8 a( t8 G( {6 y6 C
import swarm.objectbase.Swarm;5 r6 N* |; C- A+ ?0 p
import swarm.activity.ScheduleImpl;
7 ]6 |3 ?* `7 g8 L" Limport swarm.activity.Activity;0 a7 q& g7 V9 Y! j
import swarm.activity.ActionGroupImpl;
, e0 G* `7 B3 _4 E' Qimport swarm.collections.ListImpl;1 O8 S* P- B" Y3 i" I1 n) O% A
import swarm.defobj.Zone; , U( j8 u# _2 o/ C7 n# u1 L
import swarm.Globals;$ a$ D9 t( O" M
import swarm.Selector;: B- n" @, Q- e# {% L! T+ K
import swarm.activity.ActionGroup;
! _# e2 a8 p; h$ D% J$ j, iclass Agent {
& h: L6 _. w* C$ [) T char id;
( U6 T4 n' Z% d% i* F1 i; g T0 v' x8 K; R* @( h
Agent(char id) {2 s* m5 A9 n' Z/ t i2 g2 V
this.id = id;1 v* i" E4 z4 C2 p% h4 G9 ^+ g3 u2 U9 R8 K
}) Z9 J4 L2 [9 |8 X2 y/ N. g! @
+ q( T7 Y& m' F6 X( t6 Y public void agentStep() {/ S% Z' z) m% _0 H- E2 h/ X
System.out.println(id + ":" + Globals.env.getCurrentTime());
' I; w, M/ O9 Q }! {. }4 }: c( j6 Q9 A3 X) \6 J9 ^ E
}! s7 y9 o9 F+ |7 |9 @1 A6 N
; r4 _; v/ n; f0 p' p8 b5 _
public class ActionGroupDemo extends SwarmImpl {
0 J! g+ x+ g. y8 G0 ` ScheduleImpl schedule;
5 O9 @9 y* G( B. j ActionGroupImpl actionGroup;
1 U: P- o8 x1 T0 p, A- P ListImpl list;
2 X, ~, \) _! H' ~( p) M) ]4 f char Id = 'a';$ @9 ]9 L$ b# [; P
3 d2 v* t3 M/ |* o ActionGroupDemo(Zone aZone) {) g' j% e! H" e7 Q- I8 u) q
super(aZone);
9 U+ K; H" o0 P9 i0 t# N; a( U list = new ListImpl(aZone);/ f5 v# ]$ [5 P& {, K
swarmSetp();4 U" R4 l) o1 S( g8 p
actionGroup = new ActionGroupImpl(aZone);
/ W @ ]" z' B7 F& v- Q! m schedule = new ScheduleImpl(aZone);
I+ _* U8 X+ l. S5 m; j try {
: t0 q, e) u: L) g+ \+ [ Selector agentSel = new Selector(Agent.class, "agentStep", false);" a9 Z# y4 U# a0 ]' Z1 \' d- Q
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行( S/ D7 J) G) i6 U
: O! u$ w" a/ }# ~ actionGroup.createActionForEach$message(list, agentSel);
, E% q" v, j. _5 `* u actionGroup.createActionTo$message(this, swarmSel);
: t. ^# y$ @+ _# \0 ]/ E: b schedule.at$createAction(0, actionGroup);
! z ^# F' m' {+ y schedule.at$createAction(1, actionGroup);
4 \1 O. q$ l3 {" V schedule.at$createAction(2, actionGroup);
1 m, K1 [9 `9 V7 d
- X* Z& s0 m; L* L' o) n. I } catch (Exception e) {
0 p, C U7 P1 E$ L1 j e.printStackTrace(System.err);
9 u4 ?9 y1 v& c3 l R, d: ^ //System.out.println(e);6 t5 @+ K4 `* w. D/ @9 }8 G! [
System.exit(1);3 s1 Q" b& i' L7 C( C+ X
}( [( v# X* @ `! K4 }% E& i+ {0 ^
7 S$ S& p4 z) X9 p! w3 E5 N1 w3 K% T' F# l
}
; o4 _8 q* }, V* s! G. K
1 N, l+ P- [& _ private void swarmSetp() {
) w& G. N w. M: V! c9 n list.addLast(new Agent(Id));
8 T8 @3 e) {! Z" D Id++;
2 t) W) d- P3 [0 @ }
# U) H! {; D8 J) \: @" l) `$ _) y6 d$ l8 I* A. }7 a% n
public Activity activateIn(Swarm context) {
' G# @; V, }0 H super.activateIn(context);
" j: Y0 ?* l6 c F( j schedule.activateIn(this);
9 P) M+ R- p1 p2 L# X, k- s. X& Q2 e0 v return getActivity();; l1 j1 M: B7 Z( @# I6 R
}
' V7 _" `5 k1 e' X! I$ [- j# e T# t: ]! G. B/ q" [
public static void main(String[] args) {
8 ]% v& r4 U# A0 C4 r' f0 a6 y# Z Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
, l$ c3 C$ N6 u1 C Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
$ S; h1 B: ~$ o' b; A swarms.buildObjects();& d" d% u4 } {8 w, K& J, N. i' H
swarms.buildActions();
$ e4 E( w# f* r7 [) K swarms.activateIn(null).run();
t8 w, c+ a* L" V }6 U8 H8 v" U& _! n
6 ]. t& C; ]1 g0 Z$ [6 s} |
|