Derive class from Simulink.ConfigComponent
조회 수: 8 (최근 30일)
이전 댓글 표시
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
답변 (2개)
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;
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Schedule Model Components에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!