How to get the value from a inport of a customed block with s-function and tlc concept
Hello all,
Currently I have a Simulink customed block (named as Teq block) for my own project which was built in s-function for simulation and tlc for code generation. Because of some reasons on algorithm, I have to find a way to get the value of a Simulink.Parameter(another block) via my Teq_sf.tlc file. However, my tlc file can only get the name of Simulink.Parameter instead of its value as my expectation.
I tried to define a mdlRTW function in sf.c file and call this input to tlc file via RTW, as followings:
static void mdlRTW(SimStruct *S) % in sf.c file
{
real64 *u1 = (real64 *) ssGetInputPortSignal(S, 0);
if (!ssWriteRTWParamSettings( S, 1, SSWRITE_VALUE_QSTR, "Input_Value", *u1))
{
ssSetErrorStatus(S,"Error writing parameter data to .rtw file");
return;
}
}
and %assign input_value = SFcnParamSettings.Input_Value (in tlc)
However, this way did not work because system can not understand SFcnParamSettings. Currently, this is the big blocker for my progress.
Do you know any valid solutions which I can get a value of Simulink.Parameter into my Teq_sf.tlc file but not the name?
Thank you in advance!Hello all,
Currently I have a Simulink customed block (named as Teq block) for my own project which was built in s-function for simulation and tlc for code generation. Because of some reasons on algorithm, I have to find a way to get the value of a Simulink.Parameter(another block) via my Teq_sf.tlc file. However, my tlc file can only get the name of Simulink.Parameter instead of its value as my expectation.
I tried to define a mdlRTW function in sf.c file and call this input to tlc file via RTW, as followings:
static void mdlRTW(SimStruct *S) % in sf.c file
{
real64 *u1 = (real64 *) ssGetInputPortSignal(S, 0);
if (!ssWriteRTWParamSettings( S, 1, SSWRITE_VALUE_QSTR, "Input_Value", *u1))
{
ssSetErrorStatus(S,"Error writing parameter data to .rtw file");
return;
}
}
and %assign input_value = SFcnParamSettings.Input_Value (in tlc)
However, this way did not work because system can not understand SFcnParamSettings. Currently, this is the big blocker for my progress.
Do you know any valid solutions which I can get a value of Simulink.Parameter into my Teq_sf.tlc file but not the name?
Thank you in advance! Hello all,
Currently I have a Simulink customed block (named as Teq block) for my own project which was built in s-function for simulation and tlc for code generation. Because of some reasons on algorithm, I have to find a way to get the value of a Simulink.Parameter(another block) via my Teq_sf.tlc file. However, my tlc file can only get the name of Simulink.Parameter instead of its value as my expectation.
I tried to define a mdlRTW function in sf.c file and call this input to tlc file via RTW, as followings:
static void mdlRTW(SimStruct *S) % in sf.c file
{
real64 *u1 = (real64 *) ssGetInputPortSignal(S, 0);
if (!ssWriteRTWParamSettings( S, 1, SSWRITE_VALUE_QSTR, "Input_Value", *u1))
{
ssSetErrorStatus(S,"Error writing parameter data to .rtw file");
return;
}
}
and %assign input_value = SFcnParamSettings.Input_Value (in tlc)
However, this way did not work because system can not understand SFcnParamSettings. Currently, this is the big blocker for my progress.
Do you know any valid solutions which I can get a value of Simulink.Parameter into my Teq_sf.tlc file but not the name?
Thank you in advance! matlab, simulink, s-function, tlc MATLAB Answers — New Questions