|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
4 K! g. k% i6 b* K h: o* Y3 E j# e9 L( E% N; n0 |+ e
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
+ h% T$ i, W- i+ f2 ]以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.: S/ Z7 T; S+ G, u& _* u
swarm.SignatureNotFoundException+ T9 B4 F" T- |3 E% Z5 F" a
at swarm.Selector.<init>(Selector.java:76)
% U7 f, V$ B; v1 C& ` at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
2 S1 y, V& ~% L3 c9 U# [& w at ActionGroupDemo.main(ActionGroupDemo.java:67)9 g1 {' s9 ?5 o3 q% q
9 q [' n; ~# ?4 n
W& C) ~- {1 ^: _: P) B' z5 ^. _
import swarm.objectbase.SwarmImpl;" E Z+ c- `9 ?1 M# [
import swarm.objectbase.Swarm;
: ~/ {# Q8 ~8 Q! N) V, qimport swarm.activity.ScheduleImpl;, Q% X/ F" V' H6 v
import swarm.activity.Activity;
7 s- s4 M3 t& K! L P4 aimport swarm.activity.ActionGroupImpl;8 o8 h4 K6 Z* Z; F6 \+ f N
import swarm.collections.ListImpl;
* l: a& G9 c1 f3 cimport swarm.defobj.Zone; ; r- i/ G) J6 e6 \9 L( D4 e
import swarm.Globals;4 K" U$ |! ~% r4 N
import swarm.Selector;4 W# i: v& {# [9 C2 g
import swarm.activity.ActionGroup;
5 K C* g) @' |class Agent {
1 t+ m* C5 @. V char id;
% X2 A" }/ |# |. v3 p) {. @' d5 w) } t5 e- v- b8 a' f
Agent(char id) {
" E0 e# N6 f# Q this.id = id;
2 U g1 m, u3 S) v K A }& V p0 k" h; ]/ E( d9 B& X
& z8 E1 v. A$ A$ |+ R public void agentStep() {( o/ ]% s1 A( ~8 }
System.out.println(id + ":" + Globals.env.getCurrentTime());% Z4 Y8 _, A1 O& r& n
}. M" v0 T- S+ j
}
M2 n5 }. c5 r, e% E2 d; J, _2 ~3 B$ r. C, ~5 ~0 r+ V$ I3 o% t4 n
public class ActionGroupDemo extends SwarmImpl {6 s& K7 @* E* g. ]0 [* ^
ScheduleImpl schedule;
8 V6 O, t; N4 ? ActionGroupImpl actionGroup;# Y# R3 H9 V1 Y3 x& r0 o* a$ d
ListImpl list;
# F1 i( w. C. |# ` N char Id = 'a';
. U& \2 V( u( Q7 j9 C
% z b- l/ T/ ^" Z2 d ActionGroupDemo(Zone aZone) {& I( X5 l0 d4 i+ j0 k0 ^2 L' _
super(aZone);
9 K }/ O4 m" |/ Y$ u& q6 N$ b list = new ListImpl(aZone);; @7 Z M5 q9 ^! J7 F) T' k
swarmSetp();( K |. g) \' T3 u0 K# {
actionGroup = new ActionGroupImpl(aZone);
$ c) \8 J( I- `! u& f3 u/ Z& f$ x schedule = new ScheduleImpl(aZone);
2 h2 {8 s2 Q/ r% X& H try {( B& `" E- |$ n5 J9 S2 Y2 E
Selector agentSel = new Selector(Agent.class, "agentStep", false); l& e8 t! `# _9 _" ^$ |
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
# n: Z7 S! X# ^' q 3 T- ]/ |% n! m9 L
actionGroup.createActionForEach$message(list, agentSel);
( W& d F- x' Z actionGroup.createActionTo$message(this, swarmSel);# j4 Z- U2 S4 O8 w: a5 v+ H
schedule.at$createAction(0, actionGroup);: f: Z" _9 O* R. V% D9 m- U" @1 D
schedule.at$createAction(1, actionGroup);8 _9 ^ _& k. H/ t4 b! o
schedule.at$createAction(2, actionGroup);
. a4 @3 H' k' j2 }5 A& E# ~
6 _2 @1 J& s3 [: M, `9 I) ^9 ^& t } catch (Exception e) {% g n3 \7 @/ T3 P& l" w. Q
e.printStackTrace(System.err);: U3 z0 `* S" ~" ]
//System.out.println(e);, w+ A2 a2 U4 w8 P9 F
System.exit(1);+ F* b: ]7 V2 h7 b
}8 ?$ d" \3 X; W# v- B7 {
3 W9 W6 C" m8 w+ {5 v6 V
' A* [2 Y) t, `# N1 Q1 s- @ @ }4 o/ n2 W2 n6 s+ @/ O# |/ ~( N
4 R0 Q* ^! l0 w" s% V- K private void swarmSetp() {5 _: ?+ K5 m. y$ R& v& v. \
list.addLast(new Agent(Id));
9 x5 j: _; G$ q: s& D: y Id++;
- ?+ q f% C2 h& p0 D }! v7 ~" x. `! i1 c, Z5 A
! b4 @0 p: a: G+ ^& ~& V public Activity activateIn(Swarm context) {2 g+ F$ E; z u7 e6 Z* I+ U
super.activateIn(context);
6 \7 i! \: ~2 B, E$ V/ y7 f schedule.activateIn(this);
5 V+ T" }+ I, y return getActivity();6 l% l5 w" K# q' ^
}! J- k" y. e$ B* n6 i% [
3 j' f# M& ]- ^- Y5 b; f8 _ _1 w public static void main(String[] args) {. @$ s8 S9 j4 x2 ^% }. M
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
! f a3 g8 f& d: V: P2 d Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
" c1 J( c+ W o swarms.buildObjects();
7 A4 ]/ R- i b# ~! a- r swarms.buildActions();7 C$ F5 p- t3 F3 s
swarms.activateIn(null).run();2 e4 U7 y+ R4 C% l
}! u. A# B1 O( V; Z' H) T) \
" t1 q! i+ e0 W) s' Z} |
|