Package mars.tools

Class AbstractMarsToolAndApplication

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool
Direct Known Subclasses:
BHTSimulator, BitmapDisplay, CacheSimulator, DigitalLabSim, FloatRepresentation, InstructionCounter, InstructionStatistics, IntroToTools, KeyboardAndDisplaySimulator, MemoryReferenceVisualization, MipsXray

public abstract class AbstractMarsToolAndApplication extends JFrame implements MarsTool, Observer
An abstract class that provides generic components to facilitate implementation of a MarsTool and/or stand-alone Mars-based application. Provides default definitions of both the action() method required to implement MarsTool and the go() method conventionally used to launch a Mars-based stand-alone application. It also provides generic definitions for interactively controlling the application. The generic controls for MarsTools are 3 buttons: connect/disconnect to MIPS resource (memory and/or registers), reset, and close (exit). The generic controls for stand-alone Mars apps include: button that triggers a file open dialog, a text field to display status messages, the run-speed slider to control execution rate when running a MIPS program, a button that assembles and runs the current MIPS program, a button to interrupt the running MIPS program, a reset button, and an exit button. Pete Sanderson, 14 November 2006.
See Also:
Serialized Form
  • Method Details

    • getName

      public abstract String getName()
      Required MarsTool method to return Tool name. Must be defined by subclass.
      Specified by:
      getName in interface MarsTool
      Overrides:
      getName in class Component
      Returns:
      Tool name. MARS will display this in menu item.
    • go

      public void go()
      Run the simulator as stand-alone application. For this default implementation, the user-defined main display of the user interface is identical for both stand-alone and MARS Tools menu use, but the control buttons are different because the stand-alone must include a mechansim for controlling the opening, assembling, and executing of an underlying MIPS program. The generic controls include: a button that triggers a file open dialog, a text field to display status messages, the run-speed slider to control execution rate when running a MIPS program, a button that assembles and runs the current MIPS program, a reset button, and an exit button. This method calls 3 methods that can be defined/overriden in the subclass: initializePreGUI() for any special initialization that must be completed before building the user interface (e.g. data structures whose properties determine default GUI settings), initializePostGUI() for any special initialization that cannot be completed until after the building the user interface (e.g. data structure whose properties are determined by default GUI settings), and buildMainDisplayArea() to contain application-specific displays of parameters and results.
    • action

      public void action()
      Required MarsTool method to carry out Tool functions. It is invoked when MARS user selects this tool from the Tools menu. This default implementation provides generic definitions for interactively controlling the tool. The generic controls for MarsTools are 3 buttons: connect/disconnect to MIPS resource (memory and/or registers), reset, and close (exit). Like "go()" above, this default version calls 3 methods that can be defined/overriden in the subclass: initializePreGUI() for any special initialization that must be completed before building the user interface (e.g. data structures whose properties determine default GUI settings), initializePostGUI() for any special initialization that cannot be completed until after the building the user interface (e.g. data structure whose properties are determined by default GUI settings), and buildMainDisplayArea() to contain application-specific displays of parameters and results.
      Specified by:
      action in interface MarsTool
    • update

      public void update(Observable resource, Object accessNotice)
      Called when receiving notice of access to MIPS memory or registers. Default implementation of method required by Observer interface. This method will filter out notices originating from the MARS GUI or from direct user editing of memory or register displays. Only notices arising from MIPS program access are allowed in. It then calls two methods to be overridden by the subclass (since they do nothing by default): processMIPSUpdate() then updateDisplay().
      Specified by:
      update in interface Observer
      Parameters:
      resource - the attached MIPS resource
      accessNotice - AccessNotice information provided by the resource