Changeset 13613


Ignore:
Timestamp:
Sep 30, 2019 10:18:23 AM (2 months ago)
Author:
Jonathan Kämpe
Message:

#5844 Parametric min, max, nominal are now only generated in xml for inputs and states.

Location:
branches/dev-jk-2471/Compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-jk-2471/Compiler/FmiXMLCodeGen/test/modelica/FmiXMLTests.mo

    r12934 r13613  
    25002500end Start5;
    25012501
     2502model ParametricAttributes1
     2503    parameter Real p = 1;
     2504    input Real x1(min=p, max=p, nominal=p);
     2505    Real x2(min=p, max=p, nominal=p);
     2506    output Real x3(min=p, max=p, nominal=p);
     2507equation
     2508    der(x2) = x1;
     2509    x3 = x2;
     2510
     2511    annotation(__JModelica(UnitTesting(tests={
     2512        FmiXMLCodeGenTestCase(
     2513            name="ParametricAttributes1",
     2514            description="",
     2515            fmi_version="2.0",
     2516            template="
     2517$modelVariables$
     2518",
     2519            generatedCode="
     2520<ModelVariables>
     2521    <!-- Variable with index #1 -->
     2522    <ScalarVariable name=\"p\" valueReference=\"0\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
     2523        <Real relativeQuantity=\"false\" start=\"1.0\" />
     2524    </ScalarVariable>
     2525    <!-- Variable with index #2 -->
     2526    <ScalarVariable name=\"x1\" valueReference=\"3\" causality=\"input\" variability=\"continuous\">
     2527        <Real relativeQuantity=\"false\" min=\"1.0\" max=\"1.0\" nominal=\"1.0\" start=\"0.0\" />
     2528    </ScalarVariable>
     2529    <!-- Variable with index #3 -->
     2530    <ScalarVariable name=\"x2\" valueReference=\"2\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
     2531        <Real relativeQuantity=\"false\" min=\"1.0\" max=\"1.0\" nominal=\"1.0\" />
     2532    </ScalarVariable>
     2533    <!-- Variable with index #4 -->
     2534    <ScalarVariable name=\"der(x2)\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
     2535        <Real relativeQuantity=\"false\" derivative=\"3\" />
     2536    </ScalarVariable>
     2537    <!-- Variable with index #5 -->
     2538    <ScalarVariable name=\"x3\" valueReference=\"4\" causality=\"output\" variability=\"continuous\" initial=\"calculated\">
     2539        <Real relativeQuantity=\"false\" />
     2540    </ScalarVariable>
     2541</ModelVariables>
     2542")})));
     2543end ParametricAttributes1;
     2544
    25022545end FmiXMLTests;
  • branches/dev-jk-2471/Compiler/GenericCodeGen/src/jastadd/GenericXMLGenerator.jrag

    r13557 r13613  
    213213    protected void generateAttributeIfSet(String name, FVariable variable, CodeStream printer) {
    214214        if (variable.attributeSet(name)) {
    215             try {
    216                 String value = variable.attributeCValue(name).xmlValue();
    217                 generateAttribute(name, value, printer);
    218             } catch (ConstantEvaluationException e) {
    219                 throw new InternalCompilerError("Exception when generating xml attribute '" +
    220                     name + "' for variable '" + variable.name() + "'.", e);
     215            FExp attributeExp = variable.attributeExp(name);
     216            if (attributeExp.variability().constantVariability() ||
     217                    variable.isInput() || variable.isDifferentiatedVariable()) {
     218                try {
     219                    String value = attributeExp.ceval().xmlValue();
     220                    generateAttribute(name, value, printer);
     221                } catch (ConstantEvaluationException e) {
     222                    throw new InternalCompilerError("Exception when generating xml attribute '" +
     223                        name + "' for variable '" + variable.name() + "'.", e);
     224                }
    221225            }
    222226        }
Note: See TracChangeset for help on using the changeset viewer.