All Packages Class Hierarchy This Package Previous Next Index
Class pbsim.PBrick
java.lang.Object
|
+----pbsim.PBrick
- public class PBrick
- extends java.lang.Object
-
MAX_INT
-
-
MIN_INT
-
-
deliverMessage(int)
- Deliver a message to the PBrick.
-
getDatalog()
- Get the datalog.
-
getDisplay()
-
-
getOutput(int)
- Get a specified output.
-
getOutputCount()
- Get the number of outputs supported by the PBrick.
-
getSensor(int)
- Get a specified sensor.
-
getSensorCount()
- Get the number of sensors supported by the PBrick.
-
getTicks()
- Get the system tick count.
-
getWatch()
- Get the system watch.
-
isRunning()
- Check if a program is running.
-
load(Program)
- Load a program into the "active" slot.
-
reset()
- Reset the PBrick.
-
runFor(int)
- Execute for a specified number of simulation ticks.
-
setDebugListener(DebugListener)
- Set the listener to be used for Debug events
-
setDisplayListener(DisplayListener)
- Set the listener used for display events.
-
setMessageListener(MessageListener)
- Set the listener to be used for Message events
-
setOutputListener(OutputListener)
- Set the listener to be used for output events
-
setSensorListener(SensorListener)
- Set the listener to be used for sensor events
-
setSoundListener(SoundListener)
- Set the listener to be used for Sound events
-
start()
- Start the current program.
-
step()
- Execute one bytecode instruction.
-
stop()
- Stop the current program.
-
switchProgram(int)
- Select which program slot should be "active".
MAX_INT
public static final int MAX_INT
MIN_INT
public static final int MIN_INT
switchProgram
public void switchProgram(int n)
- Select which program slot should be "active". This has the side
effect of stopping the currently running program (if any).
- Parameters:
- n - desired program slot (0 based)
load
public void load(pbsim.Program p)
- Load a program into the "active" slot. This has the side
effect of stopping the currently running program (if any). Data
is read and copied out of p - any future modification to p will not
affect the running of the program within the PBrick.
- Parameters:
- p - new program to load
setSoundListener
public void setSoundListener(pbsim.SoundListener s)
- Set the listener to be used for Sound events
setDebugListener
public void setDebugListener(pbsim.DebugListener l)
- Set the listener to be used for Debug events
getDatalog
public pbsim.Datalog getDatalog()
- Get the datalog.
- Returns:
- the datalog, or null if PBrick doesn't support a datalog
setMessageListener
public synchronized void setMessageListener(pbsim.MessageListener m)
- Set the listener to be used for Message events
deliverMessage
public synchronized void deliverMessage(int m)
- Deliver a message to the PBrick. Use this call to simulate a host computer
or another PBrick sending a message to this one.
- Parameters:
- m - value of the message (0-255)
start
public synchronized void start()
- Start the current program. If the program is already runniing, it will
be stopped, then restarted. This is similar to pressing the "Run" button
on a real RCX when a program is not already running. Note that this will
not cause the simulator to actually execute any program code - it just
puts the simulator in a mode where the tasks are ready to be run. The
methods step() and runFor() are used to advance the simulation.
stop
public synchronized void stop()
- Stop the current program. This stops all tasks in the program, putting
the PBrick back in the idle state. This is similar to pressing the "Run"
button on a real RCX when a program is running.
isRunning
public boolean isRunning()
- Check if a program is running.
- Returns:
- s true iff a program is running
getTicks
public int getTicks()
- Get the system tick count.
The PBrick uses a system tick of 10ms (simulation time, not real time). This
method returns the current system tick count. It can be used to determine
how much simulation time has passed.
getWatch
public int getWatch()
- Get the system watch. The system watch keeps track of the number of minutes
since reset. It wraps after 24 hours.
- Returns:
- s the system watch value
reset
public void reset()
- Reset the PBrick.
Stops the current program and resets all timing values. This is similar
to turning a real RCX off and back on.
step
public synchronized void step()
- Execute one bytecode instruction.
One instruction is simulated, possibly resulting in callbacks
to listeners and/or advancing the system time. This is the primary
mechanism for advancing the simulation.
runFor
public synchronized void runFor(int duration)
- Execute for a specified number of simulation ticks.
The simulation is run until the specified number of ticks has
elapsed (in simulation time, not real time).
- Parameters:
- duration - amount of time in simulated 10ms ticks
getSensorCount
public int getSensorCount()
- Get the number of sensors supported by the PBrick.
- Returns:
- number of sensors
getSensor
public pbsim.Sensor getSensor(int i)
- Get a specified sensor.
- Parameters:
- i - index of the sensor (0 based)
- Returns:
- the specified sensor
setSensorListener
public void setSensorListener(pbsim.SensorListener l)
- Set the listener to be used for sensor events
getOutputCount
public int getOutputCount()
- Get the number of outputs supported by the PBrick.
- Returns:
- number of outputs
getOutput
public pbsim.Output getOutput(int i)
- Get a specified output.
- Parameters:
- i - index of the output (0 based)
- Returns:
- the specified sensor
setOutputListener
public void setOutputListener(pbsim.OutputListener l)
- Set the listener to be used for output events
setDisplayListener
public void setDisplayListener(pbsim.DisplayListener l)
- Set the listener used for display events.
getDisplay
public pbsim.Display getDisplay()
All Packages Class Hierarchy This Package Previous Next Index