[Jais-checkins] jaisteam/src/jais Jais.java,1.30,1.31
Status: Beta
Brought to you by:
maestrodd
|
From: <mae...@us...> - 2002-07-22 10:14:38
|
Update of /cvsroot/jais/jaisteam/src/jais
In directory usw-pr-cvs1:/tmp/cvs-serv3335/src/jais
Modified Files:
Jais.java
Log Message:
removed that thread, as it is unneeded, too
Index: Jais.java
===================================================================
RCS file: /cvsroot/jais/jaisteam/src/jais/Jais.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** Jais.java 15 Jul 2002 09:27:23 -0000 1.30
--- Jais.java 22 Jul 2002 10:14:33 -0000 1.31
***************
*** 23,27 ****
* @author Stephan Diederich
*/
! public class Jais extends Thread
{
static Logger logger=Logger.getLogger("jais");
--- 23,27 ----
* @author Stephan Diederich
*/
! public class Jais
{
static Logger logger=Logger.getLogger("jais");
***************
*** 56,60 ****
{
m_jaisTeam=f_jaisTeam;
- this.setName("Jais"+f_playerNumber);
m_teamName=f_teamName; //store our Teamname
m_playerNumber=f_playerNumber;
--- 56,59 ----
***************
*** 72,76 ****
m_eventList=new LinkedList();
m_singleMode=f_singleMode;
- startThread();
try
{
--- 71,74 ----
***************
*** 180,188 ****
public void onHear(HearEvent f_hearEvent)
{
! synchronized(m_eventList)
! {
! m_eventList.addLast(f_hearEvent);
! }
! wakeup();
}
--- 178,182 ----
public void onHear(HearEvent f_hearEvent)
{
! m_worldModel.updateAurealInfo(f_hearEvent);
}
***************
*** 193,201 ****
public void onSee(VisualEvent f_visualEvent)
{
! synchronized(m_eventList)
! {
! m_eventList.addLast(f_visualEvent);
! }
! wakeup();
}
--- 187,194 ----
public void onSee(VisualEvent f_visualEvent)
{
! m_worldModel.updateVisualInfo(f_visualEvent);
! m_ki.onNewData();
! if(m_visualizationEnabled)
! m_visualization.updateDisplay();
}
***************
*** 208,216 ****
//get our correct PlayerNumber first...
m_playerNumber=((InitInfo)f_initialEvent.getObjects().get(0)).m_uniformNumber;
! synchronized(m_eventList)
! {
! m_eventList.addLast(f_initialEvent);
! }
! wakeup();
}
--- 201,205 ----
//get our correct PlayerNumber first...
m_playerNumber=((InitInfo)f_initialEvent.getObjects().get(0)).m_uniformNumber;
! m_worldModel.updateInitInfo((InitialEvent) f_initialEvent);
}
***************
*** 221,229 ****
public synchronized void onSenseBody(SenseBodyEvent f_senseBodyEvent)
{
! synchronized(m_eventList)
! {
! m_eventList.addLast(f_senseBodyEvent);
! }
! wakeup();
}
--- 210,215 ----
public synchronized void onSenseBody(SenseBodyEvent f_senseBodyEvent)
{
! m_worldModel.updateSenseBodyInfo(f_senseBodyEvent);
! m_ki.onSenseBody();
}
***************
*** 267,325 ****
return;
}
- /* removed that, as it it only for hard debugging or playing ;)
- else if (l_tempString.equalsIgnoreCase("kick"))
- {
- try
- {
- m_communication.kick(Double.parseDouble(l_tokenizer.nextToken()),Double.parseDouble(l_tokenizer.nextToken()));
- }
- catch (xCommunication ex)
- {
- logger.fatal("Arg, could not send command to server!" + ex.getMessage());
- }
-
-
- return;
- }
- else if (l_tempString.equalsIgnoreCase("dash"))
- {
- try
- {
- m_communication.dash(Double.parseDouble(l_tokenizer.nextToken()));
- }
- catch (xCommunication ex)
- {
- logger.fatal("Arg, could not send command to server!" + ex.getMessage());
- }
-
-
- return;
- }
- else if (l_tempString.equalsIgnoreCase("turn"))
- {
- try
- {
- m_communication.turn(Double.parseDouble(l_tokenizer.nextToken()));
- }
- catch (xCommunication ex)
- {
- logger.fatal("Arg, could not send command to server!" + ex.getMessage());
- }
- return;
- }
- else if (l_tempString.equalsIgnoreCase("move"))
- {
- try
- {
- m_communication.move(Double.parseDouble(l_tokenizer.nextToken()),Double.parseDouble(l_tokenizer.nextToken()));
- }
- catch (xCommunication ex)
- {
- logger.fatal("Arg, could not send command to server!" + ex.getMessage());
- }
-
- return;
- }
- */
else if (l_tempString.equalsIgnoreCase("help"))
{
--- 253,256 ----
***************
*** 339,343 ****
public void quit()
{
- if (m_running) stopThread();
m_commandLineReading=false;
if (m_visualizationEnabled)
--- 270,273 ----
***************
*** 380,489 ****
m_visualizationEnabled=false;
}
-
- /**
- *
- */
- private synchronized void startThread()
- {
- m_thisThread=this;
- m_running=true;
- m_thisThread.start();
- }
-
- /**
- * @roseuid 3CE8B0FA022A
- */
- private synchronized void stopThread()
- {
- m_thisThread = null;
- m_running=false;
- notify();
- }
-
- /**
- * this methods says our thread that there's something to do
- */
- private synchronized void wakeup()
- {
- m_threadSuspended=false; // ok, he can run again if he wants to
- if (!m_threadSuspended) //check if we are suspended
- notify();
- }
-
- /**
- * @roseuid 3CE6898C03C1
- */
- public void run()
- {
- Thread l_thisThread = currentThread();
- boolean l_listIsEmpty=true;
- Event l_tempEvent;
- while(l_thisThread==m_thisThread)
- {
- synchronized (m_eventList)
- {
- l_listIsEmpty=m_eventList.isEmpty();
- }//synchronization of m_eventlist
- if (!l_listIsEmpty) //we have something to do
- {
- try
- {
- synchronized (m_eventList)
- {
- l_tempEvent=(Event)m_eventList.removeFirst();
- }
- if (l_tempEvent instanceof SenseBodyEvent)
- {
- m_worldModel.updateSenseBodyInfo((SenseBodyEvent) l_tempEvent);
- m_ki.onSenseBody();
- }
- else if (l_tempEvent instanceof VisualEvent)
- {
- m_worldModel.updateVisualInfo((VisualEvent) l_tempEvent);
- m_ki.onNewData();
- if(m_visualizationEnabled)
- m_visualization.updateDisplay();
- }
- else if (l_tempEvent instanceof HearEvent)
- {
- m_worldModel.updateAurealInfo((HearEvent) l_tempEvent);
- }
- else if (l_tempEvent instanceof InitialEvent)
- {
- m_worldModel.updateInitInfo((InitialEvent) l_tempEvent);
- }
- else
- logger.fatal("Cannot recognize Object in Eventlist!"+l_tempEvent.getClass().getName());
- }
- catch (Exception ex)
- {
- /* if(logger.getLevel().isGreaterOrEqual(Level.toPriority(Level.WARN_INT)))
- {
- logger.fatal("Got exception while dispatching events"+ex.getMessage());
- ex.printStackTrace();
- }
- */
- }
- }
- else
- {
- m_threadSuspended=true; //we want to suspend ourself after one run
- try
- {
- synchronized(this)
- {
- while (m_threadSuspended && l_thisThread==m_thisThread) //check again if we should sleep,
- {
- wait(); // this command lets our thread sleep until we wake him up
- }
- }
- }
- catch(java.lang.Exception ex)
- {
- logger.fatal("\t" + getName() + ": ARGG! Got an exception while sleeping ... "+ ex.getMessage());
- }
- }
- }//of while()
- }//of run()
private void readFromCommandline()
--- 310,313 ----
|