|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 : S6 X. A+ q7 ?. d/ c5 W
* L. J: O+ Y B1 ?- A3 s% N2 J
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
0 m6 w$ O' P- X4 x u1 A以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.! N9 S5 @ V: ^7 S% W) C2 D
swarm.SignatureNotFoundException0 w& {: Z6 v( U1 h
at swarm.Selector.<init>(Selector.java:76)
2 Q. |) a7 \, I: t; _# h0 f. l at ActionGroupDemo.<init>(ActionGroupDemo.java:37): i* x5 B: M) E2 v. j7 s+ P
at ActionGroupDemo.main(ActionGroupDemo.java:67)
; Y% ]0 f% D9 ]7 W
1 y! j" U5 C+ J, [6 [6 O9 d( y+ v6 H# S7 y
import swarm.objectbase.SwarmImpl;3 l3 s0 ~1 z# K1 j$ G6 ~/ L- |
import swarm.objectbase.Swarm;0 l+ X5 { V7 Q2 w! _& E4 ?
import swarm.activity.ScheduleImpl;6 z+ s3 a! |- D3 x" `
import swarm.activity.Activity;. ]4 G2 J" O2 Z
import swarm.activity.ActionGroupImpl;" a- B1 \& ~' J( r8 u6 G. S2 Y( [
import swarm.collections.ListImpl;; Z- C; j- i: x3 i5 v5 J; Y
import swarm.defobj.Zone; 7 a* n) D' [( G) |7 Q
import swarm.Globals;" f( Y: x5 D9 T, C: [0 ^1 t b0 D
import swarm.Selector;
, g7 Q8 |( m9 p9 I/ Rimport swarm.activity.ActionGroup;
! O7 P3 V3 M; `) \, Qclass Agent {4 ~% `% x% i" z0 J: w
char id;
- D) c& q/ \$ M1 r* `
6 J0 x; z {" R7 c$ k Agent(char id) {
5 C' k; Q+ v$ I& h( v; u2 Q% ] this.id = id;
" B' }" g- T% @ C, y }
H i" ^; A0 q- c5 _% P$ X6 [/ o2 i1 r- k! o3 I ^/ l4 [' p; F+ \
public void agentStep() {
$ @. X) X% h3 t. S% i! ? A. x System.out.println(id + ":" + Globals.env.getCurrentTime());
* @# b" i# ^: P }$ n$ o7 d* e" V- k
}& A. S" v% Z' a" Z, d& N
! u: C5 v7 D. D7 zpublic class ActionGroupDemo extends SwarmImpl {1 y! H6 n' t3 G% d# \9 E* _5 J4 W
ScheduleImpl schedule;- k4 ?5 u9 c2 v) z1 G4 p V
ActionGroupImpl actionGroup;( R& `1 T# X1 ]" j
ListImpl list;' f3 d7 z/ s" X9 u. t
char Id = 'a';, E4 z* J/ u' N3 E% m( F
8 M! C; h6 ?, P+ ?& R1 _7 F# g) e
ActionGroupDemo(Zone aZone) {5 d8 w' H4 A7 ^ X" N* E
super(aZone);% U3 G' \, {. [- N0 d
list = new ListImpl(aZone);% ~$ i# C" H# p4 r
swarmSetp();& U [+ C+ \, Y8 c
actionGroup = new ActionGroupImpl(aZone);
- M: p" V" |0 W' `" d schedule = new ScheduleImpl(aZone);/ k& f( ]/ K, `, D1 C$ T
try { z3 N$ D/ Q6 _# R
Selector agentSel = new Selector(Agent.class, "agentStep", false);, a) S3 b' Y+ Z/ g0 |
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行2 Q/ J9 J3 V- N
8 e' _% ?# Q5 r3 M
actionGroup.createActionForEach$message(list, agentSel);! q* H8 `/ D2 s% W% g7 t+ b
actionGroup.createActionTo$message(this, swarmSel);. q7 L& U! L4 q4 W1 l7 ]5 s
schedule.at$createAction(0, actionGroup);
0 s! {' g1 q2 U$ U4 N: [ schedule.at$createAction(1, actionGroup);
y6 m: O$ [6 w5 ] _ schedule.at$createAction(2, actionGroup);. b/ B: C' C( O# J1 o( H
$ a1 ~( u2 }, O" R8 ? y } catch (Exception e) {3 x: {2 y' @- M5 U. }
e.printStackTrace(System.err);
U- G! C0 j/ G0 k4 {0 I( r //System.out.println(e);7 L& r! A. s& o9 a& ~
System.exit(1);
$ t# h: E n/ [, Q% R4 B( _ }, b) e4 S+ X* G' R( ^* c; N. O# p
7 I' ^- l9 ]6 T* {5 s
% v3 R+ n/ v: ]+ @4 o
}
7 z# m. B5 e* w) O) i
) q, X# `) _# m2 d private void swarmSetp() {7 v$ l& ~8 b" E: B, B) t2 d% T
list.addLast(new Agent(Id));( P" b5 z$ Q% I( \4 U* R$ t9 K
Id++;5 X, T: L: ~' e& l6 |
}: i5 [' [: I, K$ a
0 d0 _7 c! ~, |6 A" U public Activity activateIn(Swarm context) {# t0 V8 l8 S% d: W' s
super.activateIn(context);
$ G7 t* N: `; C4 w6 J% a4 E schedule.activateIn(this);/ O9 ^# H0 C+ F
return getActivity();
# t4 m: I7 r! q: T! J( B }5 s4 B" m8 q7 b. p( I1 A
6 K' H9 W/ W1 z1 G6 h8 u6 u* b
public static void main(String[] args) {" f( P! t! W' K% H& V8 L7 `) T
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
4 Y& b; l" f$ X @ V: J, O+ ~ Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);9 W* | u# R! T" f
swarms.buildObjects();; s l X; g0 Z
swarms.buildActions();# O% M1 z2 | W: q2 _3 ^
swarms.activateIn(null).run();/ l- Y- n$ h6 B5 Q+ K6 l* ~
}8 y; ]. _+ y* O
; i' S8 N6 C9 q0 c1 J8 r0 Z$ f+ |9 F- i} |
|