All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pbsim.PBrick

java.lang.Object
   |
   +----pbsim.PBrick

public class PBrick
extends java.lang.Object

Variable Index

 o MAX_INT
 o MIN_INT

Method Index

 o deliverMessage(int)
Deliver a message to the PBrick.
 o getDatalog()
Get the datalog.
 o getDisplay()
 o getOutput(int)
Get a specified output.
 o getOutputCount()
Get the number of outputs supported by the PBrick.
 o getSensor(int)
Get a specified sensor.
 o getSensorCount()
Get the number of sensors supported by the PBrick.
 o getTicks()
Get the system tick count.
 o getWatch()
Get the system watch.
 o isRunning()
Check if a program is running.
 o load(Program)
Load a program into the "active" slot.
 o reset()
Reset the PBrick.
 o runFor(int)
Execute for a specified number of simulation ticks.
 o setDebugListener(DebugListener)
Set the listener to be used for Debug events
 o setDisplayListener(DisplayListener)
Set the listener used for display events.
 o setMessageListener(MessageListener)
Set the listener to be used for Message events
 o setOutputListener(OutputListener)
Set the listener to be used for output events
 o setSensorListener(SensorListener)
Set the listener to be used for sensor events
 o setSoundListener(SoundListener)
Set the listener to be used for Sound events
 o start()
Start the current program.
 o step()
Execute one bytecode instruction.
 o stop()
Stop the current program.
 o switchProgram(int)
Select which program slot should be "active".

Variables

 o MAX_INT
 public static final int MAX_INT
 o MIN_INT
 public static final int MIN_INT

Methods

 o 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)
 o 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
 o setSoundListener
 public void setSoundListener(pbsim.SoundListener s)
Set the listener to be used for Sound events

 o setDebugListener
 public void setDebugListener(pbsim.DebugListener l)
Set the listener to be used for Debug events

 o getDatalog
 public pbsim.Datalog getDatalog()
Get the datalog.

Returns:
the datalog, or null if PBrick doesn't support a datalog
 o setMessageListener
 public synchronized void setMessageListener(pbsim.MessageListener m)
Set the listener to be used for Message events

 o 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)
 o 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.

 o 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.

 o isRunning
 public boolean isRunning()
Check if a program is running.

Returns:
s true iff a program is running
 o 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.

 o 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
 o 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.

 o 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.

 o 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
 o getSensorCount
 public int getSensorCount()
Get the number of sensors supported by the PBrick.

Returns:
number of sensors
 o getSensor
 public pbsim.Sensor getSensor(int i)
Get a specified sensor.

Parameters:
i - index of the sensor (0 based)
Returns:
the specified sensor
 o setSensorListener
 public void setSensorListener(pbsim.SensorListener l)
Set the listener to be used for sensor events

 o getOutputCount
 public int getOutputCount()
Get the number of outputs supported by the PBrick.

Returns:
number of outputs
 o getOutput
 public pbsim.Output getOutput(int i)
Get a specified output.

Parameters:
i - index of the output (0 based)
Returns:
the specified sensor
 o setOutputListener
 public void setOutputListener(pbsim.OutputListener l)
Set the listener to be used for output events

 o setDisplayListener
 public void setDisplayListener(pbsim.DisplayListener l)
Set the listener used for display events.

 o getDisplay
 public pbsim.Display getDisplay()

All Packages  Class Hierarchy  This Package  Previous  Next  Index