CATIA-Systems / FMIKit-Simulink

Import and export Functional Mock-up Units with Simulink
Other
157 stars 51 forks source link

Error in FMU export and import #381

Closed iscopa closed 2 years ago

iscopa commented 2 years ago

Hello,

I am trying to export a source-code FMU where support for "non-finite numbers" is required:

Plaform: Windows10 Simulink r2021b Update 4 CMake version 3.24 CMake generator: Visual Studio 16 2019

FMIKit 3.0-alfa-2: export OK, import not possible, error reported by Matlab: Column 28, line 152: cvc-datatype-valid.1.2.1: 'rtInf' is not a valid value for 'double'.

The FMU checker, it provides this error:

grafik

FMIKit 3.0-alfa-4: export OK, import not possible, same error. FMIKit 3.0-alfa-5: export OK, import not possible, same error. FMIKit 3.0: export error:

Top Model Build  
### Generating code and artifacts to 'Model specific' folder structure
### Generating code into build folder: C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw
Matching "From" for "Goto" '[FMUCreation_PLE_Basic_Core_wSource_r2021b/EstimPayload_Core/Goto_DEV_ConsrvtvAndDistTransl](matlab:open_and_hilite_hyperlink ('FMUCreation_PLE_Basic_Core_wSource_r2021b/EstimPayload_Core/Goto_DEV_ConsrvtvAndDistTransl','error'))' not found
Component:Simulink | Category:Block warning
Parameter precision loss occurred for 'Gain' of '[FMUCreation_PLE_Basic_Core_wSource_r2021b/EstimPayload_Core/Calc_FCy2TqJntMeas/mm2SI](matlab:open_and_hilite_hyperlink ('FMUCreation_PLE_Basic_Core_wSource_r2021b/EstimPayload_Core/Calc_FCy2TqJntMeas/mm2SI','error'))'. The parameter's value cannot be represented exactly using the run-time data type. A small quantization error has occurred. To disable this warning or error, in the Configuration Parameters > Diagnostics > Data Validity pane, set the 'Detect precision loss' option in the Parameters group to 'none'.
Component:Simulink | Category:Block warning Suppress
### Invoking Target Language Compiler on FMUCreation_PLE_Basic_Core_wSource_r2021b.rtw
### Using System Target File: C:\MATLAB\FMIKit-Simulink-3.0\grtfmi\grtfmi.tlc
        ### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Writing header file FMUCreation_PLE_Basic_Core_wSource_r2021b_types.h
