|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
/ ^, V) U" ?) L, ?4 }) f+ h3 l ~* `
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
$ V5 i! w* r" X. G& X8 n以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
4 ?, M* h. i }* s1 aswarm.SignatureNotFoundException
, f9 |/ r O9 W: c at swarm.Selector.<init>(Selector.java:76)
, ~, I" _9 s* J$ |) @/ C at ActionGroupDemo.<init>(ActionGroupDemo.java:37)9 t7 C6 I0 a* H! F9 o" G- j
at ActionGroupDemo.main(ActionGroupDemo.java:67)
! a5 D J- u; E$ }; z1 \
! e. F' Y" @. I
' A3 V3 p2 H( B6 p5 ximport swarm.objectbase.SwarmImpl;
) |5 ^; T! U# r5 Rimport swarm.objectbase.Swarm;/ \4 G% s* n1 M6 {8 C
import swarm.activity.ScheduleImpl;- z# [+ t3 o* I) Z, Q- _
import swarm.activity.Activity;
3 R- Q, y d1 E% O4 N1 [ K) Fimport swarm.activity.ActionGroupImpl;
" M) D! w6 ]) P T1 Q5 E) Aimport swarm.collections.ListImpl;
' }# Z& P+ Q7 P l# r: G! ximport swarm.defobj.Zone; 2 @! Z) H' i( ]8 Y& l
import swarm.Globals;+ Z% n7 B2 a5 k/ g4 O; C; v8 V
import swarm.Selector;+ Y: ~5 ]7 n- C/ A: F% ~8 Y
import swarm.activity.ActionGroup;
3 t. K6 n6 A# ?) bclass Agent {
& G' S& T6 V( M$ d char id;9 ~8 Y" | l" X. b1 F# ]6 B
4 K3 s7 P* l! h$ `- j
Agent(char id) {
& |) k3 }7 D: u5 a) t this.id = id;
# E( F7 W7 t) M' s }
9 w( h: ~/ U. A8 P9 X% u1 a% P) U8 M& H- T; G
public void agentStep() {# D: O" [4 Q7 M/ f [/ \
System.out.println(id + ":" + Globals.env.getCurrentTime());
/ i; f A; w8 }. l: P/ C }: x: c( A% P2 u( @4 E, I1 t
}
: r I2 {7 v* X2 G, V$ Y2 R5 Z' R: f' s# M
public class ActionGroupDemo extends SwarmImpl {9 s1 F3 u; A$ T" r8 y8 M
ScheduleImpl schedule;
# C) p- @+ ~# x% S1 O/ D ActionGroupImpl actionGroup;' F# C( [/ }2 Y
ListImpl list;
, Q# s$ U) H+ j( a, }' H char Id = 'a';
, |; q/ y, U6 ?2 S# T
& X; o3 e% |5 [- C; R. i ActionGroupDemo(Zone aZone) {1 ?/ J; x" @ y* X2 ~7 ^
super(aZone);( `/ ^, _& o, \* {- n7 i
list = new ListImpl(aZone);( x7 s& n* g. n
swarmSetp();
4 E) b o" b) j actionGroup = new ActionGroupImpl(aZone);1 r- E; ~- m, A/ T2 B$ }: G
schedule = new ScheduleImpl(aZone);) ~ w: @" a/ n" o) L" \
try {6 n( g9 q, S4 I. e/ _1 \+ J9 n
Selector agentSel = new Selector(Agent.class, "agentStep", false);4 X% a5 [2 F+ Y9 O9 m
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
! A) C, J! d# c& E1 b( R! l. E
' ^3 W3 G/ F8 Y! D# D actionGroup.createActionForEach$message(list, agentSel);
4 G, y* v$ D" P- h/ V9 T/ O actionGroup.createActionTo$message(this, swarmSel);7 w1 m2 K) A* g" k+ H
schedule.at$createAction(0, actionGroup);6 Z; {( d1 s1 v6 d% @* q
schedule.at$createAction(1, actionGroup);
8 S3 x8 x- C; l! T( ` schedule.at$createAction(2, actionGroup);3 L0 S! a$ H R k# c
# {* m& Z7 M8 W3 z2 [
} catch (Exception e) {8 W' ^" z+ `) Y5 n
e.printStackTrace(System.err);
/ k2 n9 |9 H$ a R) P8 H //System.out.println(e);
- E; f' s& S4 {5 t' K) S8 P System.exit(1);
) j: d% U; j8 V" a) w$ w }" J) R6 [0 j7 T' k3 s0 u6 O
- g. q' S$ h: T2 q8 m
) ^. f" t3 s/ W* ?; b8 I }
! R7 u) r/ ^/ ]. {3 ?2 E) j {7 P1 H1 P. o
private void swarmSetp() {
3 r) [) S' U1 v4 \; j list.addLast(new Agent(Id));
8 I2 x2 t* t. P- g5 Q7 }* K Id++;1 i, R9 ~* s3 P5 F; @+ ~ E5 r9 ]
}
2 K) l8 X4 h m/ y& J4 G: X8 e2 R3 e4 W3 V. T
public Activity activateIn(Swarm context) {
8 K' d2 }' M( F5 A super.activateIn(context);1 _5 _2 B1 J! g- _' ^2 @; |( r' {
schedule.activateIn(this);. I4 q; {$ c3 g
return getActivity();1 k6 }" |9 d/ W* y, ~# |! t. S8 f
}( ^- s9 W) V7 o* C" A
( D9 | Z3 S2 v1 E
public static void main(String[] args) { o% u9 X5 _9 L' J
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);; Y7 E( m' Y4 ^/ q( x. |/ Y9 x
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
! N3 d) X* \% s. Z swarms.buildObjects();
- w* O G9 y+ S swarms.buildActions();+ ~" d, k( Z) e
swarms.activateIn(null).run();
7 N$ R/ ~4 F: f, h* \; A9 l }, z; p$ i0 ^% K! z1 B+ M
7 X/ t9 k- k! H) y9 o; F: @} |
|