|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
1 D/ I# ?( C, W8 z. W- f; U$ }
% p) k5 U( _8 e) Q2 V本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
2 ?+ h S9 {$ X) G; |5 Z: K以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
' t) j+ D. k, f! v) Yswarm.SignatureNotFoundException" F' H8 ?* k$ u- Y% f8 K4 g* M
at swarm.Selector.<init>(Selector.java:76)8 {$ m8 n: K \ n/ _* D# A
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
! M& i: T- ~1 M: K2 b at ActionGroupDemo.main(ActionGroupDemo.java:67)
; }* M( h7 A: W$ D0 x4 {) w: y. w& _
0 E }" K! [# o) R! i6 P) Oimport swarm.objectbase.SwarmImpl;$ v. C }( s# I* A+ g; L
import swarm.objectbase.Swarm;
0 t$ Q8 b0 m8 U$ |5 u Uimport swarm.activity.ScheduleImpl;
9 k1 E, e0 ^8 }+ a% Jimport swarm.activity.Activity;0 W( O6 X- N; Y) F
import swarm.activity.ActionGroupImpl;. r- r* K0 ~1 D+ _9 T# \9 u+ f) {
import swarm.collections.ListImpl;; u8 p7 N A( Q
import swarm.defobj.Zone; . u n7 `0 M4 ~- V4 O+ J, e* N
import swarm.Globals; g0 o9 }) X7 v2 ]
import swarm.Selector;
4 u( a& k9 I$ ~: `+ pimport swarm.activity.ActionGroup;
+ s% X2 u8 h [ p' Wclass Agent {
, B# z/ X4 S. I' s2 T char id;: C9 k/ Z- s5 E9 r% t) m' g
* N0 |, b$ h' t% ^/ o7 D, A
Agent(char id) {
6 n& p9 k4 d3 x( @: [ this.id = id;
, i @+ \) L/ N$ e3 N3 j } [( ~! x" e- x. ?
* \4 t& q$ h3 T% K0 [! L
public void agentStep() {
: B5 B J2 a0 H' `/ R* E System.out.println(id + ":" + Globals.env.getCurrentTime());7 _) k, {8 D1 H" z0 _4 r
}
2 i! d( { a2 x( A& j T, h# U) A}/ G, X& s6 s' O" F7 z O
3 x0 X0 b. v2 R$ o
public class ActionGroupDemo extends SwarmImpl {
* w$ H0 M+ R* q3 g- M ScheduleImpl schedule;
! s8 G* w1 M2 m1 d2 ^ ActionGroupImpl actionGroup;) B9 R Y: Z% B; s
ListImpl list;
. _! y; ]5 g+ ^3 J7 R' p char Id = 'a';8 h9 h1 H7 v7 V/ Y
9 R) o2 j1 B2 p& D. h8 [
ActionGroupDemo(Zone aZone) {6 Y3 L" Y* X5 [4 Z3 [8 z$ h6 P
super(aZone);5 u. `' ]& F# U' G
list = new ListImpl(aZone);+ P% x3 C& K5 O1 P; Y# i3 o# }$ C
swarmSetp();
1 g1 U' R- {$ i, L7 q3 |& H actionGroup = new ActionGroupImpl(aZone);1 ^) C; Y; G) g
schedule = new ScheduleImpl(aZone);9 D: p2 h L6 l8 u
try {* Q- G. e, m& O' [
Selector agentSel = new Selector(Agent.class, "agentStep", false);( f8 O3 J8 m8 f6 B
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
" D' ]8 [# l: g" i7 U 0 c- M# H I# F/ H; e, Z! u, _
actionGroup.createActionForEach$message(list, agentSel);$ n8 s$ w- L5 a3 v. V
actionGroup.createActionTo$message(this, swarmSel);
% d4 t3 b. v, p0 z7 z8 W% m6 a schedule.at$createAction(0, actionGroup);/ {$ }# z1 I1 _, F1 Z; t# ?5 U0 y) H
schedule.at$createAction(1, actionGroup);3 c9 @% D( L0 P z9 U9 d6 U
schedule.at$createAction(2, actionGroup);5 y, W# B8 m8 R
) K, V( z( u* {1 i' X9 x8 r
} catch (Exception e) {- }& A/ F2 J# e) K5 x+ y
e.printStackTrace(System.err);
5 r0 G' F) c+ I7 h2 c/ p //System.out.println(e);
/ D4 y: C' a- R( V$ I8 f+ N7 o System.exit(1);
7 x) I' d& W! b5 l9 U) i2 u$ c }2 Q% K- K0 K+ J7 q* ?
2 y, ^: C% U: f5 ~" x/ m i! K
]& k- b( t4 @* @! S3 u }
5 Y: K# S b; d" V! S
8 t4 K% _! U: w/ u9 ^& P) O1 { private void swarmSetp() {
8 M$ s. c8 n) g) k7 q/ ` list.addLast(new Agent(Id));; G; \+ p( |( R1 [
Id++;
, p. i" P" n" @- I, O+ k }' e% L& u9 H6 F& R4 C5 D6 E' D% J
/ ]: U- p4 E& T% U6 A$ B5 u2 n public Activity activateIn(Swarm context) {
: a1 D8 I3 w1 Z. e8 J( F super.activateIn(context);8 K4 T) ^! j( P. S, \! E, Y/ l
schedule.activateIn(this);
9 O, E# l3 f, F1 x8 ^2 N$ f# { return getActivity();" b1 _1 N( `" L: E+ g' S
}, D+ F& m( v4 M4 y
8 l* e/ d( O4 U5 l5 n" F, @1 ~3 e public static void main(String[] args) {4 W3 I r2 x! y. I
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
; B" U+ g/ @0 Z1 ~/ |$ _& w Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);; t! [: Y4 M2 w7 h
swarms.buildObjects();
+ I3 R3 \* O2 c! Y swarms.buildActions();
3 d- ~1 I7 @! Y# Q! c7 ^ swarms.activateIn(null).run();
/ T% Z: V. @& w' f/ T# m }
' `5 o3 H8 T5 O: z; V
' ?; a1 V) J9 o) K5 r} |
|