|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
- c5 E5 O7 I& N/ W6 ~) q* I2 j
% a: a. @1 d. S7 L0 k0 r本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21% b; V$ J4 S# z7 X' I
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.5 n( C& u; e/ C6 Q/ X2 Z, j& m
swarm.SignatureNotFoundException; ~9 x7 s6 v0 M5 P" a+ ~, o3 J4 a
at swarm.Selector.<init>(Selector.java:76)
" b% P6 {7 M8 A; I) a at ActionGroupDemo.<init>(ActionGroupDemo.java:37)& A, o# m* w9 |) h* y6 S: m9 f }
at ActionGroupDemo.main(ActionGroupDemo.java:67)
4 J: Z4 @3 @; u$ U& O' t
1 D' x# Q$ u+ |+ o+ A% o* g2 G# ^! ^8 G% g
import swarm.objectbase.SwarmImpl;
# R4 m# `+ C& H4 ~) P H2 \import swarm.objectbase.Swarm;
4 ~8 N7 R3 @/ e; mimport swarm.activity.ScheduleImpl; W3 c7 x" F1 o" i6 K" h
import swarm.activity.Activity;" Z9 o# x4 ]0 { z, @4 E9 p
import swarm.activity.ActionGroupImpl;9 y1 c8 V+ G% d
import swarm.collections.ListImpl;; ^# h/ M3 m* N5 [9 t( {$ W" Z- ~
import swarm.defobj.Zone;
6 V0 w& b/ t6 S; H6 P# `import swarm.Globals;
" a; |/ y! r+ ]3 u \8 yimport swarm.Selector;
# b& k/ H, L: S7 J1 Q( @8 O |! aimport swarm.activity.ActionGroup;
* ^# x7 L" [0 ~ w. x: e4 sclass Agent {' ^- R, a# f+ c0 h
char id;
& H9 R4 W$ o; n$ }8 }4 R
8 j5 X& {4 t9 [1 w( O Agent(char id) {" ]1 V- T* c9 {; P ^ _
this.id = id;; ^2 { v3 P4 A' ]* K
}1 `; h( C/ X. s, _4 U$ @4 t3 J
5 W( h$ K7 }0 H" Y$ d( ^9 C) h$ ~
public void agentStep() {
; D2 |9 c* N7 z# b' u* b! P System.out.println(id + ":" + Globals.env.getCurrentTime());
: j1 L: F# m8 G* i, E* I6 F }
+ D J# [- m) M5 h \% J/ O: U; I+ E}6 g5 R" A1 B5 G: Q
& T9 { p6 l1 ~9 ^, ~! n9 t, o7 M
public class ActionGroupDemo extends SwarmImpl {
; N; a; W" S7 o+ z. v( l ScheduleImpl schedule;
4 b5 {5 E& B9 J' K: C) H3 b, D ActionGroupImpl actionGroup;% B" l% g# }4 D7 z. X4 Z
ListImpl list;
4 X3 H% j. ]5 y char Id = 'a';
* V1 ^" U, Z6 i( ^7 q! z. D3 m, w
" c3 R* J. x) W* I, T ActionGroupDemo(Zone aZone) {
% q( [2 t6 b) F$ f9 S super(aZone);8 h: @' z+ c3 z: r. O/ `
list = new ListImpl(aZone);
+ e5 }+ Y! F* V5 J' s3 T( Q: C ~1 l swarmSetp();1 d2 }1 a# ]% R+ Q' j& ?4 i, W
actionGroup = new ActionGroupImpl(aZone);
, b. [6 O/ p6 A: v& ^2 J schedule = new ScheduleImpl(aZone);
6 F+ v! c! C% g0 a try {9 A" D: d C* B$ [/ C- w; p
Selector agentSel = new Selector(Agent.class, "agentStep", false);
- d; L2 G5 k) Q0 w Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
( ?6 d+ g* I; h , D+ R+ J- E+ h5 z0 J9 m% D
actionGroup.createActionForEach$message(list, agentSel);
! S: O6 M& }- K- O8 f actionGroup.createActionTo$message(this, swarmSel); N/ `) p |6 Y+ e( I
schedule.at$createAction(0, actionGroup);& I5 X6 C4 x! ~; Q, }$ P
schedule.at$createAction(1, actionGroup);3 P% B* U* W. U2 x6 y4 f
schedule.at$createAction(2, actionGroup);# [; m; q- C; Z. h4 c0 h) ~4 G
9 A2 o9 x) L' B/ S# Z0 D } catch (Exception e) {; e: O" n$ a3 n u
e.printStackTrace(System.err);
- t c- o( X C //System.out.println(e);
$ f! S9 M9 ?$ {0 s) o System.exit(1);
2 S2 }# W$ X9 p" j$ Z* o }# M$ H" b n- `. A& |
: k3 _9 o9 w" c. {# @
8 `, J0 \5 W% A _8 a5 c; A }
[, `4 v( b5 g" f& x3 b3 ~9 m+ P' ] g ]/ B5 o
private void swarmSetp() {' u$ X5 u4 r- G
list.addLast(new Agent(Id));& i' T7 u$ `6 c/ [
Id++;
, j6 V0 x9 B% z& R+ P2 N7 Q, Q }1 Z$ y1 }8 N& r* @
! @6 B+ R f/ Y) v
public Activity activateIn(Swarm context) {
; L+ D _+ E$ L% r9 l super.activateIn(context);
1 r2 ?: T. ^2 c; H4 O5 b9 _8 R& o2 P schedule.activateIn(this);! r$ q, p3 W" ?/ ^
return getActivity();
6 Z& y0 ^* a, k6 G2 | }
' Q9 @- f: q% L7 n$ L
1 ~6 N& e" c: }; L6 T public static void main(String[] args) {6 Q: W- B" g% ^( }
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
- H1 `1 _: o% a6 i Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);$ B0 i3 Z( `8 f8 d! ?
swarms.buildObjects();$ |8 p1 a1 I0 O3 r+ s* K/ @
swarms.buildActions();
6 Z- }6 Q. }( e1 p' I( Q swarms.activateIn(null).run(); \& e0 T1 Z v& ]. _) b
}
. L4 ^6 Z L4 t( \, \( g
+ x6 o7 o6 s% H9 N4 Z+ @} |
|