|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
% e1 S6 e% u( {8 k, P
5 {9 H1 P1 `9 w3 q本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
) x9 n `1 X4 N以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.1 O$ g2 o) Y- R6 y% i
swarm.SignatureNotFoundException
; Z4 m% u5 I; T O' r: [6 f( P at swarm.Selector.<init>(Selector.java:76)
3 i- F- P$ y5 B! B9 J' r+ ~ at ActionGroupDemo.<init>(ActionGroupDemo.java:37)3 p: D" g; }9 |3 k6 P: b6 Z, E
at ActionGroupDemo.main(ActionGroupDemo.java:67)
; I; J$ f4 N' T* S g( Y
4 z9 I/ `8 Z7 `3 p6 y. g- |% R3 t8 T h1 p3 H8 ]# L: D& e2 C
import swarm.objectbase.SwarmImpl;
. K) b) }/ O' uimport swarm.objectbase.Swarm;- Y* M% |, z: \" v+ t7 t6 ^
import swarm.activity.ScheduleImpl;4 L1 c2 p0 b) i' J; c
import swarm.activity.Activity;% X$ j8 h6 [1 e% ^% U
import swarm.activity.ActionGroupImpl;
4 N0 G4 K6 U: Yimport swarm.collections.ListImpl;7 I& d( D P$ A9 z2 Z* Z
import swarm.defobj.Zone; % A+ X6 ?5 x) z0 ]6 x" ~0 C
import swarm.Globals;. t* [; W3 O& ^. J7 E3 e6 k+ D
import swarm.Selector;
7 @- E! P# Z- C7 f3 timport swarm.activity.ActionGroup;
* X. w% ?8 W% G; _# X4 oclass Agent {
4 |; u# e( M) K# {; e, {8 Y char id;8 b( s1 t3 Q2 O) f+ Z$ K6 v
: h _0 c/ E) `( A# `
Agent(char id) {2 L, o% ]& \3 e$ v0 [
this.id = id;8 H3 I) |. U4 R0 n) z: y
}& n) o" O' ^2 p- D" L. R
9 P9 S; ]$ e/ d, `! I* U! V
public void agentStep() {2 D \9 H+ ^0 P5 F: ~
System.out.println(id + ":" + Globals.env.getCurrentTime());# x9 L% I6 S. W' U1 K7 O# D. _; L* y
}7 {/ P! o5 L! C, V
}
" Z7 R4 q) d4 S8 }
) z. w( R/ T$ _$ g* y5 Dpublic class ActionGroupDemo extends SwarmImpl {+ o2 M; F5 ]+ B7 p" x t- h8 L/ ^
ScheduleImpl schedule;" A+ ^8 t$ D" I% E. u+ V; [( H
ActionGroupImpl actionGroup;
7 k K0 p' z7 Z1 n Z) M! i ListImpl list;( Y" a. F5 t- D8 t5 n, d
char Id = 'a';
5 G' ]! W9 m: C$ A/ a8 n! Y9 ?, y* P5 f( u
ActionGroupDemo(Zone aZone) {, v/ G8 n# W* S
super(aZone);) ~' S/ e1 e2 F
list = new ListImpl(aZone);( K* T/ ^# T% F# x
swarmSetp();- v, a* h2 I' I E7 \) N6 E$ l; L
actionGroup = new ActionGroupImpl(aZone);/ ~6 S2 T, I! l0 [& P
schedule = new ScheduleImpl(aZone);; Q1 c, J! _) M7 a& D3 @) ^
try {1 N( y) }! y6 t7 M9 ^
Selector agentSel = new Selector(Agent.class, "agentStep", false);& _, q2 Y5 {- z( b4 |, D+ i. \
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
* ^$ Z' p6 N3 h& ^
% J6 G' G: T, b9 h3 ~5 y actionGroup.createActionForEach$message(list, agentSel);# |: U6 E: r8 F+ q
actionGroup.createActionTo$message(this, swarmSel);
. F! z# m% Q0 y! E9 L schedule.at$createAction(0, actionGroup);
" t4 E# }1 U' o P! G9 J schedule.at$createAction(1, actionGroup);
$ K: D0 u' ]5 F2 Y) t# i schedule.at$createAction(2, actionGroup);/ `: i/ [& b$ v# m/ ]
: G& C* g/ a7 b# c; C3 }2 p } catch (Exception e) {) i! x: y2 W/ S& i/ Y- Y- X
e.printStackTrace(System.err);% l, o6 l; [$ h; ^2 q
//System.out.println(e);! e6 Q& q' k& E _ e/ i( b
System.exit(1);7 r- d! W/ C6 K, `9 F- O
}5 R, H2 i* l4 U, {/ W! \
$ J& J1 n( p9 }; ?+ _
5 v" z3 e* T4 |+ I" @ }1 A: l- }4 y, c5 Z
9 k) T& ?' m/ F+ U; e; @, D
private void swarmSetp() {
3 d. c( T+ y+ R% ?: e* I( l, e7 x8 n list.addLast(new Agent(Id));
7 b' f# ?, t3 t' f, ]3 D, K Id++;
+ M: V/ s, R: X }
, u$ N# Z a- K. i% {5 w2 o& u3 ~' c/ O) W6 g. ~7 L
public Activity activateIn(Swarm context) {+ [5 K6 ]* t9 W) s# H% f% i
super.activateIn(context);
7 |- v- ?' E' g7 _8 i |# j schedule.activateIn(this);
- G# s8 i' r" g6 k2 p; f0 J return getActivity();9 a: A$ T, y4 l I
}7 ]8 p1 ^' ~/ B# F* ]8 A
3 _# O7 B: c( k) F4 d- }4 G! t% ` T, z
public static void main(String[] args) {
* S0 }, y* `3 ?; W3 p/ [! n( h8 }, n6 t Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
$ |' l( a" Z1 j5 y7 e5 s, S: N Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);" ?0 q6 m. n; | D1 c9 _2 b6 k! @
swarms.buildObjects();
, f8 f" U, v9 B6 E7 v2 m swarms.buildActions();
; l- L9 T* g& N! @* q! _4 q3 n swarms.activateIn(null).run();5 z8 Y9 @, }7 f+ Z; R# I& {
}1 R( W% ?0 W p# t; @1 C
( U/ o! s4 E6 c% N7 ^
} |
|