|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
% y" ?9 {* ^ g
5 F/ b$ }2 F# U! b本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21$ m7 t7 @, }6 j8 b C0 D
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.8 I/ j% [, F" k Y7 J1 F z
swarm.SignatureNotFoundException8 p: V& @" A6 `% F3 {9 o7 @
at swarm.Selector.<init>(Selector.java:76)
; B, Z! N9 n: e+ h* H. Z at ActionGroupDemo.<init>(ActionGroupDemo.java:37)) T% L) o9 P2 k: L$ c7 D3 f5 d
at ActionGroupDemo.main(ActionGroupDemo.java:67)5 P2 R- v9 n! p( v# Y; w% p
! n ?% @5 ]: k1 t: {
) d& T3 [8 I0 A7 ~" `9 E* q; S
import swarm.objectbase.SwarmImpl;6 b u" U( g' D3 O# z
import swarm.objectbase.Swarm;
% d/ `1 S5 d1 t# Y g4 u8 E3 }import swarm.activity.ScheduleImpl;" I" o; k1 d' @5 b/ Z/ t
import swarm.activity.Activity;
' B/ m% u! W' y ~2 n, c4 jimport swarm.activity.ActionGroupImpl; ] z1 t( D% H) H" E+ @/ y* B4 h
import swarm.collections.ListImpl;
[" T7 B% s+ I& `* J) mimport swarm.defobj.Zone; ; c6 h2 R% j' R$ s
import swarm.Globals;9 f7 `: L) H# O
import swarm.Selector;6 v; w3 u+ x- R" c% {! a
import swarm.activity.ActionGroup; ' V' h9 k; z# z8 s0 P5 I
class Agent {' S" K0 Q4 ^" P9 O2 Q Q8 |) l
char id;& R, W5 o) @; g6 G" S
. f% o' m) a' _1 G) Q1 ? Agent(char id) {
3 K/ ^+ J7 s$ i( L+ X9 i this.id = id;
`" P6 L$ W( @ \' D3 t } }( k* X5 K; s4 Y* D M
8 [" Q5 E" l$ A* t0 w1 [" e- t+ N public void agentStep() {9 Q, R/ o( h. ~ O5 Z" x/ ]
System.out.println(id + ":" + Globals.env.getCurrentTime());5 X8 [0 Z7 r, v6 i
}7 \2 F; f% g- y' I O4 @8 b) f
}! z+ l8 |) T/ @3 y x3 S
9 |& b: z0 z3 p$ E- l( E3 j. W
public class ActionGroupDemo extends SwarmImpl {
% F1 d9 y9 m V/ k; p" f6 j ScheduleImpl schedule;
( r+ p; V# a7 N/ g( D ActionGroupImpl actionGroup;- x# J* l- r4 M9 g( u1 W2 D2 i
ListImpl list;
, c* T4 y4 ` G$ ]0 i1 Q0 H) Y& l char Id = 'a';
7 ^5 G. j9 ~& Q3 X3 B+ E- A5 N
4 u) S: M% ~' u& c6 C( z7 C ActionGroupDemo(Zone aZone) {# T e) k/ e# r3 z! i5 s5 w. Z
super(aZone);
( u9 `+ n4 o) P; x( g list = new ListImpl(aZone);5 }6 t D% Q! @6 R! A
swarmSetp();
) J# c) k4 W' \* u actionGroup = new ActionGroupImpl(aZone);+ G7 S0 c" p: v- u# Q) t
schedule = new ScheduleImpl(aZone);5 e+ X0 M7 |$ a# f
try {0 [7 e8 Q0 j9 Z/ M
Selector agentSel = new Selector(Agent.class, "agentStep", false);9 U K8 Q3 D1 a3 x. s' P! s6 ]: U
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行. z: r2 n i# W
1 h' h# u! N0 R3 g, Z. v8 b
actionGroup.createActionForEach$message(list, agentSel);$ v- @$ Y4 u2 m& d0 Q# P& `# g
actionGroup.createActionTo$message(this, swarmSel);
2 Y7 Q( b# x M+ e7 ^ schedule.at$createAction(0, actionGroup);+ N2 I7 ~& }! m u
schedule.at$createAction(1, actionGroup);: Z6 ^4 K: H' K, T: {2 x& R0 k
schedule.at$createAction(2, actionGroup);
- [5 _9 C4 J# c! t0 y- K7 [# J, o2 g5 |# q! b- w$ D
} catch (Exception e) {
! q2 e, t( c( j8 r. _* s6 y e.printStackTrace(System.err);
! L& _: r1 r6 C% _( V //System.out.println(e);
. S( p U4 {, W0 m6 w% P; |3 P System.exit(1);
U# `3 I5 V+ |6 _* z }
* d. f% V% _ _: o; J4 X$ ?) b& a8 b9 H/ j
- x! H: w# C$ v" M }
1 h4 ]1 G1 [* E2 A: c2 }% k$ \
& V$ s5 q( |' c! ^. q9 ~ private void swarmSetp() {
# s+ \, l, u" S5 I: O list.addLast(new Agent(Id));( K# K2 A! }! v; i" w4 ]
Id++;6 }( J5 @+ N: c8 k$ B% c
}
' t I G0 r& ~8 t* _6 |, O9 F4 B3 A4 K: g. U5 r
public Activity activateIn(Swarm context) {, n. S$ [6 N3 h. f- X4 g
super.activateIn(context);7 Y" B1 Q d# I* k, u1 n
schedule.activateIn(this);2 J% u+ U. B2 g. }. ]; s' F
return getActivity();
( E. E2 ?+ ` D) Y- j x! x }2 g4 |2 `1 C: i/ E2 `& O5 S
& B# a0 d3 q- ^" b- _/ d public static void main(String[] args) {; u# G: C+ O8 b# h* P
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
7 v8 p: g, U0 ^# }/ p9 k' T# ~ Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
2 X1 T+ Q9 ?0 S1 r+ }0 G | swarms.buildObjects();
J( M2 @: e8 U, g" ?+ Z p swarms.buildActions();
, }- O; B: W% o9 g swarms.activateIn(null).run();
( H7 E$ K/ Q! w1 Q) Y }
1 y: r7 M/ S8 s) f9 E, {# Z. H* J) ~8 V
} |
|