|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
, E6 q# s9 [, x( { P) e v' w! t6 u% L$ R% V: a2 `
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
! p2 A' [* r& @以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.$ t# E9 O. n) w9 ?3 Z3 _
swarm.SignatureNotFoundException8 g2 a1 D" b5 R4 x. T0 K& ~, }& k: F
at swarm.Selector.<init>(Selector.java:76)
) C; [5 f/ p2 g; L' m5 s1 m at ActionGroupDemo.<init>(ActionGroupDemo.java:37)( \5 d7 Y( x1 i$ G0 d6 i- b# n
at ActionGroupDemo.main(ActionGroupDemo.java:67)
2 O% q3 R' V1 V& Y, K8 m* R) D5 V7 P/ W& b5 e" I, F" u7 y
' x8 V; w* A& j9 E9 ~) K
import swarm.objectbase.SwarmImpl;
7 D! t! p) j2 q7 h7 m1 f ?import swarm.objectbase.Swarm;
" d1 r9 i, q& dimport swarm.activity.ScheduleImpl;
K2 g8 I" e7 I& w% a+ ximport swarm.activity.Activity;
$ I- a- F1 L4 H& x8 r* H( E1 @$ Dimport swarm.activity.ActionGroupImpl;
0 N- Z2 c% k. }' P- Q: I# Limport swarm.collections.ListImpl;
# y. [+ ~) F" Y0 f$ dimport swarm.defobj.Zone; 3 t. j8 ?* r( j9 G# o) {
import swarm.Globals;) o g1 b3 G1 B9 W6 N/ M5 f
import swarm.Selector;
: E3 Z8 i% m& c& Iimport swarm.activity.ActionGroup;
; } k3 T. f) I) Tclass Agent {# L, N" A" O' F- K
char id;! }, I1 ]% n- F0 B& \# K' K( A, C9 |
3 ^, j D" C' V
Agent(char id) {
& n& \1 L+ a8 y! d, J* ^0 f6 |' Z this.id = id;* t2 _, ^7 p+ X/ l
}5 M( X- @4 W: q, a3 p& Q
4 s( \$ d! @; y6 l
public void agentStep() {
+ w: ?8 f! G, [, P, u System.out.println(id + ":" + Globals.env.getCurrentTime());
7 x" d$ U- u8 p8 H9 |- j$ O }( F/ C% D) p. z+ i" ]. s0 G
}
4 c8 K) {1 @: A+ u# U% Z1 {( k! K3 b
public class ActionGroupDemo extends SwarmImpl {
9 m( }/ Z( W- q& V" N ScheduleImpl schedule;
$ `* ^2 Z# r3 n/ k- u- @ ActionGroupImpl actionGroup;
8 V; |- o$ ^ X! s1 M1 ?9 w ListImpl list;
$ t! g! z- y: K _" _# Q! ^ char Id = 'a';
) H. c) m Y; z4 _1 o" P' @
1 G. Q- n$ @2 \4 ]1 _ ActionGroupDemo(Zone aZone) {: S! o8 K7 d3 o5 E
super(aZone);/ Q( I0 h6 v+ X6 B- G; \% x2 }! K0 T
list = new ListImpl(aZone);- N1 v& J2 B$ o9 b& k6 v
swarmSetp();1 P% Z( j& F+ t K
actionGroup = new ActionGroupImpl(aZone);7 F8 k) E0 [# L$ ^! g* m- q
schedule = new ScheduleImpl(aZone);+ H6 C/ L( I7 ?
try {
0 O$ m3 m6 Y7 P Selector agentSel = new Selector(Agent.class, "agentStep", false);2 V7 ?% K% E5 d1 ~# q
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行1 ` |* e+ Q: D u2 E& j) |7 q V
& b4 }9 g1 n6 N0 q: B' c
actionGroup.createActionForEach$message(list, agentSel);- u) W) V" u: Q1 j1 Q
actionGroup.createActionTo$message(this, swarmSel);5 K; A2 ?) Y( l8 E" L6 g! c% J
schedule.at$createAction(0, actionGroup);
" ~' [4 R' i- E schedule.at$createAction(1, actionGroup);; }! L/ u7 f5 o, \$ E* W
schedule.at$createAction(2, actionGroup);
& I! G' M% ]8 |$ V3 r0 k% ~! T) s! d
} catch (Exception e) {* D4 d* e3 H8 r* M$ @' T
e.printStackTrace(System.err);
" j, ]6 v% q% r6 D: Z t* b8 {- x //System.out.println(e);& X. d' {4 J2 h6 k
System.exit(1);' E" _+ W& @- q
}, q) j. P" w# ~; h7 X% i% P, ~
; w, L: n: w$ O- W
( e( h+ b1 }0 e& S$ r }, f! f( J$ U# W0 h- g' D; Z
2 n$ }* k7 s0 p! L0 N3 [+ d, j
private void swarmSetp() {
& T' l/ i, i+ H/ e$ G1 v list.addLast(new Agent(Id));" c! \/ ~1 }8 \9 B9 `
Id++;- ^* }$ I3 y7 j3 B2 S
}4 m' ?- P0 j5 A' {9 R
8 i- u2 _4 u6 \$ ^" y6 P) o! x public Activity activateIn(Swarm context) {& y5 V4 A, h/ Q) q$ C0 Y
super.activateIn(context);
. T* O* M6 X$ T1 W6 Y schedule.activateIn(this);- M$ d% {7 B8 d0 Q/ ~% m. A: N
return getActivity();" k% D4 D! H/ a# ~9 H
}+ Q2 f: c8 `, g" P
; ~8 K* o- g/ M" W public static void main(String[] args) {; V3 k, I" s4 J5 i0 O
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
" i% l9 x. D8 V$ p1 F/ _2 \; M Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
' v0 i7 G- R8 d swarms.buildObjects();. ^, d( l" c/ ]- \/ @. u# B, i7 B
swarms.buildActions();7 S3 B3 g+ [6 f
swarms.activateIn(null).run();' J! \3 f" t& W" B, p9 `! d
}; X# Y8 G8 M9 U4 p8 ?/ _
% h8 a/ c3 h% U% l0 A} |
|