|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
, ]% ^$ R& d% M l; ?& j6 R* A' A# P2 z
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
, x9 e2 X2 _5 M; Z1 e! }以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
$ C l/ P6 q( f1 ]swarm.SignatureNotFoundException' x; Z6 c" z9 i& O4 C
at swarm.Selector.<init>(Selector.java:76), E/ t3 D2 R& D
at ActionGroupDemo.<init>(ActionGroupDemo.java:37), P6 ?9 z j7 M$ z, M
at ActionGroupDemo.main(ActionGroupDemo.java:67)
3 ?3 L3 s! E' \
8 s6 v: G( I4 R8 \
" ^$ L- u" G8 T( G: O# Vimport swarm.objectbase.SwarmImpl;: u( D& o# }1 r$ F
import swarm.objectbase.Swarm;
# E% O9 p) B8 t8 Timport swarm.activity.ScheduleImpl;# \4 L, j2 J1 [3 }9 ]
import swarm.activity.Activity;# x8 v: o* F/ f( a* I
import swarm.activity.ActionGroupImpl;6 p1 B+ j& E- f8 B/ t
import swarm.collections.ListImpl;5 _7 n. o2 n) {. A* x4 z$ E" Q5 t7 T
import swarm.defobj.Zone;
5 z* M; `: ~- o# i1 s5 T$ I& V' s9 |import swarm.Globals;; s$ D1 C2 L# o5 w2 a) o d8 x" Q* o
import swarm.Selector;6 }1 X8 }' Z4 Q
import swarm.activity.ActionGroup;
6 z! S$ u8 o9 s; J" ]. J4 }( Hclass Agent {1 T- F7 w- q% O
char id;
$ m5 w' R% \% \
; M, b# M" `- U' F7 W' c Agent(char id) {
2 {* Z0 s. H) E; ^) v/ r: n this.id = id;5 [& v" h- M5 i- ^
} l9 q4 w) l+ y" {
% H( F" X0 R, a! [ G9 e
public void agentStep() {' {5 j& z9 c; n6 }2 a
System.out.println(id + ":" + Globals.env.getCurrentTime());
9 T a" Y- `" J' f }0 s+ E y9 N8 F; o0 L; O
}# I' g$ W1 H% K* x4 X! q
* j& B+ H# m- }6 C4 F: r
public class ActionGroupDemo extends SwarmImpl {: W! \; B) i% O S8 O" _) g* [) v
ScheduleImpl schedule;
3 ^: C% n- ` c9 [1 C) c& E$ u ActionGroupImpl actionGroup;) H2 u! Z* }* U* n6 z
ListImpl list;
" O7 {* }0 z n) f! q char Id = 'a'; H" d- A9 Q' P6 C9 B; n
' i( @ q) E. w( R+ I ActionGroupDemo(Zone aZone) {
4 V/ Q' l, T1 Z9 R8 r3 u# \ super(aZone);
! J* @: I5 N- Z3 q' O list = new ListImpl(aZone);
8 Z: X2 N0 ~0 N9 I7 w% | swarmSetp();% e& M( Z/ Q s* t4 ?% h2 g! C# \$ K
actionGroup = new ActionGroupImpl(aZone);, Y* b; D6 n( ^
schedule = new ScheduleImpl(aZone);! y" u7 g' s9 L b
try {( T, k; g* @& h, P
Selector agentSel = new Selector(Agent.class, "agentStep", false);9 E8 L$ B$ I, j, F* X+ P4 {( w3 g
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
5 H4 K8 k' p- E! S 3 x) i+ b6 t! I/ C6 s
actionGroup.createActionForEach$message(list, agentSel);; F5 P! ^7 y5 q& p# | d
actionGroup.createActionTo$message(this, swarmSel);1 y2 i* w8 @/ N( x) G& W
schedule.at$createAction(0, actionGroup);. Z- @7 ]' g Z; H# B" A
schedule.at$createAction(1, actionGroup);5 z6 |. F3 s% |( S! K: j
schedule.at$createAction(2, actionGroup);
4 c/ x2 b3 j' f% _0 u% L. X
, y7 v+ |$ U2 Z' P6 z } catch (Exception e) {
% g3 u+ i- z9 t2 S- u% D( M e.printStackTrace(System.err);
7 }- [0 x# s# H& |, f9 z //System.out.println(e);1 r& J3 {7 q+ ~! O. {
System.exit(1);
6 u! l/ f6 J4 _. b: |) \1 s) [ }) a% h0 _0 I2 k) Q
1 I6 l' `, U; \4 q6 m0 w$ w
+ T- ~, d d+ [5 k: E, E1 r }4 {0 g3 Z# P7 x' ^
1 k7 j8 I6 ^& C4 Q3 [ private void swarmSetp() {
1 {0 h: |: Q3 m list.addLast(new Agent(Id));
, I3 C+ L0 _ U; j Id++; j$ s. d) k- E: l6 Y" [
}
' `6 E6 a4 s- Q6 p
% ^- x3 O9 J T& p* H' s6 {; ]1 O public Activity activateIn(Swarm context) {
1 ?* H& a- U- I4 U+ K# p. p M' f" y super.activateIn(context);; p7 A F1 ~( N' u
schedule.activateIn(this); ?1 A+ Q8 ~- f/ |1 Q2 s
return getActivity();
: J. E0 y0 u; Q. k1 k- c }
3 X* F" Y3 @- u+ p, u5 _; |
8 V. X* F1 u: N2 h, b3 B public static void main(String[] args) {3 l1 z) r! `4 A: M
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
/ n, a, O ]2 u# R9 C2 [; G* ? Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);; n, I, @, G. H4 w
swarms.buildObjects();
& H9 v6 s7 S6 J" g8 B0 F swarms.buildActions();. N: T) j" Y' v! b. \2 k* u' U" ^) @
swarms.activateIn(null).run();) {$ M+ q r& l
}
! ^9 y% T/ ]) m/ h' B6 M- v. L
; ] l# C" {- \8 H- m& ^& P" G} |
|