How to write local code using a TLC custom storage class

1 Ansicht (letzte 30 Tage)
Guilherme T Silva
Guilherme T Silva am 13 Feb. 2019
I'm trying to create a class that yields the following behavior:
  1. Declare a local struct and fill its fields with data.
  2. Pass that struct to an API. This API doesn't change.
I managed to do something close do it by creating a storage class TLC:
/* Definition of data with custom storage class HblLoad */
static MY_LOAD_REQUEST_STRUCT Hbl_Request;
/* Model step function */
void HblStorageClassTest_step(int32_T arg_Arg01, int32_T arg_Arg02)
{
int32_T rtb_Sum;
/* Sum: '<S2>/Sum' incorporates:
* Inport: '<Root>/Arg01'
* Inport: '<Root>/Arg02'
*/
rtb_Sum = arg_Arg01 + arg_Arg02;
/* BusCreator: '<S2>/Bus Creator' incorporates:
* Constant: '<S3>/Constant'
* DataStoreWrite: '<S1>/Data Store Write'
* RelationalOperator: '<S3>/Compare'
*/
Hbl_Request.Int_Field = rtb_Sum;
(void)Hbl__SetLoadRequestByLoadID(LOAD_ID, PRIORITY, (uint8*)&Hbl_Request);
Hbl_Request.Bool_Field = (rtb_Sum <= 0);
(void)Hbl__SetLoadRequestByLoadID(LOAD_ID, PRIORITY, (uint8*)&Hbl_Request);
}
But this is still not quite right. My final objective is having something like this:
void HblStorageClassTest_step(int32_T arg_Arg01, int32_T arg_Arg02)
{
int32_T rtb_Sum;
MY_LOAD_REQUEST_STRUCT Hbl_Request;
rtb_Sum = arg_Arg01 + arg_Arg02;
Hbl_Request.Int_Field = rtb_Sum;
Hbl_Request.Bool_Field = (rtb_Sum <= 0);
(void)Hbl__SetLoadRequestByLoadID(LOAD_ID, PRIORITY, (uint8*)&Hbl_Request);
}
What modifications do I need to do in my TLC to get this working? I'm sending attached the model and storage class. Please open HblStorageClassTest.slx.
Thanks!

Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by