|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
: U- W( W& J b* r/ h- d5 D4 ^& o6 p
$ e9 N2 w5 {. K4 W本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
( v0 t- y; |' y" f/ N: r$ K/ M2 w* _以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激." y& j# T/ }: S: }/ e4 N) l' L% {
swarm.SignatureNotFoundException
( k, @0 R1 E# K, m8 ? at swarm.Selector.<init>(Selector.java:76); N1 _( m6 s, f2 k6 q) I. A
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)7 B" e6 K; b$ _9 N d! Y0 V
at ActionGroupDemo.main(ActionGroupDemo.java:67)/ y/ q& q6 d* V# s F9 {
+ ], y/ l c y9 y6 x3 ?6 `; P5 R+ O! J& q
import swarm.objectbase.SwarmImpl;
3 E: F6 z$ z$ c3 K) {import swarm.objectbase.Swarm;
/ V# t/ z9 L. c% R! O# jimport swarm.activity.ScheduleImpl;0 ^5 s8 o, d- u f: ?
import swarm.activity.Activity;
1 |- [( n7 _6 t, \$ ]' Q& E; f3 Rimport swarm.activity.ActionGroupImpl;
3 ?' O5 b$ `; m I7 @. w/ `+ kimport swarm.collections.ListImpl;( m) K+ \( l7 g/ X
import swarm.defobj.Zone; " f! T7 f2 [7 |. g2 g* ]
import swarm.Globals;
! S! @/ G* c- v6 \import swarm.Selector;
2 d9 T' o4 S% X' a$ bimport swarm.activity.ActionGroup; ( R4 g8 m/ ^7 Z5 O, A! S" P
class Agent {9 ~1 S) F. v O$ V2 x: b0 T- K, b& Q
char id;
( d. P4 q$ J0 f5 f* {3 M, S8 l( g6 { H
Agent(char id) {
a/ h4 @8 l) x this.id = id;0 d: V/ b, ~6 j' O# j- y: j8 f8 U
}1 H! X" ~+ F9 @# H n7 E) `
2 x; m7 k0 g9 V% r' E# q0 z public void agentStep() {
; r+ W4 M9 o: O: |5 o9 e8 E System.out.println(id + ":" + Globals.env.getCurrentTime());# v" Q% @: s }; p& V Q/ H
}
5 Q5 p( |5 @! `}6 M9 ^4 Q) f( g$ ~, z0 }' u2 m/ A
( T9 Z6 ~7 F9 w) ^% l
public class ActionGroupDemo extends SwarmImpl {
5 T" T, a% L3 {8 b c ScheduleImpl schedule;8 E, b# L) L5 ?3 z- v9 R/ {: T
ActionGroupImpl actionGroup;- A" x, x; ~0 J/ b3 }
ListImpl list;
& {2 ^0 C" p( Y" s" P) { char Id = 'a';
7 \3 T e- @! R- [3 `' t' ]; }# ~4 g7 f! _# M
ActionGroupDemo(Zone aZone) {
" p$ F- p" u [4 W2 M; J super(aZone);2 M, y8 h. [7 x+ Y7 `. b- k. V2 N
list = new ListImpl(aZone);
& R9 l7 A4 |9 @, D swarmSetp();
- X- n7 [1 `' b( b% q% x actionGroup = new ActionGroupImpl(aZone);8 h: i2 ?7 J6 R+ `, s
schedule = new ScheduleImpl(aZone);, R$ ~! Z0 J$ j
try {7 Q. f; i! C" M, z$ J
Selector agentSel = new Selector(Agent.class, "agentStep", false);1 C$ F% K! M& H7 m+ O7 X
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
* k) I. @1 ]1 q4 r- i" D+ L+ J 1 H8 ?2 Y' [3 o+ `9 u. c" |
actionGroup.createActionForEach$message(list, agentSel);, r* B, C9 n1 h3 g5 [, r8 A
actionGroup.createActionTo$message(this, swarmSel);
0 b" B' L6 B2 C schedule.at$createAction(0, actionGroup);- I+ D% ?* D$ @; m* t1 F/ i
schedule.at$createAction(1, actionGroup);& D! J, e+ T6 A i) \
schedule.at$createAction(2, actionGroup);
4 V/ X2 Y; m; Z% o7 ~% r5 B
" V9 s% s& w) f5 E3 J } catch (Exception e) {" E: s. j2 L3 s0 a( I! |/ v
e.printStackTrace(System.err);" @" y! ]4 F! p. i# ~) [ U: U
//System.out.println(e);
, I- M$ ?; E7 h) } System.exit(1);" s) p9 E# c! H
}9 |0 P1 |/ O) K+ ?
- m0 E ~" F' G5 a5 _$ R
# z! v# E8 J- o; F& K
}
# s# w% @( S: O" d5 k, m" k. D& X+ L! C: v. X0 S3 T& n( l
private void swarmSetp() {
0 M( @# c3 U4 ^# p list.addLast(new Agent(Id));
4 O# P8 B5 t' g) ]8 O9 Z3 ` Id++;& o" @0 S* Z% A* z5 I0 \
}
1 v5 ?/ R) f+ L5 K* M, ~2 G; d% i( \/ W w" K: }+ _, K$ G
public Activity activateIn(Swarm context) {
( Y1 e4 v9 \$ I' G) F super.activateIn(context);
& M; x- L; D i6 n8 \5 \4 c8 y+ {3 N: I schedule.activateIn(this);
L z; m* d9 ~2 f3 D return getActivity();' C9 [% G D9 G" H3 V$ Y% |
}
4 ~6 p; s* |1 ` |" C8 t" d
" w7 g% |1 u) g+ y: k1 _. V/ [6 o public static void main(String[] args) {/ s: _' c H3 {( o: ^ J
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
% h" B1 ~! `/ [. Z: S- y Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);& e }5 S# M: L# B+ O
swarms.buildObjects();
6 V- j+ p3 {6 z0 _) ?5 a; @) d swarms.buildActions(); {$ q* k- b; u1 A- A1 K b
swarms.activateIn(null).run();/ _% O# K# h5 ^+ P2 Y
}0 S! @) F8 H; c0 c9 z; Y' `" U
+ a' F1 C+ L4 \0 I$ O& q
} |
|