Class JSLDatabaseObserver


  • public class JSLDatabaseObserver
    extends java.lang.Object
    The purpose of this class is to facilitate the observation of a simulation model's before experiment, after replication, and after experiment actions so that the supplied JSLDatabase may collect data into the database based on the simulation run.

    The user has the option to have the collected data associated with the supplied simulation cleared prior to each executed experiment of the simulation. Any other data in the database from other simulation experiments will not be cleared.

    The default is to clear the data from the simulation's previous experiment that has the same experiment name. Thus, if you re-run the simulation w/o changing the simulation experiment's name, the data will be cleared and re-collected.

    • Constructor Detail

      • JSLDatabaseObserver

        public JSLDatabaseObserver​(JSLDatabase db,
                                   Simulation sim)
        By default collected data will be cleared before each experiment with the same name.
        Parameters:
        db - the database to collect data into, must not be null
        sim - the simulation to collect data from, must not be null
      • JSLDatabaseObserver

        public JSLDatabaseObserver​(JSLDatabase db,
                                   Simulation sim,
                                   boolean clearDataBeforeExperimentOption)
        Parameters:
        db - the database to collect data into, must not be null
        sim - the simulation to collect data from, must not be null
        clearDataBeforeExperimentOption - true indicates that data collected from previous experiments will be cleared before a new experiment executes
    • Method Detail

      • createJSLDatabaseObserver

        public static JSLDatabaseObserver createJSLDatabaseObserver​(Simulation sim)
        Creates a JSLDatabaseObserver with a JSLDatabase that is named after the simulation, as JSLDb_nameOfSimulation The database will be cleared before new experiments execute
        Parameters:
        sim - the simulation to collect data from, must not be null
        Returns:
        the created JSLDatabaseObserver
      • createJSLDatabaseObserver

        public static JSLDatabaseObserver createJSLDatabaseObserver​(Simulation sim,
                                                                    boolean clearDataBeforeExperimentOption)
        Creates a JSLDatabaseObserver with a JSLDatabase that is named after the simulation, as JSLDb_nameOfSimulation
        Parameters:
        sim - the simulation to collect data from, must not be null
        clearDataBeforeExperimentOption - true indicates that data collected from previous experiments will be cleared before a new experiment executes
        Returns:
        the created JSLDatabaseObserver
      • createJSLDatabaseObserver

        public static JSLDatabaseObserver createJSLDatabaseObserver​(java.lang.String dbName,
                                                                    Simulation sim)
        Creates a JSLDatabaseObserver with a JSLDatabase that is named after the simulation. The database will be cleared before new experiments execute
        Parameters:
        dbName - the name of the JSLDatabase, if null the name is derived from the simulation name as JSLDb_nameOfSimulation
        sim - the simulation to collect data from, must not be null
        Returns:
        the created JSLDatabaseObserver
      • createJSLDatabaseObserver

        public static JSLDatabaseObserver createJSLDatabaseObserver​(java.lang.String dbName,
                                                                    Simulation sim,
                                                                    boolean clearDataBeforeExperimentOption)
        Creates a JSLDatabaseObserver with a JSLDatabase
        Parameters:
        dbName - the name of the JSLDatabase, if null the name is derived from the simulation name as JSLDb_nameOfSimulation
        sim - the simulation to collect data from, must not be null
        clearDataBeforeExperimentOption - true indicates that data collected from previous experiments will be cleared before a new experiment executes
        Returns:
        the created JSLDatabaseObserver
      • getJSLDatabase

        public final JSLDatabase getJSLDatabase()
        Returns:
        the underlying JSLDatabase
      • getSimulation

        public final Simulation getSimulation()
        Returns:
        the underlying simulation being observed.
      • getClearDataBeforeExperimentOption

        public final boolean getClearDataBeforeExperimentOption()
        Returns:
        true indicates that data collected from previous experiments with the same name will be cleared before a new experiment with the same name executes
      • setClearDataBeforeExperimentOption

        public final void setClearDataBeforeExperimentOption​(boolean clearDataBeforeExperimentOption)
        Parameters:
        clearDataBeforeExperimentOption - true indicates that data collected from previous experiments will be cleared before a new experiment executes
      • stopObserving

        public final void stopObserving()
        Tells the observer to stop observing the Simulation Model
      • startObserving

        public final void startObserving()
        If the observer is not already observing the simulation model, then it will start observing