Derive class from Simulink.ConfigComponent

조회 수: 8 (최근 30일)
Daniel
Daniel 2016년 8월 19일
답변: Donn Shull 2019년 7월 26일
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.

답변 (2개)

Qu Cao
Qu Cao 2016년 8월 24일
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
Daniel
Daniel 2016년 8월 25일
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.

댓글을 달려면 로그인하십시오.


Donn Shull
Donn Shull 2019년 7월 26일
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.

카테고리

Help CenterFile Exchange에서 Schedule Model Components에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by