|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
, @) J6 ?5 s _6 G D [6 K3 _2 J8 }: u+ u: v$ o3 F }
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update216 j& u# L) H" q
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
( W% l9 Q( x9 S4 U5 ~swarm.SignatureNotFoundException3 ?0 p8 g: R( C; ~$ [) i
at swarm.Selector.<init>(Selector.java:76)7 F9 B2 O& @; ?2 e; t! {2 j
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
8 s; }# T2 K8 b, J' w at ActionGroupDemo.main(ActionGroupDemo.java:67) y# m% R' z* C. e3 h P$ e9 J1 n
* H' v( |7 B# _( ^8 P# ^# f- K
2 h% }4 @1 f+ B, V9 pimport swarm.objectbase.SwarmImpl;
9 k& R; W; B7 I# kimport swarm.objectbase.Swarm;8 x P& f% T# x( y4 n0 G! E) n0 ]
import swarm.activity.ScheduleImpl;8 z0 E" q) Q0 M4 q
import swarm.activity.Activity;5 M, G' s* Q* D( T/ A
import swarm.activity.ActionGroupImpl; i. K& p4 W' {! U3 S' G) \. o
import swarm.collections.ListImpl;3 k4 k% Y- S& m- U7 |: X
import swarm.defobj.Zone; # H* [- W, \. Q
import swarm.Globals;5 p5 \1 L' O# g* t& m J
import swarm.Selector;
- q* D- f" c r) S8 himport swarm.activity.ActionGroup;
0 W9 H7 z8 j2 G; _6 L: rclass Agent {
# `7 P0 O; V( U char id;9 [( e B+ e$ g+ k# {
4 x2 l1 ~( L" P' I& K Agent(char id) {
& s& u B( y& R3 e3 j/ ] this.id = id;( t- B/ J% D, R4 v5 N1 X
}
$ o& a3 T; m0 x0 V# m& [2 }: {
# r7 U$ ^& O% B6 U! K' }, K; N public void agentStep() {
; z+ a- E: F) w0 P, O9 m- M% V System.out.println(id + ":" + Globals.env.getCurrentTime());. ]0 ~' z) a" E) R$ Z" ^ O1 C
}8 S+ B: k+ D1 Z: d; A8 H) Y9 O
}
& K( n; `& I) y: m1 b+ G0 E& Y
4 M+ d5 _7 q7 | ~+ @public class ActionGroupDemo extends SwarmImpl {
5 Z+ W6 E! z# Z* Y/ K& k ScheduleImpl schedule;9 | U4 n z T- |+ R8 K
ActionGroupImpl actionGroup;
5 S7 H& q$ ^% V: Z# O0 @# p ListImpl list;" I7 f8 K* X3 R( t
char Id = 'a'; A- p( N9 l$ N& p/ W( R/ `3 v. O
7 f$ [( ~- q! D# [9 L% O ActionGroupDemo(Zone aZone) {, c3 j. Y% Z, `( g9 r: e# x9 W
super(aZone);
$ Z- G; c& c( V' C( h" y list = new ListImpl(aZone);
8 T8 p8 R. X9 p6 B7 J swarmSetp();
5 h$ {7 y8 D* {3 `3 E {! W M actionGroup = new ActionGroupImpl(aZone);
8 O( d* q4 t& Y% o/ }: R schedule = new ScheduleImpl(aZone);8 z4 o3 K1 k) q5 h+ I7 X6 B
try {( a" ^8 c0 ^+ i) s
Selector agentSel = new Selector(Agent.class, "agentStep", false);' I3 w7 t8 c0 [* r! d9 |
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
' I- o, G6 |0 U# @7 } 5 O4 Z; D+ M( W6 h, T. O
actionGroup.createActionForEach$message(list, agentSel);
: {/ U9 c+ ~9 c7 a. v2 V actionGroup.createActionTo$message(this, swarmSel);2 U/ U* e8 R3 `3 C8 v
schedule.at$createAction(0, actionGroup);- |0 L! I# l+ u! v5 u H
schedule.at$createAction(1, actionGroup);
* q" m6 Y$ ?2 S6 X& C* _ schedule.at$createAction(2, actionGroup);, W* S8 U2 C; W
4 u$ I+ {5 u% o8 H } catch (Exception e) {/ G" S" b9 Z/ Q
e.printStackTrace(System.err);
* {3 r! p8 C$ `! n# f& E3 i //System.out.println(e);( q2 r1 [+ L5 M' X8 X
System.exit(1);
" G/ F1 p$ N6 p9 n0 |% U1 s! e4 s6 a }3 Q( _# i3 {* q5 t: e9 Y- B$ p
5 O& r" A5 L3 h/ O+ B( Y
' i7 w- }' f O9 k' S" L }
' n7 Z9 q0 R* S1 `6 }( b+ q8 Q( p: p5 c/ A
private void swarmSetp() {
6 u5 G+ H* x8 M; r% q# N' Q list.addLast(new Agent(Id));
0 g! M( R1 I; g. C% Q Id++;
- @5 }1 y* u( e* B8 o( m }
& I3 L, H, J0 D; Z9 D& V, C7 W7 [2 F3 D8 ~
public Activity activateIn(Swarm context) {
# i$ y# F" G+ H8 M- \: K super.activateIn(context);, ?* N7 }3 H; U' T7 b- [9 p I, ^
schedule.activateIn(this);" Y7 o$ h3 [- W4 T3 [
return getActivity();4 p0 o! I8 L0 i5 g/ i8 C5 H
}, n$ e+ B r2 N. V: j1 v) {0 t
6 n0 t$ D- W% [+ P4 S8 X* b6 T* k$ M
public static void main(String[] args) {
- g4 O+ f; {* d$ t7 f) x) ^5 C Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
2 s% _8 d* `+ V& Z9 [6 @, o) U* X Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);* `; R4 u3 w# S$ M3 V
swarms.buildObjects();
: I# B' Y. B( Z9 N% P6 { swarms.buildActions();$ @1 o9 s9 ], B9 Q' B- j
swarms.activateIn(null).run();/ H: t4 b3 }; P- U
}# Z1 q2 i6 g A5 v# G7 \
( |7 ?5 m+ h; l1 w! ~, D' m# i% ~5 q} |
|