|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 * a9 C7 u) b: {, |4 Z: z3 [7 K3 y
( G9 ?0 H7 b. H本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21; z I7 p6 j% H c% ~9 ~
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
7 ]& y( U+ V7 }swarm.SignatureNotFoundException
, r$ @" X1 k: ^5 N3 u at swarm.Selector.<init>(Selector.java:76)# g& s$ v: x6 t0 W7 R5 K
at ActionGroupDemo.<init>(ActionGroupDemo.java:37). ~9 d- ]4 \2 q2 n x y
at ActionGroupDemo.main(ActionGroupDemo.java:67)
8 F2 a% P( o+ J+ g. D, o: d2 X
, m+ K# Y; }# D" L
% x) q N3 B# x. [% fimport swarm.objectbase.SwarmImpl;
; g6 ~; @' W9 J' e0 \* h9 I8 Aimport swarm.objectbase.Swarm;, L# A6 l9 Y' l& a! G* l/ r: C
import swarm.activity.ScheduleImpl;" L# F0 O8 @6 H4 z$ Q( V
import swarm.activity.Activity;- f/ Y* h: c& |7 _) u7 H) a, V* Y% i
import swarm.activity.ActionGroupImpl;% K2 q+ H3 ]2 \& p7 j
import swarm.collections.ListImpl;
1 H* A0 B. a/ ]; rimport swarm.defobj.Zone; ' u. x0 e4 ^8 T7 ^! d [
import swarm.Globals;
j8 }5 S0 j- k& U$ @# ^import swarm.Selector;# p P$ I- N, b, m
import swarm.activity.ActionGroup; ^( Z! ]1 L3 n" ?; \; e0 c
class Agent { A n1 o) H4 r. r, R4 Z) U4 _
char id;
! D) i" k/ X1 K0 a( k( r1 j3 l: t6 C9 h' H& J
Agent(char id) {8 q, L+ [: q) ^6 p0 q: v. Z; l! e
this.id = id;
+ S! z' s( `4 C K3 H0 D }
$ l9 h; n2 ]7 b$ M* X( ~( U
. Y2 f+ A( E! ^ F public void agentStep() {
& v+ G, E* `! X System.out.println(id + ":" + Globals.env.getCurrentTime());
5 n6 H% J! [9 l8 N }
P) J; h' D# X* d( S7 [}) Y' F3 G! n6 i! h# a
; f: y' F: ~4 K2 [/ h6 _0 h
public class ActionGroupDemo extends SwarmImpl {
( C+ }% Y5 m% b+ X, ], \7 W ScheduleImpl schedule;2 O: p% \& v1 p" T# x3 J
ActionGroupImpl actionGroup;: t! q. g- N' h
ListImpl list;. H( `- J7 Y! f* }0 f4 V, }
char Id = 'a';
/ k3 Q9 M1 [) d" s
) m" _4 ?: l; l4 p) @ ActionGroupDemo(Zone aZone) {
# A, \( k- `% `- l+ ?7 {4 E6 U super(aZone);
0 g- Q! O: I2 ?+ C2 O. J list = new ListImpl(aZone);
" @- H u' m& {" ] swarmSetp();9 B' O: w6 m q$ F& I3 g# t
actionGroup = new ActionGroupImpl(aZone);
% G& v3 W$ f; v) d schedule = new ScheduleImpl(aZone);
6 c6 U9 V0 d; [( c$ ?# h try {
C! m- m1 n \( w& |. @% V: ? Selector agentSel = new Selector(Agent.class, "agentStep", false);; [2 y! G1 [2 |. A) _+ A5 Z! z2 [+ k
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行6 E7 c4 i, t" }; D3 y
) R9 `, L- j" W' p* }2 q: N8 ?6 b actionGroup.createActionForEach$message(list, agentSel); T; L& y; V1 [" x
actionGroup.createActionTo$message(this, swarmSel);
6 q( J. c3 Y# n& g! \) X schedule.at$createAction(0, actionGroup);$ [3 S/ c/ _ v: b2 ?/ @, `
schedule.at$createAction(1, actionGroup);. j0 j: h6 D# W7 a; g& ? f/ v
schedule.at$createAction(2, actionGroup);& K( _6 K: k8 }0 X- l
5 W: Z# V F! k2 `1 X8 @2 S" x } catch (Exception e) {
9 z$ g' J" ?# k* n. A9 X) W e.printStackTrace(System.err);* J r$ M' F7 ^. J8 L- p, S% s
//System.out.println(e);+ K i" C8 S ^. w. C+ Z& I" ^) J
System.exit(1);
! ^4 p, r, x/ }, v2 U# L }
i( R" H& p3 `9 d0 o% [4 u
5 O/ [$ K. E, ^7 E' C) `+ N# m* o
}
% J' [$ u3 `. l" f+ t. }6 I! P& m0 p/ W# C5 H* x1 U G) V! L8 W
private void swarmSetp() {
$ M8 B" s$ E) L- w! V list.addLast(new Agent(Id));
) I5 \( m" G8 a; o Id++;3 S! X- l! ~1 B
}
- J5 L4 i& w: l+ K, b9 ]& l/ r
3 ]6 P" C/ ^& C* i" d4 [; ], m2 t public Activity activateIn(Swarm context) {5 w9 I# T M! i" N4 C& e2 |
super.activateIn(context); }' T% e" P; y# K, ]( f. X
schedule.activateIn(this);
7 s, Q: Z9 U$ M7 L8 \( t' J: S8 i! [ return getActivity();
/ a# O3 z, j% m, M+ M) u: ~8 ? }9 ~& e B9 G$ E# ^/ _, D* Y9 U7 k
d6 g: M/ A" j1 e1 L* D K4 c public static void main(String[] args) {
3 O) ~- z3 l% Y2 H4 d+ G Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
$ z r6 G' d& Y, d: o/ y Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
: D# A4 Q) H, ?) d swarms.buildObjects();# @" H9 {; U6 p6 _$ U- u
swarms.buildActions();# \3 D; a" ?0 v6 ?0 k/ G T
swarms.activateIn(null).run();
( Y: C4 G0 a; ? }
7 ^% L' b" I8 c9 C/ h: w! g4 g! q
* P/ n/ J6 s; ]9 i" k% ~0 Q O} |
|