sims.ihm.mdt
Class Simulation

java.lang.Object
  extended by java.lang.Thread
      extended by sims.ihm.mdt.Simulation
All Implemented Interfaces:
java.lang.Runnable, GraphicValues, InterfaceSimulation

public class Simulation
extends java.lang.Thread
implements InterfaceSimulation, GraphicValues


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface sims.InterfaceSimulation
VITESSES
 
Fields inherited from interface sims.ihm.GraphicValues
CELL_SIZE, CMD_BUTTON_HEIGHT, CMD_BUTTON_WIDTH, COMMANDS_HEIGHT, COMMANDS_WIDTH, CRED_HEIGHT, CRED_WIDTH, CRS, EDIT_HEIGHT, EDIT_WIDTH, EDIT_X, EDIT_Y, GRAPH_HEIGHT, GRAPH_WIDTH, HELP_HEIGHT, HELP_WIDTH, LAST_CELL, MAIN_HEIGHT, MAIN_WIDTH, MESS_HEIGHT, MESS_WIDTH, METAL_LAF, MOTIF_LAF, POLICE, POLIZEI, TAILLE_BARRE_TACHE, TAPE_SIZE, TAPES_SPACE, TMODIF_HEIGH, TMODIF_WIDTH, TUPDT_HEIGHT, TUPDT_WIDTH, VIEW_HEIGHT, VIEW_WIDTH
 
Constructor Summary
Simulation(java.lang.String fileName, TmLauncher l)
          Initialize the Simulation.
 
Method Summary
 void arreter()
          Same as than demarrer().
 void charger(java.io.File file)
          Compile and load a machine from its File instance.
 void charger(java.lang.String fileName)
          Compile and load a machine from its file name.
 void closeGraph()
          Close the graph, by setting it non visible and put gr at null
 void createGraph()
          cCreate the graph window, from (GraphInterface) m
 java.lang.String currentState()
           
 void decVitesse()
          Decreases the speed value of one, if the speed is at one starts the turbo mode and set speed value to zero.
 void demarrer()
          Turns the boolean value stopped to his contrary, hence stop the machine if running, restart it if stopped.
 int getLine()
           
 java.lang.String getNom()
           
 int getSpace()
           
 int getTapeNb()
           
 int getTime()
           
 int getVitesse()
           
 int headPosition(int i)
          Gives the head position index of the tape i.
 void incVitesse()
          Increases the speed value of one and display a message of the modification, if the speed value was below five.
 boolean isGravity()
           
 boolean isND()
           
 boolean isProb()
           
 boolean isStopped()
          For TmLauncher, to know if machine is running when trying to edit tapes
 int min(int i)
           
 int nbTapes()
           
 void prochainPas()
          To pass to the next step manually.
 void reinitialiser()
          Reset the machine, by turning the boolean value reset at true.
 void run()
          Starts the machine, and keep it in memory after execution to reset it, until viewing is not closed.
 void setTapeContent(java.lang.String word, int tapeNb)
          update the content of the tape i with word, display an error message if update fails.
 void setVitesse(int i)
           
 void showGraph(boolean boo)
          Show or hide the graph.
 void stopp()
          Stop the simulation by turning the semaphore running
 java.lang.String wordOnTape(int i)
          Asks the machine word on the tape i.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Simulation

public Simulation(java.lang.String fileName,
                  TmLauncher l)
Initialize the Simulation.

Parameters:
fileName - the String of the file name.
l - the TmLauncher which created the simulation.
Method Detail

run

public void run()
Starts the machine, and keep it in memory after execution to reset it, until viewing is not closed.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

wordOnTape

public java.lang.String wordOnTape(int i)
Asks the machine word on the tape i.

Parameters:
i - the number of a tape, from 0 to (number of tapes - 1).
Returns:
a String corresponding to the word on the tape i, where the first character is the leftmost non-blank cell visited.

headPosition

public int headPosition(int i)
Gives the head position index of the tape i.

Parameters:
i - the number of the tape from 0 to (number of tapes - 1 )
Returns:
the scannedSquare position number

currentState

public java.lang.String currentState()
Returns:
the current state of the machine.

nbTapes

public int nbTapes()
Returns:
the number of tapes of the machine.

demarrer

public void demarrer()
Turns the boolean value stopped to his contrary, hence stop the machine if running, restart it if stopped.

Specified by:
demarrer in interface InterfaceSimulation

arreter

public void arreter()
Same as than demarrer().

Specified by:
arreter in interface InterfaceSimulation

reinitialiser

public void reinitialiser()
Reset the machine, by turning the boolean value reset at true.

Specified by:
reinitialiser in interface InterfaceSimulation

prochainPas

public void prochainPas()
To pass to the next step manually.

Specified by:
prochainPas in interface InterfaceSimulation

getNom

public java.lang.String getNom()
Specified by:
getNom in interface InterfaceSimulation
Returns:
the name of the machine.

incVitesse

public void incVitesse()
Increases the speed value of one and display a message of the modification, if the speed value was below five. Otherwise display an error message.

Specified by:
incVitesse in interface InterfaceSimulation

decVitesse

public void decVitesse()
Decreases the speed value of one, if the speed is at one starts the turbo mode and set speed value to zero. If speed value is zero, display an error message, else display a message for the speed modification..

Specified by:
decVitesse in interface InterfaceSimulation

setVitesse

public void setVitesse(int i)

charger

public void charger(java.lang.String fileName)
             throws java.io.IOException,
                    ExceptionCompilation
Compile and load a machine from its file name.

Parameters:
fileName - a String corresponding to the file name.
Throws:
java.io.IOException
ExceptionCompilation

charger

public void charger(java.io.File file)
             throws java.io.IOException,
                    ExceptionCompilation
Compile and load a machine from its File instance.

Parameters:
file - the File instance corresponding to the file.
Throws:
java.io.IOException
ExceptionCompilation

stopp

public void stopp()
Stop the simulation by turning the semaphore running


isND

public boolean isND()
Returns:
true if the machine is non deterministic (simple, probabilistic or gravity).

isProb

public boolean isProb()
Returns:
true if the machine is probabilistic (or gravity).

isGravity

public boolean isGravity()
Returns:
true if the machine is a gravity machine.

isStopped

public boolean isStopped()
For TmLauncher, to know if machine is running when trying to edit tapes

Returns:
the boolean stopped, thus true if the machine is stopped (or paused), false otherwise.

createGraph

public void createGraph()
cCreate the graph window, from (GraphInterface) m


closeGraph

public void closeGraph()
Close the graph, by setting it non visible and put gr at null


showGraph

public void showGraph(boolean boo)
Show or hide the graph.

Parameters:
boo - if true sets the graph visible, otherwise set it non visible.

min

public int min(int i)
Returns:
the minimum square reached index.

getTime

public int getTime()
Returns:
the current time complexity value, equals to the number of transitions of the machine.

getSpace

public int getSpace()
Returns:
the current space complexitu value, equals to the number of cells visited on all the tapes.

getVitesse

public int getVitesse()
Specified by:
getVitesse in interface InterfaceSimulation
Returns:
the speed value, from zero (turbo mode) to five.

getTapeNb

public int getTapeNb()
Returns:
the number of tapes.

getLine

public int getLine()
Returns:
the line number of last used instruction line

setTapeContent

public void setTapeContent(java.lang.String word,
                           int tapeNb)
update the content of the tape i with word, display an error message if update fails.

Parameters:
tapeNb - the number of the tape.
word - the new content of the tape, each caracter for a cell of the tape.