Class SimpleCounter

java.lang.Object
net.simplace.sim.model.FWSimComponent
net.simplace.sim.components.util.SimpleCounter
All Implemented Interfaces:
net.simplace.sim.util.FWSimFieldContainer

public class SimpleCounter extends net.simplace.sim.model.FWSimComponent
Provides a resettable counter of simulation days.

Counting

Counter is incremented, if the input variable iDoCount is true.

Resetting the counter

If iReset is true, the counter is reset before an potential increment.

Customization

Increment and start value are customizable. Default increment is 1, start value is 0.

Cyclic counting

If cMin and cMax are set and cMax is bigger than cMin, then the counter counts cyclic (like a clock). The value of Counter will always be shifted between cMix and cMax (both inclusive).

If the Counter equals the (possibly shifted) cStartValue, a cycle is completed and the CycleNumber is incremented.

Examples

Example 1

For cStartValue=1, cIncrement=1, cMin=1, cMax=10 the counter will start with 1 and give following sequence:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, ...

Example 2 - Countdown

For cStartValue=3, cIncrement=-1, cMin=0, cMax=10 the counter will start with 1 and give following sequence:

3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9 ...

Example 2 - Clock

For cStartValue=18, cIncrement=5, cMin=1, cMax=12 the counter will start with 6 and give following sequence:

6, 11, 4, 9, 2, 7, 12, 5, 10, 3, 8, 1, 6, 11, 4, ...

(18 corresponds to 6 p.m., five hours later it will be 11 p.m, another five hours later 4 a.m. etc.)

Author:
Gunther Krauss, gk@uni-bonn.de

Component Variables

Content TypeNameDescriptionData TypeUnitMin ValueMax ValueDefault Value
constantcIncrementincrement of counterINT--1
constantcMaxmaximal value of the counter of a cyclic counterINT---
constantcMinminimal value of the counter of a cyclic counterINT---
constantcStartValuestart value of counterINT--0
inputiDoCountcounter is incremented if trueBOOLEAN--false
inputiResetresets the counter to its start value if trueBOOLEAN--false
outCounteractual value of the counterINT--1
outCycleNumbernumber of cycles when counting between cMin and cMaxINT--0
outNumberOfResetsnumber of resetsINT--0
outTotalCounttotal count starting from 0 and incremented by 1INT--0
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.simplace.sim.model.FWSimComponent

    net.simplace.sim.model.FWSimComponent.TEST_STATE
  • Field Summary

    Fields inherited from class net.simplace.sim.model.FWSimComponent

    iFieldMap, iFrequence, iInputMap, iJexlRule, iMasterComponentGroup, iName, iOrderNumber, isComponentGroup, iSimComponentElement, iSimModel, iVarMap
  • Constructor Summary

    Constructors
    Constructor
    Description
    Empty constructor used by class.forName()
  • Method Summary

    Modifier and Type
    Method
    Description
    protected net.simplace.sim.model.FWSimComponent
    clone(net.simplace.sim.util.FWSimVarMap aVarMap)
     
    HashMap<String,net.simplace.sim.util.FWSimVariable<?>>
    Create the FWSimVariables as interface for this SimComponent
    protected Integer
    cyclic(Integer value, Integer min, Integer max)
     
    HashMap<String,net.simplace.sim.util.FWSimVariable<?>>
    fillTestVariables(int aParamIndex, net.simplace.sim.model.FWSimComponent.TEST_STATE aDefineOrCheck)
    called for single component test to check the components algorithm.
    protected void
    Initializes the fields by getting input and output FWSimVariables from VarMap
    protected void
    Process the algorithm and write the results back to VarMap

    Methods inherited from class net.simplace.sim.model.FWSimComponent

    addVariable, bind, checkCondition, createSimComponent, createSimComponent, createSimComponent, createSimComponent, doProcess, getConstantVariables, getContentType, getCreateFormXML, getDescription, getEditFormXML, getFieldMap, getFrequence, getFrequenceRuleScript, getInputs, getInputVariables, getMasterComponentGroup, getName, getOrderNumber, getOutputVariables, getVariable, getVariableField, getVarMap, initialize, isConditionCheck, isVariableAvailable, performLinks, performLinks, readInputs, removeVariable, reset, runComponentTest, setVariablesDefault, toComponentLinkingXML, toDocXML, toGroupXML, toOutputDefinitionXML, toResourcesDataXML, toResourcesDefinitionXML, toString, toXML, writeVarInfos

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SimpleCounter

      public SimpleCounter()
      Empty constructor used by class.forName()
  • Method Details

    • createVariables

      public HashMap<String,net.simplace.sim.util.FWSimVariable<?>> createVariables()
      Create the FWSimVariables as interface for this SimComponent
      Specified by:
      createVariables in interface net.simplace.sim.util.FWSimFieldContainer
      Specified by:
      createVariables in class net.simplace.sim.model.FWSimComponent
      See Also:
      • FWSimComponent.createVariables()
    • init

      protected void init()
      Initializes the fields by getting input and output FWSimVariables from VarMap
      Specified by:
      init in class net.simplace.sim.model.FWSimComponent
      See Also:
      • FWSimComponent.init()
    • process

      protected void process()
      Process the algorithm and write the results back to VarMap
      Specified by:
      process in class net.simplace.sim.model.FWSimComponent
      See Also:
      • FWSimComponent.process()
    • cyclic

      protected Integer cyclic(Integer value, Integer min, Integer max)
    • fillTestVariables

      public HashMap<String,net.simplace.sim.util.FWSimVariable<?>> fillTestVariables(int aParamIndex, net.simplace.sim.model.FWSimComponent.TEST_STATE aDefineOrCheck)
      called for single component test to check the components algorithm.
      Specified by:
      fillTestVariables in class net.simplace.sim.model.FWSimComponent
      See Also:
      • net.simplace.sim.util.FWSimFieldContainer#fillTestVariables(int aParamIndex, TEST_STATE aDefineOrCheck)
    • clone

      protected net.simplace.sim.model.FWSimComponent clone(net.simplace.sim.util.FWSimVarMap aVarMap)
      Specified by:
      clone in class net.simplace.sim.model.FWSimComponent
      See Also:
      • FWSimComponent.clone(net.simplace.sim.util.FWSimVarMap)