Changeset 13670
- Timestamp:
- Oct 4, 2019 1:54:21 PM (2 months ago)
- Location:
- trunk/Compiler
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/FmiXMLCodeGen/test/modelica/FmiXMLTests.mo
r13636 r13670 2543 2543 end ParametricAttributes1; 2544 2544 2545 2546 model NegativeNominal1 2547 Real x1(nominal=-1); // Negative integer nominal 2548 Real x2(nominal=-1.0); // Negative real nominal 2549 equation 2550 x1 = time; 2551 x2 = time; 2552 annotation(__JModelica(UnitTesting(tests={ 2553 FmiXMLCodeGenTestCase( 2554 description="Nominals are always non-negative in FMI", 2555 fmi_version="2.0", 2556 template=" 2557 $modelVariables$ 2558 ", generatedCode=" 2559 <ModelVariables> 2560 <!-- Variable with index #1 --> 2561 <ScalarVariable name=\"x1\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\"> 2562 <Real relativeQuantity=\"false\" nominal=\"1\" /> 2563 </ScalarVariable> 2564 <!-- Variable with index #2 --> 2565 <ScalarVariable name=\"x2\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\"> 2566 <Real relativeQuantity=\"false\" nominal=\"1.0\" /> 2567 </ScalarVariable> 2568 </ModelVariables> 2569 ")}))); 2570 end NegativeNominal1; 2571 2545 2572 end FmiXMLTests; -
trunk/Compiler/GenericCodeGen/src/jastadd/GenericXMLGenerator.jrag
r13636 r13670 217 217 variable.isInput() || variable.isDifferentiatedVariable()) { 218 218 try { 219 String value = attributeExp.ceval().xmlValue(); 219 CValue cvalue = attributeExp.ceval(); 220 if (name.equals("nominal")) { 221 cvalue = cvalue.absoluteValue(); 222 } 223 String value = cvalue.xmlValue(); 220 224 generateAttribute(name, value, printer); 221 225 } catch (ConstantEvaluationException e) { -
trunk/Compiler/ModelicaFlatTree/src/jastadd/ConstantEvaluation/ConstantEvaluation.jrag
r13605 r13670 4633 4633 eq CValueUnknown.lt(CValue v1, CValue v2) = CValue.UNKNOWN; 4634 4634 4635 4636 public CValue CValue.absoluteValue() { 4637 return this; 4638 } 4639 @Override 4640 public CValue CValueReal.absoluteValue() { 4641 return new CValueReal(Math.abs(realValue())); 4642 } 4643 @Override 4644 public CValue CValueInteger.absoluteValue() { 4645 return new CValueInteger(Math.abs(intValue())); 4646 } 4647 4635 4648 } 4636 4649
Note: See TracChangeset
for help on using the changeset viewer.