Can classes or class variables be used in stateflow charts / test sequences
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm creating a test sequence for a test harness and would like to use an object in the steps. However, I receive a message that Data type of '<initialized object variable name>' is not supported in Stateflow charts. I know I can perform function calls, but I need some state maintenance to drive function behavior and would like to use an object's methods instead of raw functions.
Is this possible?
0 Commenti
Risposta accettata
Sanju
il 29 Apr 2024
It is not possible to directly use object methods in Stateflow charts. Stateflow charts only support basic data types and cannot directly handle objects. However, you can work around this limitation by using function calls instead of object methods. You can define functions that encapsulate the desired behavior and call these functions from your Stateflow chart. This way, you can still achieve the state maintenance and drive the desired behavior using functions.
Here's an example to illustrate this approach,
% Define a function that encapsulates the desired behavior
function myFunction(obj)
% Perform state maintenance and drive behavior using object methods
obj.method1();
obj.method2();
% ...
end
Then, in your Stateflow chart, you can call this function:
chart MyChart
properties
obj; % Initialized object variable
end
methods
function entry(obj)
% Call the function that encapsulates the desired behavior
myFunction(obj);
end
end
end
By using this approach, you can achieve the desired state maintenance and behavior while still working within the limitations of Stateflow charts.
Hope this helps!
4 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Complex Logic in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!