How to write local code using a TLC custom storage class
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Target Language Compiler finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!