How to write local code using a TLC custom storage class

조회 수: 2 (최근 30일)
Guilherme T Silva
Guilherme T Silva 2019년 2월 13일
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!

답변 (0개)

카테고리

Help CenterFile Exchange에서 Target Language Compiler에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by