|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 & x& J' e( r x
( D' B; y' T# S* _5 Z C* S& Y本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update217 _ `' T4 `( N1 A
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.
N! w2 H) B5 n" B$ bswarm.SignatureNotFoundException P7 [5 |. D7 V/ N6 K* Q
at swarm.Selector.<init>(Selector.java:76)
; m( r, I6 r; a& S8 P- B: o6 G at ActionGroupDemo.<init>(ActionGroupDemo.java:37)1 G! a4 I- S0 j9 A$ W" K
at ActionGroupDemo.main(ActionGroupDemo.java:67)
) |3 t4 w2 T) ~& s. q0 P/ x5 |( A$ J3 Q
- p! E( C; Q) \0 e {# uimport swarm.objectbase.SwarmImpl;0 n4 j* N9 H- U
import swarm.objectbase.Swarm;: N% b3 O& S0 i) J: z% _+ e: I
import swarm.activity.ScheduleImpl;4 j" m- R5 q( u L1 s' E0 W
import swarm.activity.Activity;
3 p, R: a7 Q- r# {' K3 x' aimport swarm.activity.ActionGroupImpl;
9 d0 A9 t Y7 v" cimport swarm.collections.ListImpl;0 P2 |0 S. P; G, C& D0 z
import swarm.defobj.Zone;
4 p f$ r8 [. p. \import swarm.Globals;5 X4 f1 x* v H# ]
import swarm.Selector;
+ j9 y" G y0 A/ i+ f: Y) oimport swarm.activity.ActionGroup; 0 P( C9 H( s% V- N, X4 I _
class Agent {
w& W# L$ C0 J6 T char id;* f* e4 A& w" E) A
* D2 B: I% I0 {* |0 y
Agent(char id) {% _# c7 D6 F% x' ^+ C
this.id = id;
: ^& a2 ^. D" A" h6 H }
' S$ r! p/ ~$ |" \. @! i$ J2 S1 M8 P, \0 \ v, T* A* \4 m" P R
public void agentStep() {# t7 L& s; i# O2 f: f0 r
System.out.println(id + ":" + Globals.env.getCurrentTime());- j; F- O4 ~9 _8 b
}, N! B7 T8 n8 J
}
2 w1 i6 W8 c: I. k! ^7 S
1 x. `: a: |, o- r4 L" Upublic class ActionGroupDemo extends SwarmImpl {9 B& E5 v5 Z$ I( b8 _ k
ScheduleImpl schedule;" X- T2 f9 e: f0 V" W6 W
ActionGroupImpl actionGroup;
: N% j" e; J* `7 z5 n ListImpl list;
+ S O2 v$ A5 m$ z# t char Id = 'a';
4 T! G3 ?- z: e* Z% t0 z5 M' M3 B. A3 X7 S$ k
ActionGroupDemo(Zone aZone) { x% D: P6 \; d7 Q. U: |
super(aZone);. a( j4 U" ?4 V$ {* g9 Q1 n
list = new ListImpl(aZone);7 m. [* y+ o' \3 H+ d7 V% c
swarmSetp();. d' V- P0 j: M4 I- e' \- k
actionGroup = new ActionGroupImpl(aZone);( L& ?( u; l8 C8 n. t
schedule = new ScheduleImpl(aZone);5 y" M4 A& V5 C5 X1 g5 p" v# r
try {' A0 E& Q O& j: ^; S
Selector agentSel = new Selector(Agent.class, "agentStep", false);
/ \0 z0 y. e5 ]1 w: D. Y/ a; E Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行7 e# L/ i# n( G1 W8 @* _
. S& _+ w; f( e( U actionGroup.createActionForEach$message(list, agentSel);' x/ Z) l& | V! q5 p2 `
actionGroup.createActionTo$message(this, swarmSel);
& {5 |: L* w s8 q schedule.at$createAction(0, actionGroup);
8 f3 V) d% x; ~. B schedule.at$createAction(1, actionGroup);
' Q& B7 C7 ^+ s( {2 n/ y* d schedule.at$createAction(2, actionGroup);6 y2 O3 b5 {. ^4 k, S& l6 O( Q' L
' p9 F8 G; ^" A6 w
} catch (Exception e) {
( Z* J0 D8 G1 `5 T/ _ e.printStackTrace(System.err);
' Q# Z( m! R, R$ x //System.out.println(e);4 n. j% i7 r& J* I
System.exit(1);) _) A& O0 T8 U. i8 ^
}3 }" {% q- \( t4 t4 x4 u% j9 e
' A- x: Q s7 n- H' i
1 W8 Q+ c0 r1 {% T' V: c
}
3 c1 A' q# p% f6 k. N8 \7 A7 _' H! C- M9 J5 E; X
private void swarmSetp() {
% u# s" R) Y* M6 c6 | list.addLast(new Agent(Id));3 i% F! B: z1 j
Id++;2 b4 y/ A/ s9 u9 Q- C. R9 T
}
- w+ d& `* d" C; C3 b$ Q7 v' G* t7 Y/ r4 X
public Activity activateIn(Swarm context) {* ^: T6 U, S @
super.activateIn(context);9 I, V8 f% V3 L7 L" N% X
schedule.activateIn(this);" n( J& Q0 ~- A% }# O
return getActivity();
# v* e' C) }% V; L1 |- P0 j( F }
# K3 Q2 j8 u- a1 p# l# c* k8 O; r" s: z- i8 S, N
public static void main(String[] args) {4 Q+ N0 E- h9 u
Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);) Q( J4 [, C8 r2 x8 j' G
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);
5 @9 j i p/ E3 C+ c swarms.buildObjects();" U% v' K, c) k3 I$ Q5 E
swarms.buildActions();9 w: R, H A$ d3 N7 K8 n* d9 T* ^: L
swarms.activateIn(null).run();' y. B! i; w+ L1 A; E
}2 t6 ~( x/ ?: \4 X7 v3 ~
4 {* K9 ^) S1 ~6 `} |
|