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
Modifier and TypeFieldDescriptionstatic final String
signifying the string used as id for the current date in the VarMapstatic final String
signifying the string used as id for the current day of monthstatic final String
signifying the string used as id for the current day of yearstatic final String
signifying the string used as id for the current month in the VarMapstatic final String
signifying the string used as id for the current year in the VarMapstatic final DateTimeFormatter
Parser for operations to be calculatedstatic final String
signifying the string used as id for the end date in the VarMapstatic final String
signifying the string used as id for the current date in the VarMapstatic final String
signifying the string used as id for the current date in the VarMapstatic final String
projectlines that are read from project filestatic final String
signifying the string used as id for the current date in the VarMapstatic final String
signifying the string used as id for the current date in the VarMapstatic final String
signifying the string used as id for the current date in the VarMapstatic final String
signifying the string used as id for the current date in the VarMapstatic final String
signifying whether date has to be reset after spinupstatic final String
signifying the integer number of spin up days in the VarMapstatic final String
signifying whether date has to be reset after spinupstatic final String
signifying whether date was reset after spinupstatic final String
signifying the string used as id for the end date in the VarMapstatic final String
signifying whether threads are synchronized within one project (true) or not (false)static final String
the rule for the data synchronized within one project if FREQUENCE is COMPLEX -
Constructor Summary
ConstructorDescriptionFor documentation reasonsFWSimVarMap
(HashMap<String, FWSimVariable<?>> aParameterMap) FWSimVarMap
(HashMap<String, FWSimVariable<?>> aFormInputParameterMap, FWSimModel aModel, String aProjectID, FWSimSession aCurrentSession) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLink
(String aKey, FWSimVariable<?> aVar, boolean performChecks) Link between 2 SimVariables is added.void
addVariable
(String aKey, FWSimVariable<?> aFWSimVariable, boolean isLink) new SimVariable is initialized and put to simVarMapvoid
calculates statisticsboolean
checkInternal
(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!boolean
Object[]
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[]boolean
forceBooleanValue
(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 statisticsint
int
int
int
Returns 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) boolean
Decorates the class as MapContextboolean
hasSimVariable
(String aRule) void
Initializes the Current Date of the VarMapvoid
initValue
(String aKey, FWSimVariable<?> aFWSimVariable) new SimVariable is initialized and put to simVarMapstatic boolean
isInternal
(String aVarName) boolean
boolean
boolean
isVariableAvailable
(String aKey) boolean
void
putAllVariables
(Map<String, FWSimVariable<?>> aVarMap) number of variables are added to the VarMapvoid
removeLink
(String aName, FWSimVariable<?> aFwSimVariable) void
removeVariable
(String aElement) use with care!replaceParamTokens
(String aString, Object aDefault) Replacement of parameters in a string is performed.void
reset()
set all variables to default valuesvoid
Decorates the class as MapContextvoid
setCurrentDate
(LocalDateTime aCurrentDate) void
setCurrentSession
(FWSimSession aFwSimSession) void
setProjectID
(String aProjectID) void
setSessionID
(String aSessionID) void
sets the simulation endvoid
setSimulationName
(String aSimulationName) void
setSimulationNumber
(Integer aSimulationNumber) void
setValue
(String aKey, Object aValue, FWSimVariable.DATA_TYPE aDataType, FWSimVariable.CONTENT_TYPE aContentType, FWSimFieldContainer aSourceComponent) sets the value to the FWSimVariable.void
setWaiting
(boolean shouldWait) String[][]
toArray()
toString()
simple output of VarMapvoid
used 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:
has
in interfaceorg.apache.commons.jexl3.JexlContext
- See Also:
-
org.apache.commons.jexl2.MapContext#has(java.lang.String)
-
get
Decorates the class as MapContext- Specified by:
get
in interfaceorg.apache.commons.jexl3.JexlContext
- See Also:
-
org.apache.commons.jexl2.MapContext#get(java.lang.String)
-
set
Decorates the class as MapContext- Specified by:
set
in interfaceorg.apache.commons.jexl3.JexlContext
- See Also:
-
org.apache.commons.jexl2.MapContext#set(java.lang.String, java.lang.Object)
-
isInternal
-
checkInternal
-