Programatically parametrize and 'refresh' CAN Pack and Unpack blocks

3 views (last 30 days)
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

Accepted Answer

Ansh Gandhi
Ansh Gandhi on 8 Sep 2020
Solved this in an ad hoc way in the end by using the java keypress events in the script.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!