|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 . a6 z9 q+ u: j8 ?/ r% L
( w9 p$ d0 _. Q; q- q本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21, R9 A) [6 U# N8 f: r
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.) s7 Q6 q) g! j2 b# C5 c
swarm.SignatureNotFoundException1 l; t2 N, b D3 f+ D7 G2 d+ e
at swarm.Selector.<init>(Selector.java:76)
, T* i- K. r- x" l3 Q1 M4 O at ActionGroupDemo.<init>(ActionGroupDemo.java:37). L3 P9 h5 d8 N$ R' b5 N
at ActionGroupDemo.main(ActionGroupDemo.java:67)
6 u9 w8 _" Y3 H4 z( g% S
0 E N; n+ S8 C* x }& r+ n9 }- s; O" }1 G2 S3 H7 V
import swarm.objectbase.SwarmImpl;
1 H/ t/ u7 m& K! limport swarm.objectbase.Swarm;( O5 S( b* X) v3 ^# [! T: Q
import swarm.activity.ScheduleImpl;7 s$ a9 e& Z' P5 Y; N" E: {
import swarm.activity.Activity;
) f, @2 y e+ W+ P5 Iimport swarm.activity.ActionGroupImpl;" X6 W& X& v! }
import swarm.collections.ListImpl;
: W3 u5 I L1 X1 O7 |import swarm.defobj.Zone; 0 ^9 v* c/ B0 n' N! h
import swarm.Globals;+ F8 m+ [& H$ Y0 r8 T( H& }' P5 o, k
import swarm.Selector;1 z. |% w6 p- l8 N2 [: M( G" y; B
import swarm.activity.ActionGroup; $ Q$ a8 C* _; m9 s7 C) C! a
class Agent {
6 p+ | t7 N7 S3 ~( O char id;1 S5 |" u: r$ s
' l5 A5 W/ x6 S7 [8 F
Agent(char id) {& X [( @+ c% `& ^
this.id = id;& @) _1 K* t) b' \$ T: m) `
}
! w1 _& P1 w! W& Y, i: V( _! o8 r5 u- C" L7 p" v1 I
public void agentStep() {
+ w& T; y3 V$ R# h. f System.out.println(id + ":" + Globals.env.getCurrentTime());
9 l$ s+ P) z7 Q9 S# y }
1 Y" b7 ~8 C( Y/ ?: D; r( Q/ U}) {! [$ H `; N: {4 _% Q' f7 J
3 ?5 H! z7 C: Q: x5 S
public class ActionGroupDemo extends SwarmImpl {
0 A: W' U$ ~; J& Z ScheduleImpl schedule;
4 e8 Z1 z0 d! x& ]8 m ActionGroupImpl actionGroup;
. h( Z( H' {* e j0 O' W ListImpl list;% j l1 m n% w5 I
char Id = 'a';
6 S1 I1 r2 J6 Z! N
( ]- w4 ^) k3 ?/ W7 @) b ActionGroupDemo(Zone aZone) {
+ w$ |% ]2 ~& {% }& C9 a super(aZone);
" ^3 Y* m( c8 G$ C8 _8 A- i list = new ListImpl(aZone);
5 q0 {+ t/ f$ L9 c/ b d t swarmSetp();
! w* f; \, \8 Y) t6 T8 G actionGroup = new ActionGroupImpl(aZone);% o( \! H) Z& P p1 i
schedule = new ScheduleImpl(aZone);2 g0 S- P$ V. p3 q+ t
try {
H8 Q$ W, o& V$ Q0 Q" t$ t8 w' v Selector agentSel = new Selector(Agent.class, "agentStep", false);
$ H* y, U, l5 e8 |. Y# t) s Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
0 H- {5 r" t2 d1 r3 p6 q& ^2 f ' ]' {- h1 _: ~ f6 I! r
actionGroup.createActionForEach$message(list, agentSel);
9 @# L9 m7 B/ h- x9 |6 _& K actionGroup.createActionTo$message(this, swarmSel);+ I# Y |! T5 a: R/ A ~* L
schedule.at$createAction(0, actionGroup);; W$ X% q8 F/ Y1 W% {- _2 u Z( s$ A
schedule.at$createAction(1, actionGroup);
" ?* P! T2 D& | schedule.at$createAction(2, actionGroup);- t) Z3 }8 G0 @3 `0 @/ k, Q: }
# B2 U$ @$ q- P" X
} catch (Exception e) {
3 T# T, I" {+ x d" ?; \8 h" N e.printStackTrace(System.err);
* A5 \* [8 j) w8 W( b, E9 @$ { //System.out.println(e);" V7 I; S, ?+ U, l. J+ q
System.exit(1);
- D" ?) c+ D J& U8 U8 m8 j }" ?% A: P5 R2 X* s$ }' Z. k% I2 B
0 B; q7 O' A& X5 ?; ^- I r3 K% `$ t2 I! `( \4 u. Z
}+ I' [$ ~5 n0 j; i$ W
. |4 i! Q. A& J% G X6 c) {
private void swarmSetp() {
. B2 w) a# S7 \% Z/ U; i list.addLast(new Agent(Id));
- J3 b; |( c% y' a& V' | Id++;- w& }) u7 l1 w; `
} V1 ], l6 k) l) W. s$ l% x
5 v9 ]( s9 I6 }
public Activity activateIn(Swarm context) {) B" p8 t: v. X$ } X
super.activateIn(context);. h5 y: ~9 ?' ~$ c* K0 a
schedule.activateIn(this);/ z7 N7 h x$ |/ Z
return getActivity();5 R$ ^3 V+ V- U3 j( W0 J
}' |- W8 C! p8 M
% Y& E/ g! @9 X: q2 H: v2 o public static void main(String[] args) {1 K! ~8 \2 [3 u% {6 w
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);) ^+ p+ Q: W/ l8 _/ I! O
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
- H* K* H7 g" M$ n swarms.buildObjects();
* Z6 {* {, U& U \3 N5 m swarms.buildActions();
8 Y9 e. G; C' T5 [* q swarms.activateIn(null).run();# R" g. J& G. D! [! q
}) x" u7 f' w4 F+ s6 q) W5 s
1 @! B$ ^+ j% Y0 g3 h% `} |
|