|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 , L4 ^, [- v6 a
+ c- h, y2 |9 t6 ]) e
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21+ q- e& k! ^0 ~# R- M
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.- A v) j- G+ t5 i0 E0 S0 s$ o" p
swarm.SignatureNotFoundException, `& O5 g1 D, D( N% C' A
at swarm.Selector.<init>(Selector.java:76)
9 Y& W! P. w* Y0 f9 u! K at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
% e$ w5 D0 K( w) N; P) @ at ActionGroupDemo.main(ActionGroupDemo.java:67)
2 {6 o7 H/ e* E. t0 Z; T' F, G) M$ Y+ g* U( X
8 i* K. ~% p/ e
import swarm.objectbase.SwarmImpl;: D; f6 b; G& p: c
import swarm.objectbase.Swarm;
! k! W0 J6 a* ^5 himport swarm.activity.ScheduleImpl;6 ?# T, r+ E8 R0 U: ^+ s3 G" g) c
import swarm.activity.Activity;$ ]$ D O+ ~+ Y
import swarm.activity.ActionGroupImpl;
. C0 V0 I Q' r, e; j% Himport swarm.collections.ListImpl;) P' @3 y- h% \% Z+ W; p- n4 Y
import swarm.defobj.Zone; 6 _* g1 L& f" M7 y0 _6 Z$ C" t
import swarm.Globals;7 V" t$ f- o" @* f
import swarm.Selector;
W; S* I% s# X( @ l" t% eimport swarm.activity.ActionGroup;
+ u1 D- f' z( f6 ], d6 k! C2 Oclass Agent {$ R, D# Q9 S5 \9 ?3 d8 h
char id;. Y& ^; ~6 o0 H
# @ J: P7 Y- H: ?. G Agent(char id) {
' k$ a) T" d7 I+ [4 g8 V8 c0 N this.id = id;
/ x( U! U% y5 y }8 G7 `- P$ X1 f$ J. n5 n
; J( Y: M1 H4 G1 `! q U7 }
public void agentStep() {5 H. U' j; S, h, v8 Z9 i! C2 l1 \ C
System.out.println(id + ":" + Globals.env.getCurrentTime());
1 h# G. |0 N( i2 y; B% k6 t) u }5 g" {9 x7 e+ z. @# F
}- _1 x' d r; L; d! |
; U/ R/ e4 @3 epublic class ActionGroupDemo extends SwarmImpl {
3 `9 t( U7 _. R# g7 f ScheduleImpl schedule;
3 E' a+ S+ k! m$ I$ @# } ActionGroupImpl actionGroup;
* L7 n3 i1 ^ q0 k ListImpl list;
: P$ |+ H/ k8 I2 D char Id = 'a';. y: _# D5 X( S# C
4 l7 t5 L6 ~- B2 {7 f% ~' u
ActionGroupDemo(Zone aZone) {
' H! m/ j7 I" X2 ?. \: S super(aZone);
+ `7 m& z0 f0 o. j' m. i list = new ListImpl(aZone);
$ |2 g+ P% [( k2 X5 y swarmSetp();/ g# h2 R; Q1 o: O
actionGroup = new ActionGroupImpl(aZone);0 o8 k5 p9 V. C
schedule = new ScheduleImpl(aZone);
6 S' n1 r% q& o8 J% H try {; |) o4 ~: l3 a$ o
Selector agentSel = new Selector(Agent.class, "agentStep", false);, s7 q6 L$ q- f. v0 }% o( B a) \; |$ N
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行- u* k( d+ B! e- G$ q) X# B d
5 q8 H d, Z& I
actionGroup.createActionForEach$message(list, agentSel);0 d/ E* p3 O4 Q" W8 Z- S) H4 ]" e
actionGroup.createActionTo$message(this, swarmSel);8 T) N8 ]- x9 Z, ]# \; x8 U
schedule.at$createAction(0, actionGroup);& r" i" u5 d6 e6 K
schedule.at$createAction(1, actionGroup);
: {' K5 T1 q% ^) m E) I schedule.at$createAction(2, actionGroup);. n% x0 m2 K5 U
; l/ q" C3 c% m) G' k } catch (Exception e) {: K7 z' l5 y% z: s( J- ?$ b6 `& V
e.printStackTrace(System.err);. }6 F, I6 y+ \+ k
//System.out.println(e);
" C9 g& O: L+ P9 r System.exit(1);5 d8 @7 K2 t* X3 p! u% @% F
}* D! p$ \) S& D |9 o2 y
- Q! v* @' C2 P! Y
1 X) r) i/ H }3 Y7 _% ?* C }' j b# u* W! r& T3 G
$ I" n. I1 J, B4 [" T. G
private void swarmSetp() {
6 i/ a% D3 J0 w/ e7 o( \/ H list.addLast(new Agent(Id));
2 C. Z% {6 ^, q) a/ H Id++;
P+ H% Q8 b3 {* U7 M }
, R( @: S# g4 q& s4 y2 S/ B( G2 x1 M/ Y0 f, s, v* d |) D4 S9 ~
public Activity activateIn(Swarm context) {
& g# y: \/ ]9 Z2 N1 U/ q( K super.activateIn(context);8 m4 [9 G! O# O6 P' M) x* O& v
schedule.activateIn(this);
. `4 P f2 m* Y& |1 c4 Z, X! n return getActivity();
: G! |& i+ O- S& u5 g; A }- j5 @2 ]: h7 \$ |) |7 j
1 y# s; _- @% ^0 a9 X4 \5 f) j Z4 n
public static void main(String[] args) {
& o* m9 c4 ]+ [' L8 f Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);2 Q# c; @/ b' D; V6 l
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);% V( g' }) X' c6 x' a
swarms.buildObjects();8 [9 v+ P) w' y. |3 P+ @" n' g3 y
swarms.buildActions();/ f* @8 B3 _; }# F( ]1 g2 j
swarms.activateIn(null).run();
/ R( H6 D5 N8 p% }# m }( `5 U) H" D3 Q" ~. V) W
8 }# F: R4 B9 r" {0 C" d
} |
|