How to write local code using a TLC custom storage class
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm trying to create a class that yields the following behavior:
- Declare a local struct and fill its fields with data.
- 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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Target Language Compiler에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!