Class SimpleCounter
- All Implemented Interfaces:
net.simplace.sim.util.FWSimFieldContainer
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 Type | Name | Description | Data Type | Unit | Min Value | Max Value | Default Value |
---|---|---|---|---|---|---|---|
constant | cIncrement | increment of counter | INT | - | - | 1 | |
constant | cMax | maximal value of the counter of a cyclic counter | INT | - | - | - | |
constant | cMin | minimal value of the counter of a cyclic counter | INT | - | - | - | |
constant | cStartValue | start value of counter | INT | - | - | 0 | |
input | iDoCount | counter is incremented if true | BOOLEAN | - | - | false | |
input | iReset | resets the counter to its start value if true | BOOLEAN | - | - | false | |
out | Counter | actual value of the counter | INT | - | - | 1 | |
out | CycleNumber | number of cycles when counting between cMin and cMax | INT | - | - | 0 | |
out | NumberOfResets | number of resets | INT | - | - | 0 | |
out | TotalCount | total count starting from 0 and incremented by 1 | INT | - | - | 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
-
Method Summary
Modifier and TypeMethodDescriptionprotected net.simplace.sim.model.FWSimComponent
clone
(net.simplace.sim.util.FWSimVarMap aVarMap) Create the FWSimVariables as interface for this SimComponentprotected Integer
fillTestVariables
(int aParamIndex, net.simplace.sim.model.FWSimComponent.TEST_STATE aDefineOrCheck) called for single component test to check the components algorithm.protected void
init()
Initializes the fields by getting input and output FWSimVariables from VarMapprotected void
process()
Process the algorithm and write the results back to VarMapMethods 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
-
Constructor Details
-
SimpleCounter
public SimpleCounter()Empty constructor used by class.forName()
-
-
Method Details
-
createVariables
Create the FWSimVariables as interface for this SimComponent- Specified by:
createVariables
in interfacenet.simplace.sim.util.FWSimFieldContainer
- Specified by:
createVariables
in classnet.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 classnet.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 classnet.simplace.sim.model.FWSimComponent
- See Also:
-
FWSimComponent.process()
-
cyclic
-
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 classnet.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 classnet.simplace.sim.model.FWSimComponent
- See Also:
-
FWSimComponent.clone(net.simplace.sim.util.FWSimVarMap)
-