miSim

misim
Class MiSimDE

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--misim.MiSimDE
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, LogListener, java.awt.MenuContainer, ProcessorListener, RobustReaderIF, java.lang.Runnable, java.io.Serializable

public class MiSimDE
extends java.applet.Applet
implements java.awt.event.ActionListener, ProcessorListener, LogListener, RobustReaderIF, java.lang.Runnable

MiSimDE - the main class that presents the miSim GUI, either as an Applet, or as an independent application.

miSim DE is an Object Oriented simulator for microcontrollers. Initially it supports the Arizona Microchip PIC®16x84 series of microcontrollers. It includes an assembler, disassembler, simple editor, simulator and plugin architecture allowing simulation of devices connected to the emulated microcontroller.

The MiSimDE presents uses a card layout to show panels for logging emulator activity, disassembly, Plugin control, file editing and other emulator facilities. It controls the emulation itself by creating a Processor instance and using that to load files and emulate the loaded software.

See Also:
Serialized Form

Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
 java.lang.String language
          This variable stores the language setting for the application..
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MiSimDE()
          Default Instantiation method which sets a flag that the class is being run as an applet.
MiSimDE(boolean isApplet, java.awt.Frame aFrame, java.lang.String language, java.lang.String settings)
          Instantiation method which allows the caller to indicate whether the class is being run as an applet
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent anEvent)
          Respond to a GUI event.
 void announce(java.lang.String message)
          Logging method displays the given message both on the bottom panel of the application and at the tail of the log window
 void assemble()
          Assemble the currently viewed file.
 void doQuit()
           
 java.awt.Image getImage(java.lang.String filename)
          Load the an image from the given filename
 java.io.InputStreamReader getStreamReader(java.lang.String filename)
          Create an input stream reader from the given filename
 void init()
          Main initialisation method for the miSim DE Read settings and initialise the applet in a separate thread
 java.awt.Panel initUI(java.util.Vector settingsLog)
          Create and layout all the GUI elements for the miSim DE
 void loadBinary()
          Prompt the user and load a hex file.
static void main(java.lang.String[] args)
          Main method to start the emulator as a stand alone application
 void newFile()
          Open a new editor window with an empty, undefined file
 void openFile()
          Open an existing file in a new editor window
 void processorStateChange(int state, java.lang.String message)
          ProcessorListener Interface implementation to respond to changes in the state of the processor (in particular starting and stopping of the emulation thread, which happens asynchronously.
 void readSettings(java.io.BufferedReader input, java.util.Vector settingsLog)
          Read the settings from the first part of the settings file, stopping at the end, or when a line starting with the text 'plugins' is encountered.
 void report(java.lang.String message)
          Logging method that only displays the given message on the bottom panel of the application
 void run()
          Run method to initialise the applet in a separate thread..
 void saveFile(boolean saveAs)
          If the current tab is the processor view, prompt the user and save a disassembly of the program loaded into the processor.
 void stop()
           
 void turnToCard(java.lang.String cardName)
          Turn the card layout to the given card, and indicate the current card by changing the colour of the buttons that run along the top of the cards as 'tabs'
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

language

public java.lang.String language
This variable stores the language setting for the application.. By default it is 'en' - English. If it is any other value, then the appropriate message file is read on start up. The language may be controlled either by an applet parameter 'language' (specified by the LANGUAGE_PARAMETER constant), or by passing a command line parameter -l language.
Constructor Detail

MiSimDE

public MiSimDE()
Default Instantiation method which sets a flag that the class is being run as an applet.

MiSimDE

public MiSimDE(boolean isApplet,
               java.awt.Frame aFrame,
               java.lang.String language,
               java.lang.String settings)
Instantiation method which allows the caller to indicate whether the class is being run as an applet
Parameters:
isApplet - Is true if this is an applet
Method Detail

announce

public void announce(java.lang.String message)
Logging method displays the given message both on the bottom panel of the application and at the tail of the log window
Specified by:
announce in interface LogListener
Parameters:
message - The message to display

report

public void report(java.lang.String message)
Logging method that only displays the given message on the bottom panel of the application
Specified by:
report in interface LogListener
Parameters:
message - The message to display

processorStateChange

public void processorStateChange(int state,
                                 java.lang.String message)
ProcessorListener Interface implementation to respond to changes in the state of the processor (in particular starting and stopping of the emulation thread, which happens asynchronously.
Specified by:
processorStateChange in interface ProcessorListener
Parameters:
state - The new state of the processor
message - A message associated with this state change
See Also:
ProcessorListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent anEvent)
Respond to a GUI event. These are sub-grouped by setting the action command to one of the CMD_ static values
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
anEvent - The event to be processed.

newFile

public void newFile()
Open a new editor window with an empty, undefined file

openFile

public void openFile()
Open an existing file in a new editor window

saveFile

public void saveFile(boolean saveAs)
If the current tab is the processor view, prompt the user and save a disassembly of the program loaded into the processor. The saved file attempts to provide all the information necessary to re-assemble the program. Otherwise, if the current tab is an file being edited, save the contents of the file..

doQuit

public void doQuit()

assemble

public void assemble()
Assemble the currently viewed file.

loadBinary

public void loadBinary()
Prompt the user and load a hex file. This method must take account of the fact that the class may be running as either an Applet or an Application, and create an InputStream that is appropriate to the environment

turnToCard

public void turnToCard(java.lang.String cardName)
Turn the card layout to the given card, and indicate the current card by changing the colour of the buttons that run along the top of the cards as 'tabs'
Parameters:
cardName - The name of the card to select

initUI

public java.awt.Panel initUI(java.util.Vector settingsLog)
Create and layout all the GUI elements for the miSim DE

init

public void init()
Main initialisation method for the miSim DE Read settings and initialise the applet in a separate thread
Overrides:
init in class java.applet.Applet

getStreamReader

public java.io.InputStreamReader getStreamReader(java.lang.String filename)
                                          throws java.io.FileNotFoundException,
                                                 java.io.IOException
Create an input stream reader from the given filename
Specified by:
getStreamReader in interface RobustReaderIF
Parameters:
filename - The file name to create a reader for
Returns:
An Input Stream Reader for this file
Throws:
java.io.FileNotFoundException - If the file is not found
java.io.IOException - If an IO Exception occurs whilst reading the file

getImage

public java.awt.Image getImage(java.lang.String filename)
Load the an image from the given filename
Specified by:
getImage in interface RobustReaderIF
Parameters:
filename - The image filename to load
Returns:
The required image

run

public void run()
Run method to initialise the applet in a separate thread.. Create the GUI elements, the processor and load the plugins.
Specified by:
run in interface java.lang.Runnable

readSettings

public void readSettings(java.io.BufferedReader input,
                         java.util.Vector settingsLog)
                  throws java.io.IOException
Read the settings from the first part of the settings file, stopping at the end, or when a line starting with the text 'plugins' is encountered.
Parameters:
input - A buffered reader for the settings file
settingsLog - A Vector that will contain Strings indicating the settings loaded, or any errors

stop

public void stop()
Overrides:
stop in class java.applet.Applet

main

public static void main(java.lang.String[] args)
Main method to start the emulator as a stand alone application
Parameters:
args - Arguments set to the application

miSim