swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: any clue?


From: Murali Nandula
Subject: RE: any clue?
Date: Tue, 5 Oct 1999 13:46:04 -0400

Thanks a lot. I guess the probelm might be due my compiler.
I am using sun jdk 2.0. I ran the example sent by you but it did
not work for me! But it worked when I changed "String" to "Object".

thanks,
Murali

> -----Original Message-----
> From: address@hidden [SMTP:address@hidden
> Sent: Tuesday, October 05, 1999 12:58 PM
> To:   address@hidden
> Subject:      Re: any clue?
> 
> >>>>> "MN" == Murali Nandula <address@hidden> writes:
> 
> MN> /src/Swarm/swarm/src/defobj/directory.m:331 [Directory
> MN> switchObjc:javaObject]
> 
> It might be a bug in Swarm related to the way you are using strings.
> 
> MN>   I had to do it like this:
> MN>   public Object moveTo(Object direction) { String dirstr =
> MN> (String) direction; // do something with 'dirstr' }
> 
> I think this is because you are passing true as the objcFlag to
> Selector.  For a Java method, that should be false.
> 
> This works for me:
> 
> import swarm.defobj.Zone;
> import swarm.activity.Schedule;
> import swarm.activity.ScheduleImpl;
> import swarm.activity.Activity;
> import swarm.objectbase.Swarm;
> import swarm.objectbase.SwarmImpl;
> import swarm.Selector;
> import swarm.Globals;
> 
> public class TestModelSwarm extends SwarmImpl {
>   Schedule schedule;
>   Schedule stopSchedule;
>   
>   TestModelSwarm (Zone aZone) {
>     super (aZone);
>   }
> 
>   public void moveTo (String direction) {
>     System.out.println ("Moving " + direction + " at: " + 
>                         Globals.env.getCurrentTime ());
>   }
> 
>   public void stopRunning () {
>     Globals.env.getCurrentSwarmActivity ().terminate ();
>   }
>   
>   public Object buildActions () {
>     schedule = new ScheduleImpl (this, 5);
>     stopSchedule = new ScheduleImpl (this, true);
>     
>     try {
>       Selector moveSel = new Selector (getClass (), "moveTo", false);
>       Selector stopSel = new Selector (getClass (), "stopRunning", false);
> 
>       schedule.at$createActionTo$message (1, this, moveSel, "left");
>       schedule.at$createActionTo$message (3, this, moveSel, "right");
>       stopSchedule.at$createActionTo$message (20, this, stopSel);
>     } catch (Exception e) {
>       e.printStackTrace (System.err);
>     }
>     return this;
>   }
>   
>   public Activity activateIn (Swarm swarmContext) {
>     super.activateIn (swarmContext);
>     
>     schedule.activateIn (this);
>     stopSchedule.activateIn (this);
>     return getActivity ();
>   }
> 
>   public static void main (String[] args) {
>     Globals.env.initSwarm ("testSchedule",
>                            "2.0.1", "address@hidden",
>                            args);
>     Swarm modelSwarm = new TestModelSwarm (Globals.env.globalZone);
> 
>     modelSwarm.buildActions ();
>     modelSwarm.activateIn (null);
>     modelSwarm.getActivity ().run ();
>   }
> }
> 
>                   ==================================
>    Swarm-Support is for discussion of the technical details of the day
>    to day usage of Swarm.  For list administration needs (esp.
>    [un]subscribing), please send a message to <address@hidden>
>    with "help" in the body of the message.

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]