Derive class from Simulink.ConfigComponent

7 visualizaciones (últimos 30 días)
Daniel
Daniel el 19 de Ag. de 2016
Respondida: Donn Shull el 26 de Jul. de 2019
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.

Respuestas (2)

Qu Cao
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;
  1 comentario
Daniel
Daniel el 25 de Ag. de 2016
Thanks for your answer. The result is quite similar to the first lines of code I posted. With that it is also possible to access existing config components. Creating instances of Simulink.ConfigComponent is even possible, if the class is not shown up in the auto completition of the commandline. But it's not possible to inherit this class by another class which shall specify a new and completely user defined configuration panel within the model configuration.
Maybe it is also not clear what I want to do: The ConfigComponent itself contains several configuration panes, for example SolverCC and so on. All of them seem to be derived from Simulink.ConfigComponent. Waht I want to do is adding a self defined "MyOwnCC" component to the configuration, which then shows up on the left side of the model configuration parameters and displays own configuration properties on the right side.

Iniciar sesión para comentar.


Donn Shull
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.

Categorías

Más información sobre System Composer 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!

Translated by