Opened 4 years ago

Last modified 3 years ago

#5686 assigned defect

Invalid FMU Export: Enumeration without start value and/or invalid combination of "input" and "fixed"

Reported by: andreas.nicolai@… Owned by: arun3688
Priority: high Milestone:
Component: FMI Version:
Keywords: Cc:

Description

Hi all,

I noticed that OpenModelica exports enumeration input values for example as follows:

---

<!-- Index of variable = "523" -->

<ScalarVariable

name="Input.flowDirection"
valueReference="20"
description="Allowed flow direction"
variability="fixed"
causality="input"

<Enumeration declaredType="Modelica.Fluid.Types.PortFlowDirection"/>

</ScalarVariable>
---

Importing such an FMU into a Co-Simulation master fails because the master does not have a valid initial value/selection for the enumeration value.

According to the FMI standard, the combination of "input" and "fixed" is invalid, when no initial value is given (see "Functional Mock-up Interface 2.0", July 25, 2014, Page 48 of 126).

I think this should be fixed by providing an initial value/selection for the enumeration.

Attachments (2)

pipe.fmu (1.6 MB) - added by anonymous 4 years ago.
pipe.mo (3.7 KB) - added by hauke.hirsch@… 4 years ago.
modelica model of the fmu

Download all attachments as: .zip

Change History (11)

Changed 4 years ago by anonymous

comment:1 Changed 4 years ago by Andreas Nicolai <andreas.nicolai@…>

To be concrete: please add a "start" attribute to the Enumeration tag.

(I don't think there must be an "initial"="exact" attribute for the ScalarVariable tag. Actually, I don't think this would be allowed for causality=input)

comment:2 Changed 4 years ago by lochel

  • Owner changed from lochel to arun3688
  • Status changed from new to assigned

Thanks for your report.

comment:3 Changed 4 years ago by casella

  • Milestone changed from Future to 1.16.0

comment:4 Changed 4 years ago by arun3688

@Andreas Nicolai Can you make a small modelica model which reproduces this problem so that it is easier for us to debug it.

Changed 4 years ago by hauke.hirsch@…

modelica model of the fmu

comment:5 Changed 4 years ago by anonymous

Hi, I've just added the corresponding modelica model. The fmu was created with OMEdit v1.13.2.

comment:6 Changed 4 years ago by arun3688

The model is still big to debug the problem, Can you make simple modelica model which reporduces the problem , I have created a small modelica model which does not reproduce the problem, Please have a look into this.

type Enum = enumeration(test1,test2,test3);
model TypeEnumeration
  input Enum et;
  output Enum et1;
  Enum et2(start=Enum.test2,fixed=true);
equation
  et1 = et.test2;
  et2 = Enum.test3;
end TypeEnumeration;

And generating the fmu, gives me the following

   <ModelVariables>                                         
<!-- Index of variable = \"1\" -->                        
<ScalarVariable                                           
  name=\"_D_outputAlias_et1\"                             
  valueReference=\"0\"                                    
  variability=\"discrete\"                                
  causality=\"local\"                                     
  initial=\"calculated\">                                 
  <Enumeration declaredType=\"Enum\"/>                    
</ScalarVariable>                                         
<!-- Index of variable = \"2\" -->                        
<ScalarVariable                                           
  name=\"et\"                                             
  valueReference=\"1\"                                    
  variability=\"discrete\"                                
  causality=\"input\"                                     
  >                                                       
  <Enumeration declaredType=\"Enum\" start=\"0\"/>        
</ScalarVariable>                                         
<!-- Index of variable = \"3\" -->                        
<ScalarVariable                                           
  name=\"et1\"                                            
  valueReference=\"2\"                                    
  variability=\"discrete\"                                
  causality=\"output\"                                    
  initial=\"exact\">                                      
  <Enumeration declaredType=\"Enum\" start=\"2\"/>        
</ScalarVariable>                                         
<!-- Index of variable = \"4\" -->                        
<ScalarVariable                                           
  name=\"et2\"                                            
  valueReference=\"3\"                                    
  variability=\"discrete\"                                
  causality=\"local\"                                     
  initial=\"exact\">                                      
  <Enumeration declaredType=\"Enum$et2\" start=\"2\"/>    
</ScalarVariable>                                         
</ModelVariables>                                         

I see that you are using older version of OpenModelica, you should try to generate the fmus with newer version and see if the problem exists, if not can you make a mininimal modelica example which reproduces the problem

comment:7 Changed 3 years ago by casella

  • Milestone changed from 1.16.0 to 1.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:8 Changed 3 years ago by casella

  • Milestone changed from 1.17.0 to 1.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:9 Changed 3 years ago by casella

  • Milestone 1.18.0 deleted

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.