curiousGeorge123
curiousGeorge123

Reputation: 13

Does MathWorks Simulink prohibit multiple inheritance for system objects?

The Problem: I am trying to use some System Objects inside a 'User-defined Function' block in Simulink. When I try to run the block, I get an error saying the following -

Diamond-shape inheritance is not supported in code generation. Class 'X' inherits from base class 'Y' via two or more paths.

Background: Class X inherits from classes A, B, C - all of which inherit from class Y. There is no conflict between any property/method/class definition between any of these classes. All of them implement their own unique methods, and there is no overloading of a common method/property.

Class X works in MATLAB - I have been able to successfully work with instances of class X.

What I'm not sure of is whether Simulink supports multiple inheritance / diamond shape inheritance, when it is guaranteed that there are no conflicts.

So I would be very interested in finding out if I can make use of class X in Simulink without having to refactor other classes to remove the multiple inheritance.

I have looked at the following MATLAB Central answer, and blog post trying to understand whether multiple inheritance poses any issues.

  1. https://www.mathworks.com/matlabcentral/answers/93189-how-does-matlab-solve-the-diamond-problem-in-multiple-inheritance
  2. https://blogs.mathworks.com/developer/2015/06/08/diamond-of-death/

But I couldn't find anything related to Simulink or Simulink Codegen

Upvotes: 1

Views: 175

Answers (0)

Related Questions