|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 1 S' a. ?* C2 h: b) V
7 y8 |& M* P9 F Q$ A8 E0 Y x
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21' k+ }/ P, C. L1 @' X4 |
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
9 R% f! ]! t: Z! O: ]; Wswarm.SignatureNotFoundException8 [1 N8 e# i! [' `5 Z
at swarm.Selector.<init>(Selector.java:76)
4 n1 z) w9 k5 h: I at ActionGroupDemo.<init>(ActionGroupDemo.java:37)! c; M J6 r# [9 q/ L* ~: g M
at ActionGroupDemo.main(ActionGroupDemo.java:67)5 s' z) w" F) D# q" i/ A
1 Z; f4 c+ U; w9 i
; f3 x# V- O( F$ Q* d( Fimport swarm.objectbase.SwarmImpl;
- I1 `1 s/ w+ Y2 i. b3 Jimport swarm.objectbase.Swarm;
0 Z7 x( Y) P' \import swarm.activity.ScheduleImpl;1 s- J5 B5 F z/ z( o" n7 W0 G
import swarm.activity.Activity;
2 z0 x; {- ?# N L9 m) v- Uimport swarm.activity.ActionGroupImpl;
8 o* b' D6 `! Z6 bimport swarm.collections.ListImpl;
( I0 c( \2 P" L+ x& N! C. |9 |import swarm.defobj.Zone; 7 l2 R' R4 m7 ?& [. g
import swarm.Globals;
. X' e( X; l0 l9 }' Oimport swarm.Selector;
2 E F; ?+ _& w9 O; f) T* jimport swarm.activity.ActionGroup; 2 L' k+ @6 Q7 m- o* \
class Agent {. u! y$ _" d I$ p6 _' Y4 a+ g
char id;0 i+ @; I6 T0 W( D& G( L9 _( {
+ @4 h, `+ [, X8 {3 {* H' W Agent(char id) {
5 V5 X9 [, l& }# ~+ l t this.id = id;4 k' c m N4 S2 l/ W( x
}* \4 D- N8 B+ _! g
& O0 T- T$ B5 ?; @/ n
public void agentStep() {& b. s0 G$ Y: ?* A% d; B
System.out.println(id + ":" + Globals.env.getCurrentTime());
( \1 |& L5 Q8 E) @' j% P }' a$ M) c: f! O5 |9 g) k
}; y5 ^5 @5 p7 r! f+ O$ I' C
; Y( X8 M7 e/ D. `' P
public class ActionGroupDemo extends SwarmImpl {
' Q0 _, q9 }7 X7 u: y$ i ScheduleImpl schedule;2 W7 ]! X; S0 Y, \
ActionGroupImpl actionGroup;
1 l C7 }- X. _6 i+ L4 P1 ? ListImpl list;
, m L- ~/ g: { r char Id = 'a';" T7 ?6 j* j5 E, j* J7 a6 h$ t9 j
4 B$ F! X/ w6 M. G! J3 Z ActionGroupDemo(Zone aZone) {
q# T0 d: N Y1 F, Z5 l super(aZone);( ?2 C! @4 m& x1 s, @
list = new ListImpl(aZone);+ W4 S! F$ c& l0 c+ m# q
swarmSetp();1 l# | P% c" B( b, I6 i0 B# q
actionGroup = new ActionGroupImpl(aZone);& N4 m: H: l" w2 Z
schedule = new ScheduleImpl(aZone);8 H" F2 U* b6 c* {$ m) ?2 d
try {& g$ }; _! `# J
Selector agentSel = new Selector(Agent.class, "agentStep", false);
; u7 g4 x8 Z4 | Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
5 I, ^8 q; p5 z9 H# A; _3 w# R; p 2 D3 \0 C* a# h& v0 t
actionGroup.createActionForEach$message(list, agentSel);+ f G4 t' H5 T- F3 L: Z4 H
actionGroup.createActionTo$message(this, swarmSel);
, g6 \6 q! y7 P p. v schedule.at$createAction(0, actionGroup);6 K7 k' K* K+ R0 Q0 R; [+ @
schedule.at$createAction(1, actionGroup);
& X: `" q" L& B# B {) ?: D schedule.at$createAction(2, actionGroup);+ N- @' a; t8 H/ b- L2 ^* q$ A
: N5 {8 @/ P! ]9 b0 s* C& {: x: u0 S
} catch (Exception e) {0 L- H% K# M1 g5 `) U# `
e.printStackTrace(System.err);
; u _, X1 {- ]0 C6 x //System.out.println(e);
, Y8 d4 R# C7 t. h+ P+ P% _ System.exit(1);
1 \# p- _: ]: l5 Q0 q+ |6 s }# v, \/ A A- j' Y9 J# W
! f( h) K% v3 g, C: i: {2 M, ^; d$ N
}
5 H5 B9 d; R( t6 m+ x! ~! D. [$ i6 w6 b/ @5 ?# Q' ^
private void swarmSetp() {* h: m, V: x! s/ {' B9 V
list.addLast(new Agent(Id));3 [$ T% [* i- d2 E: Z' x
Id++;5 V+ b0 S" @2 Z8 K9 T+ [2 }6 V
}
. J! t) ?$ H; K: D0 S8 i
* ^7 _# W: c, U# A4 K3 [' q) K public Activity activateIn(Swarm context) {5 J( H' c% p% ~! |. M, t" @! j
super.activateIn(context);# j2 ~1 t3 E+ X" L
schedule.activateIn(this);% U, h {! Z+ E% R& @; j
return getActivity();4 Z: ^7 _" H8 Q! H- {- M
}% ]+ I' c8 U: i- m8 R
6 b6 \+ y. y5 P" _
public static void main(String[] args) {
4 _1 L O, _" l2 Z' N. V Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
1 b: V% P g0 b5 k2 B8 c Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
7 p* b' M1 g3 j, G swarms.buildObjects();
/ v- o" Q) R+ x swarms.buildActions();
. b$ W: _) {0 I) ] swarms.activateIn(null).run();% M/ R% I$ H7 T7 P4 [! n. F
}
, z( c. Y3 B7 k( h5 O/ I8 \; g/ m1 p$ X) ~4 K3 a4 {1 W/ x
} |
|