Package net.simplace.sim.util
Class FWSimVarMap
java.lang.Object
net.simplace.sim.util.FWSimVarMap
- All Implemented Interfaces:
org.apache.commons.jexl3.JexlContext
Each parameter has a "string" name
Value is given as implemented member of Variable
Variable has last changed date instance, creator reference and value
Has a general simulation (model run) and project (project run) id
Implements a HashMap <String, Object>
Has replacement method for parameter tokens
Linking Variables can hereby be checked for:
Unit, DataType and ContentType
Setting Value can be checked for
DataType, Source of Data, Min/Max
Debugging can be done using
Description, Unit, Date last changed (same day yesterday, ), Source of value
- Author:
- Andreas Enders
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.commons.jexl3.JexlContext
org.apache.commons.jexl3.JexlContext.AnnotationProcessor, org.apache.commons.jexl3.JexlContext.NamespaceFunctor, org.apache.commons.jexl3.JexlContext.NamespaceResolver, org.apache.commons.jexl3.JexlContext.ThreadLocal -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringsignifying the string used as id for the current date in the VarMapstatic final Stringsignifying the string used as id for the current day of monthstatic final Stringsignifying the string used as id for the current day of yearstatic final Stringsignifying the string used as id for the current month in the VarMapstatic final Stringsignifying the string used as id for the current year in the VarMapstatic final DateTimeFormatterParser for operations to be calculatedstatic final Stringsignifying the string used as id for the end date in the VarMapstatic final Stringsignifying the string used as id for the current date in the VarMapstatic final Stringsignifying the string used as id for the current date in the VarMapstatic final Stringprojectlines that are read from project filestatic final Stringsignifying the string used as id for the current date in the VarMapstatic final Stringsignifying the string used as id for the current date in the VarMapstatic final Stringsignifying the string used as id for the current date in the VarMapstatic final Stringsignifying the string used as id for the current date in the VarMapstatic final Stringsignifying whether date has to be reset after spinupstatic final Stringsignifying the integer number of spin up days in the VarMapstatic final Stringsignifying whether date has to be reset after spinupstatic final Stringsignifying whether date was reset after spinupstatic final Stringsignifying the string used as id for the end date in the VarMapstatic final Stringsignifying whether threads are synchronized within one project (true) or not (false)static final Stringthe rule for the data synchronized within one project if FREQUENCE is COMPLEX -
Constructor Summary
ConstructorsConstructorDescriptionFor documentation reasonsFWSimVarMap(HashMap<String, FWSimVariable<?>> aParameterMap) FWSimVarMap(HashMap<String, FWSimVariable<?>> aFormInputParameterMap, FWSimModel aModel, String aProjectID, FWSimSession aCurrentSession) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLink(String aKey, FWSimVariable<?> aVar, boolean performChecks) Link between 2 SimVariables is added.voidaddVariable(String aKey, FWSimVariable<?> aFWSimVariable, boolean isLink) new SimVariable is initialized and put to simVarMapvoidcalculates statisticsbooleancheckInternal(FWSimVariable<?> aFwSimVariable) clone(FWSimSession aSession) deep clone on the SimVarMap - no references will stay same!deep clone on the SimVarMap - no references will stay same!booleanObject[]filterData(HashMap<String, FWSimVariable<?>> aFilterMap) filters data from the map and returns it as Object[]Object[]filterData(Set<String> aKeySet) filters data from the map and returns it as Object[]booleanforceBooleanValue(String aParamKey) used if generic type of the SimVariable is different but convertable to boolean. otherwise use getValue()!forceDateValue(String aParamKey) used if generic type of the SimVariable is different but convertable to date. otherwise use getValue()!Double[]forceDoubleArrayValue(String aString) used if generic type of the SimVariable is different but convertible to double array. otherwise use getValue()!forceDoubleMapValue(String aKey) used if generic type of the SimVariable is different but convertible to Double Map from array. otherwise use getValue()!forceDoubleValue(String aKey) Integer[]forceIntegerArrayValue(String aString) used if generic type of the SimVariable is different but convertible to integer array. otherwise use getValue()!forceIntegerValue(String aKey) Returns the number of observers of this Observable object.Decorates the class as MapContextcalculates statisticsintintintintReturns the number of observers of this Observable object.getSimVariable(String aKey) getStringValue(String aKey) getValueToDatabaseString(String aSourceKey) mainly used for Date, DoubleArray and IntArray to get String format of the valuesgetVariables(FWSimFieldContainer aContainer) Set<FWSimVariable<?>>getVariables(FWSimVariable.CONTENT_TYPE aContentType) booleanDecorates the class as MapContextbooleanhasSimVariable(String aRule) voidInitializes the Current Date of the VarMapvoidinitValue(String aKey, FWSimVariable<?> aFWSimVariable) new SimVariable is initialized and put to simVarMapstatic booleanisInternal(String aVarName) booleanbooleanbooleanisVariableAvailable(String aKey) booleanvoidputAllVariables(Map<String, FWSimVariable<?>> aVarMap) number of variables are added to the VarMapvoidremoveLink(String aName, FWSimVariable<?> aFwSimVariable) voidremoveVariable(String aElement) use with care!replaceParamTokens(String aString, Object aDefault) Replacement of parameters in a string is performed.voidreset()set all variables to default valuesvoidDecorates the class as MapContextvoidsetCurrentDate(LocalDateTime aCurrentDate) voidsetCurrentSession(FWSimSession aFwSimSession) voidsetProjectID(String aProjectID) voidsetSessionID(String aSessionID) voidsets the simulation endvoidsetSimulationName(String aSimulationName) voidsetSimulationNumber(Integer aSimulationNumber) voidsetValue(String aKey, Object aValue, FWSimVariable.DATA_TYPE aDataType, FWSimVariable.CONTENT_TYPE aContentType, FWSimFieldContainer aSourceComponent) sets the value to the FWSimVariable.voidsetWaiting(boolean shouldWait) String[][]toArray()toString()simple output of VarMapvoidused to set the current model date to the VarMap
-
Field Details
-
CURRENT_DATE
signifying the string used as id for the current date in the VarMap- See Also:
-
CURRENT_YEAR
signifying the string used as id for the current year in the VarMap- See Also:
-
CURRENT_DAY
signifying the string used as id for the current day of month- See Also:
-
CURRENT_MONTH
signifying the string used as id for the current month in the VarMap- See Also:
-
CURRENT_DOY
signifying the string used as id for the current day of year- See Also:
-
PROJECT_ID
signifying the string used as id for the current date in the VarMap- See Also:
-
PROJECT_ITERATION
signifying the string used as id for the current date in the VarMap- See Also:
-
SIMULATION_ID
signifying the string used as id for the current date in the VarMap- See Also:
-
SIMULATION_NAME
signifying the string used as id for the current date in the VarMap- See Also:
-
SIMULATION_NUMBER
signifying the string used as id for the current date in the VarMap- See Also:
-
SESSION_ID
signifying the string used as id for the current date in the VarMap- See Also:
-
SPINUP_DAYS
signifying the integer number of spin up days in the VarMap- See Also:
-
SPINUP_DO_RESET
signifying whether date has to be reset after spinup- See Also:
-
SPINUP_RESET
signifying whether date was reset after spinup- See Also:
-
SYNCHRONIZE_FREQUENCE
signifying whether threads are synchronized within one project (true) or not (false)- See Also:
-
SYNCHRONIZE_RULE
the rule for the data synchronized within one project if FREQUENCE is COMPLEX- See Also:
-
PROJECT_LINES
projectlines that are read from project file- See Also:
-
SIMULATIONS_SELECTED
signifying whether date has to be reset after spinup- See Also:
-
END_DATE
signifying the string used as id for the end date in the VarMap- See Also:
-
START_DATE
signifying the string used as id for the end date in the VarMap- See Also:
-
DATE_FORMAT
Parser for operations to be calculated
-
-
Constructor Details
-
FWSimVarMap
public FWSimVarMap(HashMap<String, FWSimVariable<?>> aFormInputParameterMap, FWSimModel aModel, String aProjectID, FWSimSession aCurrentSession) - Parameters:
aFormInputParameterMap-aModel-aProjectID-aCurrentSession-
-
FWSimVarMap
- Parameters:
aParameterMap-
-
FWSimVarMap
public FWSimVarMap()For documentation reasons
-
-
Method Details
-
setWaiting
- Throws:
InterruptedException
-
getVarMap
- Returns:
- the parameterMap
-
getStringValue
- Parameters:
aKey-- Returns:
- one parameter value for given key - null if key was not set
-
forceIntegerValue
- Parameters:
aKey-- Returns:
- one parameter converted to Integer value for given key - null if key was not set or value not convertible
-
forceDoubleValue
- Parameters:
aKey-- Returns:
- one parameter converted to Double value for given key - null if key was not set or value not convertible
-
forceBooleanValue
used if generic type of the SimVariable is different but convertable to boolean. otherwise use getValue()!- Parameters:
aParamKey-- Returns:
- boolean value to be forced from other data type
-
forceDateValue
used if generic type of the SimVariable is different but convertable to date. otherwise use getValue()!- Parameters:
aParamKey-- Returns:
- the date that was retrieved from convert.
-
forceDoubleArrayValue
used if generic type of the SimVariable is different but convertible to double array. otherwise use getValue()!- Parameters:
aString-- Returns:
- the converted value
-
forceDoubleMapValue
used if generic type of the SimVariable is different but convertible to Double Map from array. otherwise use getValue()!- Parameters:
aKey-- Returns:
- the converted value
-
forceIntegerArrayValue
used if generic type of the SimVariable is different but convertible to integer array. otherwise use getValue()!- Parameters:
aString-- Returns:
- the converted value
-
replaceParamTokens
Replacement of parameters in a string is performed.- Parameters:
aString-aDefault-- Returns:
- the new String after replacement of the different variable tags
- See Also:
-
getValue
- Parameters:
aKey-- Returns:
- object value of the FWSimVariable registered with key
-
getValue
- Parameters:
aKey-aDefault-- Returns:
- object value of the FWSimVariable registered with key
-
setValue
public void setValue(String aKey, Object aValue, FWSimVariable.DATA_TYPE aDataType, FWSimVariable.CONTENT_TYPE aContentType, FWSimFieldContainer aSourceComponent) throws SimValueOutOfRangeException sets the value to the FWSimVariable. If Max or Min rule is not successfully evaluated SimValueOutOfRangeException is thrown. It is typeof RuntimeException and need not to be handled If FWSimVariable is not existing it will be created with a warn Message in log.- Parameters:
aKey-aValue-aDataType-aContentType-aSourceComponent-- Throws:
SimValueOutOfRangeException
-
initValue
new SimVariable is initialized and put to simVarMap- Parameters:
aKey-aFWSimVariable-
-
addVariable
new SimVariable is initialized and put to simVarMap- Parameters:
aKey-aFWSimVariable-isLink-
-
getProjectID
- Returns:
- Identifier of this Functionality
-
getSimulationID
Returns the number of observers of this Observable object.- Returns:
- the number of observers of this object.
-
generateSimulationID
Returns the number of observers of this Observable object.- Returns:
- the number of observers of this object.
-
setSimulationName
- Parameters:
aSimulationName-
-
getSimulationName
- Returns:
- simulation name
-
getSimulationNumber
- Returns:
- the simulation number
-
getIteration
- Returns:
- the iteration number
-
getCurrentSession
- Returns:
- the current session
-
isSynchronized
public boolean isSynchronized()- Returns:
- if session is synchronized
-
getSynchronizedFrequence
- Returns:
- if session is synchronized
-
getSynchronizeRule
- Returns:
-
isWaiting
public boolean isWaiting()- Returns:
-
getCurrentDateString
calculates statistics- Returns:
- Current model date toFormated string
-
getStartDate
- Returns:
- Start Date Variable
-
getEndDate
- Returns:
- End Date Variable
-
calculateStatistics
public void calculateStatistics()calculates statistics -
setProjectID
- Parameters:
aProjectID-
-
setSessionID
- Parameters:
aSessionID-
-
setSimulationNumber
- Parameters:
aSimulationNumber-
-
setCurrentSession
- Parameters:
aFwSimSession-
-
removeVariable
use with care! Variable might be needed- Parameters:
aElement-
-
filterData
filters data from the map and returns it as Object[]- Parameters:
aFilterMap-- Returns:
-
filterData
filters data from the map and returns it as Object[]- Parameters:
aKeySet-- Returns:
-
putAllVariables
number of variables are added to the VarMap- Parameters:
aVarMap-
-
isVariableAvailable
- Parameters:
aKey-- Returns:
- s if a SimVariable is available
-
isSpinupPeriode
public boolean isSpinupPeriode()- Returns:
- s if system is in spin up period
-
doSpinupReset
public boolean doSpinupReset()- Returns:
-
toString
simple output of VarMap -
toArray
- Returns:
- Key, SimVarName and Value as Array
-
addLink
public void addLink(String aKey, FWSimVariable<?> aVar, boolean performChecks) throws SimLinkInvalidException Link between 2 SimVariables is added. If Link cannot be established a SimLinkInvalidException is thrown- Parameters:
aKey- of the target part of the linkaVar- with the source part of the linkperformChecks-- Throws:
SimLinkInvalidException
-
removeLink
- Parameters:
aName-aFwSimVariable-
-
initializeCurrentDate
Initializes the Current Date of the VarMap- Parameters:
aDate-
-
updateCurrentDate
public void updateCurrentDate()used to set the current model date to the VarMap -
getCurrentDate
- Returns:
- the current model date
-
setCurrentDate
- Parameters:
aCurrentDate- the current model date
-
getCurrentDOY
public int getCurrentDOY()- Returns:
- current DayOfYear
-
getCurrentYear
public int getCurrentYear()- Returns:
- current Year
-
getCurrentDayOfMonth
public int getCurrentDayOfMonth()- Returns:
- current Day of Month
-
getCurrentMonth
public int getCurrentMonth()- Returns:
- current Month
-
hasSimulationEnded
- Returns:
- the simulationEnd
-
setSimulationEnd
public void setSimulationEnd()sets the simulation end -
clone
deep clone on the SimVarMap - no references will stay same!- Parameters:
aSession-- Returns:
- See Also:
-
cloneToControlMap
deep clone on the SimVarMap - no references will stay same!- Returns:
- See Also:
-
getSimLinks
- Returns:
- a MultiHashMap containing all Links
-
reset
public void reset()set all variables to default values -
hasSimVariable
- Parameters:
aRule-- Returns:
- if the registered FWSimVariable is available for the given key!
-
getSimVariable
- Parameters:
aKey-- Returns:
- the registered FWSimVariable - need not be the one with the given key!
- Throws:
SimFieldMissingException
-
getValueToDatabaseString
mainly used for Date, DoubleArray and IntArray to get String format of the values- Parameters:
aSourceKey-- Returns:
- the value as converted database string
- Throws:
SimFieldMissingException
-
getVariables
- Parameters:
aContentType-- Returns:
- a list of Variables having this content type
-
getVariables
public MultiHashMap<FWSimVariable.CONTENT_TYPE,FWSimVariable<?>> getVariables(FWSimFieldContainer aContainer) - Parameters:
aContainer-aContentType-- Returns:
- a list of Variables having this source container
-
has
Decorates the class as MapContext- Specified by:
hasin interfaceorg.apache.commons.jexl3.JexlContext- See Also:
-
org.apache.commons.jexl2.MapContext#has(java.lang.String)
-
get
Decorates the class as MapContext- Specified by:
getin interfaceorg.apache.commons.jexl3.JexlContext- See Also:
-
org.apache.commons.jexl2.MapContext#get(java.lang.String)
-
set
Decorates the class as MapContext- Specified by:
setin interfaceorg.apache.commons.jexl3.JexlContext- See Also:
-
org.apache.commons.jexl2.MapContext#set(java.lang.String, java.lang.Object)
-
isInternal
-
checkInternal
-