Programatically parametrize and 'refresh' CAN Pack and Unpack blocks

조회 수: 1 (최근 30일)
Ansh Gandhi
Ansh Gandhi 2020년 7월 13일
답변: Ansh Gandhi 2020년 9월 8일
I am trying to automate some processes and programatically create a model that contains CAN Pack and Unpack blocks.
When I parametrize the mask parameters in the script, the output is as attached in the image (Message Name and dbc appear correctly, is there a way to -
  1. Emulate mask button press 'OK' or 'Apply' so the input ports are generated without human intervention? OR
  2. Pass the mask params to underlying S-func so it updates the block?
mdlname = 'Trial_VCCU';
new_system(mdlname);
open_system(mdlname);
x = 100;
y = 100;
msgname = 'VCVCCU_ChargeToVehicle';
file = 'C:\repos\VECU IO\EV_CAN.dbc';
canmsglib = 'canmsglib/';
unpack = [canmsglib 'CAN Unpack'];
pack = [canmsglib 'CAN Pack'];
msgpack_hndle = add_block(pack, [mdlname '/' msgname '_Pack']);
set_param(msgpack_hndle, 'Position',[x, y, x+1000, y+600],...
'DataFormat', 'CANdb specified signals', 'CANdbFile', file, 'MsgList', msgname);
Current ouput - A.
Preffered output - B.
Thanks in advance!
Have referred to this but would prefer another solution if it has been found-
https://www.mathworks.com/matlabcentral/answers/294355-how-can-i-click-on-ok-or-apply-button-programmatically

채택된 답변

Ansh Gandhi
Ansh Gandhi 2020년 9월 8일
Solved this in an ad hoc way in the end by using the java keypress events in the script.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subsystems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by