cz.zcu.fav.kiv.jsim.unsecure
Class UnsecureSimulation

java.lang.Object
  |
  +--cz.zcu.fav.kiv.jsim.JSimSimulation
        |
        +--cz.zcu.fav.kiv.jsim.unsecure.UnsecureSimulation

public class UnsecureSimulation
extends JSimSimulation

UnsecureSimulation is an experimental class that you probably will not use at all. It is intended to be used in distributed simulation where simulation time rollbacks can occur. This class allows you to change the simulation time arbitrarily (even backwards) and to access calendar events for reading before they are interpreted. This can be used for future forecast, e.g. for computation of the lookahead time. You had better not use this class at all.

Since:
J-Sim version 0.3.0
Version:
J-Sim version 0.3.0
Author:
Jarda KAČER

Field Summary
private  boolean undoComing
          A flag saying that the simulation will have to roll back.
 
Fields inherited from class cz.zcu.fav.kiv.jsim.JSimSimulation
calendar, MODE_GUI_BATCH, MODE_GUI_INTERACTIVE, MODE_TXT, NEW_PROCESS_FORBIDDEN, NEW_QUEUE_FORBIDDEN, NEW_SEMAPHORE_FORBIDDEN, PRN_ERROR, PRN_MESSAGE, SIMULATION_IN_PROGRESS, SIMULATION_NOT_STARTED, SIMULATION_TERMINATED, time
 
Constructor Summary
UnsecureSimulation(java.lang.String name)
          Creates a new simulation with no processes, no queues and no graphic window.
UnsecureSimulation(java.lang.String name, int mode)
          Creates a new simulation with no processes, no queues and no graphic window.
UnsecureSimulation(java.lang.String name, int mode, double guiUpdateDelta)
          Creates a new simulation with no processes, no queues and no graphic window.
 
Method Summary
protected  void addWholeEventToCalendar(JSimCalendarEvent jsce)
          Adds a new event to the calendar.
protected  void advanceTime(double positiveDelta)
          Advances the simulation time by a positive delta.
protected  java.util.ListIterator getAllEventsFromCalendar()
          Returns a list iterator over copies of all events of the calendar.
protected  JSimCalendarEvent[] getFirstNEventsFromCalendar(int n)
          Returns copies of first N events from the calendar.
 boolean isUndoComing()
          Reports the status of the undo-coming (future rollback) flag.
protected  void rollbackTime(double negativeDelta)
          Rolls back the simulation time by a negative delta.
protected  void setTime(double absoluteTime)
          Sets the value of the simulation time to a new value.
protected  void setUndoComing(boolean newUndoComing)
          Changes the status of the undo-coming (future rollback) flag.
 
Methods inherited from class cz.zcu.fav.kiv.jsim.JSimSimulation
addEntryToCalendar, addProcess, addQueue, addSemaphore, deleteEntriesInCalendar, deleteProcess, error, getCurrentTime, getFreeProcessNumber, getFreeQueueNumber, getFreeSemaphoreNumber, getGraphicLock, getChange, getName, getNumber, getNumberOfProcesses, getNumberOfQueues, getNumberOfSemaphores, getObjectsToBeDisplayed, getRunningProcess, getSimulationMode, getSimulationState, getStepLock, getTalking, getTalkStream, getWaitingForWindowClosure, getWindowClosureLock, changeTalkStream, isRunningGUI, message, messageNoNL, printString, runGUI, setTalking, shutdown, step, switchToNobody, talk, talk, talk, talk, talk, talk, talk, talk, talk, waitForWindowClosure, windowIsClosing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

undoComing

private boolean undoComing
A flag saying that the simulation will have to roll back.

Constructor Detail

UnsecureSimulation

public UnsecureSimulation(java.lang.String name)
                   throws JSimInvalidParametersException
Creates a new simulation with no processes, no queues and no graphic window. The simulation will run in text (console) mode and no graphic output will be allowed.

Parameters:
name - Name of the simulation.
Throws:
JSimInvalidParametersException - This exception is thrown out if the specified name is is null.

UnsecureSimulation

