|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 ) n7 L4 R) u$ o9 ]( |
( S! z, R- k- x2 p( G7 V1 W- C
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
$ i4 p& C( g: `( C) @ s8 s% E/ J以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.. w- g7 i c6 G8 s
swarm.SignatureNotFoundException
9 u* V+ ]. L6 ~1 E; r2 h at swarm.Selector.<init>(Selector.java:76)! a" m& P. C) g
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
% E3 B# ^( F" [( @ at ActionGroupDemo.main(ActionGroupDemo.java:67)$ T6 ~# u! n, |( J
8 Z5 R- m/ C( \: Q5 X; f
, x& |1 X. j8 s* eimport swarm.objectbase.SwarmImpl;6 a1 x) [( R% q" _
import swarm.objectbase.Swarm;
, I. k- x$ B# ^import swarm.activity.ScheduleImpl;
# m0 z' h o3 S% c1 l9 p$ y* h; R6 x- {9 Jimport swarm.activity.Activity;: X/ i* q: {" ~& n$ Y' X
import swarm.activity.ActionGroupImpl;, H) L6 i% \* U2 B2 Y0 {" m
import swarm.collections.ListImpl;
* W! t' ^- d- timport swarm.defobj.Zone;
+ e) q- W/ n/ p" ?import swarm.Globals;$ J/ L* ?9 x" u( A5 v
import swarm.Selector;1 m+ G2 \/ `! g Y8 ?: w
import swarm.activity.ActionGroup;
; g1 w M) K y3 wclass Agent {$ d. m+ q% B$ m9 F0 j8 L, Y9 F
char id;. {. x: b! j- k( K* T% Q
$ S. E* `6 X% s* g Agent(char id) {, ^9 H: @; f( Q2 n2 L) W3 ~
this.id = id;
$ g- X- D- u3 Q; Q" Y }0 F% ~& j; {6 E8 x! j
& ]+ @. t& B. y
public void agentStep() {1 N2 ~/ M, o; w ?; g
System.out.println(id + ":" + Globals.env.getCurrentTime());( I9 ~- N; M- J Y1 b! f
}
' u/ |2 {1 l* N' T9 W' O$ n% J}1 L: I1 D% x3 X: e
% y- b, Z, m9 e1 w( {
public class ActionGroupDemo extends SwarmImpl {5 B% d2 w8 z( `3 A
ScheduleImpl schedule;
' H7 S f+ r5 ^ ActionGroupImpl actionGroup;6 Y4 \4 i9 e# N
ListImpl list;7 F8 [4 b) h2 r1 |( Q3 ~+ F
char Id = 'a';
# d5 @8 I) T p1 q
% [4 |6 t6 c9 U) k1 E* \9 S ActionGroupDemo(Zone aZone) {0 _9 y7 j" {- W# U" b0 {& g
super(aZone);
. d, j% D& g* g6 M list = new ListImpl(aZone);
' H( M, N1 {5 `+ A/ J x0 W' f swarmSetp();+ i+ R% Y: q/ T5 c( K, ^
actionGroup = new ActionGroupImpl(aZone);
7 a9 t. e" m5 Q" t$ Q schedule = new ScheduleImpl(aZone);
2 O1 T6 Q- t1 s c( x5 O try {, h; A5 X2 M4 I$ Z2 e
Selector agentSel = new Selector(Agent.class, "agentStep", false);
" g; v. b) g' a Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行$ t }' d. i1 L5 E. b( m
8 X( O7 m4 s1 H4 M! {# @" i actionGroup.createActionForEach$message(list, agentSel);4 f& g& }, e/ G* O: a. U! N
actionGroup.createActionTo$message(this, swarmSel);0 d8 Q {- K7 Q
schedule.at$createAction(0, actionGroup);$ {2 ]8 M6 t! a
schedule.at$createAction(1, actionGroup);* o# Y% @+ [5 F$ o1 \
schedule.at$createAction(2, actionGroup);6 T$ y+ L% X5 }* B# @
0 [' ~& E4 r5 L* p+ k) a& d2 c
} catch (Exception e) {
1 k% o: L* { F5 F, p" G e.printStackTrace(System.err);6 U2 S# s/ {; n" A& l! Z; g, B# l
//System.out.println(e);. H, ^2 J0 s& y
System.exit(1);
/ D/ S+ t; k! j: |# D- |& Y$ F }. E/ q8 P5 `4 k2 }
" u g; W' ^5 A! i8 f8 _1 h% `- |3 _* C6 H" F4 ]5 z- ~
}. i& S3 }& o( ]) t* g! x) o+ m( B
D* x/ \6 B5 p& @7 y0 ]
private void swarmSetp() {
# C9 O9 c8 q4 Q; T; g8 u: [ list.addLast(new Agent(Id));" D/ C/ l8 I' Y% ~; c4 Q
Id++;3 `1 a8 n' u$ f* t# }' g+ x2 F
}7 Z1 V7 {. n7 S# a. h
6 d2 F. }7 G% {$ V" T public Activity activateIn(Swarm context) {
9 F/ _9 t2 V9 q. y7 h7 f super.activateIn(context);
# o# \/ e% D/ N: `# W# ~5 b8 t schedule.activateIn(this);( n8 y( f8 F& U7 c9 W% k$ ]
return getActivity();9 d3 N2 Y7 U+ W* `8 M
}
5 b) e7 a- Z2 p7 l" M+ Q% o1 l9 U* g8 a2 A3 [+ n. e7 U
public static void main(String[] args) {
6 G8 P* q8 J: ^# Y$ S/ M' O; z Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);9 J; G5 F$ G, {% h- E' r
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);- S$ s* J1 Q6 Q' z
swarms.buildObjects();! g# u$ h% ?* B/ ^1 o( r
swarms.buildActions();; Z5 k0 B) d$ k, V8 }, J
swarms.activateIn(null).run();
" T9 F3 ~3 b' ~5 u }) m3 j- ]; \, ^6 C
+ }2 j$ s# @7 Y$ g8 @- O& W! [
} |
|