|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 3 R1 O" y& F9 B2 m. u, `6 H! D
) Y6 F% [% H6 k: l
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
3 q# d. W6 g1 X0 s8 L以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
) f- W/ T; J2 [ w- lswarm.SignatureNotFoundException! }, |; K* u, p7 s" A- |5 Z1 i
at swarm.Selector.<init>(Selector.java:76)2 B, l A" U. S: }
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
' W& I% R$ C& ], ^ r at ActionGroupDemo.main(ActionGroupDemo.java:67)1 p; b8 W! j7 c# k7 B# K/ [
2 m1 n& Y) r8 W
* ]& |+ W( n( G( T& _0 a6 m( Simport swarm.objectbase.SwarmImpl;* t$ s& O5 E/ G/ c9 ^. P
import swarm.objectbase.Swarm;
% q- K9 ~: J) l2 I: Kimport swarm.activity.ScheduleImpl;1 `1 K3 B5 w* a* r7 ?# n, ]
import swarm.activity.Activity;
% n' O+ n, O! f) v$ |import swarm.activity.ActionGroupImpl;* k- a1 h( k8 M% b8 l; \0 y+ R
import swarm.collections.ListImpl;2 n$ R6 E& R9 C# ?; y9 L
import swarm.defobj.Zone;
9 W# \/ }0 @4 A" \- ]import swarm.Globals;
0 Q4 A$ |9 Z9 T3 d6 s' P7 timport swarm.Selector;
9 V9 }* R- k# R0 ?- w$ Eimport swarm.activity.ActionGroup; 7 @6 z7 P6 [* U" y: A
class Agent {9 r4 Q$ h( r" e0 m
char id;( P" l2 d* M- |. o4 y
% n! c. @, E- A' W% \! h9 { Agent(char id) {; k# V4 t4 L, J
this.id = id;
; \" ~5 H4 M( E* O" }. ` }
# x& [3 q1 b$ B
9 D2 X. g" @- s public void agentStep() {
0 A: N! I, w+ `( Q0 h0 K# k r System.out.println(id + ":" + Globals.env.getCurrentTime());
5 z- z# F- \3 S; e* M; m+ w }2 a! I; M& e2 o1 E4 {
}
, y" F2 C+ E4 I; \& h! L
, q0 _0 R* Z* y2 Q* I; O7 Epublic class ActionGroupDemo extends SwarmImpl {
0 Q& V3 Q7 l7 v7 R" C0 G* x ScheduleImpl schedule;0 m7 A( A, C% X
ActionGroupImpl actionGroup;* g4 W) |: c; V% y
ListImpl list;6 l& c4 k. e: J
char Id = 'a';
! }3 s0 L" ` M+ y
; O' Y& A5 @1 c- h$ U- k( V ActionGroupDemo(Zone aZone) {+ Q9 U# b0 i$ J' k1 m, q7 ]
super(aZone);
$ Q, G+ E$ J6 ~0 Z5 o# F; U5 R list = new ListImpl(aZone);
! d4 g* I6 P K' x# D9 j/ o& X+ r( h swarmSetp();: {6 j- Z7 K G' \7 `! e6 B
actionGroup = new ActionGroupImpl(aZone);
1 Z9 r3 ~3 X M$ X* R8 T schedule = new ScheduleImpl(aZone);9 Q/ p' r; i. P# Z% t5 x2 m
try {
% A. R6 E. v" H9 }1 X0 l6 \ Selector agentSel = new Selector(Agent.class, "agentStep", false);
# r$ c* ~! z3 E! V% N Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行6 S1 y3 V, G% _
& r) @1 ^ i: T- n8 u* V actionGroup.createActionForEach$message(list, agentSel);
% S! q2 Q e9 z" k% k actionGroup.createActionTo$message(this, swarmSel);8 U9 R4 P! M+ f- ? x
schedule.at$createAction(0, actionGroup);$ ?) t9 _7 N" E% C- G) L
schedule.at$createAction(1, actionGroup);2 s$ x4 I/ z9 @! Q& O! A
schedule.at$createAction(2, actionGroup);
) W! M2 ?% T3 }
" G8 x/ c" Y, \) Q( d } catch (Exception e) {) W$ F: H8 e8 _( r; {0 i" } x7 p( k
e.printStackTrace(System.err);
6 S7 |$ \( U( q2 {0 A! U h //System.out.println(e);
* B/ B5 [8 G2 L4 N* x System.exit(1);
( _2 d* H. M& E. j: R }
1 h, N) r9 B8 N1 `2 @! S: d" |
6 c" O, _( F6 M% m" @5 n. M& ~ f( w9 k7 b& U& s; r
}+ b6 i A( V" W
1 N$ d! n$ e8 @8 s7 Q. D private void swarmSetp() {
: C9 e$ R% W! M% K list.addLast(new Agent(Id));
8 q1 m) k( N, F3 Z! O* Y/ O Id++;0 ~& |2 O7 z$ _: z) T7 n S
}
) a9 b% G$ M4 ~1 e1 {3 \* i% g- W2 r
public Activity activateIn(Swarm context) {* v6 |; Z/ ~# j- a- h6 x* W4 G
super.activateIn(context);
' c6 u+ ~ l4 g# Q& C) j, F3 X schedule.activateIn(this);
2 r$ W- P' u+ Q1 a# ?% y6 a: h* v return getActivity();8 `* X3 b F8 }9 \" X- z; C; r5 ^
}( n; v/ \+ s9 m/ d" i$ n
' f4 W8 \5 z7 m: P public static void main(String[] args) {2 ]* t# h5 w. i
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
, p8 e! H# a T* E2 r3 { Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
3 V5 W$ Q: X R3 x; q/ d/ e( W swarms.buildObjects();
% P, r3 t& T; i. ]* s swarms.buildActions();
/ D: v5 `% S1 R swarms.activateIn(null).run();
4 g( G* L! t, f7 k3 {" `8 a }# e' R, ^/ q5 x p
: n8 j9 Y( K0 {* Z1 c
} |
|