|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
* n6 F% G1 t3 _+ K- ~: ] [; X
- w I$ j3 {2 H! _" U9 P本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21' x6 e% O% B d1 U
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.4 E% f" N# d Z7 j
swarm.SignatureNotFoundException
7 R3 a/ A) f' Q/ x at swarm.Selector.<init>(Selector.java:76)
6 S/ b0 @) J# V( a3 g: q/ N5 { at ActionGroupDemo.<init>(ActionGroupDemo.java:37)9 G% L% e0 u8 ?0 m: h
at ActionGroupDemo.main(ActionGroupDemo.java:67)
8 S4 D( q2 [2 i; L: O: ~- F: M* a9 M2 Z5 L. }1 e ?
" Z* W, Q& m( u$ K3 E. ?# simport swarm.objectbase.SwarmImpl;
4 R; ]0 @5 A# fimport swarm.objectbase.Swarm;
, u# A# L6 f5 w4 timport swarm.activity.ScheduleImpl;" z9 Y, \0 x5 @# F& G9 {
import swarm.activity.Activity;
. e- @( G! P) G/ y, b* Cimport swarm.activity.ActionGroupImpl;/ d8 n: q3 @* g( h2 x7 ]8 T1 {
import swarm.collections.ListImpl;/ D& ]4 v& E4 I/ {
import swarm.defobj.Zone;
- J: u3 }% Y" w5 O$ @6 Kimport swarm.Globals;! D* F( A1 _, [0 a
import swarm.Selector;. d$ m' o( }: n+ ]4 P% q
import swarm.activity.ActionGroup;
/ a' c8 f0 _) v; i6 x2 jclass Agent {: w1 `1 M$ M6 E: M
char id;2 T* I z8 C M. F
O% @$ K" t' U) o) [7 u+ h G Agent(char id) {) m0 i% _# f3 J' r
this.id = id;' V8 c# s- V0 g1 j% R$ N( }% X
}
, k0 K" ^' _9 f5 U/ [% a+ j/ {8 q3 t9 G, `( n" s
public void agentStep() {
+ k8 {/ d" J% f' U System.out.println(id + ":" + Globals.env.getCurrentTime());
# Z, f8 m: [ X( H+ { }
; [. m" w x# d: [9 n$ W}5 @' l# ?- i/ ~7 K$ c0 V
5 y; F' S; M6 h9 W3 z T
public class ActionGroupDemo extends SwarmImpl {
* t, z4 S+ V( l/ m1 |8 y9 T ScheduleImpl schedule;
5 D. P) z0 d- z' ^5 r* t. K1 H ActionGroupImpl actionGroup;; U* ~3 R5 t0 g) d/ w
ListImpl list;1 U: H7 B! t, b+ j* I
char Id = 'a';
$ t* x! H; x, P1 p% Z) M2 _
5 `/ S0 I& X: X# u ActionGroupDemo(Zone aZone) {
& O8 A6 r8 r4 J7 `) [4 V super(aZone);2 x( g5 l9 D# D4 j7 D3 l
list = new ListImpl(aZone);9 L: t$ A4 h- o
swarmSetp();* h5 B! x) O4 f& o5 d: ^9 ~
actionGroup = new ActionGroupImpl(aZone);
+ I# ?) O2 p% l! |3 s; N! K schedule = new ScheduleImpl(aZone);- } x+ f7 L3 E( A3 s2 N
try {
) f, Q p+ j0 Z Selector agentSel = new Selector(Agent.class, "agentStep", false);
2 \. s! G- B2 Z Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行. r, f x5 b% A
T8 E- L9 }& J" ~$ L+ L* O actionGroup.createActionForEach$message(list, agentSel);
; C" V( a4 j1 ~% l" B, Q& R0 a actionGroup.createActionTo$message(this, swarmSel);+ ~1 E7 a5 l# i& @3 Q @! c9 C2 ^+ ?
schedule.at$createAction(0, actionGroup);3 z! n' Q( N9 Y+ T. ^. k" `0 ?4 ?
schedule.at$createAction(1, actionGroup);0 d" c W2 Y3 C( l, b* O5 ` v
schedule.at$createAction(2, actionGroup);
g: X0 k" Y3 h/ d0 `: A1 _. C6 a% U7 l0 Y. w! A5 _" b1 `
} catch (Exception e) {
* I" ]* o* K- ^! L2 Y Z# ?+ k: B5 _& D e.printStackTrace(System.err);% t4 N7 B) J; |4 C$ _- G) x% l
//System.out.println(e);1 |. A- }6 w9 f9 t9 a1 H) \
System.exit(1);# n* [4 x+ F' q4 w# L
}
O* Q& S8 f9 c+ W( u$ c; s* T: I4 n1 h
4 F0 g8 t! b& `
}& U& z" k: v" I7 [. L+ t
8 Y1 u; ]# f4 X; i
private void swarmSetp() {) {9 Z* y G. h. G8 U' ?# u
list.addLast(new Agent(Id));
2 T# K9 \4 @ Z h3 ^( I& G7 o Id++;
8 @! d- Y7 X. a* `$ ] }
( A2 B% `$ }* x
8 m2 D8 Y. X& c7 u7 ? public Activity activateIn(Swarm context) {. g: q+ s; o: c& j) E. j
super.activateIn(context);$ j. u8 Q9 B* C% y: u. n
schedule.activateIn(this);
; F; V8 d7 e* ?: ^. t return getActivity();4 Q- E0 N! y6 _; M+ Q7 C- p1 l1 O: {
}: _0 n) B" I* A# B5 h
/ F1 O# f( R1 F$ w0 O' f
public static void main(String[] args) {( J9 Q5 i7 y% M) U- @$ ^$ c3 y! e- |
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);6 b2 M! N3 B# g
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);6 X5 B# G) m5 c4 R; P7 I
swarms.buildObjects();! G3 Z. v3 {: x5 F+ s+ Z
swarms.buildActions();) M( g3 f" g/ C! e- A6 Q) j
swarms.activateIn(null).run();& k, V7 z* Z2 Q8 u- h
}
% I; ^2 t. r: H2 m( [% u3 y z+ G' T; x: U( y2 T; G E
} |
|