Page 1 of 1

StereoSystem: Why the startObjectBehavior actions?

PostPosted: Tue Jul 20, 2021 7:50 am
by yshragai.firmware@gmail.com
Hi,
In the StereoSystem example in MD 19.0:

The StereoSystem class has properties comprising 2 instances of Speaker class ("big", "small") and 1 instance of Player class ("dvd player").
And, the StereoSystem class has starting behavior "System init". In this behavior, it gets the property instances, and does a startObjectBehavior action on each one.

However, the property objects are already started as soon as the StereoSystem class is instantiated - apparently, as soon as you start the simulation, all of the start behaviors are started: For StereoSystem, for the "big" Speaker, for the "small" Speaker, and the "dvd player" Player.
And so, by the time the simulation gets to the startObjectBehavior actions in the "System init" activity, it doesn't (seem to) accomplish anything.

Attached is the Console log from running with Debug logging level.

Am I missing something?

Thanks!

Re: StereoSystem: Why the startObjectBehavior actions?

PostPosted: Tue Jul 20, 2021 9:06 am
by saulius_p
Hello,

Good to talk to you. Yes it is optional. Older style of modeling. You can actually treat all objects as active in simulation config so no need to activate them. You can delete whole System Init activity. Just do not forget to set sim config properties as identified in screenshot.

Kind regards,
Saulius

Capture.PNG

Re: StereoSystem: Why the startObjectBehavior actions?

PostPosted: Tue Jul 20, 2021 9:45 am
by yshragai.firmware@gmail.com
Thank you. Between your response and looking at the help pages (https://docs.nomagic.com/display/CST185 ... stereotype) and trying to piece things together, I (think I) get it now.

There's the SimulationConfig object, in the "simulation" package in the model. If you start the simulation via that simulation config (right click the SimulationConfig object, or (didn't even notice this) click play where it says "Stereo System" in the top left just under the menu bar), it actually starts things in the right sequence.
But if you start the simulation by right clicking the "Stereo System" class (in the "system" package) or the "stereo System" instance (in the "instances" package), everything starts up immediately, asynchronously.

Why?

Because, apparently, by default, Autostart Active Objects is True.
But, wait, all of the objects in the model have "is active" set to False!
Oh, but wait, there's also Treat All Classifiers As Active, which is True by default.
So, if you start the simulation by right-clicking the class or the instance, everything starts up together.

Whereas, in the SimulationConfig object, both Treat All Classifiers As Active and Autostart Active Objects have been reset to "undefined", which is effectively false.
So, if you start the simulation via the SimulationConfig object, things start up in an orderly fashion.

And by the way, those are "Tags", so if you are viewing the properties in "All" view, as opposed to "Expert" view, you'd have to go to the "Tags" category to see them.

Thanks!

Re: StereoSystem: Why the startObjectBehavior actions?

PostPosted: Wed Jul 21, 2021 10:10 am
by saulius_p
Hello,

Good to talk to you. You are right. Always start simulation from simulation config in other case you can not get simulation properties to take an desired effect just some default ones.

Sincerely,
Saulius