Class FWCheckHelper
FWCheckHelper.CHECK_LEVEL). Violations are logged and written to
<outputdir>/CheckResult.csv.
How the violations of the runtime checks (limits, owning component, write protection, conditions of components) are
reported depends on the FWCheckHelper.CHECK_REPORT: with DETAIL every violation is logged and written (as before), with
SUMMARY they are only counted per check, variable and details, and a summary (count, number of simulations, first
reported occurrence, value range) is logged and written when the session ends (finalize()). Numbers in
condition messages are replaced by #, so that the messages of one condition are counted together. The
session uses SUMMARY
for project runs unless DETAIL is requested (console option -checkreport, see
FWSimEngine.setCheckReport(CHECK_REPORT)). Violations of large project runs thus no longer cost a log line,
a line in CheckResult.csv and a lock shared by all parallel simulations each, but they are still reported. The check
levels themselves are not changed (INTENSE still limits values, STRICT still stops). Missing resources and script
parameter checks are always reported in detail.
- Author:
- Andreas Enders
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumCheck levels.static enumHow violations of the runtime checks are reported. -
Constructor Summary
ConstructorsConstructorDescriptionFWCheckHelper(FWCheckHelper.CHECK_LEVEL aLevel, String aCustomCheckerClassName, FWSimSession aSession) Creates the check helper; for level CUSTOM the custom checker is instantiated. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckCondition(Boolean aCheckResult, String aMessage, FWSimFieldContainer aInstance) Reports a failed condition of a component (e.g.checkLimits(FWSimVariable<?> aSource, Number aValue, Number aMin, Number aMax) Checks a value against its limits (nulllimits are ignored): LAZY reports a violation and keeps the value, INTENSE replaces it by the exceeded limit and reports it, STRICT throws an exception, CUSTOM delegates to the custom checker; OFF and ONLY do nothing.booleancheckOnlyMode(String aSimulationID) Level ONLY: decides whether a simulation is run; only the first simulation (and the same one again) is run.booleancheckParametersInScript(Collection<String> aAllowedFields, Collection<String> aForbiddenFields, String aJexlScript, FWSimFieldContainer aSource) Checks the parameters (${...}) of a script: all must be in the allowed fields (if given), none in the forbidden fields (if given).booleancheckResource(Map<String, FWSimInputAdapter> aResourceCreators, FWSimVarMap aVarMap, Map<String, FWSimResourceCache> aResourcesCacheMap) Check level ONLY: reads all resources (not transformers and project data) to check them; missing or bad resources are reported.booleancheckSource(FWSimVariable<?> aTarget, FWSimFieldContainer aSimFieldContainer, FWSimFieldContainer aSource) Checks whether a variable is written by its owning component.booleancheckWriteProtectionOnContentType(FWSimVariable<?> aTarget, FWSimVariable.CONTENT_TYPE aContentType, FWSimFieldContainer aSource) Checks whether the content type allows the writing component to write the variable:privatonly by its owner;constant,dyn,inputandvaronly by the solution, control components and simple components;mgmonly by the management;sysonly by the solution and control components.voidfinalize()Writes the summary of the checks (summary mode, seeFWCheckHelper.CHECK_REPORT) and closes the check result file.booleanbooleanvoidsetCheckLevel(FWCheckHelper.CHECK_LEVEL aCheckLevel) voidsetSummary(boolean aSummary) Sets how violations of the runtime checks are reported (seeFWCheckHelper.CHECK_REPORT).
-
Constructor Details
-
FWCheckHelper
public FWCheckHelper(FWCheckHelper.CHECK_LEVEL aLevel, String aCustomCheckerClassName, FWSimSession aSession) Creates the check helper; for level CUSTOM the custom checker is instantiated.- Parameters:
aLevel- the check levelaCustomCheckerClassName- class name of the customFWChecker(level CUSTOM only)aSession- the session
-
-
Method Details
-
getCheckLevel
- Returns:
- the check level
-
setCheckLevel
- Parameters:
aCheckLevel- the check level
-
isSummary
public boolean isSummary()- Returns:
trueif violations of the runtime checks are only counted and summarized at the end
-
setSummary
public void setSummary(boolean aSummary) Sets how violations of the runtime checks are reported (seeFWCheckHelper.CHECK_REPORT).- Parameters:
aSummary-trueforFWCheckHelper.CHECK_REPORT.SUMMARY,falseforFWCheckHelper.CHECK_REPORT.DETAIL
-
checkLimits
public Number checkLimits(FWSimVariable<?> aSource, Number aValue, Number aMin, Number aMax) throws SimValueOutOfRangeException Checks a value against its limits (nulllimits are ignored): LAZY reports a violation and keeps the value, INTENSE replaces it by the exceeded limit and reports it, STRICT throws an exception, CUSTOM delegates to the custom checker; OFF and ONLY do nothing. NaN is not checked.- Parameters:
aSource- the variable (for messages)aValue- the valueaMin- lower limit, may benullaMax- upper limit, may benull- Returns:
- the value to use (the limit in INTENSE mode if it was exceeded)
- Throws:
SimValueOutOfRangeException- in STRICT mode if a limit is exceeded
-
checkSource
public boolean checkSource(FWSimVariable<?> aTarget, FWSimFieldContainer aSimFieldContainer, FWSimFieldContainer aSource) throws SimLinkInvalidException Checks whether a variable is written by its owning component. Writing is always allowed by the solution and the control components. LAZY reports a violation, INTENSE reports it and returnsfalse, STRICT throws an exception, CUSTOM delegates to the custom checker. Other errors while checking are logged andtrueis returned.- Parameters:
aTarget- the variable writtenaSimFieldContainer- the owning component of the variableaSource- the writing component- Returns:
falsein INTENSE mode if the variable is written by another component, otherwisetrue- Throws:
SimLinkInvalidException- in STRICT mode if the variable is written by another component
-
checkWriteProtectionOnContentType
public boolean checkWriteProtectionOnContentType(FWSimVariable<?> aTarget, FWSimVariable.CONTENT_TYPE aContentType, FWSimFieldContainer aSource) throws SimLinkInvalidException Checks whether the content type allows the writing component to write the variable:privatonly by its owner;constant,dyn,inputandvaronly by the solution, control components and simple components;mgmonly by the management;sysonly by the solution and control components. LAZY reports a violation and allows it, INTENSE reports it and returnsfalse, STRICT throws an exception, CUSTOM delegates to the custom checker.- Parameters:
aTarget- the variable writtenaContentType- content type of the variableaSource- the writing component; no check ifnull- Returns:
trueif writing is allowed- Throws:
SimLinkInvalidException- in STRICT mode if writing is not allowed
-
checkResource
public boolean checkResource(Map<String, FWSimInputAdapter> aResourceCreators, FWSimVarMap aVarMap, Map<String, FWSimResourceCache> aResourcesCacheMap) Check level ONLY: reads all resources (not transformers and project data) to check them; missing or bad resources are reported.- Parameters:
aResourceCreators- the resource adapters by nameaVarMap- variable map of the first simulation of the projectaResourcesCacheMap- map the read caches are put into- Returns:
truefor the first checked project (and the same project again),falsefor other projects
-
isConditionCheck
public boolean isConditionCheck()- Returns:
trueif conditions are checked (levels ONLY, LAZY, INTENSE, STRICT)
-
checkCondition
Reports a failed condition of a component (e.g. an initialization error): if the condition result istrue(i.e. the problem occurred), the message is logged as warning and written to the check result, in levels ONLY, LAZY, INTENSE and STRICT.- Parameters:
aCheckResult-trueif the problem occurredaMessage- the messageaInstance- the component reporting it
-
checkOnlyMode
Level ONLY: decides whether a simulation is run; only the first simulation (and the same one again) is run.- Parameters:
aSimulationID- id of the simulation- Returns:
trueif the simulation is run; alwaystruein other levels
-
checkParametersInScript
public boolean checkParametersInScript(Collection<String> aAllowedFields, Collection<String> aForbiddenFields, String aJexlScript, FWSimFieldContainer aSource) Checks the parameters (${...}) of a script: all must be in the allowed fields (if given), none in the forbidden fields (if given). Only if the check fails, a warning is logged (LAZY, INTENSE) or an exception is thrown (STRICT).- Parameters:
aAllowedFields- allowed parameter names, ornullaForbiddenFields- forbidden parameter names, ornullaJexlScript- the scriptaSource- the component using the script (for messages)- Returns:
trueif the check passed (always in LAZY mode)- Throws:
SimLinkInvalidException- in STRICT mode
-
finalize
public void finalize()Writes the summary of the checks (summary mode, seeFWCheckHelper.CHECK_REPORT) and closes the check result file.
-