|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
! j0 S$ ^8 M# q0 L# R* f& I3 G
6 R1 L" ~6 F, G3 m$ y3 s7 k本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update210 X1 F2 ]: |: u/ J% U1 g o3 k
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.) f: b9 l8 x9 R
swarm.SignatureNotFoundException
: L; W. ?5 U3 T1 `3 ]; H/ b at swarm.Selector.<init>(Selector.java:76)
9 O* y2 l! I& U" |. k2 l at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
- e ?) z; R, H* K5 N$ ^ at ActionGroupDemo.main(ActionGroupDemo.java:67)
7 J1 d# z! q1 |% @4 X w, M3 J: ]* e8 z/ r
% ~2 o+ s( L$ A( c9 d
import swarm.objectbase.SwarmImpl;7 `$ E) c( H9 @& N- B2 B) U5 a
import swarm.objectbase.Swarm;
1 {0 M' j+ H/ t1 u1 himport swarm.activity.ScheduleImpl;
: q% u5 Y" Q' gimport swarm.activity.Activity;
2 [# T: w, D k5 ]* Himport swarm.activity.ActionGroupImpl;0 c( Y: F6 X, O% i, R- ~
import swarm.collections.ListImpl;- X1 U: Z$ i5 y; g, V$ V
import swarm.defobj.Zone; + Z$ ?. |' ], o* O
import swarm.Globals;! p) e. n8 Y' T" h
import swarm.Selector;
4 o: Z7 Q5 j( _5 C, R' Vimport swarm.activity.ActionGroup; 2 }6 u G. r9 R2 M5 S1 G1 d
class Agent {
$ o F6 n- D8 @! ?# R char id;& h( z+ m9 f% ?) h. Y& ~4 R6 y7 C
) k: u0 M% V# f+ I8 j3 t
Agent(char id) {# @& q0 V8 E) Y- s6 r
this.id = id;
- t" A f- g$ W2 }4 l }
5 N$ O6 X' v0 s
. ^) c" x/ i( O; l- ` t public void agentStep() {/ f+ I. b$ a* u! _6 b
System.out.println(id + ":" + Globals.env.getCurrentTime());
@% m1 E* ~; b$ l }
1 v% Y8 D+ J% o+ t}
- ^) c$ C1 w, x+ K& V9 h! g! V
) S( x" G/ N( L8 M( ^public class ActionGroupDemo extends SwarmImpl {
1 k4 }4 l6 K, {* e6 d ScheduleImpl schedule;" k8 Y6 y1 c1 [# s+ ?; w" @
ActionGroupImpl actionGroup;: D6 C( w/ k4 X v
ListImpl list;
$ `( }& X. i7 J char Id = 'a';5 ~5 ^0 b/ r) D4 v* `
6 o J$ w+ x" N
ActionGroupDemo(Zone aZone) {8 j9 G+ t8 F, T. w7 i2 f: c& r& b
super(aZone);! Q% I2 U4 U& u) e. _, D
list = new ListImpl(aZone);- W0 ~& Z* `5 E" A! _. V
swarmSetp();5 L8 A% Q. v* p" S! y4 S: V
actionGroup = new ActionGroupImpl(aZone);2 K! c6 [" z% Y2 X, h6 t1 U9 u
schedule = new ScheduleImpl(aZone);
' r7 g" L; `/ p* z6 X$ J try {" s, C: A; N* B8 e
Selector agentSel = new Selector(Agent.class, "agentStep", false);/ w, W7 ^5 \ Y- T$ W
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
0 h( v( |* L) d
6 l+ m1 z3 U; b, u actionGroup.createActionForEach$message(list, agentSel);% [3 n; @$ [& e2 C- U$ d9 e, e
actionGroup.createActionTo$message(this, swarmSel);
4 k! R4 b% u: w1 ?8 I- Q schedule.at$createAction(0, actionGroup);+ K# ?" t% d1 J( h# Q |- }
schedule.at$createAction(1, actionGroup);+ T3 ~& H \6 i* O% B* r
schedule.at$createAction(2, actionGroup);+ p( c5 d: @* H5 e9 ~# j J
0 C" j4 O; ~' R
} catch (Exception e) {
' e9 ?# F- ] b6 w& r e.printStackTrace(System.err);0 ?) f# b, D9 \# K0 d. a s
//System.out.println(e);1 v/ r3 \, R0 v; y9 H2 r( s0 N
System.exit(1);" N5 m0 I4 _$ A2 }& t
}: R, ]- d: w) N0 l5 u @+ \
- K. s, Q: f- L" w' @
; s2 Y/ }2 Y' C0 g, g, ^$ _4 V
}
3 T' S8 I7 ~4 r
3 T8 k w: ?0 q* f5 O/ K private void swarmSetp() {& X. M2 `5 V( U4 N) d8 ^
list.addLast(new Agent(Id));4 i$ T2 p7 ~; p8 @0 Q! I( @6 R
Id++;6 R% K; \/ a5 }
}
7 N3 Z% _" L6 i: ~0 W1 H+ M0 `, @: N) f: k
public Activity activateIn(Swarm context) {
+ h, n9 V( q0 f super.activateIn(context);" ]) E2 y) _1 i. q) {$ P
schedule.activateIn(this);2 | }4 |4 z& I% _, ]2 T. d* {/ f7 W
return getActivity();
' @% ~" J4 W# ~+ y! L }
, Q1 R" _" S2 F8 t# \$ V# u6 n3 c9 E* ^# E7 \
public static void main(String[] args) {6 E1 J! Y X/ J4 p% ]
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
6 n' o! V: s6 J Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);1 E0 m$ Z' Q% o& E' p
swarms.buildObjects();
@( v* H& I( Z swarms.buildActions();3 K F f3 ^& |6 j
swarms.activateIn(null).run();
$ o/ h0 p) m' o; d+ G0 x }
% s3 X( s0 G V% u0 c8 w
5 p! P* G( [8 j& Z3 M. q$ ~} |
|