Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to export FMU with S-function target in Model Exchange mode with FMI Kit 2.8 #205

Closed
krishnashukla201 opened this issue Aug 21, 2020 · 5 comments
Labels
bug Something isn't working RTWSFCN This issue is related to the S-Function based FMU export

Comments

@krishnashukla201
Copy link

I got a issue when trying to export simple model through s-function target for Model Exchange.
I simply created a new enum type BOOL_TYPE and some other typedef to use in my model.
During the FMU export for that model, when it generate model_interface.c file it create 2 times case with same value 8 and create 3 times case with value 0.

size_t getCGTypeSize(int typeIndex)
{
switch (typeIndex) {
case 0:
return 8; /* real_T */

case 1:
return 4; /* real32_T */

case 2:
return 1; /* int8_T */

case 3:
return 1; /* uint8_T */

case 4:
return 2; /* int16_T */

case 5:
return 2; /* uint16_T */

case 6:
return 4; /* int32_T */

case 7:
return 4; /* uint32_T */

case 8:
return 1; /* boolean_T */

case 9:
return 0; /* fcn_call_T */

case 10:
return 4; /* int_T */

case 11:
return 8; /* pointer_T */

case 12:
return 8; /* action_T */

case 13:
return 8; /* timer_uint32_pair_T */

case 8:
return 1; /* BOOL_TYPE */

case 0:
return 8; /* TemperatureType */

case 0:
return 8; /* Q16_15_TYPE */

default:
return 0; /* unknown type */
}
}

Error given in Matlab is

model_interface.c
D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\model_interface.c(49): error C2196: case value '8' already used [D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\test_func.vcxproj]
D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\model_interface.c(52): error C2196: case value '0' already used [D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\test_func.vcxproj]
D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\model_interface.c(55): error C2196: case value '0' already used [D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\test_func.vcxproj].

please let me know the solution.

To reproduce - Create a simple model and add some user defined enum types(boolean) and typedef(any base type). assign variables in the model with these enum or typedef. Then export the FMU. it will through this error.

@t-sommer
Copy link
Contributor

@krishnashukla201, can you share an example model to reproduce the problem?

@t-sommer t-sommer added the RTWSFCN This issue is related to the S-Function based FMU export label Aug 25, 2020
@krishnashukla201
Copy link
Author

test_sfcn.zip
sample model.

t-sommer added a commit that referenced this issue Aug 26, 2020
@t-sommer
Copy link
Contributor

@krishnashukla201, can you give f3e14a8 a try?

@t-sommer t-sommer added the bug Something isn't working label Aug 26, 2020
@krishnashukla201
Copy link
Author

By using this new file i am getting this error now.

image

@t-sommer
Copy link
Contributor

I can successfully export the above model with R2020a if I remove the sources in Configuration Parameters > Simulation Target (these are not required for the model).

Please re-open if the problem persists and provide steps to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working RTWSFCN This issue is related to the S-Function based FMU export
Projects
None yet
Development

No branches or pull requests

2 participants