|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
' i; a, g, {1 f3 L+ g. m. X8 c0 {( p d2 |8 M3 [ t8 h
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
" v3 I3 B+ n- A; p# s9 g8 J' H以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
+ ]1 U$ O# L2 Yswarm.SignatureNotFoundException" e9 q# P. D2 d+ A" J
at swarm.Selector.<init>(Selector.java:76)5 |0 U% g! z/ ] @
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)7 j, H8 G' f5 ^* b% z3 ]7 j
at ActionGroupDemo.main(ActionGroupDemo.java:67); M" B5 ?: V9 T0 B3 \* F
1 h, i, a. G. u: Q' U
( B4 B1 n/ ^7 M' m& c
import swarm.objectbase.SwarmImpl;
, e% D# Y4 _7 m9 simport swarm.objectbase.Swarm;
1 g# Z5 ^ k$ t1 \' ~* J9 Limport swarm.activity.ScheduleImpl;
9 W" s `$ S& a1 K$ Zimport swarm.activity.Activity;4 o" U! m, V+ t8 Y' _6 v
import swarm.activity.ActionGroupImpl;
. g+ g8 L+ I6 o* |. g' Simport swarm.collections.ListImpl;
$ z; o0 u/ h- Fimport swarm.defobj.Zone; 5 b/ {$ P) a3 @
import swarm.Globals;0 y' }2 O5 N, o, E& }: f
import swarm.Selector;
7 |; R1 ]5 u; eimport swarm.activity.ActionGroup;
' q6 ^4 D$ j o7 Vclass Agent {
5 R; }, t6 b- w. F* G0 ` char id;
' u3 S6 j, K, R& S; E; v5 O m5 Y6 F ?4 k3 J; b6 D) F/ W1 |
Agent(char id) {
- V i1 R& K- c/ E7 S: A' O7 Q this.id = id;3 j2 h+ ]4 |7 B+ s, O! c
}! E4 C# p. f0 M. W
: Y, n- u2 \1 Z' K* c0 m
public void agentStep() {5 ^6 `% E( C0 y/ q
System.out.println(id + ":" + Globals.env.getCurrentTime());! Z6 h+ ^, g) H7 w5 B8 K, p& F) k
}
# m4 I; H1 d+ z& o8 X& ~}
9 z' D% f O2 X* p, K0 x8 h, M( r
/ A$ i0 h8 l$ M" g: O& B7 apublic class ActionGroupDemo extends SwarmImpl {
- I$ s3 f5 O1 c, m ScheduleImpl schedule;
3 F" D4 M9 Z% \ V5 S ActionGroupImpl actionGroup;
4 S4 Q" a r! t5 N# f* s5 J9 C ListImpl list;
: s8 O# @9 a/ C char Id = 'a';0 }. a4 `5 ~1 h7 s8 U" c+ S
& L! m. N3 P: y; z# m ActionGroupDemo(Zone aZone) {& E- J3 I& i0 E: M7 I
super(aZone);
6 c3 }! n" }! E list = new ListImpl(aZone);
+ E; y: V; @# X8 G' D- `2 u swarmSetp();: l F- ^" L' E" ]" o+ Y% k
actionGroup = new ActionGroupImpl(aZone);# b7 @9 p2 L* r$ T$ h& e/ ~# G
schedule = new ScheduleImpl(aZone);! b8 C* m. l' T
try {/ [& c, s4 F3 A9 K/ X) a) q
Selector agentSel = new Selector(Agent.class, "agentStep", false);
9 h* a) Y9 H! @3 W8 Z! p Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行 B& G( i9 _( \: S9 u
6 i: w4 N" i% R
actionGroup.createActionForEach$message(list, agentSel);
4 ^/ M5 z$ o" y% ]1 z( i5 A. y actionGroup.createActionTo$message(this, swarmSel);% S& P5 l$ q" t/ Y. C) B7 z
schedule.at$createAction(0, actionGroup);. i# Q3 v/ a6 c2 z+ _' L
schedule.at$createAction(1, actionGroup);5 E' P7 `7 C6 y- o6 {
schedule.at$createAction(2, actionGroup);
7 O3 Y) {# O8 X. q9 y( }2 h, q1 O1 R; @
} catch (Exception e) {
# q4 w9 E) g. B, e) K e.printStackTrace(System.err);% D9 a8 W- ~* B4 J) O2 N6 ` d& g
//System.out.println(e);, L% R# u+ {4 P$ |( A
System.exit(1);- w1 f+ n* v: i( M W* S& y2 T
}
4 a# o) s! ]9 I9 J( V% K) y2 K% N) [( {2 ~) i, M8 u0 h
; u+ U4 @6 q- O3 o }
- B4 c! W& _6 J1 z2 a( w) I. S8 g* P
1 s! v9 R6 W) \. u private void swarmSetp() {* e% V# T4 w: u( T3 y# g
list.addLast(new Agent(Id));9 V5 C4 [' S& p S3 j# J; V1 n. R
Id++;( w% U9 b) O- U$ u+ P- i/ V
}
4 K7 b* m! ^: B1 X2 m; `
5 p/ s$ ^2 |! Q" x9 X4 k public Activity activateIn(Swarm context) {) j, t/ _+ H0 B4 g
super.activateIn(context);
; O: m5 ?5 c9 B1 i+ T schedule.activateIn(this);- j3 j7 V. e' i+ v3 H! @4 N6 M
return getActivity();
' k# x! i5 i; |% I, B& w) n }
5 c: n# i: X J u9 c9 |: Q4 j2 N: A
, d4 l: c' m/ ] public static void main(String[] args) {
' H$ B, ^+ s# s0 K+ X' R' t% H Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
! ?; z! H3 P$ x( s Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);0 G( X) Q! g% e, X0 y8 U
swarms.buildObjects();
$ C$ }! P7 k# J/ l swarms.buildActions();+ c$ P! C% S' M2 M
swarms.activateIn(null).run();! C" ~( b" c: |9 ]
}
. v! g8 y2 h0 |& I# p3 ^# j2 ~/ o% g! J6 a- T0 o0 i; M& c1 `
} |
|