public UnsecureSimulation(java.lang.String name,
                          int mode)
                   throws JSimInvalidParametersException
Creates a new simulation with no processes, no queues and no graphic window. According to the simulation mode specified as a parameter, it will / will not be allowed to use graphic output later. If GUI batch or interactive mode is used, the output will be updated after every step.

Parameters:
name - Name of the simulation.
mode - Simulation mode. Possible values are MODE_TXT, MODE_GUI_BATCH, and MODE_GUI_INTERACTIVE.
Throws:
JSimInvalidParametersException - This exception is thrown out if the specified name is is null or an invalid simulation mode is given to the constructor.

UnsecureSimulation

public UnsecureSimulation(java.lang.String name,
                          int mode,
                          double guiUpdateDelta)
                   throws JSimInvalidParametersException
Creates a new simulation with no processes, no queues and no graphic window. According to the simulation mode specified as a parameter, it will / will not be allowed to use graphic output later.

Parameters:
name - Name of the simulation.
mode - Simulation mode. Possible values are MODE_TXT, MODE_GUI_BATCH, and MODE_GUI_INTERACTIVE.
Throws:
JSimInvalidParametersException - This exception is thrown out if the specified name is is null, an invalid simulation mode is given to the constructor, or if the update interval is less than zero.
Method Detail

isUndoComing

public boolean isUndoComing()
Reports the status of the undo-coming (future rollback) flag.

Returns:
True if the simulation will have to roll back, false otherwise.

setUndoComing

protected void setUndoComing(boolean newUndoComing)
Changes the status of the undo-coming (future rollback) flag.

Parameters:
newUndoComing - The new value of the undo-coming flag.

advanceTime

protected void advanceTime(double positiveDelta)
                    throws JSimInvalidParametersException
Advances the simulation time by a positive delta.

Parameters:
positiveDelta - A simulation time difference between the current and desired simulation time.
Throws:
JSimInvalidParametersException - This exception is thrown out if the delta is negative.

rollbackTime

protected void rollbackTime(double negativeDelta)
                     throws JSimInvalidParametersException
Rolls back the simulation time by a negative delta.

Parameters:
negativeDelta - A simulation time difference between the current and desired simulation time.
Throws:
JSimInvalidParametersException - This exception is thrown out if the delta is positive.

setTime

protected void setTime(double absoluteTime)
Sets the value of the simulation time to a new value.

Parameters:
absoluteTime - The new value of simulation time.

addWholeEventToCalendar

protected void addWholeEventToCalendar(JSimCalendarEvent jsce)
                                throws JSimInvalidParametersException
Adds a new event to the calendar. The event must be valid, i.e. its process must not be null and its simulation time must not be negative. You are fully responsible for correct creation of the event. Adding an incorrect event to the calendar may lead to an unpredicted behavior. Pay attention especially to the following:
  1. The simulation time of the event should not be less than the current simulation time. If it is, your simulation will jump to the past.
  2. The event's process should be a valid J-Sim process present in the same simulation as the calendar.

Parameters:
jsce - The event to be added to the calendar.
Throws:
JSimInvalidParametersException - This exception is thrown out if the event is null or it is rejected by the calendar.

getFirstNEventsFromCalendar

protected JSimCalendarEvent[] getFirstNEventsFromCalendar(int n)
                                                   throws JSimInvalidParametersException
Returns copies of first N events from the calendar. You can modify them at your discretion since they are just copies of the original events. If there are less events in the calendar than you specified (N), some positions in the resulting array will be null. A valid (not-null) array will always be returned, even if there are no events in the calendar.

Parameters:
n - The number of events to be returned.
Returns:
An array of N first events from the calendar, some of which can be null.
Throws:
JSimInvalidParametersException - This exception is thrown out if N is less than 1.

getAllEventsFromCalendar

protected java.util.ListIterator getAllEventsFromCalendar()
Returns a list iterator over copies of all events of the calendar. You may modify them at your discretion without affecting the calendar itself.

Returns:
A list iterator over copies of all events of the calendar.


Copyright © 2000-2004 University of West Bohemia, FAV-KIV. All Rights Reserved. Build date 20040510.