verinec.netsim.gui
Class Simulator

java.lang.Object
  extended by verinec.netsim.gui.Simulator
All Implemented Interfaces:
IVerinecModule

public class Simulator
extends Object
implements IVerinecModule

Simulator module for Verinec. Provides ways to start a simulation and visualizes the simulation output. This module will disallow modifications.

Author:
david.buchmann at unifr.ch
See Also:
to learn how to run simulation in endless loop

Nested Class Summary
(package private)  class Simulator.GenerateAction
          Display the dialog to generate input events.
(package private)  class Simulator.LoadSimuInputAction
          Load simulation input.
(package private)  class Simulator.PlaySimuResultAction
          Load simulation result and display it.
(package private)  class Simulator.RunSimulationAction
          Calculate simulation result and display it.
(package private)  class Simulator.SaveSimuInputAction
          Save simulation input that was edited for this network.
(package private)  class Simulator.SaveSimuResultAction
          Save simulation result, normally created by the simulator.
 
Field Summary
private  Component configPanel
           
private  Events events
           
private  Action loadSimuInputAction
           
private  Action loadSimuResultAction
           
private  Logger logger
           
private  JMenu menuSimulation
           
private static String NETWORK_ICON
          Icon for the new action.
private  Action runSimulationAction
           
private  Action saveSimeResultAction
           
private  Action saveSimuInputAction
           
private  Events simulationEvents
           
private  SimulationToolbar simulationToolbar
           
private  VerinecStudio verinecStudio
           
 
Constructor Summary
Simulator()
           
 
Method Summary
 void addSimuInput(Event input)
          Add an input event to the list for running the simulation.
 boolean calculateSimulation()
          Use test definition objects to run the simulator with and play the results.
 void editEvent(Event event, boolean isNewEvent)
          Shows the dialog to create/edit an event.
 void editEvent(int index)
          Shows the dialog to edit an Event from the Events List.
 void editEvents(int[] selectedIndices)
           
 void enableSaveMenu()
          This method enables the save menu point in the simulation Menu
 Events getEvents()
          Gets the input Events for the Simulator
 void inputChanged()
          This method indicates the config Panel that something in the event list has changed.
 void load(VerinecStudio parent)
          Load this module to be the active module.
 void loadResult(String filename)
          Load a test result file and display it.
 void playSimulation()
          Start playing the simulation.
 void resetConfiguration(Component c)
          Will never be called because we have no config panel.
 void resultAvailable(boolean b)
          Tell the module whether there is a result that can be saved.
 void saveConfiguration(Component c)
          Will never be called because we have no config panel.
 String toString()
          The toString method should just return the modules name for the module selection dropdown.
 void unload()
          Stops the simulation.
 void updateComponent(NwComponent c)
          Adds context menues depending on the types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private Logger logger

NETWORK_ICON

private static final String NETWORK_ICON
Icon for the new action. Taken from crystalsvg /usr/share/icons/crystalsvg/16x16/filesystems/

See Also:
Constant Field Values

menuSimulation

private JMenu menuSimulation

loadSimuInputAction

private Action loadSimuInputAction

saveSimuInputAction

private Action saveSimuInputAction

runSimulationAction

private Action runSimulationAction

loadSimuResultAction

private Action loadSimuResultAction

saveSimeResultAction

private Action saveSimeResultAction

events

private Events events

simulationEvents

private Events simulationEvents

simulationToolbar

private SimulationToolbar simulationToolbar

verinecStudio

private VerinecStudio verinecStudio

configPanel

private Component configPanel
Constructor Detail

Simulator

public Simulator()
Method Detail

toString

public String toString()
Description copied from interface: IVerinecModule
The toString method should just return the modules name for the module selection dropdown.

Specified by:
toString in interface IVerinecModule
Overrides:
toString in class Object
Returns:
The module name for the dropdown.
See Also:
IVerinecModule.toString()

load

public void load(VerinecStudio parent)
          throws VerinecException
Description copied from interface: IVerinecModule
Load this module to be the active module. A module can rely on this method being called before it is used, except for the three configuration methods. During this method call, however, it is not yet the active module in the analyser. The module is unloaded and loaded again when an other network is opened in the gui.

Specified by:
load in interface IVerinecModule
Parameters:
parent - The analyser to use for call backs.
Throws:
VerinecException - If something goes wrong while loading. The module will not be used after throwing an exception.
See Also:
IVerinecModule.load(verinec.gui.VerinecStudio)

updateComponent

public void updateComponent(NwComponent c)
Adds context menues depending on the types. When the module is loading, this method is called for each NwComponent to update the component.

Parameters:
c - The component to update.

resultAvailable

public void resultAvailable(boolean b)
Tell the module whether there is a result that can be saved.

Parameters:
b - True if there is a result available, false otherwise.

unload

public void unload()
Stops the simulation.

Specified by:
unload in interface IVerinecModule
See Also:
IVerinecModule.unload()

addSimuInput

public void addSimuInput(Event input)
Add an input event to the list for running the simulation.

Parameters:
input - The input element.

inputChanged

public void inputChanged()
This method indicates the config Panel that something in the event list has changed. So it can reread this list and update the display.


enableSaveMenu

public void enableSaveMenu()
This method enables the save menu point in the simulation Menu


calculateSimulation

public boolean calculateSimulation()
Use test definition objects to run the simulator with and play the results. The simulation is performed by the verinec.netsim module.

Returns:
True if successful, false if failed.

playSimulation

public void playSimulation()
Start playing the simulation.


loadResult

public void loadResult(String filename)
Load a test result file and display it. Similar to the calculateSimulation() method, but loads an exisiting result file. After the file is loaded, automatically starts the simulation.

Parameters:
filename - Name of a existing test result file.

saveConfiguration

public void saveConfiguration(Component c)
Will never be called because we have no config panel.

Parameters:
c - Configuration panel.

resetConfiguration

public void resetConfiguration(Component c)
Will never be called because we have no config panel.

Parameters:
c - Configuration panel.

editEvent

public void editEvent(Event event,
                      boolean isNewEvent)
Shows the dialog to create/edit an event.

Parameters:
event - the event object that will be edited in the dialog.
isNewEvent - true if a new event will be created, false otherwise.

editEvents

public void editEvents(int[] selectedIndices)
Parameters:
selectedIndices -

getEvents

public Events getEvents()
Gets the input Events for the Simulator

Returns:
the input Events for the Simulator

editEvent

public void editEvent(int index)
Shows the dialog to edit an Event from the Events List.

Parameters:
index - the index of the Event from the Events List that should be edited.

Copyright © 2005 Verinec, DIUF