|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
4 B2 r5 p! |( `2 w9 s
; t5 w- l: d6 j本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21& `% ~1 r( Z1 z' H" m! V
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
, D5 L E6 u. ?% B* E+ hswarm.SignatureNotFoundException; P9 `$ \" p; @* T4 {
at swarm.Selector.<init>(Selector.java:76), F! C6 |" `( b/ H1 {. }
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
: \4 U, ^( ]/ S% T. r8 u3 x at ActionGroupDemo.main(ActionGroupDemo.java:67), d+ K b, f( A# u2 g
- R6 Y8 \7 `0 K& |9 |
3 T# p) L. @& d1 g
import swarm.objectbase.SwarmImpl;2 T* Z) c9 }, V( j% U9 r: b
import swarm.objectbase.Swarm;: a0 G* K5 a8 W; C3 O: K
import swarm.activity.ScheduleImpl;! O! m* b! I9 D7 e8 a
import swarm.activity.Activity;, B+ Z5 _; X+ H( J5 P) U
import swarm.activity.ActionGroupImpl;8 M3 M- w& x! \- o
import swarm.collections.ListImpl;5 t. f; y9 b S/ a7 c6 ]' `: ^ K
import swarm.defobj.Zone; 0 T2 ?: d! g- k7 ]; |6 f2 Y! a
import swarm.Globals;1 u$ _6 F6 P+ k2 L1 i
import swarm.Selector;
# W$ L$ q; \2 s4 n8 R( ?import swarm.activity.ActionGroup; 2 Y9 Y- F' r8 p& i1 \9 u- W
class Agent {: T4 P& y- G3 ~9 F: x; n
char id;
# u7 `! }0 O* l0 [, }: n
' h+ b3 \6 x- v D7 A Agent(char id) {. x! G! n7 Q% G0 r: j
this.id = id;* A- k' B6 d* L7 u1 K9 I X
}
9 H' @; y( |- d) N0 s# k
! @7 n, d3 P3 Y1 d public void agentStep() {
5 Q& D4 N9 i0 O! `( v; m/ @1 P0 ~ System.out.println(id + ":" + Globals.env.getCurrentTime());9 U; ^& H! t/ b% |
}
2 l& u" C" j- F}
1 V! U h4 i4 N( Q) f( c# Y4 M9 s: @, v! h
( J/ b( h r3 U- g6 Q) xpublic class ActionGroupDemo extends SwarmImpl {3 j6 M0 ?8 _. [% B$ e# I
ScheduleImpl schedule;- v0 I9 T4 R6 a' i
ActionGroupImpl actionGroup;( B2 B( o' k( H
ListImpl list; _" X' e; A: d3 T0 J2 V$ }3 V+ ]. D* f6 Z
char Id = 'a';/ a1 n( o6 H- v$ E/ _/ ~" w( @6 b" }" C
# d% H# Q6 r! J, r# G* u ActionGroupDemo(Zone aZone) {
# Q8 y" b/ i f. p' v- P/ W: I' k super(aZone);: t, Z( E* \; ], k& q8 @
list = new ListImpl(aZone);
# P& f/ A K& R) z$ c' C swarmSetp();* C# l8 A9 H# t7 R% o% y
actionGroup = new ActionGroupImpl(aZone);7 D" M; l& f& a+ o$ e9 s
schedule = new ScheduleImpl(aZone);
# `: w# g5 t( z/ H3 `4 y% Z" l8 | try {# y+ d: o2 ^, o5 n4 n
Selector agentSel = new Selector(Agent.class, "agentStep", false);
! B) ^9 M6 e+ ^8 j' G Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行( B: ^" n' A/ ?0 h
: A' Y, \* k% K
actionGroup.createActionForEach$message(list, agentSel);
6 S# e0 R6 L- X- N8 _0 ? actionGroup.createActionTo$message(this, swarmSel);6 C5 J" K" r- o8 R$ |( p4 M
schedule.at$createAction(0, actionGroup);
% K6 M7 F0 ?5 w schedule.at$createAction(1, actionGroup);) z: M: C, x6 [4 i1 w
schedule.at$createAction(2, actionGroup);! g2 n. F6 h5 L/ y( F) C8 q4 m) Q s) J
6 @5 x+ q" y/ {3 P% [. |0 }+ {
} catch (Exception e) {. _4 u; {& t3 c! \" a7 p
e.printStackTrace(System.err);/ c/ A+ E+ T( I0 P
//System.out.println(e);
: K+ k- O3 t4 ]3 Y( M3 k4 s System.exit(1);- P5 C1 Z t6 v- ?4 s+ `
}
) W+ E( `/ N. T4 Z6 l' \( J& ]9 m7 R* y5 v) z
) `( f+ z& L/ b- [3 z3 a+ c }/ r& S& ^0 K. N3 @ {
& ^( G) i3 P2 t: `" m* b private void swarmSetp() {2 u5 Q) d4 i. J* J6 }
list.addLast(new Agent(Id));( {+ o) u0 J) ?
Id++;
( f. |/ r; v8 w }: _# Z4 l- c4 Q7 [9 Z
; }) W/ B& N; U) p' J9 h
public Activity activateIn(Swarm context) {
7 Q' _: [' [7 O% [. I$ b. [ super.activateIn(context);
% N1 f. l3 a1 S schedule.activateIn(this);
: V1 Q. C1 ~, M! V R& a6 S return getActivity();9 E: j7 d0 ~6 e0 ^4 i8 [
}
& J! v9 Y i1 n0 ?2 `$ E9 H1 e$ v! x$ ^; S- ?
public static void main(String[] args) {
3 G, ]7 N1 s' s8 z5 f+ V4 w Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
: z* Y4 z/ q3 I- f Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);& H# T0 ~! Y8 u0 n ^5 e
swarms.buildObjects();9 X8 I2 E$ b: ^" m9 B& Y2 d P
swarms.buildActions();" m; H" p6 w! X0 T# X6 q
swarms.activateIn(null).run();
* f$ B8 E6 [ ^. w }' s0 c: A; ?0 x$ _% p0 x8 s
/ m, q+ P3 K/ w} |
|