|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
. A% c: ~9 p+ N5 R, V* ?; {3 y- J+ c
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
) k; m) N( U+ X R- B以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.3 g+ W+ y8 M+ |: b; m1 Y
swarm.SignatureNotFoundException# A) i2 e. f8 t
at swarm.Selector.<init>(Selector.java:76)8 k/ u' I1 \- A$ X: s
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
/ [% v4 U ]- _ at ActionGroupDemo.main(ActionGroupDemo.java:67)
x+ C, x3 a. t* r8 a9 {; W1 X ]- o9 `9 j
; n6 G$ r. d/ b6 |! r- s+ I& c) u9 w
import swarm.objectbase.SwarmImpl;
& q5 R8 H$ C3 m( }8 M5 ~2 |7 Iimport swarm.objectbase.Swarm;
# ?" p! `' g( j3 ^: P2 ~3 Mimport swarm.activity.ScheduleImpl;
5 t6 ~; T- S! @4 vimport swarm.activity.Activity;" W \6 Y7 H) O6 g$ z
import swarm.activity.ActionGroupImpl;! Q( _4 a) _, J$ v6 P$ _
import swarm.collections.ListImpl;6 A. _! K7 K: W3 q0 T
import swarm.defobj.Zone;
' s0 V4 i4 m) }8 y- y+ Jimport swarm.Globals;
- q* r+ m/ i, r" y. u- p1 {# Pimport swarm.Selector;
1 o* R, }2 @4 ?/ a8 X( fimport swarm.activity.ActionGroup; ) i% {* f. S0 D
class Agent {
( |. K" ]7 @0 @- Z) v- V char id;( h' w A7 m+ V) U! R2 R. y6 j
. S) J& `- g Q' |. z, w$ P Agent(char id) {# \" t7 ^. C3 I3 }1 C" `) I# k" Z0 c
this.id = id;
5 v* }/ U& r/ r6 [ }
$ s! J" g- N) W( }+ s/ R9 L( I4 Y
( ^2 g0 O1 S) @* q1 p public void agentStep() {+ t) F+ O1 |# B8 t5 j
System.out.println(id + ":" + Globals.env.getCurrentTime());9 R' v) y" ~ p# G3 [/ m* Y' m& t" M
}
/ u2 l' E0 n$ d}
1 \6 k7 f. ?' H& H
0 ]% P5 x' W" s8 f9 r/ b. f6 h- \public class ActionGroupDemo extends SwarmImpl {7 @: x2 K( |4 H+ r( m; W
ScheduleImpl schedule;/ \' R S: x- P1 B5 J; _; k
ActionGroupImpl actionGroup;
& k; S+ e4 A" Q5 a6 x5 C ListImpl list;
& y/ U7 g. C. ^& y3 W4 v char Id = 'a';8 c: N" A1 q/ r4 u; G; Z
$ u3 i& x. z5 O7 m ActionGroupDemo(Zone aZone) {
7 j( M( `& t$ Q! C' t) i super(aZone);+ {8 W q3 _& F- w3 W$ S1 u
list = new ListImpl(aZone);
0 R: q3 g& s1 A7 b swarmSetp();
5 M# \+ r( |) I& k# R# O# q actionGroup = new ActionGroupImpl(aZone);
0 |% r3 d: h3 x schedule = new ScheduleImpl(aZone); d+ A5 b, R! w+ _
try {
; T) A, E* u, w% u Selector agentSel = new Selector(Agent.class, "agentStep", false);
! X3 r9 B5 E% s0 d: J& {$ S Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
" V- \% W: G. F' X
: ~: g; L+ k9 N( O0 Z1 B actionGroup.createActionForEach$message(list, agentSel);3 i ^6 d0 D, u
actionGroup.createActionTo$message(this, swarmSel);
% h* h4 ]# [7 c3 O+ o) ^" \% x) U schedule.at$createAction(0, actionGroup);
/ x- o" ^ |$ Y! m5 M schedule.at$createAction(1, actionGroup);
7 P: y. G5 A- n2 ]: J schedule.at$createAction(2, actionGroup);
8 ~: V7 q5 E3 W
$ e0 F0 e: j: {& x( k" k" F2 K } catch (Exception e) {7 ^) b2 c% l1 p0 _; |( [6 f1 c5 ]
e.printStackTrace(System.err);
* e+ F0 K3 {0 R" J0 l5 { //System.out.println(e);9 N! h. z; Q. n X& a/ P
System.exit(1);
0 z+ l0 u; C% t& g. C }" Z& Y$ T1 v5 F$ z* X
1 E: o4 e; N, ^- n1 _
/ |/ l; m* x6 d/ q6 A+ W8 ^ }, @9 G$ q# ~% c4 T% d" T2 ?
7 K3 \; ? i& J$ o$ B7 b! c
private void swarmSetp() {2 f6 ?2 U4 F1 {& b* j ?/ @
list.addLast(new Agent(Id));5 y9 |" M& S, v/ s* Z K( r! Q
Id++;9 B1 z2 \/ W( d" D7 b: D$ l
}
' w( h" e T! N3 \5 R( H+ h1 |& P! X
public Activity activateIn(Swarm context) {: L1 X& a) C& J+ `
super.activateIn(context);' P& o" n/ S) H
schedule.activateIn(this);
T" Q/ w4 j1 r: C return getActivity();) x$ {. ? X8 {3 A* D A
}
% W. T0 s8 |* q7 E$ E# N ?3 ?5 |( p( f8 j+ l8 }
public static void main(String[] args) {
2 j3 h& N' w; l; F& Y1 n Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args); `! s/ J6 N3 n3 b2 A R; V- O
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
) q) z7 T. q! v2 Z' a4 t+ \/ D6 g swarms.buildObjects();: h. b5 E) O" \) o5 ?# S- F7 |. M3 R. y
swarms.buildActions();
8 ^$ i2 Z1 N& j6 Z& l swarms.activateIn(null).run();
6 z$ i4 d6 u# E& g' J1 u }' ]7 x9 b9 t4 ]1 I1 v
4 _! f/ r. A/ q4 }! n: z( y
} |
|