|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
& h; I# _8 P& {) k# ~5 Q. ~! F2 V% }* q% I
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21; \. {. R1 Z/ v! N# Y- G
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
$ \, a8 F7 ^6 S, l& o9 kswarm.SignatureNotFoundException
9 q0 U8 h! a4 C" U1 [4 a, t& o at swarm.Selector.<init>(Selector.java:76), |$ u) _8 N1 p3 @' g' s$ \
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
, C% G! X7 E2 |4 A, M& y+ | at ActionGroupDemo.main(ActionGroupDemo.java:67)
7 \1 V/ L m6 P5 d$ p, o5 f$ i# W9 p4 D! O& Z/ A. V
) K1 d! K/ f8 _1 r& eimport swarm.objectbase.SwarmImpl;
( H$ ^) y* d. ?/ `import swarm.objectbase.Swarm;& Z2 t& D& U$ z# H, W @+ `
import swarm.activity.ScheduleImpl;
: |- d% \, E r, L+ B5 F9 oimport swarm.activity.Activity;2 ^( B& }( e8 ?
import swarm.activity.ActionGroupImpl;8 \7 l3 p( \/ W
import swarm.collections.ListImpl;
* C! p# R9 j7 ]$ p0 f) |import swarm.defobj.Zone; 7 D c. e/ ?3 f9 \, \* N+ m
import swarm.Globals;1 }7 Y) y. q4 R
import swarm.Selector;& C6 Z8 |; z, V! n5 R; y
import swarm.activity.ActionGroup;
' D) w' T; o0 Z( I1 Y. sclass Agent {; P4 J7 b: j# J" h
char id;1 L* z- Q( B# Z' i k$ Q
K* B/ ?9 `! y1 { Agent(char id) {$ Z# O- g1 @% s
this.id = id;
9 U) u. B2 H: D; N+ }, K C `, Q }
) x" t, u4 x1 ^! K, M2 \ w7 x2 e( ~; x# d8 D/ p( I! G4 M
public void agentStep() {
4 n! u- E( w* L: D: y System.out.println(id + ":" + Globals.env.getCurrentTime());
) n6 ]3 W/ H! {; ? }
$ \4 f' \: Y# i# j+ p}
1 {6 X f% @: t, m# R
# E2 d {& Z) d3 ]public class ActionGroupDemo extends SwarmImpl {, O, D/ _+ m- w, S6 \& }, s. l
ScheduleImpl schedule;/ I6 D* w8 H5 x0 r2 \2 _; ~
ActionGroupImpl actionGroup;7 A5 Q9 V- }: ]1 E. Y+ J8 k
ListImpl list;
0 ^4 b1 @4 N$ b! g( k, P char Id = 'a';
0 K7 F. f0 a& e x3 b0 a% p. g- a
" g2 |! C9 y/ s5 { ActionGroupDemo(Zone aZone) {1 c1 C! r3 k+ W& Z" H! [4 g
super(aZone);
: ~1 @8 X6 g$ K5 E# Q1 F( j- R list = new ListImpl(aZone);" j }1 U4 T4 l. j
swarmSetp();# U( k9 U: r( H( R! H7 P& J
actionGroup = new ActionGroupImpl(aZone);
5 u( }$ C( k n" n4 i, K! e8 T' s A schedule = new ScheduleImpl(aZone);
( ~# O) p4 }/ V& J try {# z( R5 W J8 e3 J+ M
Selector agentSel = new Selector(Agent.class, "agentStep", false);
2 j- F# m# I; K$ U Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
# u) @- u) _) d+ I( C' q, [
2 R6 Z. }5 S- u* ~. t2 f& r actionGroup.createActionForEach$message(list, agentSel);8 }3 e- S9 U# w4 m
actionGroup.createActionTo$message(this, swarmSel);
3 C& }3 t g" }5 d6 B i7 g" N8 w schedule.at$createAction(0, actionGroup);
8 s& p8 @( G( w' s. z schedule.at$createAction(1, actionGroup);
) d3 S0 n7 V4 k# C. ~/ P% s schedule.at$createAction(2, actionGroup);
. N ?! l. ^2 G" {0 ?
5 p/ e5 |6 b4 J4 v6 s } catch (Exception e) {
/ b& M; S& t% c' ^" @ e.printStackTrace(System.err);1 P& c& S+ l9 [+ |8 Z1 ]! v
//System.out.println(e);) f! s- u# J. z$ d6 ]- O( m( E" ^
System.exit(1);
l/ |4 B5 i" _& Y Y* w }
6 z; Z" g1 x4 w# J% ^# [7 _3 g# `2 ^* x2 O- T7 L+ ]4 Y
+ {$ I! G4 m q: ]5 |; S
}3 {0 m, ^- l- a* j2 C4 j
; H O6 Q4 {$ j" i. } private void swarmSetp() {
* V4 x& e4 u: f# y- g" n' o list.addLast(new Agent(Id));$ y! [; a3 I* E: V
Id++;
# {1 y; B, ~" U }& R4 `* C" l4 j) r; y4 G6 y- H$ J @
7 r8 l" Z; a' r V! F
public Activity activateIn(Swarm context) {9 }; z+ H& b) q- {- c, k
super.activateIn(context);
3 X+ f* y( \8 P; ^5 S0 y schedule.activateIn(this);
& w& {# t5 h! T0 P/ I* y return getActivity();0 f* c/ c2 c* ^; w
}+ l: o) w: D& K3 A
% n+ T6 P6 J/ X6 S) ] public static void main(String[] args) {6 p$ i/ l0 S0 p* X+ F8 `; x$ a1 \
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);( @. l: B/ h, S2 \; w
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
* U4 l1 [" d% p! \ swarms.buildObjects();
' U" b+ H2 W3 c8 ?5 _: ? i5 m0 c swarms.buildActions();% e/ J: g" G6 y+ z/ W6 ?
swarms.activateIn(null).run();
' L& F# A3 m+ w( d/ a }
. V3 w$ Q: i) n. r& _
/ f P& D5 n2 c7 P0 P- Z} |
|