shady.sim.multi
Class MultiShadySim

java.lang.Object
  extended by shady.common.multi.MultiShadyCommon
      extended by shady.sim.multi.MultiShadySim
All Implemented Interfaces:
MultiShadyCommonAPI, MultiShadySimAPI

public class MultiShadySim
extends MultiShadyCommon
implements MultiShadySimAPI

MultiShady simulator implementation.

Copyright (C) 2006 Marsette A. Vona, III

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Author:
Marsette (Marty) A. Vona, III

Nested Class Summary
 
Nested classes/interfaces inherited from interface shady.common.multi.MultiShadyCommonAPI
MultiShadyCommonAPI.MemberProcessor
 
Field Summary
protected  vona.time.SuperClock clock
          Keeps track of time for this MultiShady.
(package private) static java.lang.String cvsid
          CVS id.
(package private)  boolean discreteMode
          Whether we're in discrete mode.
protected  vona.time.PeriodicThread updateThread
          An async thread to update(double).
 
Fields inherited from class shady.common.multi.MultiShadyCommon
members, membersByIndex, membersByName, unmodifiableMembers
 
Constructor Summary
MultiShadySim(MemberShadySim[] member)
          Create a new MultiShadySim.
 
Method Summary
 void chargeBatteries(double newBatteryLevel)
          Atomically simulate charging the battery to the same level for all members.
 double getAccel()
          Get the simulation time acceleration factor.
 vona.time.Clock getClock()
          Get the clock this MultiShady is using.
 double getShadyTime()
          Get the acceltime in accelseconds relative to an arbitrary epoch.
 MemberShadyCommonAPI makeMember(ShadyPose pose)
          Make and a new member but don't add it.
 void pause()
          Pause this MultiShadySim.
 void rechargeBatteries()
          Atomically simulate recharging the battery of all members.
 void setAccel(double accel)
          Atomically set the simulation time acceleration factor for all members.
 void setDiscreteMode(boolean discreteMode)
          Atomically set the same discrete mode to all members.
 void shadySleep(double seconds)
          Sleep the current thread for the requested number of accelseconds.
 void unPause()
          Un-MultiShadySimAPI.pause() this MultiShadySim.
protected  void update(double dt)
          Updates all members.
 
Methods inherited from class shady.common.multi.MultiShadyCommon
addMember, addMember, clearMembers, exec, forEachMember, forMembers, getMember, getMember, getMember, getMembers, getNumActiveActuators, makeMemberName, numMembers, removeLastMember, reset, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface shady.common.multi.MultiShadyCommonAPI
addMember, addMember, clearMembers, exec, forEachMember, forMembers, getMember, getMember, getMember, getMembers, getNumActiveActuators, numMembers, removeLastMember, reset, stop
 

Field Detail

cvsid

static final java.lang.String cvsid

CVS id.

See Also:
Constant Field Values

clock

protected vona.time.SuperClock clock

Keeps track of time for this MultiShady.


updateThread

protected vona.time.PeriodicThread updateThread

An async thread to update(double).

Started by the constructor.


discreteMode

boolean discreteMode

Whether we're in discrete mode.

See the class header doc in ShadySim for a description of discrete mode.

Constructor Detail

MultiShadySim

public MultiShadySim(MemberShadySim[] member)

Create a new MultiShadySim.

Parameters:
member - the MemberShadys, not null
Method Detail

makeMember

public MemberShadyCommonAPI makeMember(ShadyPose pose)

Make and a new member but don't add it.

This impl returns a new MemberShadySim.

Specified by:
makeMember in interface MultiShadyCommonAPI
Specified by:
makeMember in class MultiShadyCommon
Parameters:
pose - the pose of the new member
Returns:
the new number of members

setDiscreteMode

public void setDiscreteMode(boolean discreteMode)

Atomically set the same discrete mode to all members.

See ShadySimAPI.setDiscreteMode(boolean).

Specified by:
setDiscreteMode in interface MultiShadySimAPI
Parameters:
discreteMode - the discrete mode state

rechargeBatteries

public void rechargeBatteries()

Atomically simulate recharging the battery of all members.

See ShadySimAPI.rechargeBattery().

Specified by:
rechargeBatteries in interface MultiShadySimAPI

chargeBatteries

public void chargeBatteries(double newBatteryLevel)

Atomically simulate charging the battery to the same level for all members.

See ShadySimAPI.chargeBattery(double).

Specified by:
chargeBatteries in interface MultiShadySimAPI
Parameters:
newBatteryLevel - the new battery level, in Joules

setAccel

public void setAccel(double accel)

Atomically set the simulation time acceleration factor for all members.

See ShadySimAPI.setAccel(double).

Specified by:
setAccel in interface MultiShadySimAPI
Parameters:
accel - the simulation time acceleration factor

getAccel

public double getAccel()

Get the simulation time acceleration factor.

Specified by:
getAccel in interface MultiShadySimAPI
Returns:
the simulation time acceleration factor

getShadyTime

public double getShadyTime()

Get the acceltime in accelseconds relative to an arbitrary epoch.

Specified by:
getShadyTime in interface MultiShadySimAPI
Returns:
the acceltime in accelseconds relative to an arbitrary epoch

shadySleep

public void shadySleep(double seconds)
                throws java.lang.InterruptedException

Sleep the current thread for the requested number of accelseconds.

Specified by:
shadySleep in interface MultiShadySimAPI
Parameters:
seconds - how long to sleep in accelseconds, non-negative
Throws:
java.lang.InterruptedException

pause

public void pause()

Pause this MultiShadySim.

See ShadySimAPI.pause().

Specified by:
pause in interface MultiShadySimAPI

unPause

public void unPause()

Un-MultiShadySimAPI.pause() this MultiShadySim.

Specified by:
unPause in interface MultiShadySimAPI

getClock

public vona.time.Clock getClock()

Get the clock this MultiShady is using.

This impl returns clock.

Specified by:
getClock in interface MultiShadyCommonAPI
Returns:
the clock this MultiShady is using

update

protected void update(double dt)

Updates all members.

Parameters:
dt - the time since the last update, in accelseconds