Skip to content

Commit

Permalink
Update variable variability defaults for 3.0.1
Browse files Browse the repository at this point in the history
Reflect clarifications in 3.0.1 in the way variability defaults are determined for parameters. Fixes #590.
  • Loading branch information
pmai authored Sep 20, 2024
1 parent 9904675 commit bfd46c2
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions fmusim/FMIModelDescription.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,18 +1038,6 @@ static FMIModelDescription* readModelDescriptionFMI3(xmlNodePtr root) {

variable->type = type;

if (variable->variability == -1) {
switch (variable->type) {
case FMIFloat32Type:
case FMIFloat64Type:
variable->variability = FMIContinuous;
break;
default:
variable->variability = FMIDiscrete;
break;
}
}

const char* vr = (char*)xmlGetProp(variableNode, (xmlChar*)"valueReference");

variable->valueReference = FMIValueReferenceForLiteral(vr);
Expand Down Expand Up @@ -1078,6 +1066,27 @@ static FMIModelDescription* readModelDescriptionFMI3(xmlNodePtr root) {

xmlFree((void*)causality);

if (variable->variability == -1) {
switch (variable->causality) {
case FMIParameter:
case FMICalculatedParameter:
case FMIStructuralParameter:
variable->variability = FMIFixed;
break;
default:
switch (variable->type) {
case FMIFloat32Type:
case FMIFloat64Type:
variable->variability = FMIContinuous;
break;
default:
variable->variability = FMIDiscrete;
break;
}
break;
}
}

variable->derivative = (FMIModelVariable*)xmlGetProp(variableNode, (xmlChar*)"derivative");

xmlXPathObjectPtr xpathObj2 = xmlXPathNodeEval(variableNode, (xmlChar*)".//Dimension", xpathCtx);
Expand Down

0 comments on commit bfd46c2

Please sign in to comment.