|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
! [* i' X3 {( }, \- c) i2 {7 g8 P; [, ]+ e: J
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21+ v: c1 Y, L0 W; A9 u- \
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.+ C! i- M# z+ K* {. m7 Q+ G7 z6 Z
swarm.SignatureNotFoundException- [! y( Z& ~% ?2 n" x! E
at swarm.Selector.<init>(Selector.java:76)
1 F" h$ @; g; ?. ^5 y at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
$ d) ]5 l9 q) s s# ?; Z) k at ActionGroupDemo.main(ActionGroupDemo.java:67): Z2 o, o- x/ F/ H5 d
, f8 R' g7 L, l( M" @
; `7 A: A' O( S P
import swarm.objectbase.SwarmImpl;2 W' p# a0 k! f8 A ~6 m
import swarm.objectbase.Swarm;3 z. M" b! S, b" K
import swarm.activity.ScheduleImpl;
( s1 i6 ~5 z# i4 F! I7 s3 y# ^import swarm.activity.Activity;9 ?1 x" ~/ i8 }8 x, [
import swarm.activity.ActionGroupImpl;
5 T- y* u9 O) |import swarm.collections.ListImpl;
/ q7 {+ n6 s) M# f! Iimport swarm.defobj.Zone; ( x% u/ |& b! _8 H
import swarm.Globals;
! l5 Q7 I+ l4 U+ D2 Dimport swarm.Selector;' t6 W4 H5 n. ~; x' H
import swarm.activity.ActionGroup; : z# n* Q, Z. j- {. @- n
class Agent {( |9 k" o8 N% v4 L: q
char id;
& ]) U3 G5 `3 `7 K, B0 c( l+ V @& O1 Q$ d. b
Agent(char id) { K2 Z- n' E% P8 k# {+ J
this.id = id;5 r4 V( {9 A z: R* ]0 U% z
}/ {% |' Z: k$ I9 I0 ~" [% O
% L9 B. ^4 p9 I5 o4 C+ g
public void agentStep() {- g* L Z' `' K
System.out.println(id + ":" + Globals.env.getCurrentTime());
! {8 ?8 A# A9 T; c% n( M' G }, {+ B( V& ~! A$ f+ h5 D! ?
}% ^% h2 y1 E8 M' O/ F$ s# \+ t
0 j. v( ~; D8 k. f" z
public class ActionGroupDemo extends SwarmImpl {
]) K7 {! Y' \- a8 c( F2 d ScheduleImpl schedule;
2 v: \9 x$ j. H8 r6 `# T( g ActionGroupImpl actionGroup;
5 a1 K& p) Z6 F- z+ p: y ListImpl list;( N. O9 p' D/ x, R! |, ?$ w* Z( n
char Id = 'a';2 @8 S$ Z" R# E( G
* u; J- u2 `0 [4 ~% j+ ]/ |
ActionGroupDemo(Zone aZone) {) n/ {0 d0 [7 Q/ K8 e5 ]6 ^7 T \
super(aZone);* j% B- B% s. J' {
list = new ListImpl(aZone);
8 ]8 V( \7 Z$ Z* d2 f7 Z swarmSetp();
& e Q1 p% X2 H$ ?2 [ actionGroup = new ActionGroupImpl(aZone);
* m# t) Z1 M+ r schedule = new ScheduleImpl(aZone);
' P f' S. S6 c! J L, p try {/ ~5 }0 j' N0 F8 O: y
Selector agentSel = new Selector(Agent.class, "agentStep", false);/ _9 h8 U* D: I8 g) S6 g/ e
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
. W7 v6 A8 Z) v0 ^7 _
( c, ]4 w6 R. T7 r: o8 M actionGroup.createActionForEach$message(list, agentSel);
9 f% C- o, }3 y" m0 W actionGroup.createActionTo$message(this, swarmSel);$ V, F( ?3 g" k3 [$ O: y5 W% x) ~
schedule.at$createAction(0, actionGroup);
$ _( j1 c9 d+ m, q! ] schedule.at$createAction(1, actionGroup);! c, m9 C* m; E/ G% W4 i# }
schedule.at$createAction(2, actionGroup);
7 r1 r! ?: z9 S2 [6 W
0 S: r7 L* r9 m7 {! _; H8 n: i6 n0 r N } catch (Exception e) {
8 k5 c1 N) m* t. J A+ R e.printStackTrace(System.err);7 D. u0 q& I2 p0 L c) U
//System.out.println(e);
+ I5 P/ ]5 {0 w ]( Y System.exit(1);* r8 n5 S: ~" N8 ~; S) g
}1 p0 \7 d5 Z; H/ k
- `+ q) U6 q) I4 [6 L- a3 j* P. U# u- q7 h
# L. l; f2 e1 q; [) P; C }- f) @4 c6 ^/ D
! d! A- ~& F9 L: d* g4 I private void swarmSetp() {* N. `( S9 @3 g( H
list.addLast(new Agent(Id));
7 ~1 U% {# v* X5 P$ } Id++;
9 M/ H9 b6 R) D' A }+ ~$ e# `" f9 A' R
! d7 D- d Y4 |7 S2 U, a q
public Activity activateIn(Swarm context) {. H0 y; F* ?0 S, ?2 @1 }
super.activateIn(context);
7 O, r9 R! I6 S( G9 H5 W" U2 Y6 x schedule.activateIn(this);" w, r% ^# l {$ `6 s! J
return getActivity();5 c& Z) u% o8 i+ [
}, y' v* G+ Q' K- `* Z+ t
9 N% L, v! z) t* @
public static void main(String[] args) {' \( O- a+ j$ ^; P3 v' d7 }
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
) R# S( e+ L9 ~" s7 _( `( g+ H3 i' W, ? Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);9 {$ h$ E' G6 V- c1 w- `
swarms.buildObjects();/ k! I6 _2 m O+ _" |. `! ]
swarms.buildActions();
! B0 F; B( ?" [& t2 E swarms.activateIn(null).run();
9 r; w+ [( ?$ c. k2 j }
% x# F# g# k* h2 t
" V/ \$ x9 w3 o* ]7 l. a0 ~} |
|