Class AbstractDevsModel<T extends Number & Comparable<T>>

java.lang.Object
org.djutils.event.LocalEventProducer
nl.tudelft.simulation.dsol.formalisms.devs.esdevs.AbstractDevsModel<T>
Type Parameters:
T - the time type
All Implemented Interfaces:
Serializable, Remote, org.djutils.event.EventProducer
Direct Known Subclasses:
AbstractDevsPortModel, AbstractEntity

public abstract class AbstractDevsModel<T extends Number & Comparable<T>> extends org.djutils.event.LocalEventProducer
AbstractDevsModel class. The basic model or component from which the AtomicModel, the CoupledModel, and the AbstractEntity are derived. The DevsModel provides basic functionality for reporting its state changes through the publish/subscribe mechanism.

Copyright (c) 2009-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.

Since:
1.5
Author:
Mamadou Seck
, Alexander Verbraeck
See Also:
  • Field Details

    • parentModel

      protected CoupledModel<T extends Number & Comparable<T>> parentModel
      the parent model we are part of.
    • simulator

      protected DevsSimulatorInterface<T extends Number & Comparable<T>> simulator
      the simulator this model or component will schedule its events on.
    • modelName

      protected String modelName
      all DEVS models are named - this is the component name.
    • fullName

      protected String fullName
      all DEVS models are named - this is the full name with dot notation.
    • STATE_UPDATE

      public static final org.djutils.event.EventType STATE_UPDATE
      event for listeners about state update.
  • Constructor Details

    • AbstractDevsModel

      public AbstractDevsModel(String modelName, DevsSimulatorInterface<T> simulator, CoupledModel<T> parentModel)
      Constructor for an abstract DEVS model: we have to indicate the simulator to schedule the events on, and the parent model we are part of. A parent model of null means that we are the top model.
      Parameters:
      modelName - String; the name of this component
      simulator - DevsSimulatorInterface<T>; the simulator to schedule the events on.
      parentModel - CoupledModel<T>; the parent model we are part of.
  • Method Details

    • getSimulator

      public DevsSimulatorInterface<T> getSimulator()
      Returns:
      the simulator this model schedules its events on.
    • setSimulator

      public void setSimulator(DevsSimulatorInterface<T> simulator)
      Parameters:
      simulator - DevsSimulatorInterface<T>; the simulator to use from now on
    • getParentModel

      public CoupledModel<T> getParentModel()
      Returns:
      the parent model we are part of.
    • getModelName

      public String getModelName()
      Returns:
      the name of the model.
    • getFullName

      public String getFullName()
      Returns:
      the full name of the model in dot notation.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • printModel

      public abstract void printModel(String header)
      Print the model, preceded by a user provided string.
      Parameters:
      header - String; the user provided string to print in front of the model (e.g. newlines, header).
    • fireUpdatedState

      protected void fireUpdatedState()
      Fire a state update. At this moment, all state variables are reported for an atomic model when it fires its delta_internal or delta_external method. More intelligence can be added here later. For simple types, a comparison with the old value (state map) is possible. For complex variables (objects) this is more difficult as a deep clone should be saved as old state, followed by a full comparison. This does not seem practical, and more expensive than firing the state change of all state variables. The intelligence to detect real state changes then has to be built in at the receiver's side.