|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 ! H$ r2 B; E+ u, D
4 d: j& G8 S' [本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update218 X5 k+ u h; t+ B/ m. ?- f* G) P: k; i
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
8 l* r2 r/ ^" m0 mswarm.SignatureNotFoundException) X* L3 N( D; o* ~/ [6 D, x# T5 H
at swarm.Selector.<init>(Selector.java:76)
2 y( b5 n% h! o: \ at ActionGroupDemo.<init>(ActionGroupDemo.java:37)- r4 k6 b2 J' M" N( W. Q$ s
at ActionGroupDemo.main(ActionGroupDemo.java:67)# @0 N# N5 U# D
. `. g H$ K$ N7 b4 }% o* Q
9 J1 D5 r9 N) T1 ]7 @import swarm.objectbase.SwarmImpl;
4 s8 J& Y. j* A$ @) ?import swarm.objectbase.Swarm;0 E" {% _- U4 i6 Q- X
import swarm.activity.ScheduleImpl;
! a8 |) Q2 v3 H; I2 Fimport swarm.activity.Activity;; `$ f* J% ?) O5 y- o0 v! O
import swarm.activity.ActionGroupImpl;- b/ {: G) j. F8 a2 l, a" D
import swarm.collections.ListImpl;" T7 [2 P( u4 v% y: q
import swarm.defobj.Zone; g T0 P* v: G
import swarm.Globals;# @# x; J2 e1 C$ O" `" q8 n. Z3 m
import swarm.Selector;
* ?' D/ C8 A1 b2 ?# c, ^import swarm.activity.ActionGroup; % C) A. u, z8 m! e- H
class Agent {/ P! L8 r- k2 _7 C! `
char id;
+ G) D, G$ j) T' a: q. E& x, k
4 E2 E- ?' k2 h# t, F5 _4 g% l# k Agent(char id) {+ N6 r1 H/ T0 ?) `5 ^: ?
this.id = id;
1 P& y, x3 O. ^+ m: c' X }
2 a' h, i- w; Z$ B, N, U
1 Z5 f+ K4 H0 h. L) u public void agentStep() {
7 j6 H+ H4 `/ k$ v/ ` System.out.println(id + ":" + Globals.env.getCurrentTime());+ I8 L$ a+ z; z/ q1 }& `" ?
}2 r4 ]; S2 ^1 Y% @; G( Y. {% h
}
. w/ F9 z( v$ u* N A! F: R- }& ?
0 @/ |0 U4 C6 j. Ppublic class ActionGroupDemo extends SwarmImpl {
( x8 _' n( W" K) d ScheduleImpl schedule;9 e* F7 J3 `( f
ActionGroupImpl actionGroup;
. h& G R R v* F. i$ x8 Q; o ListImpl list;
+ o' ~1 ? W! D/ y char Id = 'a';8 H2 ~% @$ M: t) N( n
' R/ W: m- k/ m) f/ u+ p4 @ ActionGroupDemo(Zone aZone) {, N- o b% K6 Q/ e, y3 W4 `
super(aZone);
* q2 c9 V% x* C% w! [* M list = new ListImpl(aZone);* y0 Q, |! j% R- ~8 j* F5 v8 s7 a
swarmSetp();( ]% Z1 V$ h/ S. ]
actionGroup = new ActionGroupImpl(aZone);
. y7 f8 d7 P3 A+ U$ P schedule = new ScheduleImpl(aZone);+ G: k6 X3 U' |7 I. ]* E% \, g$ [3 o4 v
try {5 d; N7 K6 g3 `& y% R
Selector agentSel = new Selector(Agent.class, "agentStep", false);
2 s/ d/ F( G- S( s Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行2 {% `) Y- E: M' n! K. M
2 y3 |# C* _. L
actionGroup.createActionForEach$message(list, agentSel);; X H R1 Z5 M
actionGroup.createActionTo$message(this, swarmSel);2 p5 ]( K' S3 n7 R% c8 p& s9 n
schedule.at$createAction(0, actionGroup);$ v4 R/ M& m/ A* A3 r
schedule.at$createAction(1, actionGroup);" b, h9 d% J. P+ S- d6 q/ |
schedule.at$createAction(2, actionGroup);
' Q5 H* N- z+ J p4 W$ C2 S# B2 @* \( g! H" O
} catch (Exception e) {
' l$ r" e; m7 \1 d' O/ z e.printStackTrace(System.err);' [+ H$ b; Z; ?2 |
//System.out.println(e);
4 q' I6 l$ {( ]* l0 |' G- ~ System.exit(1);
" B$ L( G, `7 C2 W( `) ~; S6 r }+ Q" C; x" O% a" [; c" \
; _) w' l, V7 \- k! F+ x4 m
t- c: N) p( V2 ? [5 r) A }
* o7 b0 G5 K. V, |* L+ ?, i6 S9 d* n1 e! g
private void swarmSetp() {! q5 p+ S4 O) D, _) a
list.addLast(new Agent(Id));4 }( M* n/ ~9 B8 x
Id++;
+ i# ~, w" M- a }) {5 E% v q9 q( w! s5 g. [
; q, W# m3 p9 K! S% w8 e0 T" }# o5 q public Activity activateIn(Swarm context) {" F7 Y8 [. Z1 Y0 K$ E" h+ i* l5 N( D
super.activateIn(context);
5 }3 _# M/ t5 } schedule.activateIn(this);
0 {- P; A3 f5 } i4 W return getActivity();/ T+ k2 |% V2 A5 `
}
" p! K; \0 k8 f8 \( v
$ z: V" {1 b1 F& u4 C, k public static void main(String[] args) {
9 \) e+ a0 d$ @% _% D3 w Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);; c/ d2 W3 o3 Z
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);" r$ w' X m1 j9 v. V* Q [
swarms.buildObjects();; ?" Z' V! u, N( F0 @% w0 O
swarms.buildActions();
( s; }+ R6 h9 \1 p% e swarms.activateIn(null).run();9 `2 K4 T# \& T: V. i1 {4 z9 Z
}0 L2 h9 R7 p3 S0 u- W* M
$ a z$ d! e& z6 l1 M E} |
|