|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
+ h" @7 j/ J) Y5 e8 c
7 a, @' a. a3 e本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update214 E; C9 \- F( l7 D( T- T8 e
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
, x! P$ L' S" L$ U$ ^! Q) x% ?3 d0 iswarm.SignatureNotFoundException
7 o: ?% A1 n& `: \9 p) P at swarm.Selector.<init>(Selector.java:76)5 O$ m' C+ S) R" E3 B' w- T. {
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)* z8 ], `- O( i' ]
at ActionGroupDemo.main(ActionGroupDemo.java:67), C; G4 P* ^' N- Y( f, j
4 P: w5 |# l' C: |% \: {, n F5 Q4 O. T8 E* C9 j% j1 k& D3 Q% ^
import swarm.objectbase.SwarmImpl;1 H* v* [ W9 P; W: P; ~; ]: H8 ?
import swarm.objectbase.Swarm;" D: x& r5 u- z# ?% n
import swarm.activity.ScheduleImpl;
5 e" b R$ d3 iimport swarm.activity.Activity;: u5 ?2 O- c$ Y1 w n" {
import swarm.activity.ActionGroupImpl;
& {6 A- Z' c$ P# Zimport swarm.collections.ListImpl;* I' z# Y' ?7 Y w3 H
import swarm.defobj.Zone;
4 Q/ W9 K! h9 [" J9 k9 K* Y4 F1 timport swarm.Globals;
7 R; Z1 q& {- [! {+ i8 V! k) G, Ximport swarm.Selector;
: F3 G1 |7 L$ @import swarm.activity.ActionGroup;
- X3 u( f1 b% p, \$ xclass Agent {) ]4 e9 e. i% x' d/ a H4 @& n$ y
char id;
& v, {: P- j; T0 p u; O
" s+ H0 P9 f: Q7 I# }& Y$ n Agent(char id) {0 K1 O5 S! o+ }- C9 ]
this.id = id;% B8 @* X6 I$ j" t
}
- _5 O" l. B3 V" t* g( P' w+ B* a% H d% W
public void agentStep() {) s, b. e3 k5 y% Y, q
System.out.println(id + ":" + Globals.env.getCurrentTime());3 \( e5 Z+ N+ _2 s8 \# U
}+ B, g* y; F; N7 f& k9 r
}
5 c3 |$ g. l! g5 [2 H: s8 A8 b7 C8 y4 B1 N7 B# R
public class ActionGroupDemo extends SwarmImpl {
( m; @4 T+ l# T& n6 V. k ScheduleImpl schedule;
+ ^/ W0 u: K# B4 a# d" ^' X4 L7 X% g6 H ActionGroupImpl actionGroup;3 o+ g& i9 R! n! P
ListImpl list;
% X% f4 J. ]( @$ o char Id = 'a';# V( i8 s0 h! {6 B2 C0 C
8 w' m! p' h0 a ActionGroupDemo(Zone aZone) {6 t% |( Z3 d* q: C( t7 }# t; @2 `
super(aZone);
; b" U% |5 |$ e; B list = new ListImpl(aZone);/ b& N' n6 E7 H V7 J: P9 y
swarmSetp();
. o+ Q U7 ?2 T4 H actionGroup = new ActionGroupImpl(aZone);
/ s$ M$ V# j( v0 V# a5 Y: T schedule = new ScheduleImpl(aZone);3 f* n1 ~5 f5 q7 c
try {# P( e" C: {* G8 N! Y$ r9 I
Selector agentSel = new Selector(Agent.class, "agentStep", false);' d5 p5 T2 ~3 d4 ]6 t1 |
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
$ n5 s# _' v: U" y 7 ?$ |/ a5 i I/ f
actionGroup.createActionForEach$message(list, agentSel);. |' ~3 q+ _1 C9 O4 R
actionGroup.createActionTo$message(this, swarmSel);. H, Y. ]5 A- w: T
schedule.at$createAction(0, actionGroup);0 h2 s9 C5 V. K, ~8 T' B: H
schedule.at$createAction(1, actionGroup);3 E, `" b, P9 M% F9 ?: ?
schedule.at$createAction(2, actionGroup);; T9 i7 z3 @7 O3 O! W& {- s
0 w g0 x5 ~& l$ v9 o
} catch (Exception e) {
. E2 `% X1 K* Q; {, R; \ e.printStackTrace(System.err);) t6 J: d" a5 G
//System.out.println(e);
0 y# i1 e! x# C System.exit(1); ~6 w' L9 w% S) q4 I3 _% ]
}
+ [8 _2 d1 l7 h6 _4 W- ]9 ^& l9 i8 t5 J3 H9 i) x/ k5 z" W. K
5 F: K) W9 J' c) P# L } m! S. M7 G" {
0 ?! J x& O. z" H; G2 Y0 v( @ private void swarmSetp() {# v$ `3 i& K6 }3 e9 X
list.addLast(new Agent(Id));
3 o/ J3 ~) q( w Id++;" J" ^0 \: j4 G* y4 X) _
}- y( F' T/ [% t/ O$ I
+ }2 y' l, w4 A9 x; |2 k7 g& y public Activity activateIn(Swarm context) {+ o! C8 |% T$ w& l$ `
super.activateIn(context);, s0 d, f5 B6 V" l4 }
schedule.activateIn(this);
6 D* L* z. }. X return getActivity();* O! d8 l7 N! \" ~) [& P
}
( Y$ _8 {: m/ U; f# p+ V0 u: y& `, [! g& b ^0 S
public static void main(String[] args) {1 Z; P E2 x8 S7 f2 ^- `8 X9 Q
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);% {7 d* V' P6 I
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);/ `) c3 Q2 m9 ^5 F1 t$ v! Z% b* o! x
swarms.buildObjects();0 {; T/ D* v5 b) O/ Y
swarms.buildActions();
* ?# J7 u, [5 `3 z swarms.activateIn(null).run();
' r3 y* M h) x- {3 L }* {% s" h1 I% n3 @. I+ g
. g$ l* [9 K2 } i5 T, f
} |
|