设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8921|回复: 1

[求助] 总是出现swarm.SignatureNotFoundException错误

  [复制链接]
发表于 2010-11-11 10:28:14 | 显示全部楼层 |阅读模式
本帖最后由 generate2000 于 2010-11-11 10:46 编辑 3 J- B7 I  o7 g* H5 a
5 \- n: X3 F* _9 O( T, t
本人swarm菜鸟,有个问题请教下下.swarm2.2,jdk1.6update21
0 t7 Z8 w  }$ g( {3 F以下是actiongroupdemo程序,在执行时出现以下错误.请各位高手帮忙解决一下,不胜感激.' i" z, q/ D# M. \) r  F
swarm.SignatureNotFoundException
4 v, g" B8 a" [# Y! ]% b" }) y3 S        at swarm.Selector.<init>(Selector.java:76)3 V* \2 R$ {0 M  ^
        at ActionGroupDemo.<init>(ActionGroupDemo.java:37)
# K7 r" g) w) V' z/ H; ?( i+ Y        at ActionGroupDemo.main(ActionGroupDemo.java:67)
2 h5 R; j" y8 F7 P1 r$ R3 e; r: q! Y- ^

- s" @0 s, T* A. c& @* Himport swarm.objectbase.SwarmImpl;! F7 {8 a/ ]( Q- I
import swarm.objectbase.Swarm;+ m7 k, ~5 P4 M: r) }( \
import swarm.activity.ScheduleImpl;7 M* _2 q! b% k5 ?7 H" I+ d
import swarm.activity.Activity;) P9 p. O2 k6 t/ ?+ n5 J% @
import swarm.activity.ActionGroupImpl;
& a( V$ t( M+ F2 t  S4 t) himport swarm.collections.ListImpl;  d9 e1 D+ e- W2 \5 q- L# E* g" Z
import swarm.defobj.Zone;
4 L/ {& e7 {6 @4 m0 cimport swarm.Globals;
" U, G  k& {" R% L  Yimport swarm.Selector;! B5 f4 j& P% P* R( x
import swarm.activity.ActionGroup; ' D" |0 @9 L9 |& s/ [8 N
class Agent {5 `7 s9 h$ a- [/ B. d6 L8 K% t  k
        char id;5 k' G. P4 e  V3 V

3 E0 h5 z2 [1 E( ]) A        Agent(char id) {3 L" L! l( r5 b8 a+ W: L- ~4 @
                this.id = id;9 K) `) |% G' ?# `/ f
        }
3 N) {( a! I' ]8 v2 h  W( @8 N: A
5 G3 v3 O; J3 K4 I3 A8 |        public void agentStep() {
* |8 U( ~- \! I0 `1 R                System.out.println(id + ":" + Globals.env.getCurrentTime());
2 T( }  |1 l( W* X& [" B3 M        }% k' i* A0 y9 y7 w4 `! u
}3 B3 g9 ^- K0 d

8 s! |/ \7 J6 b) Z# fpublic class ActionGroupDemo extends SwarmImpl {
7 e. s% ~3 N; v- h. j        ScheduleImpl schedule;2 W. s2 u0 l5 t& Y9 u) R
        ActionGroupImpl actionGroup;3 O& B6 Z; M) \9 l$ H4 C
        ListImpl list;
6 K/ U! G. R$ h3 R        char Id = 'a';
1 ?( k' A' `0 _0 h6 z: s2 o. w4 {8 L+ p) I2 `8 ^: x& C% E
        ActionGroupDemo(Zone aZone) {
) b& J5 @/ V# V' r! y                super(aZone);
' M% G# R$ q. F8 X5 b8 t: E8 U; p                list = new ListImpl(aZone);
9 l- W. E7 w5 t- [                swarmSetp();& Z$ I$ S0 C. l. L! A# |, ~3 A
                actionGroup = new ActionGroupImpl(aZone);! r) Z4 Y, G8 T: k+ A
                schedule = new ScheduleImpl(aZone);* f6 [* Q# H1 b" E9 [- h" ]; F& l
                try {) V: ?2 ~; O4 q2 e" o) F$ U
                        Selector agentSel = new Selector(Agent.class, "agentStep", false);% I* _" m) i/ j: ?: x
                        Selector swarmSel = new Selector(ActionGroupDemo.class,"swarmSetp", false);//问题就出现在这一行
" X$ K6 p6 Y5 M+ C9 ?+ u5 f: T' m                        
2 J1 t/ i# y( f; E8 `: G                        actionGroup.createActionForEach$message(list, agentSel);
9 w$ h  s8 p4 b1 A% g( @                        actionGroup.createActionTo$message(this, swarmSel);
- I6 [) q) X* Y+ J( v5 ~' z                        schedule.at$createAction(0, actionGroup);8 @" R2 ~6 h+ g. y$ S5 Z
                        schedule.at$createAction(1, actionGroup);
$ g# d: \: e, _3 ?) c+ w$ ]                        schedule.at$createAction(2, actionGroup);4 R$ [5 ^" W7 q% c+ m2 J
% s1 W/ s5 i# R( t$ h( Z1 N) I6 I
                } catch (Exception e) {
* A1 G' H6 p  @1 _9 @7 f                        e.printStackTrace(System.err);! a: A( r+ x- w, p0 p
                        //System.out.println(e);' a) Y! ?  n* a* }7 L2 e
                        System.exit(1);- e6 `1 @4 z% q( u5 i7 ]! r/ N
                }" L4 U& a6 i( l8 P
) C2 V- [. H1 K0 a/ H
( a  P2 w! y$ ^# ]# F* p
        }
9 F2 \9 k0 x2 w3 z$ C5 m! H. M
5 F. z  @9 n% Q6 Q, X, `        private void swarmSetp() {$ T9 ~* Z. p8 v9 O: W
                list.addLast(new Agent(Id));
3 I( `: J' A1 i( X+ W+ D# [                Id++;
7 V2 W0 A) M) \1 _7 B        }7 L+ I5 x3 Z$ e4 f: q' j
1 K2 u( D8 h' y( ^) y; n6 j$ L
        public Activity activateIn(Swarm context) {
: H, V+ U# q6 O+ O' a" \1 p                super.activateIn(context);
. ^8 p( C( f) q4 A" \  J5 o                schedule.activateIn(this);2 X' F8 H& S! C1 D
                return getActivity();. p: V3 y6 ^8 ]" i4 _1 \
        }
: u% \8 q9 B" h7 h1 P- _7 w" x+ x- H
        public static void main(String[] args) {% y6 }6 |& `4 w2 K
                Globals.env.initSwarm("ActionGroupdemo", "1.1", "s@s", args);
" `4 F( A/ Q- {/ `. _                Swarm swarms = new ActionGroupDemo(Globals.env.globalZone);0 v* o- s" m, p8 D
                swarms.buildObjects();$ F5 l; Z# V$ b, W8 m4 S
                swarms.buildActions();1 \' K- }* [5 Q1 ]& T
                swarms.activateIn(null).run();
+ _- m6 m. ^) G: {8 J        }
) t2 _% \, h+ ], i
; |1 C3 n# s, i% }/ m4 W% O4 ?}
发表于 2010-11-22 22:09:23 | 显示全部楼层
你的函数swarmStep 不能为private 要是public才行。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2026-4-26 18:43 , Processed in 0.018565 second(s), 14 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表