Skip to content

Commit

Permalink
export Clocks in modeldescription.xml (#7564)
Browse files Browse the repository at this point in the history
  • Loading branch information
arun3688 committed Jun 15, 2021
1 parent 30b2648 commit 32dc92f
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 2 deletions.
6 changes: 5 additions & 1 deletion OMCompiler/Compiler/Template/CodegenFMUCommon.tpl
Expand Up @@ -479,6 +479,8 @@ match simVar
let valueReference = getValueReference(simVar, simCode, false)
let description = if comment then 'description="<%Util.escapeModelicaStringToXmlString(comment)%>"'
let variability_ = if getClockIndex(simVar, simCode) then "discrete" else getVariability2(variability)
let clockIndex = getClockIndex(simVar, simCode)
let previous = match varKind case CLOCKED_STATE(__) then '<%getVariableIndex(cref2simvar(previousName, simCode))%>'
let caus = getCausality2(causality)
let initial = getInitialType2(initial_)
<<
Expand All @@ -487,6 +489,8 @@ match simVar
<%description%>
<%if boolNot(stringEq(variability_, "")) then 'variability="'+variability_+'"' %>
<%if boolNot(stringEq(caus, "")) then 'causality="'+caus+'"' %>
<%if boolAnd(boolNot(stringEq(clockIndex, "")), Flags.getConfigBool(Flags.EXPORT_CLOCKS_IN_MODELDESCRIPTION)) then 'clockIndex="'+clockIndex+'"' %>
<%if boolAnd(boolNot(stringEq(previous, "")), Flags.getConfigBool(Flags.EXPORT_CLOCKS_IN_MODELDESCRIPTION)) then 'previous="'+previous+'"' %>
<%if boolNot(stringEq(initial, "")) then 'initial="'+initial+'"' %>
>>
end ScalarVariableAttribute2;
Expand Down Expand Up @@ -730,7 +734,7 @@ end fmiTypeDefinitions;
template TypeDefinitionsHelper(SimCode simCode, list<SimCodeVar.SimVar> vars, String FMUVersion)
"Generates code for TypeDefinitions for FMU target."
::=
let clocks = if boolOr(isFMIVersion10(FMUVersion), isFMIVersion20(FMUVersion)) then "" else TypeDefinitionsClocks(simCode)
let clocks = if isFMIVersion10(FMUVersion) then "" else if Flags.getConfigBool(Flags.EXPORT_CLOCKS_IN_MODELDESCRIPTION) then TypeDefinitionsClocks(simCode) else ""
if boolOr(intGt(listLength(vars), 0), boolNot(stringEq(clocks, ""))) then
<<
<TypeDefinitions>
Expand Down
1 change: 1 addition & 0 deletions OMCompiler/Compiler/Template/SimCodeTV.mo
Expand Up @@ -3917,6 +3917,7 @@ package Flags
constant ConfigFlag ZEROMQ_SERVER_ID;
constant ConfigFlag ZEROMQ_CLIENT_ID;
constant ConfigFlag FMI_FILTER;
constant ConfigFlag EXPORT_CLOCKS_IN_MODELDESCRIPTION;

function isSet
input DebugFlag inFlag;
Expand Down
4 changes: 4 additions & 0 deletions OMCompiler/Compiler/Util/Flags.mo
Expand Up @@ -1363,6 +1363,10 @@ constant ConfigFlag ALLOW_NON_STANDARD_MODELICA = CONFIG_FLAG(143, "allowNonStan
})),
Gettext.gettext("Flags to allow non-standard Modelica."));

constant ConfigFlag EXPORT_CLOCKS_IN_MODELDESCRIPTION = CONFIG_FLAG(144, "exportClocksInModelDescription",
NONE(), EXTERNAL(), BOOL_FLAG(false), NONE(),
Gettext.gettext("exports clocks in modeldescription.xml for fmus, The default is false."));

function getFlags
"Loads the flags with getGlobalRoot. Assumes flags have been loaded."
input Boolean initialize = true;
Expand Down
3 changes: 2 additions & 1 deletion OMCompiler/Compiler/Util/FlagsUtil.mo
Expand Up @@ -393,7 +393,8 @@ constant list<Flags.ConfigFlag> allConfigFlags = {
Flags.NEW_BACKEND,
Flags.PARMODAUTO,
Flags.INTERACTIVE_PORT,
Flags.ALLOW_NON_STANDARD_MODELICA
Flags.ALLOW_NON_STANDARD_MODELICA,
Flags.EXPORT_CLOCKS_IN_MODELDESCRIPTION
};

public function new
Expand Down

0 comments on commit 32dc92f

Please sign in to comment.