|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
. G) E7 A$ Q% {7 Z3 h( A6 t2 f3 o6 d7 Q# r
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update217 b6 _7 B N, w; |
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.2 `- p; k& Y( X0 H
swarm.SignatureNotFoundException5 x; N; ^4 }% p
at swarm.Selector.<init>(Selector.java:76)/ ^ N1 ?3 F0 |1 o
at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
# t; o( W5 H) X# _0 U- B4 L at ActionGroupDemo.main(ActionGroupDemo.java:67)
5 Z" r( j. A# R' A' o2 U! U n, y6 L& [* ?% v8 ?: _ X% ?0 g
/ X2 b- O9 k$ Yimport swarm.objectbase.SwarmImpl;
& s! \8 V; ?9 c! `import swarm.objectbase.Swarm;7 [+ v3 O0 d+ ^: E% p* w5 N
import swarm.activity.ScheduleImpl;; h* i6 }3 ~: D, U3 }
import swarm.activity.Activity;7 ?9 s1 Z6 s% N1 S# C
import swarm.activity.ActionGroupImpl;0 e6 B2 R8 g" e, w
import swarm.collections.ListImpl;" T% l1 w6 l" ]- f; E1 S& _
import swarm.defobj.Zone; & D! T6 N/ z0 f8 l
import swarm.Globals;+ |7 r5 [1 c+ S& P; o {0 {
import swarm.Selector;# y1 Q" k) s0 n6 H$ C3 d6 s$ u$ J
import swarm.activity.ActionGroup;
. V5 j- m/ m- u+ V4 N3 H1 yclass Agent {/ ^& v$ g6 |6 n) }5 ^% p6 w' C
char id;
7 B: Y4 @. Q: y' o! ]# T+ E: g2 F0 Q L/ W& g" b
Agent(char id) {
7 z4 p9 z O% i0 P" O0 f# u this.id = id;
* G" H/ c" t3 L* G, n+ _" ~ }
+ |% Y5 z4 u2 O, g3 ^/ K/ Y4 \7 X8 d `* N# Y2 Z
public void agentStep() {0 h( N( ~, g4 l5 E
System.out.println(id + ":" + Globals.env.getCurrentTime());) n7 u8 p0 y, d7 P3 U
}9 V8 s4 |* d0 k) t& ^/ ~
}" {7 c1 o* x- G* Q, j; D
2 ?* w N8 l8 Cpublic class ActionGroupDemo extends SwarmImpl {& r1 p8 [& c- a9 N Q9 L
ScheduleImpl schedule;
5 q) g% r, N2 F9 D' x ActionGroupImpl actionGroup;8 W s8 C" U. I A7 M8 }. X
ListImpl list;5 T4 f& Y; ]' M. g) l
char Id = 'a';
" k$ C5 V. S0 n* n Q0 {! D7 M* d$ ]$ i
ActionGroupDemo(Zone aZone) {
) r3 }$ U- [0 ^ super(aZone);7 J5 k3 e3 a/ ~$ `8 b
list = new ListImpl(aZone);; Q) f3 r& n" k/ r8 @# M4 L
swarmSetp();; ^) q% \- d8 l! W2 ~( m! Z( K, O1 x" A
actionGroup = new ActionGroupImpl(aZone);% h6 E+ L( S2 Q5 e- U' O& f; W# A5 N
schedule = new ScheduleImpl(aZone);
$ g0 r, v! a& G9 i4 _! ?' l try {. g- n1 X ^: y. \7 I8 Z
Selector agentSel = new Selector(Agent.class, "agentStep", false);
& a4 G4 f# e( G0 T5 K Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
) p! @; ?! T" B: [( C " G! q7 d6 M5 Y6 _$ }
actionGroup.createActionForEach$message(list, agentSel);' y4 {3 s$ i5 g0 M
actionGroup.createActionTo$message(this, swarmSel);
& R/ f! ?# K- y. j$ V3 G schedule.at$createAction(0, actionGroup);
* J9 i! p7 w t schedule.at$createAction(1, actionGroup);) S9 Q% d/ L/ P0 Z3 x( ^. K& t
schedule.at$createAction(2, actionGroup);$ k: P* `: N: f( }2 ]
7 U" J- k9 r4 B
} catch (Exception e) {
- [5 J: F4 ?1 S8 w8 u( u/ P& }* Y e.printStackTrace(System.err);
' I* u$ Z+ O% `0 P: U //System.out.println(e);7 ?1 y( ?9 K+ s/ q. I5 B: v
System.exit(1);
' q: x) S7 n) k6 y% V: e }
; z# ]6 H0 L- T+ M: U1 P. \7 @( S
2 U. s! q/ W" t0 a& b0 u }
* p2 u+ q5 P; u; ]
4 W& q6 z+ e, g private void swarmSetp() {
' s' A; f' V- n( r2 ^/ D list.addLast(new Agent(Id));
8 l9 @$ W6 y0 E Id++;
" S: C& e3 e' U* b* o$ l }$ \( l+ M0 F' u
9 o: Z- s2 a6 g7 b public Activity activateIn(Swarm context) {+ h9 g$ o! s2 }
super.activateIn(context);
" d" ^$ ?& k' D6 p9 Q schedule.activateIn(this);% o' E ?& [/ _/ @' {% {$ t
return getActivity();9 i' |& i9 C5 t- f8 a6 f9 u
}3 O) o' |, O. [! a F
' X' ~5 C6 r i! l, M( b, J
public static void main(String[] args) {% d* Q8 X I K
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);. l/ e+ K0 x M$ }" e% m" R
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);$ f ~7 N; {# m: r$ l' ^
swarms.buildObjects();* o' c9 F$ ]( I' D9 w" Z
swarms.buildActions();1 w/ m% U8 n( i, p, {' ?; W1 F2 @
swarms.activateIn(null).run();
: }% Y& T4 s h }" c ?, H, g/ a0 N% Z
e9 P8 ~. P2 [; u+ X} |
|