|
|
本帖最后由 generate2000 于 2010-11-11 10:46 编辑
% s# `) B1 {! Q( {1 N1 {. ^$ i* c5 q. b
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update217 F* ]) N5 r/ p3 x9 K4 R
以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.4 \/ g2 Z/ q* q
swarm.SignatureNotFoundException
5 x0 G# C$ J( K" M" X- z Y { at swarm.Selector.<init>(Selector.java:76)
. [1 i, Y4 P; t1 H0 \2 ~ at ActionGroupDemo.<init>(ActionGroupDemo.java:37)" |6 W ~0 f. y
at ActionGroupDemo.main(ActionGroupDemo.java:67). p0 {$ d& E3 G' _ j' k
; X9 c/ ^0 i3 o+ {6 [! t# g6 n
" t' n5 q3 S! w+ d/ Himport swarm.objectbase.SwarmImpl;
. w, e2 t# }+ ?/ k- Y6 x' x2 ?/ E1 r m* cimport swarm.objectbase.Swarm;+ F9 i; T& l- v: j, ^5 S/ E7 S
import swarm.activity.ScheduleImpl;: [. r5 W1 F9 x2 c9 A: k
import swarm.activity.Activity;
. S, C3 L2 W( }' u% ~0 K7 Vimport swarm.activity.ActionGroupImpl;9 X: z, z* V; L; E' t, c
import swarm.collections.ListImpl;
1 {% y' }. X% d% F1 [import swarm.defobj.Zone; 0 Z$ N/ w1 ?# A+ E5 Z+ P+ |
import swarm.Globals;& S* O5 |7 u5 e5 d0 k
import swarm.Selector;. s5 O, r" V5 ~0 Q5 g, q; b/ b
import swarm.activity.ActionGroup; ( Q2 e3 @$ u1 I# ~) M9 L) V
class Agent {
0 M( r8 ?# y* p' d$ L- Z. s4 t! Q" T" E char id;( W, I2 o$ b& g* g# m- n# V
' d8 |) z( g. R- R }
Agent(char id) { F' X& t2 W, Q7 \ }) O
this.id = id;
" k& P6 }! M8 p" _ }& Q3 d3 N7 E3 w* I$ n2 Z
: t+ v/ ~! n5 R1 x3 X7 L
public void agentStep() {
; b* G% H3 e$ G* A System.out.println(id + ":" + Globals.env.getCurrentTime());6 y+ ?' z, B- }3 f/ ~; m/ }
}8 z# s4 A7 Z9 i
}/ P$ g, J) h) g, ]2 l, a
8 |0 s. o, u0 U) U# ]3 ppublic class ActionGroupDemo extends SwarmImpl {! e# W! F$ h, c& h' a4 s( o8 {5 `
ScheduleImpl schedule;
& N9 G/ @' B) U ActionGroupImpl actionGroup;# u! d( k3 r! z7 t
ListImpl list;
2 t' H3 S6 ?; G1 P1 f/ X& b char Id = 'a';0 @6 Z; l6 T7 ?3 k# e7 t
5 `' ~# G$ a' P8 E
ActionGroupDemo(Zone aZone) {
. E4 p6 M( m7 ^1 f5 A% [ super(aZone);. q4 Y- l' ~# e7 W) R. E
list = new ListImpl(aZone);
1 ^/ l/ \2 l2 @) z2 `3 h swarmSetp();" {6 M3 r3 m3 f8 a; y6 |
actionGroup = new ActionGroupImpl(aZone);+ q0 p3 C$ u+ _1 C* i4 {5 f, H0 y( Z7 B
schedule = new ScheduleImpl(aZone);; X% q0 t3 @! u: S5 R# x2 P
try {
- _# B' z+ k4 p. Y O Selector agentSel = new Selector(Agent.class, "agentStep", false);$ t1 ^: x+ h* m" z. c
Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行& P! O4 v; O' X2 {& g: S% H, T
( e1 `+ z4 u. J: w9 I
actionGroup.createActionForEach$message(list, agentSel);( w: L( T. w. G) J a+ O# T
actionGroup.createActionTo$message(this, swarmSel);
! H- h, {" s* ?. F7 ` schedule.at$createAction(0, actionGroup);- O3 ?1 Q' A/ [7 H) h8 Y5 b# ^
schedule.at$createAction(1, actionGroup);
9 {& D1 V: ~2 [$ s: F; B schedule.at$createAction(2, actionGroup);
4 G2 X/ ]+ \: E8 j
( J, H2 j3 e2 ^+ ^5 t( V9 I& P } catch (Exception e) {
; F4 w7 p+ l( \) P' y4 M; s e.printStackTrace(System.err);4 B, X" ]* I- b1 [1 i( G: X
//System.out.println(e);
6 _. v' a$ e: U; l' A3 { System.exit(1);
% D5 z" h( a6 J& A" j1 P }, g' U* A0 u. g! x( G7 x
' a; N- ?! o" J$ D) C
2 C# \. ]) @% d: \ }
- \( b2 V/ @( D; h! _* m
3 Z, H6 @. C0 b: I private void swarmSetp() {
% ~9 X+ c* D9 Y3 N5 s. P list.addLast(new Agent(Id));
7 v" }- M3 A: g7 h1 V. S5 Q" n$ z; } Id++;
3 B& ?! t1 n9 r }" g% J+ a( b7 I' ~( Q* P
% g5 R$ [. G; K9 x; n public Activity activateIn(Swarm context) {& n, D% Y2 b" K5 X" H+ p
super.activateIn(context);
1 z/ j) c; v4 Q- r1 R- o schedule.activateIn(this);
. ~1 o3 B: s5 V' ^! M9 C# `" z return getActivity();, `; w- n/ E( @" V
}
% {/ B" g( f% W" \% J+ z% W5 h) g! j3 y2 O0 U9 ?/ @
public static void main(String[] args) {
1 Q" B. r6 r2 M' n2 q- Z Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);/ d+ I: G( z1 Z6 _% {$ O5 r
Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);1 e, d4 S0 A( Y b% K
swarms.buildObjects();) }4 ~' r# R1 s! {/ ]3 e
swarms.buildActions();/ u3 D+ E3 B# Y Y' i! A
swarms.activateIn(null).run();& d5 r4 r% O4 m+ ]9 s
} R; J& z" i$ r- M
" {+ F# t4 A6 |9 ?6 X/ y- c. g} |
|