Derive class from Simulink.ConfigComponent
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Qu Cao
am 24 Aug. 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
am 26 Jul. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Schedule Model Components finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!