Class State

    • Constructor Summary

      Constructors 
      Constructor Description
      State()  
      State​(int number)
      Create a state with no name and do not use a Statistic object to collect additional statistics
      State​(int number, boolean useStatistic)
      Create a state with no name
      State​(java.lang.String name)  
      State​(java.lang.String name, boolean useStatistic)  
      State​(java.lang.String name, int number)
      Create a state with given name and do not use a Statistic object to collect additional statistics
      State​(java.lang.String name, int number, boolean useStatistic)
      Create a state with given name and indicate usage of a Statistic object to collect additional statistics
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void enter​(double time)
      Causes the state to be entered If the state has already been entered then nothing happens.
      double exit​(double time)
      Causes the state to be exited
      int getId()
      Gets a uniquely assigned integer identifier for this state.
      java.lang.String getName()
      Gets this model element's name.
      int getNumber()  
      double getNumberOfTimesEntered()
      Gets the number of times the state was entered
      double getNumberOfTimesExited()
      Gets the number of times the state was exited
      boolean getSojournTimeCollectionFlag()
      Indicates whether or not statistics should be collected on the sojourn times within the state
      java.util.Optional<Statistic> getSojournTimeStatistic()
      Gets a statistic that collected sojourn times
      double getTimeFirstEntered()  
      double getTimeStateEntered()
      Gets the time that the state was last entered
      double getTimeStateExited()
      Gets the time that the state was last exited
      double getTotalTimeInState()
      Gets the total time spent in the state
      void initialize()
      Initializes the state back to new - not in state - enter/exited time/time first entered = Double.NaN - total time in state = 0.0 - enter/exited count = 0.0 - sojourn statistics reset if turned on
      boolean isEntered()
      Gets whether or not the state has been entered
      protected void onEnter()
      can be overwritten by subclasses to perform work when the state is entered
      protected void onExit()
      can be overwritten by subclasses to perform work when the state is exited
      void resetSojournTimeStatistics()
      Resets the statistics collected on the sojourn time in the state
      void resetStateCollection()
      Resets the counters for the number of times a state was entered, exited, and the total time spent in the state This does not effect whether or the state has been entered, the time it was last entered, or the time it was last exited.
      void setName​(java.lang.String str)
      Sets the name of this state
      java.lang.String toString()  
      void turnOffSojournTimeCollection()
      Turns off statistical collection of the sojourn times in the state
      void turnOnSojournTimeCollection()
      Turns on statistical collection for the sojourn time in the state
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • myName

        protected java.lang.String myName
        The name of the state
      • myInStateIndicator

        protected boolean myInStateIndicator
        indicates whether or not currently in the state
      • myNumTimesEntered

        protected double myNumTimesEntered
        number of times the state was entered
      • myNumTimesExited

        protected double myNumTimesExited
        number of times the state was exited
      • myEnteredTime

        protected double myEnteredTime
        time the state was last entered
      • myTimeFirstEntered

        protected double myTimeFirstEntered
        time that the state was entered for the first time
      • myExitedTime

        protected double myExitedTime
        time the state was last exited
      • myTotalStateTime

        protected double myTotalStateTime
        Total time spent in state
      • myStatistic

        protected Statistic myStatistic
        statistical collector
      • myCollectSojournStatisticsFlag

        protected boolean myCollectSojournStatisticsFlag
        Indicates whether or not statistics should be collected on time spent in the state. The default is false
    • Constructor Detail

      • State

        public State()
      • State

        public State​(int number)
        Create a state with no name and do not use a Statistic object to collect additional statistics
      • State

        public State​(java.lang.String name,
                     int number)
        Create a state with given name and do not use a Statistic object to collect additional statistics
        Parameters:
        name - The name of the state
      • State

        public State​(java.lang.String name)
      • State

        public State​(java.lang.String name,
                     boolean useStatistic)
      • State

        public State​(int number,
                     boolean useStatistic)
        Create a state with no name
        Parameters:
        useStatistic - True means collect additional statistics
      • State

        public State​(java.lang.String name,
                     int number,
                     boolean useStatistic)
        Create a state with given name and indicate usage of a Statistic object to collect additional statistics
        Parameters:
        name - The name of the state
        number - a number assigned to the state for labeling purposes
        useStatistic - True means collect sojourn time statistics
    • Method Detail

      • getNumber

        public final int getNumber()
        Returns:
        the number assigned to the state, by default getId() if never assigned
      • setName

        public final void setName​(java.lang.String str)
        Sets the name of this state
        Parameters:
        str - The name as a string.
      • getName

        public final java.lang.String getName()
        Gets this model element's name.
        Specified by:
        getName in interface GetNameIfc
        Returns:
        The name of the model element.
      • getId

        public final int getId()
        Gets a uniquely assigned integer identifier for this state. This identifier is assigned when the state is created. It may vary if the order of creation changes.
        Specified by:
        getId in interface IdentityIfc
        Returns:
        The identifier for the state.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isEntered

        public final boolean isEntered()
        Gets whether or not the state has been entered
        Specified by:
        isEntered in interface StateAccessorIfc
        Returns:
        True means that the state has been entered
      • enter

        public final void enter​(double time)
        Causes the state to be entered If the state has already been entered then nothing happens. Preconditions: time must be >= 0, must not be Double.NaN and must not be Double.Infinity
        Parameters:
        time - The time that the state is being entered
      • onEnter

        protected void onEnter()
        can be overwritten by subclasses to perform work when the state is entered
      • exit

        public final double exit​(double time)
        Causes the state to be exited
        Parameters:
        time - the time that the state was exited, must be >= time entered, >= 0, not Double.NaN not Double.Infinity
        Returns:
        the time spent in the state as a double
      • onExit

        protected void onExit()
        can be overwritten by subclasses to perform work when the state is exited
      • initialize

        public final void initialize()
        Initializes the state back to new - not in state - enter/exited time/time first entered = Double.NaN - total time in state = 0.0 - enter/exited count = 0.0 - sojourn statistics reset if turned on
      • getSojournTimeCollectionFlag

        public final boolean getSojournTimeCollectionFlag()
        Indicates whether or not statistics should be collected on the sojourn times within the state
        Returns:
        Returns the collect sojourn time flag.
      • turnOnSojournTimeCollection

        public final void turnOnSojournTimeCollection()
        Turns on statistical collection for the sojourn time in the state
      • turnOffSojournTimeCollection

        public final void turnOffSojournTimeCollection()
        Turns off statistical collection of the sojourn times in the state
      • resetSojournTimeStatistics

        public final void resetSojournTimeStatistics()
        Resets the statistics collected on the sojourn time in the state
      • resetStateCollection

        public final void resetStateCollection()
        Resets the counters for the number of times a state was entered, exited, and the total time spent in the state This does not effect whether or the state has been entered, the time it was last entered, or the time it was last exited. To reset those quantities and the state counters use initialize()
      • getTimeFirstEntered

        public final double getTimeFirstEntered()
        Returns:
        The time that the state was first entered
      • getTimeStateEntered

        public final double getTimeStateEntered()
        Gets the time that the state was last entered
        Specified by:
        getTimeStateEntered in interface StateAccessorIfc
        Returns:
        A double representing the time that the state was last entered
      • getTimeStateExited

        public final double getTimeStateExited()
        Gets the time that the state was last exited
        Specified by:
        getTimeStateExited in interface StateAccessorIfc
        Returns:
        A double representing the time that the state was last exited
      • getNumberOfTimesEntered

        public final double getNumberOfTimesEntered()
        Gets the number of times the state was entered
        Specified by:
        getNumberOfTimesEntered in interface StateAccessorIfc
        Returns:
        A double representing the number of times entered
      • getNumberOfTimesExited

        public final double getNumberOfTimesExited()
        Gets the number of times the state was exited
        Specified by:
        getNumberOfTimesExited in interface StateAccessorIfc
        Returns:
        A double representing the number of times exited
      • getSojournTimeStatistic

        public final java.util.Optional<Statistic> getSojournTimeStatistic()
        Gets a statistic that collected sojourn times
        Specified by:
        getSojournTimeStatistic in interface StateAccessorIfc
        Returns:
        A statistic for sojourn times or null if the statistics were never turned on
      • getTotalTimeInState

        public final double getTotalTimeInState()
        Gets the total time spent in the state
        Specified by:
        getTotalTimeInState in interface StateAccessorIfc
        Returns:
        a double representing the total sojourn time