System object not stop on breakpoints in stepImpl block when running simulink

3 vues (au cours des 30 derniers jours)
shu
shu le 4 Déc 2020
Commenté : shu le 4 Déc 2020
I have several breakpoints in the system object files.
The debugger does not stop on the breakpoints in the "stepImpl" part. But they do stop in the parts such as "getOutputDataTypeImpl" or "getOutputSizeImpl" and so on.
I used the "system object-->simulink extension" file and modified it a little bit.
classdef test0_systemObject < matlab.System & matlab.system.mixin.Propagates ...
& matlab.system.mixin.CustomIcon
% Untitled Add summary here
%
% NOTE: When renaming the class name Untitled, the file name
% and constructor name must be updated to use the class name.
%
% This template includes most, but not all, possible properties, attributes,
% and methods that you can implement for a System object in Simulink.
% Public, tunable properties
properties
end
% Public, non-tunable properties
properties(Nontunable)
end
properties(DiscreteState)
end
% Pre-computed constants
properties(Access = private)
output=5;
end
methods
% Constructor
function obj = test0_systemObject(varargin)
% Support name-value pair arguments when constructing object
setProperties(obj,nargin,varargin{:})
end
end
methods(Access = protected)
%% Common functions
function setupImpl(obj)
% Perform one-time calculations, such as computing constants
end
function [y1,y2] = stepImpl(obj,u)
% Implement algorithm. Calculate y as a function of input u and
% discrete states.
obj.output = obj.output+u;
y1 = u;
y2 = obj.output;
end
function resetImpl(obj)
% Initialize / reset discrete-state properties
end
%% Backup/restore functions
% function s = saveObjectImpl(obj)
% % Set properties in structure s to values in object obj
%
% % Set public properties and states
% s = saveObjectImpl@matlab.System(obj);
%
% % Set private and protected properties
% %s.myproperty = obj.myproperty;
% end
%
% function loadObjectImpl(obj,s,wasLocked)
% % Set properties in object obj to values in structure s
%
% % Set private and protected properties
% % obj.myproperty = s.myproperty;
%
% % Set public properties and states
% loadObjectImpl@matlab.System(obj,s,wasLocked);
% end
%% Simulink functions
% function ds = getDiscreteStateImpl(obj)
% % Return structure of properties with DiscreteState attribute
% ds = struct([]);
% end
function flag = isInputSizeMutableImpl(obj,index)
% Return false if input size cannot change
% between calls to the System object
flag = false;
end
function [y1,y2] = getOutputSizeImpl(obj)
% Return size for each output port
y1 = [1 1];
y2 = [1 1];
% Example: inherit size from first input port
% out = propagatedInputSize(obj,1);
end
function [y1,y2] = isOutputFixedSizeImpl(obj)
% Return true for each output port with fixed size
y1 = true;
y2 = true;
end
function [y1,y2]= getOutputDataTypeImpl(obj)
% Return data type for each output port
y1 = "double";
y2 = "double";
end
function [y1,y2] = isOutputComplexImpl(obj)
% Return true for each output port with complex data
y1 = false;
y2 = false;
end
end
end
  1 commentaire
shu
shu le 4 Déc 2020
For anyone who may come aross the same problem, refer to the link:
Change the system object from "code generation" to "Interpreted execution", the "stepImpl" part can be debugged now.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Create System Objects dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by