|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
/ S$ u$ X" ~0 T; j) G8 i
; o7 U1 {0 y: s- Y! n. t8 a( z4 P& N本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21% Z; H" _; Y7 n9 Y. h5 V- e) M' S3 I# b% s
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
; M* D; \9 a9 u) D8 }/ zswarm.SignatureNotFoundException. ?5 {( b7 J- w$ O1 J/ J
at swarm.Selector.<init>(Selector.java:76)- h/ r! f: N* G. W
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
h/ P+ K) V. F5 I- ^) t3 | at ActionGroupDemo.main(ActionGroupDemo.java:67)8 l1 `# r9 p' M3 ~9 c( I; `/ g
' j/ ^* Y* c0 m6 `# Z
/ [/ X2 L6 h, L+ S; w3 [" i% } P
import swarm.objectbase.SwarmImpl;# ?- F! e( _3 y" E. X0 {
import swarm.objectbase.Swarm;
- \" V U K$ f0 Vimport swarm.activity.ScheduleImpl;3 O! a0 s$ J5 D6 K" ] t( Y
import swarm.activity.Activity;
3 G. T9 o3 n7 s& [" C% m$ L1 timport swarm.activity.ActionGroupImpl;
" ^7 {1 P# |) J. Bimport swarm.collections.ListImpl;4 M2 T* \7 {- w1 S
import swarm.defobj.Zone;
9 \6 B4 |$ G( X: a; d- x( F7 wimport swarm.Globals;6 p$ n) n5 y6 K6 _- ]3 v: g
import swarm.Selector;4 p6 h, }4 f ^
import swarm.activity.ActionGroup; # }; G& s0 M- ~+ x' N2 @
class Agent {8 O( G. ~/ U0 f" H3 o+ l
char id;6 V* Y. k3 E+ e
( j- ], J* ? w5 }# x+ t/ Z( s/ P
Agent(char id) {
) z. P F5 z- a. D3 |# s$ X this.id = id;
8 d0 }5 K& M) e }
9 V7 U/ W3 G5 C' U% c; N, Z& _! W+ M) b U. }
public void agentStep() {
: w. H+ ~5 B3 f9 j4 p& K System.out.println(id + ":" + Globals.env.getCurrentTime());
% W$ ]- m" o! [. x3 z+ z. @: I* ? }+ \5 Y' a2 K l( m2 p# j9 I: ]6 o0 J* _
}+ \8 V B" Z/ y6 ?1 N7 |; m
& ?7 K# g$ r" ^4 O: o& x6 b% B- Zpublic class ActionGroupDemo extends SwarmImpl {
9 w1 d3 [/ p3 `; s; h; F2 w8 A! U( r ScheduleImpl schedule;
/ G3 H0 h }5 R7 g; ~ }* p ActionGroupImpl actionGroup;
+ O: c7 W1 |$ f" |5 T ListImpl list;
4 t* K9 a+ C) N5 N ?( ` char Id = 'a';
9 }1 u. z1 z* S3 ?) ^4 `+ j( m* E7 @; @5 k8 ^2 N
ActionGroupDemo(Zone aZone) {) v- M" F9 Q* _4 ~
super(aZone);
" {' l* P4 H- V& Z5 u5 J3 x list = new ListImpl(aZone);
4 K8 |! L; }* y. K- O swarmSetp();& t; b- Q) p& J [! \5 o+ B+ g
actionGroup = new ActionGroupImpl(aZone);
- _( ~* s& T9 H9 h schedule = new ScheduleImpl(aZone);! G2 i$ K+ a. C4 f
try {. F j# n) Z# A# D' [
Selector agentSel = new Selector(Agent.class, "agentStep", false);
% D; C n4 d y h3 V Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
8 A: R1 }5 r% l" J $ Z; ^- A) P7 U+ Y0 d
actionGroup.createActionForEach$message(list, agentSel);
$ F$ i S% m% j& z2 x( } actionGroup.createActionTo$message(this, swarmSel);
, G+ V4 s: V: Z- D7 K schedule.at$createAction(0, actionGroup);% O; m! ?8 |( h' M* n- N
schedule.at$createAction(1, actionGroup);
; u. Q* Y4 [9 w# S schedule.at$createAction(2, actionGroup);
) g7 C2 L" u. D5 s! v/ K) B
" d. U4 m, S8 S# G5 T. U } catch (Exception e) {
# I, q" D0 f& H9 ?; ?, n e.printStackTrace(System.err);
; j. }4 d& T/ d- L* w8 C //System.out.println(e);
: I. j; D$ y# e9 B5 a System.exit(1);
. C" `# b }* a; q" I: G }; f2 j7 b9 K- ]2 U
! f/ `# K9 f& h: r- r( h
; M' G3 u" ^ ]2 d5 ~
}. R' ?% l0 g9 }7 n9 n' Z; W: A6 V
6 T/ ?; ]4 A( M) y2 E
private void swarmSetp() {
1 h9 n- `% P! ?% u list.addLast(new Agent(Id));8 F: c6 M! d0 }
Id++;
$ H7 M& R5 c @/ W! p- f" e5 M }) A- q2 G9 h0 |
# U1 r. i) b" Z$ M2 v public Activity activateIn(Swarm context) {- w7 p" n! @% t$ c9 H ^5 a
super.activateIn(context);+ y3 o$ n5 G. Y' h. ]
schedule.activateIn(this);
/ }, [+ E& n, @! H! j return getActivity();
?# N$ P9 h( ^2 f }3 l+ Y& }/ A; P" e2 e* Z# o: ~/ W
1 M9 W" Y& R0 |$ S3 ^" x
public static void main(String[] args) {
2 w) O: k5 [# h7 } Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);7 n4 ?3 T- F4 h# f2 G
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);; ?3 ]+ s1 ^. {* l
swarms.buildObjects();
% G* ~7 Z2 b# {' I8 O$ { swarms.buildActions();7 A# a# z' W T- j* Q% w& F
swarms.activateIn(null).run();
/ d2 v( \5 }( L9 s( p }* d& m" M0 _2 u7 O
/ A3 Q- o; i6 x" B+ O} |
|