[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Finding events at a particular time in a Schedule
From: |
Tee Toth-Fejel |
Subject: |
RE: Finding events at a particular time in a Schedule |
Date: |
Fri, 29 Sep 2000 10:03:06 -0400 |
> -----Original Message-----
> From: address@hidden [mailto:address@hidden
> Sent: Thursday, September 21, 2000 9:52 PM
> To: address@hidden
> Subject: Re: Finding events at a particular time in a Schedule
>
> >>>>> "TTF" == Tee Toth-Fejel <address@hidden> writes:
>
> TTF> swarm.collections.StringImpl strc = new StringImpl(getZone());
> TTF> System.out.println("DUMP SCHEDULE at " +
> Globals.env.getCurrentTime());
> TTF> schedule.describeForEach(strc);
> TTF> System.out.println(strc.getC());
> TTF> strc.drop();
>
> Huh? `strc' does nothing here.
>
> TTF> But what if I don't care about the past, i.e. events
> scheduled before
> TTF> Globals.env.getCurrentTime())?
>
> A Schedule is a kind of Map. You can traverse it with a
> MapIndex, i.e. by using begin:.
I assume that you mean something like:
System.out.println("dumpSchedule: begin="+schedule.begin(
this.getZone()).getCollection().toString());
Index sheduleIndex = schedule.begin(this.getZone());
System.out.println("dumpSchedule: sheduleIndex="+sheduleIndex);
System.out.println("dumpSchedule: sheduleIndex="+
sheduleIndex.getName().toString());
Object next = null;
System.out.println("dumpSchedule: first next="+sheduleIndex.next());
while(next != null)
{
System.out.println("dumpSchedule: next="+sheduleIndex.next());
}
But it results in:
dumpSchedule: address@hidden
dumpSchedule: address@hidden
dumpSchedule: sheduleIndex=swarm.collections.MapIndexImpl
Internal error: caught an unexpected exception.
Please check your CLASSPATH and your installation.
java/lang/NullPointerException
0 [sig] Kaffe 1129 stackdump: Dumping stack trace to
Kaffe.exe.stackdump
$ less Kaffe.exe.stackdump
60006709 [sig] Kaffe 1129 sig_send: wait for sig_complete event failed, sig
11, rc 258, Win32 error
0
60008381 [main] Kaffe 1129 sig_send: wait for sig_complete event failed, sig
6, rc 258, Win32 error
0
Two questions:
1. Why can't I do a .next on the MapIndexImpl I got from my schedule?
2. In general, how does one debug such a stackdump?
There seems to be no useful information here. sig 6? rc 258?
Thanks for any help that you can give.
In the meantime, I wrote a parser that does what I want (builds a HashMap of
Lists that contain actions in the schedule, which I can then search for
events at a particular time), but it also crashes for unknown reasons,
though half the time.
// UGLY! UGLY! UGLY! But indexing methods cause a stackdump.
public HashMap parseSchedule()
{
String token;
int count = 0;
int sub = 0;
String time, method;
boolean multiple = false;
boolean first = true;
HashMap actions = new HashMap();
Vector subactions = new Vector();
// Possible states are: multiple or single; first or next
swarm.collections.StringImpl strc = new StringImpl(getZone());
System.out.println("parseSchedule: Begin at " +
Globals.env.getCurrentTime());
schedule.describeForEach(strc);
StringTokenizer parser = new StringTokenizer(strc.getC()," \n");
try
{
while (parser.hasMoreTokens())
{
token = "";
token = parser.nextToken();
System.out.println("\n--------Reading *"+token+"*");
if (token.equals("time:"))
{
time = parser.nextToken();
count = new Integer(time).intValue();
System.out.print("\n Time: "+count+" ");
first = true;
}
else if (token.equals("concurrentGroup:"))
{
multiple = true;
System.out.print("Concurrent ");
}
else if (token.equals("]")) // must do this before checking for
"method]"
{
multiple = false;
System.out.print("Single ");
}
else if
(token.substring(0,Math.min(token.length(),10)).equals("ActionTo_c"))
{
//multiple = false;
System.out.print("Single ");
}
else if (token.endsWith("]"))
{
method = token.substring(0,token.length()-1);
if (multiple == true)
{
if (first == true)
{
subactions = new Vector();
System.out.print("first ");
System.out.print("subactions="+subactions);
subactions.addElement(method);
actions.put(new Integer(count), subactions);
first = false;
}
else
{
subactions.addElement(method);
System.out.print("next ");
}
}
else
{
actions.put(new Integer(count), method);
}
System.out.print("Method: "+method+" ");
}
else if (token.equals("GUISwarm")) {;}
else if (token.equals("is:")) {;}
else if (token.equals("at")) {;}
else if (token.equals("action")) {;}
else
{
System.out.print("substring="+token.substring(0,Math.min(token.length(),10))
);
System.out.println("Else "+count+"."+sub+" "+token);
;
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
strc.drop();
return actions;
}
public int getTimeOfNextEvent(int now)
{
HashMap scheduledActions;
int next = now;
boolean after = false;
//System.out.println("getTimeOfNextEvent:"+ now +". Start.");
scheduledActions = parseSchedule();
Set keys = scheduledActions.keySet();
Iterator keysIterator = keys.iterator();
for (Iterator i = keys.iterator(); i.hasNext(); )
{
Integer timeOfActionI = (Integer) i.next();
int timeOfAction = timeOfActionI.intValue();
if (timeOfAction< now)
{
//System.out.println(timeOfAction+"<"+now);
;
}
else if (timeOfAction == now)
{
//System.out.println(timeOfAction+"="+now);
;
}
else
{
//System.out.println(timeOfAction+">"+now);
after = true;
return timeOfAction;
}
}
return now;
}
Tihamer "Tee" Toth-Fejel Member of Technical Staff
(734) 623-2544 address@hidden http://www.anteaters.net/ttf/
Center for Electronic Commerce, Environmental Research Institute of Michigan
==================================
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.