Borrar filtros
Borrar filtros

Can't get information in workspace from an S-function in an automated manner

3 visualizaciones (últimos 30 días)
I have an S-function that I've built using some referenced c-files, and I want to store some of the properties regarding the names of those files in an automated way. To do so, I search for the block, get its handle, then use sfunctionwizard to get the block data and find the field that I want to reference. It looks like this:
Current_Simulation = 'sys_v5';
blkHandle = find_system(Current_Simulation,'lookundermasks','all','Variants','AllVariants','BlockType','S-Function','FunctionName','PosMPC_new');
bH = get_param(blkHandle{1},'Handle');
appdata = sfunctionwizard(bH,'GetApplicationData');
content = appdata.SfunWizardData.LibraryFilesText;
The problem is that the second-to-last command doesn't always execute in time and the fields don't fully load, causing the S-function builder dialog to appear, along with an error message:
Reference to non-existent field 'SfunWizardData'.
I can get around it by adding a pause() right before the last command, but it's rather finicky. If I run it line-by-line, I don't need the pause. If I run just that section of the script, pause(1) is usually enough. If I run the whole script, I need at least pause(5). I'd like a solution that's more dependable and less arbitrary, and that preferably is as fast as possible.
I've tried using do-nothing while loops (this sometimes works, but only if the counter variable name has a certain minimum length, which is really strange), and using a while loop with isfield() to check if the field exists yet (doesn't work; it just stays in the loop forever). Are there other options that I'm not aware of? Thanks in advance.

Respuestas (0)

Categorías

Más información sobre Block Authoring Basics en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by