Derive class from Simulink.ConfigComponent
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to attach an own configuration component to the Simulink configuration pane. The attach-mechanism is shown up in the documentation of Simulink.ConfigSet as follows:
hCs = getActiveConfigSet('B');
hSolverConfig = hCs.getComponent('Solver');
hSolverConfig = hSolverConfig.copy;
hCs = getActiveConfigSet('A');
hCs.attachComponent(hSolverConfig);
Where the parameter of attachComponent is described as "Instance of Simulink.ConfigComponent class". Sadly it is not described how to implement the configuration component itself. My approach was defining a class and inherit the Simulink.ConfigComponent. But until now my trials were without any success. Using the "classdef" pattern for defining classes results in following error message:
classdef ConfComp1 < Simulink.ConfigComponent
[...]
end
Error using ConfComp1
The specified superclass 'Simulink.ConfigComponent' contains a parse error, cannot be found on MATLAB's search path, or is shadowed
by another file with the same name.
Using the old OOP approach with @<classname> defined with the constructor as follows:
function obj = ConfComp2()
obj.Name = 'asdf';
obj.Description = 'yxcv';
pc = Simulink.CustomCC();
obj = class(obj, 'ConfComp2', pc);
end
results in the error message
Error using class
Base object for class 'ConfComp2' constructor is invalid.
Error in ConfComp2 (line 5)
obj = class(obj, 'ConfComp2', pc);
The only possibility getting it work was some very dirty code with schema.m files. The files are not documented and seem to be a feature which may change in future versions.
Does anyone have an idea why it's not possible to derive the class? Is there any documentation about creating configuration components for simulink?
Thanks in advance.
0 comentarios
Respuestas (2)
Qu Cao
el 24 de Ag. de 2016
After opening a model (any model), you can use the following code to get access to the Simulink.ConfigComponent of the model:
config_set=getConfigSet(bdroot,'Configuration');
var = config_set.getChildren;
open var;
Donn Shull
el 26 de Jul. de 2019
Simulink.ConfigComponent is a UDD (Universal Data Dictionary) class. This type of class system has been a part of Simulink since R12. It is not compatible with either the old user class definition syntax or the new MCOS (classdef) syntax. It is instead either internal (c code) or defined by m code using a special directory sysnad and schema.m files. The MathWorks has not published documentation for this system and discourages its use. If you have a definate need to extend Simulink.ConfigComponent you will have to do it using UDD. You can find some information about the schema.m system at Yair Altmans Undocumented MATLAB website starting at Introduction to UDD.
0 comentarios
Ver también
Categorías
Más información sobre Schedule Model Components en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!