### Writing header file FMUCreation_PLE_Basic_Core_wSource_r2021b.h
### Writing header file FMUCreation_PLE_Basic_Core_wSource_r2021b_private.h
### Writing header file rtwtypes.h
### Writing header file multiword_types.h
.
### Writing header file rtGetInf.h
### Writing source file rtGetInf.c
### Writing header file rtGetNaN.h
### Writing source file rtGetNaN.c
### Writing header file rt_defines.h
### Writing header file rt_nonfinite.h
.
### Writing source file rt_nonfinite.c
### Writing source file FMUCreation_PLE_Basic_Core_wSource_r2021b.c
### Writing header file rtmodel.h
### Writing source file FMUCreation_PLE_Basic_Core_wSource_r2021b_data.c
### TLC code generation complete.
### Writing modelDescription.xml
### Saving binary information cache.
### Running CMake generator
### Generating project
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.28.29914.0
-- The CXX compiler identification is MSVC 19.28.29914.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMAKE_C_FLAGS_RELEASE /O2 /Ob2 /DNDEBUG
CMAKE_C_FLAGS_RELEASE /Od /Ob2 /DNDEBUG
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Isidro/MATRICS/RCU/40_weightEstimator/workspace/res/slx/FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw
### Building FMU
Microsoft (R) Build Engine version 16.9.0+5e4b48a27 for .NET Framework 
Copyright (C) Microsoft Corporation. All rights reserved.
  rt_matrx.c
  FMUCreation_PLE_Basic_Core_wSource_r2021b.c 
  FMUCreation_PLE_Basic_Core_wSource_r2021b_data.c
  rtGetInf.c 
  rtGetNaN.c 
  rt_nonfinite.c 
  fmi2Functions.c
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(34,1): warning C4005: 'rtmGetU': macro redefinition [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.h(56): message : see previous definition of 'rtmGetU' [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(35,1): warning C4005: 'rtmGetY': macro redefinition [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.h(64): message : see previous definition of 'rtmGetY' [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(36,1): warning C4005: 'rtmGetBlockIO': macro redefinition [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.h(40): message : see previous definition of 'rtmGetBlockIO' [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(656,37): error C2065: 'FMUCreation_PLE_Basic_Core_wS_U': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(656,49): error C2223: left of '->pCylBmHd_fild_bar' must point to struct/union [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(659,37): error C2065: 'FMUCreation_PLE_Basic_Core_wS_U': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(659,49): error C2223: left of '->pCylBmRd_fild_bar' must point to struct/union [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(662,37): error C2065: 'FMUCreation_PLE_Basic_Core_wS_U': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(662,49): error C2223: left of '->pCylTltHd_fild_bar' must point to struct/union [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(665,37): error C2065: 'FMUCreation_PLE_Basic_Core_wS_U': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(665,49): error C2223: left of '->pCylTltRd_fild_bar' must point to struct/union [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(668,37): error C2065: 'FMUCreation_PLE_Basic_Core_wS_U': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(668,49): error C2223: left of '->sCyl_Bm_mm' must point to struct/union [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(671,37): error C2065: 'FMUCreation_PLE_Basic_Core_wS_U': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(671,49): error C2223: left of '->sCyl_Tlt_mm' must point to struct/union [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(674,37): error C2065: 'FMUCreation_PLE_Basic_Core_wS_U': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(674,49): error C2223: left of '->IMU_MM710_Chassis_accX_raw' must point to struct/union [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(677,37): error C2065: 'FMUCreation_PLE_Basic_Core_wS_U': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(677,49): error C2223: left of '->IMU_MM710_Chassis_accY_raw' must point to struct/union [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(680,37): error C2065: 'FMUCreation_PLE_Basic_Core_wS_U': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(680,49): error C2223: left of '->IMU_MM710_Chassis_accZ_raw' must point to struct/union [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(683,37): error C2065: 'FMUCreation_PLE_Basic_Core_wS_Y': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
[...]\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\fmiwrapper.inc(683,49): error C2223: left of '->m_EstimdPayLoadLive_kg' must point to struct/union [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
C:\MATLAB\FMIKit-Simulink-3.0\grtfmi\fmi2Functions.c(91,12): error C2198: 'FMUCreation_PLE_Basic_Core_wSource_r2021b_step': too few arguments for call [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
C:\MATLAB\FMIKit-Simulink-3.0\grtfmi\fmi2Functions.c(187,36): error C2065: 'FMUCreation_PLE_Basic_Core_w_M': undeclared identifier [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
C:\MATLAB\FMIKit-Simulink-3.0\grtfmi\fmi2Functions.c(187,36): warning C4047: '=': 'RT_MODEL_FMUCreation_PLE_Basi_T *' differs in levels of indirection from 'int' [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
C:\MATLAB\FMIKit-Simulink-3.0\grtfmi\fmi2Functions.c(236,18): error C2198: 'FMUCreation_PLE_Basic_Core_wSource_r2021b_initialize': too few arguments for call [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
C:\MATLAB\FMIKit-Simulink-3.0\grtfmi\fmi2Functions.c(258,17): error C2198: 'FMUCreation_PLE_Basic_Core_wSource_r2021b_terminate': too few arguments for call [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
C:\MATLAB\FMIKit-Simulink-3.0\grtfmi\fmi2Functions.c(270,24): error C2198: 'FMUCreation_PLE_Basic_Core_wSource_r2021b_terminate': too few arguments for call [C:\Isidro\MATRICS\RCU\40_weightEstimator\workspace\res\slx\FMUCreation_PLE_Basic_Core_wSource_r2021b_grt_fmi_rtw\FMUCreation_PLE_Basic_Core_wSource_r2021b.vcxproj]
  Generating Code...
 Build Summary  
Top model targets built:

Model                                      Action  Rebuild Reason                                    
=====================================================================================================
FMUCreation_PLE_Basic_Core_wSource_r2021b  Failed  Code generation information file does not exist.  

0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 35.23s
The call to grtfmi_make_rtw_hook, during the after_make hook generated the following error:
    Failed to build FMU

The build process will terminate as a result.

Caused by: Failed to build FMU
Component:Simulink | Category:Block diagram error

Could you please help on this?

Thank you and regards

t-sommer commented 2 years ago

Can you share a model to reproduce the issue?

iscopa commented 2 years ago

Thank you. Attached you can find a part of the model. When I try to export the FMU with the FMIKit 3.0 I get the errors C2065, C2223 and C2198

FMU_export_FMIKit_3_0.zip

t-sommer commented 2 years ago

I can export the model successfully with

get_param(gcs, 'CodeInterfacePackaging', 'Nonreusable function')
iscopa commented 2 years ago

perfect! The complete model can be now exported.

The problem related to the FMU import persists, as I still get:

Column 28, line 152: cvc-datatype-valid.1.2.1: 'rtInf' is not a valid value for 'double'.

Attached is the "modeldescription.xml" of the FMU. In order to import the FMU, I currently replace the 'rtInf' with a double value.

modelDescription.zip

t-sommer commented 2 years ago

Can you share the model that you have used to generated the above XML?

iscopa commented 2 years ago

unfortunately I cannot share the complete model. However, I have found the place where the inf is declared:

grafik

There, the error can be avoided replacing inf with a number.

t-sommer commented 2 years ago

I cannot reproduce the problem. For an upper limit inf I get the following XML:

    <ScalarVariable name="Parameters.Saturation_UpperSat" valueReference="1" causality="parameter" variability="tunable">
      <Real start="INF"/>
    </ScalarVariable>