|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 ; [6 P+ b" _% ?4 ?. Z0 E
9 |8 g* A8 m7 x) h+ T0 j* S6 b本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
+ o% d) X5 N% x, y4 Y以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.6 ?# K5 X) t7 c6 b3 e6 O
swarm.SignatureNotFoundException( j5 J1 w/ Z w2 H" ^
at swarm.Selector.<init>(Selector.java:76)5 M7 ?% b* ]; R7 D
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
% h2 w( {6 _+ q0 A1 Z" H at ActionGroupDemo.main(ActionGroupDemo.java:67)! x: R, Y( Q5 a% q) S
- w" J* }: C( m A
% o7 w2 _$ P( I. q2 p
import swarm.objectbase.SwarmImpl;/ m; e3 ^; G' g& S( Q f( S
import swarm.objectbase.Swarm;
: O. r7 P/ n2 M7 W |7 ~import swarm.activity.ScheduleImpl;
: O h7 L+ t2 [9 l: }" l8 D( Aimport swarm.activity.Activity;
* |& {4 Z& X Wimport swarm.activity.ActionGroupImpl;
; z& d9 y1 E/ \2 F1 l7 bimport swarm.collections.ListImpl;
" Y. t* o/ Y6 h: Cimport swarm.defobj.Zone; 5 ]& t! u, j3 l) v3 s
import swarm.Globals;3 V) A8 H# j. o' h: y% {3 H
import swarm.Selector;
' Q/ \! _& B. y& V/ D+ Oimport swarm.activity.ActionGroup; # R1 f: w& f$ @3 e
class Agent {& v9 L9 ^2 S- u1 @- W1 i3 i
char id;
; \/ N: h9 v. O. G9 h
# @7 j* X1 p% \5 M- h6 ~7 I' s Agent(char id) {
9 s; D% L p p, o3 F' G3 E5 ? this.id = id; q( Z. P# d& Q4 u% v
}
* ]# A9 {1 C! a
0 x, ]1 a9 q& @: x6 g: w( X public void agentStep() { S3 W" w+ t( R
System.out.println(id + ":" + Globals.env.getCurrentTime());
" m# |' y8 `- g& L }5 J7 P- Z r! K
}+ X4 ?+ U8 \. h8 j/ C
9 i4 [$ h" d9 z/ ] t
public class ActionGroupDemo extends SwarmImpl {3 I0 q+ z/ _, G- v
ScheduleImpl schedule;( o' ]/ F/ ?0 C1 B, F5 O
ActionGroupImpl actionGroup;
) }- w+ V Y0 X5 k4 U ListImpl list;; ^) R# i) U# _9 i& f/ c# p
char Id = 'a';
- Y! O1 j& d. {- x) c: j, A
& O9 H; P; D3 F4 f ActionGroupDemo(Zone aZone) {, W$ c) X1 r$ c: ^' X1 o! h) q3 O* r
super(aZone);
7 H t; s2 v& f5 ^ list = new ListImpl(aZone);
; _% g1 ^1 ?4 C9 n) F/ z swarmSetp();2 |6 e. m: c0 C) m
actionGroup = new ActionGroupImpl(aZone);1 h( E7 E9 i8 H! s
schedule = new ScheduleImpl(aZone);1 k& a) N! c0 ~) b3 Q
try {
; J* a+ E+ F# d% T Selector agentSel = new Selector(Agent.class, "agentStep", false);6 Z+ `4 Q4 R" r9 q6 X) B7 T, P
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行" z) T% Q I& R7 m. a! N) P) E
$ |2 g$ ~8 \) R' g" h
actionGroup.createActionForEach$message(list, agentSel);, e6 R* x" I, v9 i7 Z
actionGroup.createActionTo$message(this, swarmSel);
7 m! G! Z$ [" R; _' N4 u schedule.at$createAction(0, actionGroup);
/ u* [4 W- X+ y) c schedule.at$createAction(1, actionGroup);
2 g8 w& }9 f" h& F p% R1 c schedule.at$createAction(2, actionGroup);
$ @: V e4 {! @& G9 }) P. R9 F2 v9 G% G; U( F$ I# l( H3 t
} catch (Exception e) {
g7 r$ I& r7 g6 V: K e.printStackTrace(System.err);! }3 Q. I: t/ Y4 K x; c
//System.out.println(e);
9 s6 F7 q# t) V( G+ T System.exit(1);+ L( P, m/ T! b6 t) {
}
1 q: t. Q# [! N4 s( E$ `& H4 a$ _% ^/ p( ^! j% m7 m! o+ b
! m0 ?! W0 P+ Z1 P9 E2 ~' C7 S& A }
0 V. j8 z# L6 V# d0 r( ]' ^2 O5 E1 f( X. v
private void swarmSetp() {
" A1 L- `1 j# L, X4 X) Z list.addLast(new Agent(Id));
2 Q0 z8 ?2 L) m" d Id++;( j9 x0 N7 q$ P6 \, T
}
* Q$ l2 u# {! o8 x6 I! F1 o9 J& \% \
public Activity activateIn(Swarm context) {
" [' ^8 u" I' T/ O3 K# { ]: y- ] super.activateIn(context);
2 A7 ^6 F/ X y l4 K# Y+ V2 f/ V schedule.activateIn(this);4 Y% }+ k# x+ Q" V( |2 _
return getActivity();. `2 |8 C5 M0 c) ~( B6 M$ b
}8 \$ e% W5 l) V
* ?5 u& ~1 o3 H; W5 P
public static void main(String[] args) {
) O. x) h7 a; N Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
7 \/ w: c$ Q3 G# J7 l0 ^ Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);8 ]) E/ w. V1 b' Q$ L
swarms.buildObjects();& I8 p: x. ]0 \# o. I
swarms.buildActions();
6 K; @- i5 N! C6 N6 \ swarms.activateIn(null).run();
8 s1 B1 k4 p& _+ g) e1 }# W0 @ }
) y! B" N7 c C n) z! l, q/ }2 W/ H% C8 X# C8 d9 j T( K
} |
|