java.lang.Object
desmoj.core.simulator.NamedObject
desmoj.core.simulator.ModelComponent
desmoj.core.simulator.Schedulable
desmoj.core.simulator.Entity
de.rss.fachstudie.MiSim.entities.networking.RequestSender
de.rss.fachstudie.MiSim.entities.generator.Generator
All Implemented Interfaces:
IRequestUpdateListener, IParsableSelfScheduled, ISelfScheduled, IParsable, Comparable<IRequestUpdateListener>
Direct Known Subclasses:
IntervalGenerator, LIMBOGenerator

public abstract class Generator
extends RequestSender
implements IRequestUpdateListener, IParsableSelfScheduled
Superclass for all generators. Automatically takes care of the (re-)scheduling of the generation events, sending of the UserRequests and observation of send requests.
Author:
Lion Wagner
See Also:
UserRequest, IntervalGenerator, LIMBOGenerator
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected AccumulativeDataPointReporter accReporter  
    protected desmoj.core.simulator.Model model  
    protected Operation operation
    Target Operation
    protected MultiDataPointReporter reporter  

    Fields inherited from class de.rss.fachstudie.MiSim.entities.networking.RequestSender

    updateListenerProxy

    Fields inherited from class desmoj.core.simulator.Schedulable

    _schedule
  • Constructor Summary

    Constructors
    Constructor Description
    Generator​(desmoj.core.simulator.Model model, String name, boolean showInTrace, Operation operation)
    Superclass for all generators.
  • Method Summary

    Modifier and Type Method Description
    void doInitialSelfSchedule()
    Does the initial scheduling of this generator.
    void eventRoutine()
    This method is automatically called by the Generator itself.
    protected abstract desmoj.core.simulator.TimeInstant getFirstTargetTime()
    Method to compute the first or initial target time.
    desmoj.core.simulator.TimeInstant getLastTargetTime()  
    desmoj.core.simulator.TimeInstant getNextTargetTime()  
    protected abstract desmoj.core.simulator.TimeInstant getNextTargetTime​(desmoj.core.simulator.TimeInstant lastTargetTime)
    Method to compute the next target time.
    Class<? extends Parser<?>> getParserClass()
    Dummy to allow extension of IParsableSelfScheduled
    boolean onRequestFailed​(Request request, desmoj.core.simulator.TimeInstant when, RequestFailedReason reason)
    Listener for the failure of the sending process.
    boolean onRequestResultArrivedAtRequester​(Request request, desmoj.core.simulator.TimeInstant when)
    Listener for the successful receiving of the answer of a request.

    Methods inherited from class de.rss.fachstudie.MiSim.entities.networking.RequestSender

    addUpdateListener, addUpdateListeners, sendRequest, sendRequest, sendRequest, sendRequest

    Methods inherited from class desmoj.core.simulator.Entity

    clone, generateTraceForScheduling, getIdentNumber, getQueueingPriority, getQueues, getScheduledEvents, isEqual, isLarger, isLargerOrEqual, isNotEqual, isQueued, isSimProcess, isSmaller, isSmallerOrEqual, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, scheduleAfter, scheduleAfter, scheduleAfter, scheduleBefore, scheduleBefore, scheduleBefore, schedulePreempt, schedulePreempt, schedulePreempt, setQueueingPriority

    Methods inherited from class desmoj.core.simulator.Schedulable

    assignReporter, cancel, getCorrespondingReportable, isCurrent, isScheduled, rename, reSchedule, reSchedule, reSchedulePreempt, scheduledNext, setCorrespondingReportable

    Methods inherited from class desmoj.core.simulator.ModelComponent

    current, currentEntity, currentEntityAll, currentEvent, currentlySendDebugNotes, currentlySendTraceNotes, currentModel, currentSimProcess, debugIsOn, debugOff, debugOn, getModel, isExperimentCompatible, isModelCompatible, presentTime, sendDebugNote, sendMessage, sendTraceNote, sendWarning, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOn

    Methods inherited from class desmoj.core.simulator.NamedObject

    getName, getQuotedName, toString

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface de.rss.fachstudie.MiSim.entities.networking.IRequestUpdateListener

    compareTo, getListeningPriority, onRequestArrivalAtTarget, onRequestSend
  • Field Details

  • Constructor Details

    • Generator

      public Generator​(desmoj.core.simulator.Model model, String name, boolean showInTrace, Operation operation)
      Superclass for all generators. Automatically takes care of the (re-)scheduling of the generation events, sending of the * UserRequests and observation of send requests.
      Parameters:
      model - Default desmoj parameter
      name - Default desmoj parameter
      showInTrace - Default desmoj parameter
      operation - Target Operation Instance
  • Method Details

    • getNextTargetTime

      protected abstract desmoj.core.simulator.TimeInstant getNextTargetTime​(desmoj.core.simulator.TimeInstant lastTargetTime)
      Method to compute the next target time. Called by the superclass upon need for a new target TimeInstance. Provides the TimeInstance of last scheduling.

      Can return null or throw a GeneratorStopException to stop the generator.

      Parameters:
      lastTargetTime - last target time
      Returns:
      the next target time
      Throws:
      GeneratorStopException - when the Generator is stops.
    • getFirstTargetTime

      protected abstract desmoj.core.simulator.TimeInstant getFirstTargetTime()
      Method to compute the first or initial target time. Called by the superclass upon need for the first TimeInstance. Should return a constant value.

      Can return null or throw a GeneratorStopException to stop the generator.

      Returns:
      the point in simulation time when the first request should be sent by this generator
      Throws:
      GeneratorStopException - when the Generator is stops.
    • doInitialSelfSchedule

      public void doInitialSelfSchedule()
      Does the initial scheduling of this generator.
      Specified by:
      doInitialSelfSchedule in interface ISelfScheduled
    • eventRoutine

      public void eventRoutine()
      This method is automatically called by the Generator itself. (by rescheduling via its GeneratorTriggerEvent)

      If absolutely needed it can be manually called to send the next request immediately.

    • getLastTargetTime

      public desmoj.core.simulator.TimeInstant getLastTargetTime()
    • getNextTargetTime

      public desmoj.core.simulator.TimeInstant getNextTargetTime()
    • onRequestFailed

      public boolean onRequestFailed​(Request request, desmoj.core.simulator.TimeInstant when, RequestFailedReason reason)
      Listener for the failure of the sending process. This could for example be due to the receiving service not being available, the request being canceled or timed out. Provides a reference to the failed request.
      Specified by:
      onRequestFailed in interface IRequestUpdateListener
      Parameters:
      request - request that triggered this event
      when - time of this event
      reason - reason why the request failed
      Returns:
      true if the request was terminally handled (consumed) by this instance
    • onRequestResultArrivedAtRequester

      public boolean onRequestResultArrivedAtRequester​(Request request, desmoj.core.simulator.TimeInstant when)
      Listener for the successful receiving of the answer of a request.
      Specified by:
      onRequestResultArrivedAtRequester in interface IRequestUpdateListener
      Parameters:
      request - request that triggered this event
      when - time of this event
      Returns:
      true if the request was terminally handled (consumed) by this instance
    • getParserClass

      public Class<? extends Parser<?>> getParserClass()
      Dummy to allow extension of IParsableSelfScheduled
      Specified by:
      getParserClass in interface IParsable
      Returns:
      The parser related to this class