|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
; r, o* N: P, ?" K# ~, `4 C3 [+ U& o: C$ n6 A
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
. U& Q0 E& l5 h以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
- J, O s! \# ?+ v$ l) p! n/ Zswarm.SignatureNotFoundException
! X0 R6 o% j% [! t+ m3 d! I/ D/ i2 F at swarm.Selector.<init>(Selector.java:76)
8 r' ~! `, h& ]- J, y at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
, t; i6 c+ P- V G1 a v# b at ActionGroupDemo.main(ActionGroupDemo.java:67), ~2 v. D" g3 y7 s) ?& n
) c; w$ y; a- b/ M+ y% F$ v, \
- v1 q, x" X/ B$ d& E
import swarm.objectbase.SwarmImpl;7 Z2 X" N7 W2 N- P- r9 v7 I
import swarm.objectbase.Swarm;
5 r2 z' n% I$ M l1 limport swarm.activity.ScheduleImpl;
! `: h5 R4 q/ r* s* X1 ~import swarm.activity.Activity;
9 A1 O+ v3 ` C$ Yimport swarm.activity.ActionGroupImpl;
K/ w9 J/ K" B \! K: u+ kimport swarm.collections.ListImpl;4 b* @& `$ Q0 Z/ E
import swarm.defobj.Zone;
# w) W0 F, m( } o/ q, X, j* O3 R; limport swarm.Globals;
3 L, Z. X& z% C/ ` J8 Q7 s, Uimport swarm.Selector;' N3 o( `2 I- e! ^: C0 I/ i
import swarm.activity.ActionGroup;
( G- ?! L" u/ t! j) J0 Lclass Agent {$ ~ _8 p/ c' \2 A9 E
char id;
9 P9 | Q' ?! N( d* T
4 {' m. w; B; A# [ Agent(char id) {
; T0 K% g5 f+ L$ L2 y2 @ this.id = id;( r; F0 _# P* v) c0 u, m
}
% q. W9 ~2 g3 G' N1 A9 l
; y/ [% r: u* G M7 k/ m0 ?2 b. Q public void agentStep() {5 H$ C+ z& v$ [# B7 F6 D% E
System.out.println(id + ":" + Globals.env.getCurrentTime());
3 C9 a4 ]- |' Y5 X" e! p( s1 r$ ? }
9 q8 ?1 u/ X$ p& Y}$ W! l. A6 Y+ r1 `: M! |
. H& t* r+ ]& t
public class ActionGroupDemo extends SwarmImpl {
, o8 r& o: e: ~! n8 B: h, d& X ScheduleImpl schedule;% `, P( U& ? Q [4 w' j' H a" K& y/ g
ActionGroupImpl actionGroup;! d9 G* ^3 |. Q% D% @# j, @1 D
ListImpl list;- n, R1 g: y7 U2 [2 {
char Id = 'a';# h" G2 l7 ~; f& _8 d' B+ W$ \
/ Z5 G r1 l* Q1 c& o" O$ G6 R
ActionGroupDemo(Zone aZone) {3 c7 F( t% U7 {) h- R* a) W' y
super(aZone);) |2 {" R5 B' u2 B2 n
list = new ListImpl(aZone);! C9 r$ g/ {8 ? e
swarmSetp();/ B) U% U8 x* a3 A3 Z
actionGroup = new ActionGroupImpl(aZone);2 H. Q# t8 i8 x y7 b3 L
schedule = new ScheduleImpl(aZone);7 u) J6 ^8 C5 t
try {
. Y; I" a: F6 L& c7 k Selector agentSel = new Selector(Agent.class, "agentStep", false);2 R/ v" L' D" y$ J2 ?5 q
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
0 S1 q5 j& B: u 9 {. y5 G1 w& A+ g5 }
actionGroup.createActionForEach$message(list, agentSel);
6 c1 K+ X' F) e! m# Z actionGroup.createActionTo$message(this, swarmSel);
/ ?8 n1 u, y: j7 q schedule.at$createAction(0, actionGroup);
) ] L/ R0 m( d. ^: M6 S# g# ~ schedule.at$createAction(1, actionGroup);
: F6 [; T6 z" r% o) V# ^( o H2 ^1 {3 e schedule.at$createAction(2, actionGroup);
5 g( q8 c! r3 K1 M
5 Z, x. @+ E* B+ T: A6 x& Y } catch (Exception e) {0 n4 n3 R$ B0 d& {1 [ c. @9 ^" J+ ~( }
e.printStackTrace(System.err);
g/ f& N P- l6 F0 m/ W //System.out.println(e);$ T- B! B6 _9 P) n* R/ W
System.exit(1);
6 `( ~4 R! b9 o$ N6 F( s }
' k4 v' E, x" u5 F
( p7 u6 M! B' m6 O' a3 k- z ? F
3 K6 i( O3 @. V, p# m }
5 `* a% C3 w9 Z5 r7 e8 V; |, R$ v1 ?$ d
private void swarmSetp() {; q5 A9 a1 C1 s9 {3 K8 M H
list.addLast(new Agent(Id));
+ g# @0 P6 T( g1 X% K m$ L Id++;
7 E- \% p3 `8 `( g }
2 B3 F, @1 c+ A% W3 d k3 B( J7 X' B6 ^. W
public Activity activateIn(Swarm context) {- `0 o R, y1 `4 ^2 g
super.activateIn(context);
- @( c, _$ L- x& g) Y6 [% E schedule.activateIn(this);1 I; K: B7 M" T
return getActivity();: x2 H/ g7 ?" ? P
}: ?" w+ g2 s; t/ l# T4 L
. }, u1 `9 |! J, K
public static void main(String[] args) {) R! f' \- o; @) r2 R
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
# ]2 {* r1 M' F; A9 l5 v8 f Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
4 { i9 l& ^; v' R& D3 P9 o# X swarms.buildObjects(); `$ n* H+ F, m! q3 ^( W% e J% l# b
swarms.buildActions();
t c9 R" X4 q9 d swarms.activateIn(null).run();
& a, ~! a/ z7 L }
/ L7 A1 h- @0 ]6 @ B# H
6 R1 [" C v- y1 Z& b Q1 q} |
|