modelica / ModelicaSpecification

Specification of the Modelica Language
https://specification.modelica.org
Creative Commons Attribution Share Alike 4.0 International
95 stars 41 forks source link

Standardize annotation __Dymola_Commands #2321

Open dietmarw opened 5 years ago

dietmarw commented 5 years ago

This actually stems from #1118-MSL but I could not find a ticket on that here where it really should get fixed first.

__Dymola_Commands is a vendor specific annotation to execute Modelica functions in a scripting environment (e.g. defining default plots for a model or model conversion). This functionality should be "somehow" standardized and this annotation be replaced by a tool-independent functionality.

This annotation is currently the only vendor annotation remaining in the MSL and it would be nice to be able to remove that and replace it by a standard annotation.

HansOlsson commented 5 years ago

I tried to check what is currently used in MSL.

The script files contain plot-commands (including subplots - but I couldn't see anything else fancy; e.g. no x-y plots) and animation commands, and in some cases also simulateModel (in my opinion those scripts should have used ensureSimulated-functionality).

So, apart from the robot it seems the main functionality is to simulate (according to settings in model) and then plot some variables in one or more sub-plots (and possibly multiple plot-windows; need to check more).

One possibility would be to just standardize existing commands, but so far we haven't managed to standardize scripting. Note that the current scripts contain positions for windows, and ranges for plots. I believe they are mostly just the defaults for some screen and aren't needed.

However, specifying a set of plot-variables for a model split into sub-windows seems that something that would be generally useful, fairly easy to specify - and wouldn't need standardized scripting.

Additionally one example (robot) has an animation-setup stored, as far as I know there are commercial libraries (e.g. VeSyMA and VehicleDynamics) that use this more extensively (in particular multiple animation-setups for the same model - and hiding/highlighting/following parts). That seems also seems possible - but is more complicated; and it might be that the current scripts partially rely on some internal setup that isn't present in the scripts.

thorade commented 5 years ago

__Dymola_Commands is also used a lot in the IBPSA library: https://github.com/ibpsa/modelica-ibpsa/search?q=__Dymola_Commands&unscoped_q=__Dymola_Commands It always simulates an example and plots selected key result variables.

The information what variables are considered key variables is also used for unit testing: All plotted signals will be compared to reference results.

HansOlsson commented 4 years ago

Except for the animation-scripts (used e.g., for the robot in MSL, and a lot in commercial libraries) it should be handled by MCP0033: #2482 Please verify that nothing is missing in that proposal.

henrikt-ma commented 4 years ago

After we've completed MCP-0033, I hope that we could also find a standardized solution for the animations. SystemModeler is already using an annotation for this, and the based on the looks of fullRobotPlot.mos it doesn't seem like it would be too hard to reach agreement on how to standardize it, or what do you think @otronarp?

HansOlsson commented 1 year ago

After we've completed MCP-0033, I hope that we could also find a standardized solution for the animations. SystemModeler is already using an annotation for this, and the based on the looks of fullRobotPlot.mos it doesn't seem like it would be too hard to reach agreement on how to standardize it, or what do you think @otronarp?

I agree that it might not be too hard, but I think we need some time for it. I would say that the main ones are:

animationView(view =
[0.870550563296124, 0, 0, 0.331165168988837;
0, 0.870550563296124, 0, (-0.947330337977674);
0, 0, 0.870550563296124, (-2.2947672397066E-009);
0, 0, 0, 1]);
animationFollow(followX = true, followY = true, followZ = false, followRotation = false);
animationSelected(highlight = true, follow = false, selectedName = "");
animationColor(background = {0.75, 0.75, 0.75}, selected = {1, 0, 0}, selectedbackground = {1, 1, 1});
animationPerspective(perspective = {(-40.0), 40.0, 1, 100.0, 0, 0, (-3.0)});

(Well, animationVectorScaling might also be needed, but there are similar possibilities in the world-object. Notice that I removed some sub-settings)