|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 & K0 z0 N$ \9 B1 Y( W2 v" C* d4 h
3 l, b' } y D. ^' y4 b本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
; m+ H. _! ~" G8 U4 A' X以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激. G' j7 M) p2 s
swarm.SignatureNotFoundException& } S. M2 g( G0 l! V! l
at swarm.Selector.<init>(Selector.java:76)
$ i7 m$ W% I9 k; Q, ` at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
! Z7 f& T) U3 G2 j2 T at ActionGroupDemo.main(ActionGroupDemo.java:67)
2 X* P4 E6 Y5 l# o6 A7 p
6 `0 K6 O& i9 I! ]3 j* m( }; m2 _" H+ Z* J7 p5 i9 c: A d0 T+ D& W
import swarm.objectbase.SwarmImpl;" `/ S* |" @9 [) s
import swarm.objectbase.Swarm;0 p1 ?9 D5 P7 _' z0 I- T0 c
import swarm.activity.ScheduleImpl;. o& P" H; q6 N& u$ W1 N
import swarm.activity.Activity;
6 l; B1 e' P* n7 u1 X5 g7 Pimport swarm.activity.ActionGroupImpl;
! D* R* A6 P/ k' M0 q4 O! H5 Jimport swarm.collections.ListImpl;
; [) }9 }9 g, Limport swarm.defobj.Zone;
( U4 Z! {; W- K6 U1 R& u7 e6 oimport swarm.Globals;
3 f2 ~4 R- [/ Dimport swarm.Selector;
|/ C) q4 D- Y6 F' Simport swarm.activity.ActionGroup;
& W/ S c; { z5 m5 o% dclass Agent { c$ i" g9 a5 b1 ]
char id;
. n5 J: h# y0 |/ R& g d( f
0 k1 H: ?& y6 f6 T' V Agent(char id) {
1 k& b x, \6 q7 }( E& o this.id = id;, c% g' P1 P! f* n% Z1 u& b0 t) E; `
}
) e0 e+ m. W, d% F' H9 ` |
. L$ J3 l" @* j6 ]5 w8 t& o public void agentStep() {: f& \ e' U5 _
System.out.println(id + ":" + Globals.env.getCurrentTime());0 l7 n- A( v# D: u5 D. {1 w
}) \3 m3 T: a. T& D; n* J
}
/ }5 M# }; e I( g% q% r7 z( [( r$ a& f! }3 f4 @, q
public class ActionGroupDemo extends SwarmImpl {
7 G/ I! M$ g0 U$ A2 J ScheduleImpl schedule;
% m) ^6 y" m% c l ActionGroupImpl actionGroup;
! n' _# G- x8 k' _; J ListImpl list;7 r: G' O) I1 H$ V" ~' U# h& n2 m7 m
char Id = 'a'; C. g6 y/ X* H0 c% O" P
/ Z+ e! X; q6 w. g ActionGroupDemo(Zone aZone) {
2 ]5 K' }8 b- S9 P super(aZone);( K+ g3 X( ~! R' A. C0 k0 A G8 Z
list = new ListImpl(aZone);
0 q/ z) l: A# F3 v: |, ?( X/ p swarmSetp();/ U' G: p3 p2 p$ T2 h7 B. B
actionGroup = new ActionGroupImpl(aZone);
: c$ s c N5 J2 u S+ W schedule = new ScheduleImpl(aZone);
1 y7 T' z* R* T: p try {' ~. P) }# P1 R( a
Selector agentSel = new Selector(Agent.class, "agentStep", false);
! d7 O# A$ S" I! J+ g4 ` Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
. H6 e" Z. }# q) o, v, Q# D' x8 R $ L- u( D+ b d8 E2 b0 a: E
actionGroup.createActionForEach$message(list, agentSel);
7 C4 z0 x3 [+ v' S actionGroup.createActionTo$message(this, swarmSel);# q4 ]" x. ~( i8 I" R
schedule.at$createAction(0, actionGroup);1 A" P( ]6 V- B! k! N7 ~
schedule.at$createAction(1, actionGroup);
) S& m9 C/ _, ^) M7 r1 U2 r schedule.at$createAction(2, actionGroup);" v; ^& ?3 D. u& P1 o
% M1 }3 q9 S+ w* Z1 j
} catch (Exception e) {
6 f9 l' z9 g1 L, d+ O e.printStackTrace(System.err);% W* {5 u _3 H9 c1 J
//System.out.println(e);
0 h% k9 ]- R( r) b: E System.exit(1);' V9 T, k7 Y9 I3 J$ J7 B7 l
}' d. H4 c6 r& S' O- L$ I. x
. i& J, [! _6 ]2 h% b" ^
j+ N5 ~+ ]0 y/ M: k }- [0 h9 R9 v" v. f C- T7 C% \
/ {& B! b& O6 a( ?
private void swarmSetp() {! l" r, y% ^. j. R' D; \2 H( x( |+ \1 [
list.addLast(new Agent(Id));5 l: h; R5 ] T! U
Id++;% q7 Y2 V3 V/ ?: |9 K. R1 e1 ?
}
- C2 y, h( w; F2 `
c. C0 W1 w6 p! r) M% C% b9 s public Activity activateIn(Swarm context) {- j6 g2 z! D5 r! R& q
super.activateIn(context);" K! a* d$ \7 R; @+ W! g
schedule.activateIn(this);
# D( d' w& U9 H+ r return getActivity();1 L, y) _/ x. g0 r
}8 E6 {2 d0 W0 i8 \# Z* j
& [( o3 u3 G2 S: p" d( j public static void main(String[] args) {
; w! S7 B) \! O$ J: ]8 H Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);9 o; D8 h) J$ @- h8 h0 G( k
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
. ]) o1 \; d! U& M) d I! q swarms.buildObjects();4 ^% |, Q$ N% L
swarms.buildActions();+ U; A5 ^# J! z
swarms.activateIn(null).run();
7 y s) p2 J- \+ p( O8 m4 E9 ] }* V6 j/ A; K" Z$ `
- g5 e* ]; T2 j4 I5 K} |
|