|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
; V7 d4 L3 A6 S1 k! l0 _( F
$ M6 {8 p& V+ a) w% b# v本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
3 S& ?+ t2 j @+ `* J' P1 ~以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.. O" c: P- @7 K7 y
swarm.SignatureNotFoundException
+ e% G+ m0 q1 _7 e! M$ u- z5 j at swarm.Selector.<init>(Selector.java:76)
! o1 q/ ?) G6 P- R- j Z at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
6 o! `2 M# F* r8 a5 N" J; i at ActionGroupDemo.main(ActionGroupDemo.java:67)2 r3 v& i8 Z% D5 V
2 M" u6 \ o0 h, a" e( i' l
+ f8 M; ]. ^9 y& J% I0 Q& timport swarm.objectbase.SwarmImpl;
6 f" M h# U7 {0 \4 ?0 Mimport swarm.objectbase.Swarm;
! T* a, |7 I$ u5 M$ Bimport swarm.activity.ScheduleImpl;5 }/ U" I! H$ }- i& R: X
import swarm.activity.Activity;
! x# p" M0 H: h1 fimport swarm.activity.ActionGroupImpl;
+ @* `/ ?+ M) A: kimport swarm.collections.ListImpl;
& O+ X! |4 [2 m! q8 t0 i6 zimport swarm.defobj.Zone; % I+ G1 O! t+ C: O3 g) f! o
import swarm.Globals;
9 S0 Y% C7 s) @# i5 V T wimport swarm.Selector;
$ Q K& @$ y3 _9 Y% e. f& y8 \import swarm.activity.ActionGroup;
2 F' f1 q2 B& H8 M8 Jclass Agent {
- X' C8 z4 {) S" X char id;+ F2 H/ v; w- ~: e/ U. H9 t$ s
6 O( z. I) R0 E! y4 ~
Agent(char id) {
& E5 b* H$ b1 y# y% ` I5 N this.id = id;
W2 O0 ^8 x1 u' C, d }
! p; x( j2 ]+ ]" d" f5 ]
) H3 B* C: n1 m& r public void agentStep() {
5 @0 _6 Z# f/ B1 W) ~- B System.out.println(id + ":" + Globals.env.getCurrentTime());
" M( e- z# V+ V( }* T }
' D/ ]: y# B H1 |# c}* X5 G& y9 `' c
9 e4 P s) o4 [% R3 }1 |public class ActionGroupDemo extends SwarmImpl {6 C- I4 T. @2 L5 Z* f
ScheduleImpl schedule;* A& f2 E. g: d1 g w( ^
ActionGroupImpl actionGroup;- P' k! r9 V, ?6 ~9 W
ListImpl list;
- H5 A5 D, q+ l. t& o; ^$ A# _' l9 e char Id = 'a';
" P3 [" C8 i" G: N& _; x7 O' P
( F5 i" p, i& n+ b# O ActionGroupDemo(Zone aZone) {2 s2 a5 D U7 S- c4 N V2 X
super(aZone);
3 O" j8 l' p5 L* p$ G) @* M" {: x list = new ListImpl(aZone);9 u2 y- }$ K2 }8 \# }4 I
swarmSetp();
7 Q2 j8 S6 r" I# b- ^4 A5 a% k0 P actionGroup = new ActionGroupImpl(aZone);6 g( o: r2 C! q- q2 q7 C
schedule = new ScheduleImpl(aZone);& i; {% r) C/ q, g8 Q) g# h8 ~# R; I
try {
9 {2 Z& S% Y3 X Selector agentSel = new Selector(Agent.class, "agentStep", false);
M5 F$ ?1 C) o2 H# @0 I Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
$ u; e- y' e t. ?: e
V- @( z2 d" k, W, H8 U# a actionGroup.createActionForEach$message(list, agentSel);
" o$ u6 g: `! ?+ R# k/ N actionGroup.createActionTo$message(this, swarmSel);
/ g: `0 U3 `$ a5 G7 I$ `. d schedule.at$createAction(0, actionGroup);/ }! t" t0 F( T3 `% i6 R
schedule.at$createAction(1, actionGroup);% g9 r! a* h4 v; }4 E. _6 `# ~- D
schedule.at$createAction(2, actionGroup);: x) g6 b8 j v! s& C9 f9 F; V" W9 J
3 B3 b. f" k$ |- p, J9 k& J Z } catch (Exception e) {
0 ]$ X6 S( m% w e.printStackTrace(System.err);
! J/ u. {5 W% ?" Z) z2 g6 v( n, L: { //System.out.println(e);& a) i6 k" G/ Z8 w" q
System.exit(1);
7 l! I3 S1 u E' x }
( V7 v- X" o1 x5 t1 a- z+ I( n3 t0 G
3 P6 v; @6 i- o6 C, W q, V }2 A* [! } J& Z* f+ r1 y
7 C1 m% e6 S6 a! }* `3 s" x& j8 L private void swarmSetp() {0 ] q5 p# ]( ]8 h P
list.addLast(new Agent(Id));
* Y" i3 \* T3 S* ]+ l1 g Id++;5 O5 U) a* Q# M7 t+ U, Y2 ?4 Z* I) ?$ h
}
5 G q! W, r p: U6 e' ?4 c* o, w
public Activity activateIn(Swarm context) {' ~' c, f3 W7 L: G3 g8 S
super.activateIn(context);
3 B8 f3 Y* z& }) f. u schedule.activateIn(this);. E& |0 K4 m2 n
return getActivity();
/ e- ^/ [, _2 [. D6 ]. C }6 y( s5 H+ D: L8 g
3 A" H0 U8 A) m5 `. k# L Y- P3 \" [' }
public static void main(String[] args) {
" n0 b- I" x6 d Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
6 J& @ L: H8 k Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);2 I( E5 Y C+ @0 ~( p
swarms.buildObjects();
% h) x3 E- Q, w$ O3 y, s swarms.buildActions();
O D/ R8 [- n/ t, O7 G swarms.activateIn(null).run();. M) e2 B" w$ `
}" u" K& ?7 ^! F
" _! j: y, O" j B* k G
} |
|